forked from gitbot/uguu
dont use == :)
This commit is contained in:
parent
ee3976f997
commit
a24bf794b0
@ -26,10 +26,10 @@ define('UGUU_DB_USER', 'NULL');
|
|||||||
define('UGUU_DB_PASS', 'NULL');
|
define('UGUU_DB_PASS', 'NULL');
|
||||||
|
|
||||||
/** Log IP of uploads */
|
/** Log IP of uploads */
|
||||||
define('LOG_IP', 'false');
|
define('LOG_IP', false);
|
||||||
|
|
||||||
/** Dont upload a file already in the DB */
|
/** Dont upload a file already in the DB */
|
||||||
define('ANTI_DUPE', 'false');
|
define('ANTI_DUPE', false);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* File system location where to store uploaded files
|
* File system location where to store uploaded files
|
||||||
|
@ -109,7 +109,7 @@ function uploadFile($file)
|
|||||||
// Check if a file with the same hash and size (a file which is the same)
|
// 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
|
// does already exist in the database; if it does, return the proper link
|
||||||
// and data. PHP deletes the temporary file just uploaded automatically.
|
// 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 = $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(':hash', $file->getSha1(), PDO::PARAM_STR);
|
||||||
$q->bindValue(':size', $file->size, PDO::PARAM_INT);
|
$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
|
// Generate a name for the file
|
||||||
$newname = generateName($file);
|
$newname = generateName($file);
|
||||||
|
|
||||||
@ -152,15 +149,15 @@ function uploadFile($file)
|
|||||||
); // HTTP status code "500 Internal Server Error"
|
); // HTTP status code "500 Internal Server Error"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add it to the database
|
// Log IP
|
||||||
if(LOG_IP == 'true'){
|
if(LOG_IP){
|
||||||
$q = $db->prepare('INSERT INTO files (hash, originalname, filename, size, date, ip) VALUES (:hash, :orig, :name, :size, :date, :ip)');
|
$ip = $_SERVER['REMOTE_ADDR'];
|
||||||
} else {
|
} else {
|
||||||
$ip = '0';
|
$ip = null;
|
||||||
$q = $db->prepare('INSERT INTO files (hash, originalname, filename, size, date, ip) VALUES (:hash, :orig, :name, :size, :date, :ip)');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Common parameters binding
|
// 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(':hash', $file->getSha1(), PDO::PARAM_STR);
|
||||||
$q->bindValue(':orig', strip_tags($file->name), PDO::PARAM_STR);
|
$q->bindValue(':orig', strip_tags($file->name), PDO::PARAM_STR);
|
||||||
$q->bindValue(':name', $newname, PDO::PARAM_STR);
|
$q->bindValue(':name', $newname, PDO::PARAM_STR);
|
||||||
|
Loading…
Reference in New Issue
Block a user