Skip to content

Commit

Permalink
dont use == :)
Browse files Browse the repository at this point in the history
  • Loading branch information
nokonoko committed Jun 28, 2021
1 parent ee3976f commit a24bf79
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions static/php/includes/settings.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
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
Expand Down
19 changes: 8 additions & 11 deletions static/php/upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -125,9 +125,6 @@ function uploadFile($file)
}
}

// Get IP
$ip = $_SERVER['REMOTE_ADDR'];

// Generate a name for the file
$newname = generateName($file);

Expand All @@ -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);
Expand Down

0 comments on commit a24bf79

Please sign in to comment.