diff --git a/dist.json b/dist.json index 6163063..2a13914 100644 --- a/dist.json +++ b/dist.json @@ -18,7 +18,7 @@ "max_upload_size": 128, "production": false, "siteName": "SITENAME", - "siteUrl": "https://yoursite.com", + "siteUrl": "http://localhost", "abuseContact": "abuse@example.com", "infoContact": "info@example.com", "ServerCountryLocation": "Sweden", @@ -27,4 +27,4 @@ "paypalUrl": "", "bitcoinAddress": "", "flattrUrl": "" -} \ No newline at end of file +} diff --git a/static/php/classes/UploadedFile.class.php b/static/php/classes/UploadedFile.class.php index d90a9a4..4a92df8 100644 --- a/static/php/classes/UploadedFile.class.php +++ b/static/php/classes/UploadedFile.class.php @@ -4,29 +4,27 @@ class UploadedFile { /* Public attributes */ public $name; - public $mime; public $size; public $tempfile; public $error; - /** - * SHA-1 checksum - * - * @var string 40 digit hexadecimal hash (160 bits) - */ private $sha1; - - /** - * Generates the SHA-1 or returns the cached SHA-1 hash for the file. - * - * @return string|false $sha1 - */ public function getSha1() { if (!$this->sha1) { $this->sha1 = sha1_file($this->tempfile); } - return $this->sha1; } + + private $mime; + public function getMime() + { + if (!$this->mime) { + $finfo = finfo_open(FILEINFO_MIME_TYPE); + $this->mime = finfo_file($finfo, $this->tempfile); + finfo_close($finfo); + } + return $this->mime; + } } diff --git a/static/php/upload.php b/static/php/upload.php index 23200cc..a7a3160 100644 --- a/static/php/upload.php +++ b/static/php/upload.php @@ -27,11 +27,6 @@ function generateName($file) //Get EXT $ext = pathinfo($file->name, PATHINFO_EXTENSION); - //Get MIME - $finfo = finfo_open(FILEINFO_MIME_TYPE); - $type_mime = finfo_file($finfo, $file->tempfile); - finfo_close($finfo); - // Check if extension is a double-dot extension and, if true, override $ext $revname = strrev($file->name); foreach ($doubledots as $ddot) { @@ -62,7 +57,7 @@ function generateName($file) } //Check if MIME is blacklisted - if (in_array($type_mime, unserialize(CONFIG_BLOCKED_MIME))) { + if (in_array($file->getMime(), unserialize(CONFIG_BLOCKED_MIME))) { http_response_code(415); throw new UploadException(UPLOAD_ERR_EXTENSION); exit(0); @@ -208,7 +203,6 @@ function refiles($files) foreach ($files as $file) { $f = new UploadedFile(); $f->name = $file['name']; - $f->mime = $file['type']; $f->size = $file['size']; $f->tempfile = $file['tmp_name']; $f->error = $file['error'];