This commit is contained in:
Trygve 2023-12-01 00:30:06 +01:00
commit aa0a6c2e8c
8 changed files with 203 additions and 0 deletions

Binary file not shown.

2
common/XP.css Normal file

File diff suppressed because one or more lines are too long

BIN
common/ms_sans_serif.woff2 Normal file

Binary file not shown.

Binary file not shown.

BIN
img/fisk.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
img/sand.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

141
index.php Executable file
View File

@ -0,0 +1,141 @@
<?php
session_start();
?>
<!DOCTYPE html>
<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="#263238"/>
<link rel="icon" type="image/png" href="/dist/favicon.png">
<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 {
height: 100vh;
background: url('img/sand.bmp');
}
.center {
margin: auto;
}
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;
}
</style>
</head>
<body>
<div class="window center" style="width: 800px">
<div class="title-bar">
<div class="title-bar-text">Trygves filopplasting!</div>
<div class="title-bar-controls">
<button aria-label="Close"></button>
</div>
</div>
<div class="window-body">
<form action="upload.php" method="post" enctype="multipart/form-data">
<div class="form-group">
<input type="checkbox" id="privat">
<label for="privat">Privat opplasting</label><br>
<input type="file" name="file">
<button type="submit">Last opp </button>
</div>
</form>
</div>
</div>
<?php
if(isset($_SESSION['fileupload-response'])) {
$errorMSG = '
<div class="window" style="width: 300px">
<div class="title-bar">
<div class="title-bar-text">' .$_SESSION['filename'] . '</div>
<div class="title-bar-controls">
<button aria-label="Close"></button>
</div>
</div>
<div class="window-body">
Hmmmm... Her var det visst noe som gikk galt.
<button>Ok</button>
</div>
</div>';
$bannedMSG = '
<div class="window" style="width: 300px">
<div class="title-bar">
<div class="title-bar-text">' . $_SESSION['filename'] . '</div>
<div class="title-bar-controls">
<button aria-label="Close"></button>
</div>
</div>
<div class="window-body">
Denne filtypen er forbudt!
<button>Ok</button>
</div>
</div>';
if($_SESSION['fileupload-response'] == "success") {
$successMSG = '
<div class="window" style="width: 300px">
<div class="title-bar">
<div class="title-bar-text">' . $_SESSION['filename'] . '</div>
<div class="title-bar-controls">
<button aria-label="Close"></button>
</div>
</div>
<div class="window-body">
'
. $_SESSION['linkData'] .
'
<button type="button" class="btn btn-primary" onclick="copyToClipboard(\'' . $_SESSION['link'] . '\')">Kopier lenke</button>
</div>
</div>
';
echo($successMSG);
}
elseif ($_SESSION['fileupload-response'] == "failed") {
echo($errorMSG);
}
elseif ($_SESSION['fileupload-response'] == "banned") {
echo($bannedMSG);
}
session_destroy();
}
?>
</body>
</html>

60
upload.php Executable file
View File

@ -0,0 +1,60 @@
<?php
session_start();
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
if(isset($_FILES['file'])) {
$file = $_FILES['file'];
$fileName = $_FILES['file']['name'];
$file_name = $file['name'];
$file_tmp = $file['tmp_name'];
$file_size = $file['size'];
$file_error = $file['error'];
$fileError = $_FILES['file']['error'];
$_SESSION['filename'] = $fileName;
$file_destination = 'filer/' . $file_name;
$fileExt = explode('.', $fileName);
$fileActualExt = strtolower(end($fileExt));
$banned = array('php', 'js', 'php5', 'pht', 'phtml', 'shtml', 'asa', 'cer', 'asax', 'swf');
$allowed = array('zip', 'gz', 'tar', 'png', 'jpg', 'bmp', 'html', 'htm');
foreach ($banned as $url) {
if (strpos($fileActualExt, $url) !== FALSE) {
$fileError = 2;
}
}
if ($file_name === 'index.htm' || $file_name === 'index.html') {
$fileError = 2;
}
if($fileError == 0)
{
if(move_uploaded_file($file_tmp, $file_destination))
{
$path = 'https://trygve.me/filopplasting/' . $file_destination;
$filLink = '<a href=" ' . $path . '" class="alert-link">' . $path . '</a>';
//echo $fillink;()
$buttonData = 'Filen ble lastet opp! <a href="' . $filLink . '" class="btn btn-info">Kopier lenke</a>';
$_SESSION['linkData'] = 'Filen ble lastet opp! ' . $filLink;
$_SESSION['link'] = $path;
$_SESSION['fileupload-response'] = 'success';
}
}
elseif($fileError === 2)
{
$_SESSION['fileupload-response'] = 'banned';
}
else
{
$_SESSION['fileupload-response'] = 'failed';
}
}
header("location:../filopplasting");
?>