summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar steering72532026-07-10 07:04:52 +0000
committerGravatar steering72532026-07-10 07:04:52 +0000
commit81cce7f517246080bbcf2d4faadc3f982c5415f4 (patch)
tree65b0f95ffef4bc55e43ac5e5ae1d69238eed34f3
parentrework remap_files a bit (diff)
downloadhostfiles-81cce7f517246080bbcf2d4faadc3f982c5415f4.tar.gz
hostfiles-81cce7f517246080bbcf2d4faadc3f982c5415f4.tar.bz2
hostfiles-81cce7f517246080bbcf2d4faadc3f982c5415f4.zip
rework die_error a bit
-rw-r--r--upload.php11
1 files changed, 4 insertions, 7 deletions
diff --git a/upload.php b/upload.php
index d643d0a..043c5ee 100644
--- a/upload.php
+++ b/upload.php
@@ -16,10 +16,7 @@ $c_t = strtolower($_SERVER['HTTP_CONTENT_TYPE'] ?? '');
if ($c_t == 'multipart/form-data' || 0 === strpos($c_t, 'multipart/form-data;')) {
$FILES = remap_files();
if (!isset($FILES['file'])) {
- header('Status: 406 Not Acceptable');
- header('Content-Type: text/plain');
- echo "You need to upload the file within the field name 'file' or 'file[]' if you want to use multipart/form-data.\n";
- exit;
+ die_error("You need to upload the file within the field name 'file[]' (or 'file' if there's only one) if you want to use multipart/form-data.", '406 Not Acceptable');
}
foreach ($FILES['file'] as $file) {
if (!is_uploaded_file($file['tmp_name'])) {
@@ -101,10 +98,10 @@ function send_notification($note) {
}
-function die_error($s) {
+function die_error($s, $status='500 Server Is 💩') {
global $tmp_path, $filepath, $size;
- header('Status: 500 Server Is 💩');
- echo $s;
+ header('Status: ' . $status);
+ echo $s . "\n";
error_log($s);
@$debug = json_encode(array('s'=>$_SERVER, 'f'=>$_FILES, 't'=>$tmp_path, 'p'=>$filepath, 'size' => $size));
send_notification("[hostfil.es] $_SERVER[REMOTE_ADDR] ! $s\n$debug");