Filopplasting/index.php

159 lines
5.4 KiB
PHP
Executable File

<?php
session_start();
?>
<!DOCTYPE html>
<!-- Saus: https://git.willy.club/Trygve/Filopplasting-->
<html lang="no">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta charset="UTF-8">
<meta name="theme-color" content="#0058F4"/>
<link rel="icon" type="image/png" href="/img/comp.png">
<meta name="description" content="Gratis fildeling!" />
<link rel="stylesheet" href="/common/XP.css">
<script>
const copyToClipboard = str => {
const el = document.createElement('textarea');
el.value = str;
el.setAttribute('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
};
</script>
<style>
body {
background: url('img/sand.bmp');
}
form {
margin-top: 1rem;
}
.center {
margin: auto;
margin-top: 2rem;
margin-bottom: 2rem;
}
.main{
width: 100%;
}
input::file-selector-button {
font-family: "Pixelated MS Sans Serif",Arial;
-webkit-font-smoothing: antialiased;
font-size: 11px;
box-sizing: border-box;
border: 1px solid #003c74;
background: linear-gradient(180deg,#fff,#ecebe5 86%,#d8d0c4);
box-shadow: none;
border-radius: 3px;
min-width: 75px;
min-height: 23px;
padding: 0 12px;
}
input::file-selector-button:hover {
box-shadow: inset -1px 1px #fff0cf,inset 1px 2px #fdd889,inset -2px 2px #fbc761,inset 2px -2px #e5a01a;
}
input::file-selector-button:active {
box-shadow: none;
background: linear-gradient(180deg,#cdcac3,#e3e3db 8%,#e5e5de 94%,#f2f2f1);
}
input::file-selector-button:focus {
outline: 1px dotted #000;
outline-offset: -4px;
box-shadow: inset -1px 1px #cee7ff,inset 1px 2px #98b8ea,inset -2px 2px #bcd4f6,inset 1px -1px #89ade4,inset 2px -2px #89ade4;
}
@media screen and (min-width: 600px) {
.main{
width: 600px;
}
}
</style>
</head>
<body>
<div class="window center main">
<div class="title-bar">
<div class="title-bar-text">Trygves filopplasting!</div>
<div class="title-bar-controls">
<a href="https://trygve.net"><button aria-label="Close" ></button></a>
</div>
</div>
<div class="window-body">
<p>Hei! Her kan du laste opp filer du ønsker å dele med andre, eller bare deg selv. Fra tid til annen sletter jeg filene her for for å spare plass så denne sida er kun for midlertidig fillagring.</p>
<a href="/offentlig/">Her kan du bla gjennom alle offentlige filer</a>
<article>
<form action="upload.php" method="post" enctype="multipart/form-data">
<div class="form-group">
<div class="field-row">
<label for="file">Velg fil</label>
<input type="file" name="file" id="file">
</div>
<div class="field-row">
<label for="name">Gi fila et nytt navn:</label>
<input name="new_filename" type="text" />
</div>
<div class="field-row">
<input type="checkbox" name="public" id="public_check" checked="True">
<label for="public_check">Gjør fila søkbar</label>
<button type="submit">Last opp </button>
</div>
</div>
</form>
</div>
</div>
<?php
function popup($title, $message, $icon_name) {
return '<div class="window center" style="width: 300px" id="popup">
<div class="title-bar">
<div class="title-bar-text">' . $title . '</div>
<div class="title-bar-controls">
<button aria-label="Close" onclick="document.getElementById(\'popup\').remove()"></button>
</div>
</div>
<div class="window-body">
<section class="field-row">
<img src="'. $icon_name .'" height="32px"><p>'. $message . '</p>
</section>
<section class="field-row" style="justify-content: flex-end"><button onclick="document.getElementById(\'popup\').remove()">Ok</button></section>
</div>
</div>';
}
if(isset($_SESSION['fileupload-response'])) {
if($_SESSION['fileupload-response'] == "success") {
$successMSG = '
<div class="window center" style="width: 300px" id="popup">
<div class="title-bar">
<div class="title-bar-text">' . $_SESSION['filename'] . '</div>
<div class="title-bar-controls">
<button aria-label="Close" onclick="document.getElementById(\'popup\').remove()"></button>
</div>
</div>
<div class="window-body">
<section class="field-row">
<img src="img/info.ico" height="32px">
<p>'
. $_SESSION['linkData'] .
'</p>
</section>
<section class="field-row" style="justify-content: flex-end"><button onclick="copyToClipboard(\'' . $_SESSION['link'] . '\')">Kopier lenke</button></section>
</div>
</div>
';
echo($successMSG);
}
elseif ($_SESSION['fileupload-response'] == "failed") {
echo(popup($_SESSION['filename'], 'Oisan, noe gikk vist galt!', 'img/!.png'));
}
elseif ($_SESSION['fileupload-response'] == "banned") {
echo(popup($_SESSION['filename'], 'Stoppe en hall! Denne filtypen er forbudt!', 'img/x.png'));
}
session_destroy();
}
?>
</body>
</html>