From 342c0128119367392072760ef14a1a5f4443e905 Mon Sep 17 00:00:00 2001 From: Eliot Whalan Date: Tue, 21 Jun 2016 19:34:28 +1000 Subject: Reintroduce moe panel support --- php/upload.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'php') 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 @@ 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(); -- cgit v1.2.3