forked from gitbot/uguu
things
parent
85d74c0d22
commit
5d44b61c16
|
@ -18,7 +18,7 @@
|
||||||
"max_upload_size": 128,
|
"max_upload_size": 128,
|
||||||
"production": false,
|
"production": false,
|
||||||
"siteName": "SITENAME",
|
"siteName": "SITENAME",
|
||||||
"siteUrl": "https://yoursite.com",
|
"siteUrl": "http://localhost",
|
||||||
"abuseContact": "abuse@example.com",
|
"abuseContact": "abuse@example.com",
|
||||||
"infoContact": "info@example.com",
|
"infoContact": "info@example.com",
|
||||||
"ServerCountryLocation": "Sweden",
|
"ServerCountryLocation": "Sweden",
|
||||||
|
@ -27,4 +27,4 @@
|
||||||
"paypalUrl": "",
|
"paypalUrl": "",
|
||||||
"bitcoinAddress": "",
|
"bitcoinAddress": "",
|
||||||
"flattrUrl": ""
|
"flattrUrl": ""
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,29 +4,27 @@ class UploadedFile
|
||||||
{
|
{
|
||||||
/* Public attributes */
|
/* Public attributes */
|
||||||
public $name;
|
public $name;
|
||||||
public $mime;
|
|
||||||
public $size;
|
public $size;
|
||||||
public $tempfile;
|
public $tempfile;
|
||||||
public $error;
|
public $error;
|
||||||
|
|
||||||
/**
|
|
||||||
* SHA-1 checksum
|
|
||||||
*
|
|
||||||
* @var string 40 digit hexadecimal hash (160 bits)
|
|
||||||
*/
|
|
||||||
private $sha1;
|
private $sha1;
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates the SHA-1 or returns the cached SHA-1 hash for the file.
|
|
||||||
*
|
|
||||||
* @return string|false $sha1
|
|
||||||
*/
|
|
||||||
public function getSha1()
|
public function getSha1()
|
||||||
{
|
{
|
||||||
if (!$this->sha1) {
|
if (!$this->sha1) {
|
||||||
$this->sha1 = sha1_file($this->tempfile);
|
$this->sha1 = sha1_file($this->tempfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->sha1;
|
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
|
//Get EXT
|
||||||
$ext = pathinfo($file->name, PATHINFO_EXTENSION);
|
$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
|
// Check if extension is a double-dot extension and, if true, override $ext
|
||||||
$revname = strrev($file->name);
|
$revname = strrev($file->name);
|
||||||
foreach ($doubledots as $ddot) {
|
foreach ($doubledots as $ddot) {
|
||||||
|
@ -62,7 +57,7 @@ function generateName($file)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if MIME is blacklisted
|
//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);
|
http_response_code(415);
|
||||||
throw new UploadException(UPLOAD_ERR_EXTENSION);
|
throw new UploadException(UPLOAD_ERR_EXTENSION);
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -208,7 +203,6 @@ function refiles($files)
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
$f = new UploadedFile();
|
$f = new UploadedFile();
|
||||||
$f->name = $file['name'];
|
$f->name = $file['name'];
|
||||||
$f->mime = $file['type'];
|
|
||||||
$f->size = $file['size'];
|
$f->size = $file['size'];
|
||||||
$f->tempfile = $file['tmp_name'];
|
$f->tempfile = $file['tmp_name'];
|
||||||
$f->error = $file['error'];
|
$f->error = $file['error'];
|
||||||
|
|
Loading…
Reference in New Issue