mirror of
https://git.v0l.io/Kieran/void.cat.git
synced 2025-09-28 21:52:37 +02:00
support uploads > 4GB
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@ out/
|
|||||||
*.xml
|
*.xml
|
||||||
src/php/config.php
|
src/php/config.php
|
||||||
google*.html
|
google*.html
|
||||||
|
bower_components/
|
@@ -3,9 +3,9 @@ CREATE TABLE `files` (
|
|||||||
`hash256` varchar(64) NOT NULL,
|
`hash256` varchar(64) NOT NULL,
|
||||||
`filename` varchar(255) NOT NULL,
|
`filename` varchar(255) NOT NULL,
|
||||||
`mime` varchar(64) NOT NULL,
|
`mime` varchar(64) NOT NULL,
|
||||||
`size` int(11) NOT NULL,
|
`size` bigint(20) NOT NULL,
|
||||||
`path` varchar(512) 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,
|
`isAdminFile` bit(1) DEFAULT 0 NULL,
|
||||||
`uploaded` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
`uploaded` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
`lastview` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
`lastview` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
@@ -2,6 +2,8 @@
|
|||||||
include_once('db.php');
|
include_once('db.php');
|
||||||
include_once("functions.php");
|
include_once("functions.php");
|
||||||
|
|
||||||
|
set_time_limit(1200);
|
||||||
|
|
||||||
$response = array(
|
$response = array(
|
||||||
"status" => 0,
|
"status" => 0,
|
||||||
"msg" => null,
|
"msg" => null,
|
||||||
@@ -132,23 +134,23 @@
|
|||||||
hash_update($phc, $fh);
|
hash_update($phc, $fh);
|
||||||
$ph = hash_final($phc);
|
$ph = hash_final($phc);
|
||||||
$response["publichash"] = $ph;
|
$response["publichash"] = $ph;
|
||||||
|
|
||||||
//save to disk
|
//save to disk
|
||||||
$op = _FILEPATH . $ph;
|
$op = _FILEPATH . $ph;
|
||||||
$fo = fopen($op, 'wb+');
|
$fo = fopen($op, 'wb+');
|
||||||
if($fo !== False){
|
if($fo !== False){
|
||||||
stream_copy_to_stream($tmpf, $fo);
|
|
||||||
fclose($fo);
|
|
||||||
|
|
||||||
//save to db
|
//save to db
|
||||||
$f_e = new FileUpload();
|
$f_e = new FileUpload();
|
||||||
$f_e->hash160 = $ph;
|
$f_e->hash160 = $ph;
|
||||||
$f_e->hash256 = $fh;
|
$f_e->hash256 = $fh;
|
||||||
$f_e->mime = $mime;
|
$f_e->mime = $mime;
|
||||||
$f_e->size = filesize($op);
|
$f_e->size = $fsize;
|
||||||
$f_e->path = $op;
|
$f_e->path = $op;
|
||||||
$f_e->filename = $fname;
|
$f_e->filename = $fname;
|
||||||
|
|
||||||
$db->InsertFile($f_e);
|
if($db->InsertFile($f_e)) {
|
||||||
|
stream_copy_to_stream($tmpf, $fo);
|
||||||
|
fclose($fo);
|
||||||
$discord_data = array("content" => _SITEURL . '#' . $f_e->hash160);
|
$discord_data = array("content" => _SITEURL . '#' . $f_e->hash160);
|
||||||
send_discord_msg($discord_data);
|
send_discord_msg($discord_data);
|
||||||
|
|
||||||
@@ -164,6 +166,10 @@
|
|||||||
$response["status"] = 500;
|
$response["status"] = 500;
|
||||||
$response["msg"] = "Server error!";
|
$response["msg"] = "Server error!";
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$response["status"] = 500;
|
||||||
|
$response["msg"] = "Server error!";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//close streams
|
//close streams
|
||||||
fclose($tmpf);
|
fclose($tmpf);
|
||||||
|
Reference in New Issue
Block a user