diff --git a/.gitignore b/.gitignore index 294a377..9b52137 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ out/ *.xml src/php/config.php google*.html +bower_components/ \ No newline at end of file diff --git a/src/db.sql b/src/db.sql index d80cb5b..a483d1a 100644 --- a/src/db.sql +++ b/src/db.sql @@ -3,9 +3,9 @@ CREATE TABLE `files` ( `hash256` varchar(64) NOT NULL, `filename` varchar(255) NOT NULL, `mime` varchar(64) NOT NULL, - `size` int(11) NOT NULL, + `size` bigint(20) NOT NULL, `path` varchar(512) NOT NULL, - `views` int(11) DEFAULT 0 NULL, + `views` bigint(20) DEFAULT 0 NULL, `isAdminFile` bit(1) DEFAULT 0 NULL, `uploaded` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `lastview` timestamp NULL DEFAULT CURRENT_TIMESTAMP, diff --git a/src/php/upload.php b/src/php/upload.php index ce36c4e..b6fac71 100644 --- a/src/php/upload.php +++ b/src/php/upload.php @@ -2,6 +2,8 @@ include_once('db.php'); include_once("functions.php"); + set_time_limit(1200); + $response = array( "status" => 0, "msg" => null, @@ -14,7 +16,7 @@ ); $isMultipart = strpos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') !== False; - + //check input size is large enough $maxsizeM = ini_get('post_max_size'); $maxsize = (int)(str_replace('M', '', $maxsizeM) * 1024 * 1024); @@ -132,35 +134,39 @@ hash_update($phc, $fh); $ph = hash_final($phc); $response["publichash"] = $ph; + //save to disk $op = _FILEPATH . $ph; $fo = fopen($op, 'wb+'); if($fo !== False){ - stream_copy_to_stream($tmpf, $fo); - fclose($fo); - //save to db $f_e = new FileUpload(); $f_e->hash160 = $ph; $f_e->hash256 = $fh; $f_e->mime = $mime; - $f_e->size = filesize($op); + $f_e->size = $fsize; $f_e->path = $op; $f_e->filename = $fname; - $db->InsertFile($f_e); - $discord_data = array("content" => _SITEURL . '#' . $f_e->hash160); - send_discord_msg($discord_data); - - $response["status"] = 200; - $response["link"] = _SITEURL . $f_e->hash160; - $response["mime"] = $mime; - - if($isMultipart) { - $response["success"] = true; - $response["files"] = array(array("url" => $response["link"])); + if($db->InsertFile($f_e)) { + stream_copy_to_stream($tmpf, $fo); + fclose($fo); + $discord_data = array("content" => _SITEURL . '#' . $f_e->hash160); + send_discord_msg($discord_data); + + $response["status"] = 200; + $response["link"] = _SITEURL . $f_e->hash160; + $response["mime"] = $mime; + + if($isMultipart) { + $response["success"] = true; + $response["files"] = array(array("url" => $response["link"])); + } + } else { + $response["status"] = 500; + $response["msg"] = "Server error!"; } - }else{ + } else { $response["status"] = 500; $response["msg"] = "Server error!"; }