diff --git a/about.php b/about.php index 3f7a942..40ca137 100644 --- a/about.php +++ b/about.php @@ -1,4 +1,4 @@ -query('SELECT * FROM keys'); while ($line = $DatabaseQuery->fetchArray()) { - if ($line['key'] == $_COOKIE[$cookieName] && $_COOKIE[$cookieName] != "" && $line['key'] != "" && $line['keytype'] == 2 && ($enableKeys || $enableKeys == "true")) { + if ($line['key'] == $_SESSION['key'] && $_SESSION['key'] != "" && $line['key'] != "" && $line['keytype'] == 2 && ($enableKeys || $enableKeys == "true")) { $Authorized = 1; $Primary = $line['primaryadmin']; break; diff --git a/config.def.ini b/config.def.ini index 1db7b8a..7d7eeb0 100644 --- a/config.def.ini +++ b/config.def.ini @@ -26,7 +26,6 @@ sqldb = curload.sql enable_keys = true enable_temporary_keys = true enable_admin_keys = true -cookie_name = speedierocks [logging] store_ip = true diff --git a/config.php b/config.php index cb1a7cc..0f1cf09 100644 --- a/config.php +++ b/config.php @@ -24,13 +24,11 @@ $dateFormat = "Y/m/d"; $instanceName = "curload"; $instanceDescription = "curload is a simple file uploading site allowing users to upload files by authenticating using a key."; $footerText = "Licensed under the GNU Affero General Public License version 3.0."; -$cookieName = "speedierocks"; $enableKeys = true; $enableAdminKeys = true; $enableTemporaryKeys = true; $enableUploadRemoval = true; $enableKeyUploadRemoval = false; -$cookieTypeName = "$cookieName" . "_type"; $configFile = ""; @@ -72,7 +70,5 @@ $enableAdminKeys = $configEntries['enable_admin_keys']; $enableTemporaryKeys = $configEntries['enable_temporary_keys']; $enableUploadRemoval = $configEntries['enable_upload_removal']; $enableKeyUploadRemoval = $configEntries['enable_key_upload_removal']; -$cookieName = $configEntries['cookie_name']; $javaScript = $configEntries['javascript']; -$cookieTypeName = "$cookieName" . "_type"; ?> diff --git a/core.php b/core.php index 2b9160f..80387ef 100644 --- a/core.php +++ b/core.php @@ -51,7 +51,7 @@ function printHeader($html) { $html .= "\t\t\t\n"; if (file_exists($Logo)) $html .= "\t\t\t\t\n"; $html .= "\t\t\t\t$instanceName\n"; - if (isset($_COOKIE[$cookieName])) $html .= "\t\t\t\tYour files\n"; + if (isset($_SESSION['key'])) $html .= "\t\t\t\tYour files\n"; foreach (glob('*.php') as $file) { if (!file_exists("$file".".name")) { @@ -63,13 +63,13 @@ function printHeader($html) { $html .= "\t\t\t\t$name\n"; } - if (!isset($_COOKIE[$cookieName])) { + if (!isset($_SESSION['key'])) { $html .= "\t\t\t\tLog in\n"; } else { $html .= "\t\t\t\tLog out\n"; } - if (isset($_COOKIE[$cookieTypeName]) && $_COOKIE[$cookieTypeName] == 2) { + if (isset($_SESSION['type']) && $_SESSION['type'] == 2) { $html .= "\t\t\t\tAdministration\n"; } @@ -101,7 +101,7 @@ function printFileUploadForm($html, $Error) { include "config.php"; // print the form - if (isset($_COOKIE[$cookieTypeName]) || ($publicUploading || $publicUploading == "true")) { + if (isset($_SESSION['type']) || ($publicUploading || $publicUploading == "true")) { $html .= "\t\t\t
\n"; $html .= "\t\t\t\t\n"; $html .= "\t\t\t\t\n"; diff --git a/create.php b/create.php index b34f87e..89654d3 100644 --- a/create.php +++ b/create.php @@ -1,4 +1,4 @@ -query('SELECT * FROM keys'); if (!checkIfAdminExists()) { $firstKey = 1; } else { - if (!isset($_COOKIE[$cookieName]) || !isset($_COOKIE[$cookieTypeName])) { + if (!isset($_SESSION['key']) || !isset($_SESSION['type'])) { header('Location: login.php?redir=admin'); die(); - } else if ($_COOKIE[$cookieTypeName] != 2) { // not allowed + } else if ($_SESSION['type'] != 2) { // not allowed header('Location: /'); die(); } @@ -42,7 +42,7 @@ if (!checkIfAdminExists()) { $DatabaseQuery = $Database->query('SELECT * FROM keys'); while ($line = $DatabaseQuery->fetchArray()) { - if ($line['key'] == $_COOKIE[$cookieName] && $_COOKIE[$cookieName] != "" && $line['key'] != "" && ($enableKeys || $enableKeys == "true")) { + if ($line['key'] == $_SESSION['key'] && $_SESSION['key'] != "" && $line['key'] != "" && ($enableKeys || $enableKeys == "true")) { $AuthorizedCreation = 1; $AdminIsPrimary = $line['primaryadmin']; break; diff --git a/files.php b/files.php index 6f550e4..2bdbf50 100644 --- a/files.php +++ b/files.php @@ -1,4 +1,4 @@ -Your files\n"; $html .= "\t\t\t\t

These are the files you have uploaded using this key.

\n"; // If logged in ... -if (isset($_COOKIE[$cookieTypeName]) && (!$publicUploading || $publicUploading == "false")) { +if (isset($_SESSION['type']) && (!$publicUploading || $publicUploading == "false")) { $Database = createTables($sqlDB); $DatabaseQuery = $Database->query('SELECT * FROM uploads'); @@ -46,7 +46,7 @@ if (isset($_COOKIE[$cookieTypeName]) && (!$publicUploading || $publicUploading = $UserDatabaseQuery = $Database->query('SELECT * FROM keys'); while ($uline = $UserDatabaseQuery->fetchArray()) { - if ($uline['id'] == $keyID && $_COOKIE[$cookieName] == $uline['key']) { + if ($uline['id'] == $keyID && $_SESSION['key'] == $uline['key']) { $CorrectFile = 1; break; } diff --git a/index.php b/index.php index 2098549..7a68f34 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,4 @@ -$instanceName\n"; $html .= "\t\t\t\t

$instanceDescription

\n"; // If logged in ... -if (isset($_COOKIE[$cookieTypeName]) || ($publicUploading || $publicUploading == "true")) { +if (isset($_SESSION['type']) || ($publicUploading || $publicUploading == "true")) { $html = printFileUploadForm($html, $Error); } else { $html .= "\t\t\t\t

To upload a file, log in using your key and select a file to upload. After uploading, you will receive a link to the file stored on the servers.

\n"; diff --git a/login.php b/login.php index 68c3752..97663f1 100644 --- a/login.php +++ b/login.php @@ -1,4 +1,4 @@ -query('SELECT * FROM keys'); while ($line = $DatabaseQuery->fetchArray()) { - if ($line['keytype'] == 2 && $line['key'] == $_COOKIE[$cookieName] && $_COOKIE[$cookieName] != "" && $line['key'] != "" && ($enableKeys || $enableKeys == "true")) { + if ($line['keytype'] == 2 && $line['key'] == $_SESSION['key'] && $_SESSION['key'] != "" && $line['key'] != "" && ($enableKeys || $enableKeys == "true")) { $AuthorizedRemoval = 1; $AdminIsPrimary = $line['primaryadmin']; break; diff --git a/remove.php b/remove.php index 863a353..6331d68 100644 --- a/remove.php +++ b/remove.php @@ -1,4 +1,4 @@ -fetchArray()) { } while ($kline = $keyDatabaseQuery->fetchArray()) { - if ($kline['key'] == $_COOKIE[$cookieName] && $_COOKIE[$cookieName] != "" && $kline['key'] != "" && $kline['keytype'] == 2) { // key = passed key + if ($kline['key'] == $_SESSION['key'] && $_SESSION['key'] != "" && $kline['key'] != "" && $kline['keytype'] == 2) { // key = passed key if (($fileUploadedByPrimary == 1 && $kline['primaryadmin'] == 1) || ($fileUploadedByPrimary == 0)) { // primary key passed and primary file OR non primary file $AuthorizedRemoval = 1; break; diff --git a/setup.php b/setup.php index 274b9b5..923918c 100644 --- a/setup.php +++ b/setup.php @@ -1,4 +1,4 @@ -