diff options
| author | Eliot Whalan <ewhal@pantsu.cat> | 2016-06-21 11:34:28 +0200 |
|---|---|---|
| committer | Eliot Whalan <ewhal@pantsu.cat> | 2016-06-21 11:34:28 +0200 |
| commit | 342c0128119367392072760ef14a1a5f4443e905 (patch) | |
| tree | e761c8a8e34fb816051d6c8a47745186b227beb5 | |
| parent | fc60a53e8a0d58d23716c6a15cc48daad5a3f584 (diff) | |
Reintroduce moe panel support
| -rw-r--r-- | php/upload.php | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/php/upload.php b/php/upload.php index 9b58ba4..b9e5f55 100644 --- a/php/upload.php +++ b/php/upload.php @@ -1,4 +1,5 @@ <?php +session_start(); /** * Handles POST uploads, generates filenames, moves files around and commits @@ -134,9 +135,18 @@ function uploadFile($file) // Add it to the database // 'expire' support is deprecated since version 2.1.0. It may be // removed in a future release. - $q = $db->prepare('INSERT INTO files (hash, originalname, filename, size, date, '. - 'expire, delid) VALUES (:hash, :orig, :name, :size, :date, '. - ':exp, :del)'); + if (empty($_SESSION['id'])) { + // Query if user is NOT logged in + $q = $db->prepare('INSERT INTO files (hash, originalname, filename, size, date, ' . + 'expire, delid) VALUES (:hash, :orig, :name, :size, :date, ' . + ':exp, :del)'); + } else { + // Query if user is logged in (insert user id together with other data) + $q = $db->prepare('INSERT INTO files (hash, originalname, filename, size, date, ' . + 'expire, delid, user) VALUES (:hash, :orig, :name, :size, :date, ' . + ':exp, :del, :user)'); + $q->bindValue(':user', $_SESSION['id'], PDO::PARAM_INT); + } // Common parameters binding $q->bindValue(':hash', $file->getSha1(), PDO::PARAM_STR); @@ -144,7 +154,7 @@ function uploadFile($file) $q->bindValue(':name', $newname, PDO::PARAM_STR); $q->bindValue(':size', $file->size, PDO::PARAM_INT); $q->bindValue(':date', date('Y-m-d'), PDO::PARAM_STR); - $q->bindValue(':exp', null, PDO::PARAM_STR); // Deprecated since version 2.1.0 + $q->bindValue(':exp', null, PDO::PARAM_STR); $q->bindValue(':del', sha1($file->tempfile), PDO::PARAM_STR); $q->execute(); |
