2023-10-06 14:48:06 +01:00
|
|
|
<?php
|
|
|
|
include 'include/db.php';
|
|
|
|
include 'include/templates.php';
|
|
|
|
|
2024-07-28 19:28:08 +01:00
|
|
|
loggedInCheck();
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
|
|
$path_parts = pathinfo($_FILES["fileToUpload"]["name"]);
|
|
|
|
$location = "img/" . bin2hex(random_bytes(16)) . "-" . time() . "." . $path_parts['extension'];
|
|
|
|
$uploadValid = 1;
|
|
|
|
|
|
|
|
if(@is_array(getimagesize($_FILES["fileToUpload"]["tmp_name"])) == false){
|
|
|
|
$uploadValid = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if($_FILES['userfile']['size'] > 300000000){
|
|
|
|
$uploadValid = 0;
|
|
|
|
}
|
|
|
|
|
2024-07-28 21:23:46 +01:00
|
|
|
if(ctype_alnum(str_replace("_", "",str_replace(",","",$_POST["tags"]))) == false){
|
2024-07-28 19:28:08 +01:00
|
|
|
$uploadValid = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if($uploadValid == 0){
|
|
|
|
showHeader();
|
|
|
|
echo '<h3>An error has occured, please try again.</h3>';
|
|
|
|
echo $footer;
|
|
|
|
die();
|
|
|
|
} else {
|
|
|
|
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $location);
|
|
|
|
|
|
|
|
addImage($location, tokenToUsername($_COOKIE["meowboardSession"]), $_POST["tags"]);
|
|
|
|
showHeader();
|
|
|
|
echo '<h3>File uploaded!</h3>';
|
|
|
|
echo $footer;
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2023-10-06 14:48:06 +01:00
|
|
|
showHeader();
|
|
|
|
echo '<h3>Upload</h3><form action="upload.php" method="post" enctype="multipart/form-data">
|
2024-07-28 19:28:08 +01:00
|
|
|
<div class="upload">Upload <input type="file" name="fileToUpload" id="fileToUpload"> <icon>⇑</icon></div>
|
2023-10-06 14:48:06 +01:00
|
|
|
<label for="tags">Tags</label><br/><input type="text" id="tags" name="tags">
|
|
|
|
<br/><button>submit</button>
|
|
|
|
</form>';
|
|
|
|
echo $footer;
|
|
|
|
}
|
|
|
|
?>
|