forked from gitbot/uguu
things
parent
85d74c0d22
commit
5d44b61c16
|
@ -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": ""
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'];
|
||||
|
|
Loading…
Reference in New Issue