diff --git a/static/php/includes/settings.inc.php b/static/php/includes/settings.inc.php index fb09d6c..e94f49b 100644 --- a/static/php/includes/settings.inc.php +++ b/static/php/includes/settings.inc.php @@ -26,10 +26,10 @@ define('UGUU_DB_USER', 'NULL'); define('UGUU_DB_PASS', 'NULL'); /** Log IP of uploads */ -define('LOG_IP', 'false'); +define('LOG_IP', false); /** Dont upload a file already in the DB */ -define('ANTI_DUPE', 'false'); +define('ANTI_DUPE', false); /* * File system location where to store uploaded files diff --git a/static/php/upload.php b/static/php/upload.php index 23200cc..f49ae4c 100644 --- a/static/php/upload.php +++ b/static/php/upload.php @@ -109,7 +109,7 @@ function uploadFile($file) // Check if a file with the same hash and size (a file which is the same) // does already exist in the database; if it does, return the proper link // and data. PHP deletes the temporary file just uploaded automatically. - if(ANTI_DUPE == 'true'){ + if(ANTI_DUPE){ $q = $db->prepare('SELECT filename, COUNT(*) AS count FROM files WHERE hash = (:hash) AND size = (:size)'); $q->bindValue(':hash', $file->getSha1(), PDO::PARAM_STR); $q->bindValue(':size', $file->size, PDO::PARAM_INT); @@ -125,9 +125,6 @@ function uploadFile($file) } } - // Get IP - $ip = $_SERVER['REMOTE_ADDR']; - // Generate a name for the file $newname = generateName($file); @@ -152,15 +149,15 @@ function uploadFile($file) ); // HTTP status code "500 Internal Server Error" } - // Add it to the database - if(LOG_IP == 'true'){ - $q = $db->prepare('INSERT INTO files (hash, originalname, filename, size, date, ip) VALUES (:hash, :orig, :name, :size, :date, :ip)'); - } else { - $ip = '0'; - $q = $db->prepare('INSERT INTO files (hash, originalname, filename, size, date, ip) VALUES (:hash, :orig, :name, :size, :date, :ip)'); - } + // Log IP + if(LOG_IP){ + $ip = $_SERVER['REMOTE_ADDR']; + } else { + $ip = null; + } // Common parameters binding + $q = $db->prepare('INSERT INTO files (hash, originalname, filename, size, date, ip) VALUES (:hash, :orig, :name, :size, :date, :ip)'); $q->bindValue(':hash', $file->getSha1(), PDO::PARAM_STR); $q->bindValue(':orig', strip_tags($file->name), PDO::PARAM_STR); $q->bindValue(':name', $newname, PDO::PARAM_STR);