deploy draft version

This commit is contained in:
Pierre Guillod 2023-07-05 15:17:10 +02:00
parent 22f8480e1a
commit 1bae5969ab
Signed by: pierre
GPG key ID: 78018D943E9CBD0C
7 changed files with 166 additions and 0 deletions

6
Dockerfile Normal file
View file

@ -0,0 +1,6 @@
FROM php:8.0-apache
WORKDIR /var/www
COPY src/ html/
RUN mkdir uploads && chown -R www-data:www-data uploads
RUN apt-get update && apt-get -y install ffmpeg
EXPOSE 80/tcp

5
src/css/pico.min.css vendored Normal file

File diff suppressed because one or more lines are too long

1
src/css/pico.min.css.map Normal file

File diff suppressed because one or more lines are too long

BIN
src/fonts/anybody.ttf Normal file

Binary file not shown.

49
src/index.php Normal file
View file

@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/pico.min.css">
</head>
<body>
<header class="container">
<hgroup>
<h1>Munta</h1>
<p>Your locally hosted one-stop-shop for all your conversion needs.</p>
</hgroup>
</header>
<main class="container">
<form action="upload.php" method="post" enctype="multipart/form-data">
<input id="picker" type="file" name="file">
<div id="buttons" class="grid"></div>
</form>
</main>
<script>
document.getElementById('picker').addEventListener('change', function(e) {
if (e.target.files[0]) {
fetch('json/conversions.json')
.then((response) => response.json())
.then((json) => {
const fromExt = e.target.files[0].name.split('.').pop();
const elButtons = document.getElementById("buttons");
while (elButtons.firstChild) {
elButtons.removeChild(elButtons.lastChild);
}
for (toExt of json[fromExt]) {
const elButton = document.createElement("input");
elButton.setAttribute("type", "submit");
elButton.setAttribute("name", "submit");
elButton.setAttribute("value", toExt);
elButtons.appendChild(elButton);
}
});
}
});
</script>
</body>
</html>

84
src/json/conversions.json Normal file
View file

@ -0,0 +1,84 @@
{
"jpeg": [
"jp2",
"webp",
"png",
"gif"
],
"jp2": [
"jpeg",
"webp",
"png",
"gif"
],
"webp": [
"jpeg",
"jp2",
"png",
"gif"
],
"png": [
"jpeg",
"jp2",
"webp",
"gif"
],
"gif": [
"jpeg",
"jp2",
"webp",
"png"
],
"av1": [
"mkv",
"webm",
"ogv"
],
"mkv": [
"av1",
"webm",
"ogv"
],
"webm": [
"av1",
"mkv",
"ogv"
],
"ogv": [
"av1",
"mkv",
"webm"
],
"alac": [
"flac",
"mp3",
"ogg",
"wav"
],
"flac": [
"alac",
"mp3",
"ogg",
"wav"
],
"mp3": [
"alac",
"flac",
"ogg",
"wav"
],
"ogg": [
"alac",
"flac",
"mp3",
"wav"
],
"wav": [
"alac",
"flac",
"ogg",
"mp3"
]
}

21
src/upload.php Normal file
View file

@ -0,0 +1,21 @@
<?php
$fromExt = strtolower(pathinfo($_FILES["file"]["name"])['extension']);
$toExt = $_POST["submit"];
$targPat = "/var/www/uploads/upload.$fromExt";
move_uploaded_file($_FILES["file"]["tmp_name"], $targPat);
chdir('/var/www/uploads/');
exec("ffmpeg -y -i upload.$fromExt output.$toExt");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=output.$toExt");
header("Content-Type: application/jpeg");
header("Content-Transfer-Encoding: binary");
readfile("/var/www/uploads/output.$toExt");
?>