Updated 7 files and added 2 files (automated)
parent
97cbc28a2d
commit
5680b32f1a
File diff suppressed because one or more lines are too long
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php";
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php";
|
||||
|
||||
global $_PROFILE; global $_USER;
|
||||
|
||||
$uuid = uuid();
|
||||
|
||||
header("Content-Type: application/json");
|
||||
|
||||
if (!isset($_FILES["upload"])) {
|
||||
die(json_encode([
|
||||
"error" => [
|
||||
"message" => l("lang_upload_errors_unreceived")
|
||||
]
|
||||
]));
|
||||
}
|
||||
|
||||
if ($_FILES["upload"]["error"] !== 0) {
|
||||
die(json_encode([
|
||||
"error" => [
|
||||
"message" => l("lang_upload_errors_internal")
|
||||
]
|
||||
]));
|
||||
}
|
||||
|
||||
if ($_FILES["upload"]["type"] !== "image/png" && $_FILES["upload"]["type"] !== "image/jpeg" && $_FILES["upload"]["type"] !== "image/webp" && $_FILES["upload"]["type"] !== "image/gif" && $_FILES["upload"]["type"] !== "image/bmp" && $_FILES["upload"]["type"] !== "image/avif") {
|
||||
die(json_encode([
|
||||
"error" => [
|
||||
"message" => l("lang_upload_errors_type")
|
||||
]
|
||||
]));
|
||||
}
|
||||
|
||||
$im = imagecreate(1, 1);
|
||||
|
||||
switch ($_FILES["upload"]["type"]) {
|
||||
case "image/png":
|
||||
$im = imagecreatefrompng($_FILES["upload"]["tmp_name"]);
|
||||
break;
|
||||
|
||||
case "image/jpeg":
|
||||
$im = imagecreatefromjpeg($_FILES["upload"]["tmp_name"]);
|
||||
break;
|
||||
|
||||
case "image/webp":
|
||||
$im = imagecreatefromwebp($_FILES["upload"]["tmp_name"]);
|
||||
break;
|
||||
|
||||
case "image/gif":
|
||||
$im = imagecreatefromgif($_FILES["upload"]["tmp_name"]);
|
||||
break;
|
||||
|
||||
case "image/bmp":
|
||||
$im = imagecreatefrombmp($_FILES["upload"]["tmp_name"]);
|
||||
break;
|
||||
|
||||
case "image/avif":
|
||||
$im = imagecreatefromavif($_FILES["upload"]["tmp_name"]);
|
||||
break;
|
||||
}
|
||||
|
||||
imagejpeg($im, $_SERVER['DOCUMENT_ROOT'] . "/uploads/" . $uuid . ".jpg");
|
||||
|
||||
$list = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/embeds.json")), true);
|
||||
|
||||
$list[] = $uuid;
|
||||
|
||||
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/embeds.json", pf_utf8_encode(json_encode($list)));
|
||||
|
||||
die(json_encode([
|
||||
"url" => "/uploads/" . $uuid . ".jpg"
|
||||
]));
|
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php";
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php";
|
||||
|
||||
global $_PROFILE; global $_USER;
|
||||
|
||||
$id = $_GET['id'] ?? null;
|
||||
$uuid = uuid();
|
||||
|
||||
header("Content-Type: text/plain");
|
||||
var_dump($_POST, $_FILES["file"], $uuid);
|
||||
|
||||
if (!isset($_FILES["file"])) {
|
||||
header("Location: /upload/$id&error=unreceived");
|
||||
die();
|
||||
}
|
||||
|
||||
if ($_FILES["file"]["error"] !== 0) {
|
||||
header("Location: /upload/$id&error=internal");
|
||||
die();
|
||||
}
|
||||
|
||||
if ($_FILES["file"]["type"] !== "image/png" && $_FILES["file"]["type"] !== "image/jpeg" && $_FILES["file"]["type"] !== "image/webp" && $_FILES["file"]["type"] !== "image/gif" && $_FILES["file"]["type"] !== "image/bmp" && $_FILES["file"]["type"] !== "image/avif") {
|
||||
header("Location: /upload/$id&error=type");
|
||||
die();
|
||||
}
|
||||
|
||||
$im = imagecreate(1, 1);
|
||||
|
||||
switch ($_FILES["file"]["type"]) {
|
||||
case "image/png":
|
||||
$im = imagecreatefrompng($_FILES["file"]["tmp_name"]);
|
||||
break;
|
||||
|
||||
case "image/jpeg":
|
||||
$im = imagecreatefromjpeg($_FILES["file"]["tmp_name"]);
|
||||
break;
|
||||
|
||||
case "image/webp":
|
||||
$im = imagecreatefromwebp($_FILES["file"]["tmp_name"]);
|
||||
break;
|
||||
|
||||
case "image/gif":
|
||||
$im = imagecreatefromgif($_FILES["file"]["tmp_name"]);
|
||||
break;
|
||||
|
||||
case "image/bmp":
|
||||
$im = imagecreatefrombmp($_FILES["file"]["tmp_name"]);
|
||||
break;
|
||||
|
||||
case "image/avif":
|
||||
$im = imagecreatefromavif($_FILES["file"]["tmp_name"]);
|
||||
break;
|
||||
}
|
||||
|
||||
imagejpeg($im, $_SERVER['DOCUMENT_ROOT'] . "/uploads/" . $uuid . ".jpg");
|
||||
|
||||
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/requests/" . $uuid . ".json", pf_utf8_encode(json_encode([
|
||||
"type" => "galleryupload",
|
||||
"author" => $_USER,
|
||||
"id" => $id,
|
||||
"contents" => null,
|
||||
"summary" => $_POST["summary"],
|
||||
"date" => date('c')
|
||||
])));
|
||||
|
||||
$_PROFILE["requests"][$id . ":" . $uuid] = $uuid;
|
||||
saveProfile();
|
||||
|
||||
header("Location: /upload/$id&success");
|
||||
die();
|
Loading…
Reference in New Issue