+ //fixes a bug
+ $lol = $file->getSha1();
+
+ // 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'){
+ $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);
+ $q->execute();
+ $result = $q->fetch();
+ if ($result['count'] > 0) {
+ return [
+ 'hash' => $file->getSha1(),
+ 'name' => $file->name,
+ 'url' => UGUU_URL.rawurlencode($result['filename']),
+ 'size' => $file->size,
+ ];
+ }
+}
+
+ // Get IP
+ $ip = $_SERVER['REMOTE_ADDR'];
+