From c0dc531ebefd8912819f3b6c8bda1fed3c7e750c Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Wed, 31 Jan 2024 06:11:00 +0300 Subject: make it simple, but not simpler --- handler/admin/Uploads.php | 73 ----------------------------------------------- 1 file changed, 73 deletions(-) delete mode 100644 handler/admin/Uploads.php (limited to 'handler/admin/Uploads.php') diff --git a/handler/admin/Uploads.php b/handler/admin/Uploads.php deleted file mode 100644 index 0cbb2f6..0000000 --- a/handler/admin/Uploads.php +++ /dev/null @@ -1,73 +0,0 @@ -input('error'); - $uploads = \uploads::getAll(); - - $this->skin->title = ($this->lang)('blog_upload'); - return $this->skin->renderPage('admin/uploads', - error: $error, - uploads: $uploads); - } - - public function post(): Response { - csrf::check('addupl'); - - list($custom_name, $note) = $this->input('name, note'); - - if (!isset($_FILES['files'])) - return new RedirectResponse('/uploads/?error='.urlencode('no file')); - - $files = []; - for ($i = 0; $i < count($_FILES['files']['name']); $i++) { - $files[] = [ - 'name' => $_FILES['files']['name'][$i], - 'type' => $_FILES['files']['type'][$i], - 'tmp_name' => $_FILES['files']['tmp_name'][$i], - 'error' => $_FILES['files']['error'][$i], - 'size' => $_FILES['files']['size'][$i], - ]; - } - - if (count($files) > 1) { - $note = ''; - $custom_name = ''; - } - - foreach ($files as $f) { - if ($f['error']) - return new RedirectResponse('/uploads/?error='.urlencode('error code '.$f['error'])); - - if (!$f['size']) - return new RedirectResponse('/uploads/?error='.urlencode('received empty file')); - - $ext = extension($f['name']); - if (!\uploads::isExtensionAllowed($ext)) - return new RedirectResponse('/uploads/?error='.urlencode('extension not allowed')); - - $upload_id = \uploads::add( - $f['tmp_name'], - $custom_name ?: $f['name'], - $note); - - if (!$upload_id) - return new RedirectResponse('/uploads/?error='.urlencode('failed to create upload')); - } - - return new RedirectResponse('/uploads/'); - } - -} \ No newline at end of file -- cgit v1.2.3