Add web interface
parent
b4bdcfe57e
commit
cdef19479d
Binary file not shown.
@ -0,0 +1,58 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Upload to the archive</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php echo "aaa";
|
||||
var_dump(getcwd()); ?>
|
||||
<div class="container recorder">
|
||||
|
||||
<article>
|
||||
<h1>Signal lost archive unzipped</h1>
|
||||
<p>some info on what this even is</p>
|
||||
</article>
|
||||
<div class="button__wrapper"><button class='fn-start-recording button--record'>
|
||||
<span class="button__label">RECORD</span>
|
||||
</button>
|
||||
|
||||
<a href="" class="fn-file-upload">Upload a file instead</a>
|
||||
</div>
|
||||
<div></div>
|
||||
<audio controls></audio>
|
||||
</div>
|
||||
|
||||
<section class='upload'>
|
||||
|
||||
<form enctype="multipart/form-data" class="fn-upload-form" action="upload.php" method="POST">
|
||||
|
||||
<input name="userfile" type="file" />
|
||||
<input type="submit" value="Send File" />
|
||||
</form>
|
||||
</section>
|
||||
|
||||
|
||||
<script type="text/javascript" src="script.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
<?php
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
|
||||
$uploaddir = '/opt/homebrew/var/www/uploads/';
|
||||
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
|
||||
|
||||
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
|
||||
echo "File is valid, and was successfully uploaded.\n";
|
||||
} else {
|
||||
echo "Possible file upload attack!\n";
|
||||
}
|
||||
}
|
||||
?>
|
@ -0,0 +1,84 @@
|
||||
var micEl;
|
||||
let chunks = [];
|
||||
|
||||
var mediaRecorder = false;
|
||||
|
||||
var sendFile = function (blob) {
|
||||
const formData = new FormData();
|
||||
|
||||
formData.append('userfile', blob, new Date() + ".webm");
|
||||
|
||||
return fetch('upload.php', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
}
|
||||
|
||||
var initRecording = function (autostart) {
|
||||
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
|
||||
console.info("getUserMedia supported.");
|
||||
|
||||
navigator.mediaDevices
|
||||
.getUserMedia({ audio: true })
|
||||
.then((stream) => {
|
||||
mediaRecorder = new MediaRecorder(stream);
|
||||
console.log(mediaRecorder.mimeType);
|
||||
console.log("should i autostarty", autostart);
|
||||
|
||||
mediaRecorder.ondataavailable = (e) => {
|
||||
chunks.push(e.data);
|
||||
};
|
||||
|
||||
mediaRecorder.onstop = (e) => {
|
||||
console.log("got a call to stop");
|
||||
var audioEl = document.querySelectorAll("audio")[0];
|
||||
const blob = new Blob(chunks, {
|
||||
type: mediaRecorder.mimeType
|
||||
});
|
||||
console.log(blob);
|
||||
chunks = [];
|
||||
const audioURL = window.URL.createObjectURL(blob);
|
||||
audioEl.src = audioURL;
|
||||
console.log(audioEl.src);
|
||||
sendFile(blob);
|
||||
}
|
||||
|
||||
if (autostart) {
|
||||
mediaRecorder.start();
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.error("not supported");
|
||||
}
|
||||
}
|
||||
|
||||
var startRecording = function (e) {
|
||||
|
||||
if (!mediaRecorder) {
|
||||
console.log("did not initalise");
|
||||
initRecording(true);
|
||||
e.currentTarget.setAttribute("active", true);
|
||||
} else {
|
||||
|
||||
if (mediaRecorder.state === "recording") {
|
||||
console.log("recording was already happening")
|
||||
mediaRecorder.stop();
|
||||
e.currentTarget.setAttribute("active", false);
|
||||
} else {
|
||||
console.log("not yet recording, about tos tart");
|
||||
mediaRecorder.start();
|
||||
e.currentTarget.setAttribute("active", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
window.onload = function () {
|
||||
console.log("load app");
|
||||
|
||||
micEl = document.querySelector('.fn-start-recording');
|
||||
|
||||
micEl.addEventListener('click', startRecording);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
:root {
|
||||
--primary: #c5ff27;
|
||||
--black: black;
|
||||
--white: white;
|
||||
--gutter-sm: .5rem;
|
||||
--gutter-md: 1rem;
|
||||
--gutter-lg: 3rem;
|
||||
|
||||
--font-size-base: 1rem;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "WonderType";
|
||||
src:
|
||||
local("WonderType"),
|
||||
url("WonderType-Regular.otf") format("opentype"),
|
||||
url("trickster-outline.woff") format("woff");
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0 0;
|
||||
padding: 0 0;
|
||||
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--primary);
|
||||
font-family: "WonderType";
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 900px;
|
||||
margin: 0 auto;
|
||||
padding: var(--gutter-md);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
button,
|
||||
.button {
|
||||
width: 100%;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
text-transform: uppercase;
|
||||
background-color: var(--black);
|
||||
border: none;
|
||||
padding: var(--gutter-sm) var(--gutter-md);
|
||||
color: var(--white);
|
||||
font-weight: bolder;
|
||||
font-size: var(--font-size-base);
|
||||
transition: .2s all ease-in-out;
|
||||
font-family: "WonderType";
|
||||
}
|
||||
|
||||
audio {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.button__wrapper {
|
||||
display: flex;
|
||||
justify-content: flex-center;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
padding: var(--gutter-lg);
|
||||
gap: var(--gutter-md);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.button__wrapper a {
|
||||
color: var(--black);
|
||||
}
|
||||
|
||||
.button--record {
|
||||
border-radius: 100%;
|
||||
flex-grow: 1;
|
||||
max-width: 500px;
|
||||
max-height: 500px;
|
||||
aspect-ratio: 1 / 1;
|
||||
margin: 0 auto;
|
||||
position: relative;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
@keyframes recording {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.button--record:before {
|
||||
content: '';
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background-color: var(--black);
|
||||
border-radius: 100%;
|
||||
z-index: -1;
|
||||
transform: scale(1);
|
||||
transition: transform .1s linear;
|
||||
}
|
||||
|
||||
|
||||
.button--record[active="true"]:before {
|
||||
transform: scale(0);
|
||||
}
|
||||
|
||||
|
||||
.button--record[active="true"] {
|
||||
color: var(--black);
|
||||
animation-delay: 1s;
|
||||
border: none;
|
||||
border: 1rem dashed black;
|
||||
border-right-color: transparent;
|
||||
border-left-color: transparent;
|
||||
background-color: transparent;
|
||||
animation: 2s linear recording infinite;
|
||||
}
|
||||
|
||||
.button--record[active="true"] .button__label {
|
||||
animation: 2s linear recording infinite;
|
||||
animation-direction: reverse;
|
||||
}
|
||||
|
||||
.recorder {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
|
||||
<?php
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
|
||||
$uploaddir = getcwd() . '/uploads/';
|
||||
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
|
||||
|
||||
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
|
||||
echo "File is valid, and was successfully uploaded.\n";
|
||||
} else {
|
||||
echo "Possible file upload attack!\n";
|
||||
}
|
||||
}
|
||||
?>
|
Binary file not shown.
Loading…
Reference in New Issue