prepare("DELETE FROM emotes WHERE id = ?"); $stmt->execute([$id]); $db = null; array_map("unlink", glob("$path/*.*")); rmdir($path); } include "../../src/utils.php"; include "../../src/images.php"; $max_width = EMOTE_MAX_SIZE[0]; $max_height = EMOTE_MAX_SIZE[1]; if ($_SERVER['REQUEST_METHOD'] != "POST") { include "../../src/partials.php"; echo '' ?> Upload an emote - <?php echo INSTANCE_NAME ?>

Image*

Emote name*


test

prepare("INSERT INTO emotes(id, code, notes, uploaded_by, visibility) VALUES (?, ?, ?, ?, ?)"); $stmt->execute([$id, $code, $notes, $uploaded_by, $visibility]); $path = "../static/userdata/emotes/$id"; if (!is_dir($path)) { mkdir($path, 0777, true); } if ($is_manual) { $image_1x = $_FILES["file-1x"]; $image_2x = $_FILES["file-2x"]; $image_3x = $_FILES["file-3x"]; $file_1x = does_file_meet_requirements($image_1x["tmp_name"], $max_width / 4, $max_height / 4); $file_2x = does_file_meet_requirements($image_2x["tmp_name"], $max_width / 2, $max_height / 2); $file_3x = does_file_meet_requirements($image_3x["tmp_name"], $max_width, $max_height); if (!$file_1x[0] || !$file_2x[0] || !$file_3x[0]) { generate_alert("/emotes/upload.php", "Files don't meet requirements"); abort_upload($path, $db, $id); exit; } if ( !move_uploaded_file($image_1x["tmp_name"], "$path/1x.$file_1x[1]") || !move_uploaded_file($image_2x["tmp_name"], "$path/2x.$file_2x[1]") || !move_uploaded_file($image_3x["tmp_name"], "$path/3x.$file_3x[1]") ) { generate_alert("/emotes/upload.php", "Failed to move the uploaded files"); abort_upload($path, $db, $id); exit; } } else { $image = $_FILES["file"]; // resizing the image if ($err = resize_image($image["tmp_name"], "$path/3x", $max_width, $max_height)) { error_log("Error processing image: $err"); generate_alert("/emotes/upload.php", "Error occurred while processing the image ($err)", 500); abort_upload($path, $db, $id); exit; } if ($err = resize_image($image["tmp_name"], "$path/2x", $max_width / 2, $max_height / 2)) { error_log("Error processing image: $err"); generate_alert("/emotes/upload.php", "Error occurred while processing the image ($err)", 500); abort_upload($path, $db, $id); exit; } if ($err = resize_image($image["tmp_name"], "$path/1x", $max_width / 4, $max_height / 4)) { error_log("Error processing image: $err"); generate_alert("/emotes/upload.php", "Error occurred while processing the image ($err)", 500); abort_upload($path, $db, $id); exit; } } $db = null; if (CLIENT_REQUIRES_JSON) { json_response([ "status_code" => 201, "message" => null, "data" => [ "id" => $id, "code" => $code, "uploaded_by" => $uploaded_by ] ], 201); exit; } header("Location: /emotes?id=$id", true, 307);