X-Git-Url: https://jfr.im/git/uguu.git/blobdiff_plain/4e2292a92e4cc78b61889b8abf28eb26a845db43..317f6899046421f99276b7656f025f3fcc030ae2:/static/php/upload.php diff --git a/static/php/upload.php b/static/php/upload.php index 02c83e6..6c6786b 100644 --- a/static/php/upload.php +++ b/static/php/upload.php @@ -22,8 +22,8 @@ function generateName($file) global $doubledots; // We start at N retries, and --N until we give up - $tries = POMF_FILES_RETRIES; - $length = POMF_FILES_LENGTH; + $tries = UGUU_FILES_RETRIES; + $length = UGUU_FILES_LENGTH; //Get EXT $ext = pathinfo($file->name, PATHINFO_EXTENSION); //Get mime @@ -67,7 +67,6 @@ function generateName($file) exit(0); } - //Check if EXT is blacklisted if (in_array($ext, unserialize(CONFIG_BLOCKED_EXTENSIONS))) { http_response_code(415); @@ -75,17 +74,6 @@ function generateName($file) exit(0); } - // Check blacklist DB - $q = $db->prepare('SELECT hash, COUNT(*) AS count FROM blacklistedfiles WHERE hash = (:hash)'); - $q->bindValue(':hash', $file->getSha1(), PDO::PARAM_STR); - $q->execute(); - $result = $q->fetch(); - if ($result['count'] > 0) { - http_response_code(415); - throw new UploadException(UPLOAD_ERR_BLACKLISTED); - exit(0); - } - // Check if a file with the same name does already exist in the database $q = $db->prepare('SELECT COUNT(filename) FROM files WHERE filename = (:name)'); $q->bindValue(':name', $name, PDO::PARAM_STR); @@ -121,7 +109,7 @@ function uploadFile($file) $ip = $_SERVER['REMOTE_ADDR']; // Store the file's full file path in memory - $uploadFile = POMF_FILES_ROOT . $newname; + $uploadFile = UGUU_FILES_ROOT . $newname; // Attempt to move it to the static directory if (!move_uploaded_file($file->tempfile, $uploadFile)) { @@ -145,7 +133,8 @@ function uploadFile($file) if(LOG_IP == 'yes'){ $q = $db->prepare('INSERT INTO files (hash, originalname, filename, size, date, ip) VALUES (:hash, :orig, :name, :size, :date, :ip)'); }else{ - $q = $db->prepare('INSERT INTO files (hash, originalname, filename, size, date) VALUES (:hash, :orig, :name, :size, :date)'); + $ip = '0'; + $q = $db->prepare('INSERT INTO files (hash, originalname, filename, size, date, ip) VALUES (:hash, :orig, :name, :size, :date, :ip)'); } // Common parameters binding $q->bindValue(':hash', $file->getSha1(), PDO::PARAM_STR); @@ -159,7 +148,7 @@ function uploadFile($file) return array( 'hash' => $file->getSha1(), 'name' => $file->name, - 'url' => POMF_URL.rawurlencode($newname), + 'url' => UGUU_URL.rawurlencode($newname), 'size' => $file->size, ); }