diff --git a/functions/account_functions.php b/functions/account_functions.php
index 5c1be10..970de5e 100644
--- a/functions/account_functions.php
+++ b/functions/account_functions.php
@@ -22,34 +22,19 @@ function username_exists($username)
return true;
}
-function cookies($user, $time)
-{
- setcookie('user_id', $user['user_id'], $time);
- setcookie('username', $user['username'], $time);
- setcookie('email', $user['email'], $time);
- setcookie('role_id', $user['role_id'], $time);
- setcookie('profile_picture', $user['profile_picture'], $time);
-}
-
function logout()
{
- foreach (array_keys($_COOKIE) as $key) {
- setcookie($key, '', time() - 3600, '/');
- unset($_COOKIE[$key]);
- }
-
- foreach (array_keys($_SESSION) as $key) {
+ foreach (array_keys($_SESSION) as $key)
unset($_SESSION[$key]);
- }
- header('Location: articles.php');
+ header('Location: .');
}
function login($username, $password, $stay_logged_in)
{
$password_hash = hash('sha256', $password);
- $user = exec_stmt('SELECT user_id, username, email, role_id, profile_picture FROM user WHERE username = ? OR email = ? AND password_hash = ?', 'sss', $username, $username, $password_hash)->fetch_assoc();
+ $user = exec_stmt('SELECT user_id, username, role_id FROM user WHERE username = ? OR email = ? AND password_hash = ?', 'sss', $username, $username, $password_hash)->fetch_assoc();
if ($user == null) {
$error_msg = '
@@ -61,8 +46,8 @@ function login($username, $password, $stay_logged_in)
return $error_msg;
}
- $time = time() + 60 * 60 * 1;
- cookies($user, $time);
+ $_SESSION['user_id'] = $user['user_id'];
+ $_SESSION['username'] = $user['role_id'];
if ($stay_logged_in) {
$token = bin2hex(random_bytes(64));
@@ -247,7 +232,7 @@ function delete_account($user_id, $password = null, $verify_password = null)
exec_stmt('DELETE FROM user WHERE user_id = ?', 'i', $user_id);
logout();
- } else if ($_COOKIE['role_id'] <= 2) {
+ } else if ($_SESSION['role_id'] <= 2) {
$user = exec_stmt('SELECT user_id, profile_picture FROM user WHERE user_id = ?', 'i', $user_id)->fetch_assoc();
if ($user['user_id'] == 2025) {
diff --git a/functions/init.php b/functions/init.php
index d67324b..3f61510 100644
--- a/functions/init.php
+++ b/functions/init.php
@@ -21,23 +21,15 @@ if (!isset($_SESSION['initialized'])) {
}
// Update the database and cookies to keep the user logged in.
-if (isset($_COOKIE['user_id'])) {
+if (isset($_SESSION['user_id'])) {
$conn = get_connection();
$stmt = $conn->prepare('UPDATE user SET is_active = true WHERE user_id = ?');
- $stmt->bind_param('i', $_COOKIE['user_id']);
+ $stmt->bind_param('i', $_SESSION['user_id']);
$stmt->execute();
$stmt = $conn->prepare('UPDATE user SET last_active = CURRENT_TIMESTAMP WHERE user_id = ?');
- $stmt->bind_param('i', $_COOKIE['user_id']);
+ $stmt->bind_param('i', $_SESSION['user_id']);
$stmt->execute();
-
- $stmt = $conn->prepare('SELECT user_id, username, email, role_id, profile_picture FROM user WHERE user_id = ?');
- $stmt->bind_param('i', $_COOKIE['user_id']);
- $stmt->execute();
- $user = $stmt->get_result()->fetch_assoc();
-
- $time = time() + 60 * 15;
- cookies($user, $time);
} else if (isset($_COOKIE['remember_user'])) {
$conn = get_connection();
$stmt = $conn->prepare('SELECT * FROM remember_user WHERE token = ?');
@@ -49,21 +41,21 @@ if (isset($_COOKIE['user_id'])) {
// TODO: Log the attempt to use a cookie from a different browser/device than the cookie was created
echo "Naughty, you are trying to use someone else's cookie...";
} else {
- $stmt = $conn->prepare('SELECT user_id, username, email, role_id, profile_picture FROM user WHERE user_id = ?');
+ $stmt = $conn->prepare('SELECT user_id, username, role_id FROM user WHERE user_id = ?');
$stmt->bind_param('s', $remember['user_id']);
$stmt->execute();
$user = $stmt->get_result()->fetch_assoc();
- $conn = get_connection();
+ $_SESSION['user_id'] = $user['user_id'];
+ $_SESSION['username'] = $user['username'];
+ $_SESSION['role_id'] = $user['role_id'];
+
$stmt = $conn->prepare('UPDATE user SET is_active = true WHERE user_id = ?');
- $stmt->bind_param('i', $_COOKIE['user_id']);
+ $stmt->bind_param('i', $_SESSION['user_id']);
$stmt->execute();
$stmt = $conn->prepare('UPDATE user SET last_active = CURRENT_TIMESTAMP WHERE user_id = ?');
- $stmt->bind_param('i', $_COOKIE['user_id']);
+ $stmt->bind_param('i', $_SESSION['user_id']);
$stmt->execute();
-
- $time = time() + 60 * 15;
- cookies($user, $time);
}
}
diff --git a/resources/HackNerdFont-Bold.ttf b/resources/HackNerdFont-Bold.ttf
deleted file mode 100644
index 7b73ac5..0000000
Binary files a/resources/HackNerdFont-Bold.ttf and /dev/null differ
diff --git a/resources/HackNerdFont-BoldItalic.ttf b/resources/HackNerdFont-BoldItalic.ttf
deleted file mode 100644
index 06375dd..0000000
Binary files a/resources/HackNerdFont-BoldItalic.ttf and /dev/null differ
diff --git a/resources/HackNerdFont-Italic.ttf b/resources/HackNerdFont-Italic.ttf
deleted file mode 100644
index 39009f9..0000000
Binary files a/resources/HackNerdFont-Italic.ttf and /dev/null differ
diff --git a/resources/HackNerdFont-Regular.ttf b/resources/HackNerdFont-Regular.ttf
deleted file mode 100644
index f397f20..0000000
Binary files a/resources/HackNerdFont-Regular.ttf and /dev/null differ
diff --git a/resources/HackNerdFontMono-Bold.ttf b/resources/HackNerdFontMono-Bold.ttf
deleted file mode 100644
index 1e9e746..0000000
Binary files a/resources/HackNerdFontMono-Bold.ttf and /dev/null differ
diff --git a/resources/HackNerdFontMono-BoldItalic.ttf b/resources/HackNerdFontMono-BoldItalic.ttf
deleted file mode 100644
index f4fc85f..0000000
Binary files a/resources/HackNerdFontMono-BoldItalic.ttf and /dev/null differ
diff --git a/resources/HackNerdFontMono-Italic.ttf b/resources/HackNerdFontMono-Italic.ttf
deleted file mode 100644
index 29fbdf4..0000000
Binary files a/resources/HackNerdFontMono-Italic.ttf and /dev/null differ
diff --git a/resources/HackNerdFontMono-Regular.ttf b/resources/HackNerdFontMono-Regular.ttf
deleted file mode 100644
index c43eee0..0000000
Binary files a/resources/HackNerdFontMono-Regular.ttf and /dev/null differ
diff --git a/resources/HackNerdFontMono-Regular.woff b/resources/HackNerdFontMono-Regular.woff
deleted file mode 100644
index 399594c..0000000
Binary files a/resources/HackNerdFontMono-Regular.woff and /dev/null differ
diff --git a/resources/HackNerdFontPropo-Bold.ttf b/resources/HackNerdFontPropo-Bold.ttf
deleted file mode 100644
index 379e8e2..0000000
Binary files a/resources/HackNerdFontPropo-Bold.ttf and /dev/null differ
diff --git a/resources/HackNerdFontPropo-BoldItalic.ttf b/resources/HackNerdFontPropo-BoldItalic.ttf
deleted file mode 100644
index 893546a..0000000
Binary files a/resources/HackNerdFontPropo-BoldItalic.ttf and /dev/null differ
diff --git a/resources/HackNerdFontPropo-Italic.ttf b/resources/HackNerdFontPropo-Italic.ttf
deleted file mode 100644
index 353cf94..0000000
Binary files a/resources/HackNerdFontPropo-Italic.ttf and /dev/null differ
diff --git a/resources/HackNerdFontPropo-Regular.ttf b/resources/HackNerdFontPropo-Regular.ttf
deleted file mode 100644
index d8fc76d..0000000
Binary files a/resources/HackNerdFontPropo-Regular.ttf and /dev/null differ
diff --git a/resources/LICENSE.md b/resources/LICENSE.md
deleted file mode 100644
index 08927e5..0000000
--- a/resources/LICENSE.md
+++ /dev/null
@@ -1,45 +0,0 @@
-The work in the Hack project is Copyright 2018 Source Foundry Authors and licensed under the MIT License
-
-The work in the DejaVu project was committed to the public domain.
-
-Bitstream Vera Sans Mono Copyright 2003 Bitstream Inc. and licensed under the Bitstream Vera License with Reserved Font Names "Bitstream" and "Vera"
-
-### MIT License
-
-Copyright (c) 2018 Source Foundry Authors
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-
-### BITSTREAM VERA LICENSE
-
-Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is a trademark of Bitstream, Inc.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions:
-
-The above copyright and trademark notices and this permission notice shall be included in all copies of one or more of the Font Software typefaces.
-
-The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing either the words "Bitstream" or the word "Vera".
-
-This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "Bitstream Vera" names.
-
-The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself.
-
-THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
-
-Except as contained in this notice, the names of Gnome, the Gnome Foundation, and Bitstream Inc., shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Font Software without prior written authorization from the Gnome Foundation or Bitstream Inc., respectively. For further information, contact: fonts at gnome dot org.
diff --git a/resources/README.md b/resources/README.md
deleted file mode 100644
index d5bd32b..0000000
--- a/resources/README.md
+++ /dev/null
@@ -1,48 +0,0 @@
-# Nerd Fonts
-
-This is an archived font from the Nerd Fonts release v3.3.0.
-
-For more information see:
-* https://github.com/ryanoasis/nerd-fonts/
-* https://github.com/ryanoasis/nerd-fonts/releases/latest/
-
-# Hack
-
-A typeface designed for source code.
-
-For more information have a look at the upstream website: https://github.com/source-foundry/Hack
-
-Version: 3.003
-
-## Which font?
-
-### TL;DR
-
-* Pick your font family:
- * If you are limited to monospaced fonts (because of your terminal, etc) then pick a font with `Nerd Font Mono` (or `NFM`).
- * If you want to have bigger icons (usually around 1.5 normal letters wide) pick a font without `Mono` i.e. `Nerd Font` (or `NF`). Most terminals support this, but ymmv.
- * If you work in a proportional context (GUI elements or edit a presentation etc) pick a font with `Nerd Font Propo` (or `NFP`).
-
-### Ligatures
-
-Ligatures are generally preserved in the patched fonts.
-Nerd Fonts `v2.0.0` had no ligatures in the `Nerd Font Mono` fonts, this has been dropped with `v2.1.0`.
-If you have a ligature-aware terminal and don't want ligatures you can (usually) disable them in the terminal settings.
-
-### Explanation
-
-Once you narrow down your font choice of family (`Droid Sans`, `Inconsolata`, etc) and style (`bold`, `italic`, etc) you have 2 main choices:
-
-#### `Option 1: Download already patched font`
-
- * For a stable version download a font package from the [release page](https://github.com/ryanoasis/nerd-fonts/releases)
- * Or download the development version from the folders here
-
-#### `Option 2: Patch your own font`
-
- * Patch your own variations with the various options provided by the font patcher (i.e. not include all symbols for smaller font size)
-
-For more information see: [The FAQ](https://github.com/ryanoasis/nerd-fonts/wiki/FAQ-and-Troubleshooting#which-font)
-
-[SIL-RFN]:http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web_fonts_and_RFNs#14cbfd4a
-
diff --git a/user.php b/user.php
index 1f8f3d9..edbe75e 100644
--- a/user.php
+++ b/user.php
@@ -27,7 +27,7 @@ if (isset($_POST['form_id'])) {
if ($msg === true) {
login($_POST['username'], $_POST['password'], false);
- header('Location: user.php?action=view&user_id=' . $_COOKIE['user_id']);
+ header('Location: user.php?action=view&user_id=' . $_SESSION['user_id']);
}
break;
case 'login_form':
@@ -45,7 +45,7 @@ if (isset($_POST['form_id'])) {
break;
case 'reset_pw_form':
$msg = reset_password(
- ($_COOKIE['role_id'] <= 2 && $_COOKIE['user_id'] != $_POST['user_id'] ? $_POST['user_id'] : $_COOKIE['user_id']),
+ ($_SESSION['role_id'] <= 2 && $_SESSION['user_id'] != $_POST['user_id'] ? $_POST['user_id'] : $_SESSION['user_id']),
$_POST['new_pw'],
$_POST['verify_new_pw']
);
@@ -53,7 +53,7 @@ if (isset($_POST['form_id'])) {
break;
case 'update_email_form':
$msg = update_email(
- ($_COOKIE['role_id'] <= 2 && $_COOKIE['user_id'] != $_POST['user_id'] ? $_POST['user_id'] : $_COOKIE['user_id']),
+ ($_SESSION['role_id'] <= 2 && $_SESSION['user_id'] != $_POST['user_id'] ? $_POST['user_id'] : $_SESSION['user_id']),
$_POST['new_email'],
$_POST['verify_new_email']
);
@@ -61,23 +61,23 @@ if (isset($_POST['form_id'])) {
break;
case 'update_username_form':
$msg = update_username(
- ($_COOKIE['role_id'] <= 2 && $_COOKIE['user_id'] != $_POST['user_id'] ? $_POST['user_id'] : $_COOKIE['user_id']),
+ ($_SESSION['role_id'] <= 2 && $_SESSION['user_id'] != $_POST['user_id'] ? $_POST['user_id'] : $_SESSION['user_id']),
$_POST['new_username'],
$_POST['verify_new_username']
);
break;
case 'update_profile_picture_form':
- update_profile_picture();
+ update_profile_picture($_SESSION['user_id']);
break;
case 'request_role_change_form':
request_role_change(
- $_COOKIE['user_id'],
+ $_SESSION['user_id'],
$_POST['requested_role']
);
break;
case 'delete_account_form':
$msg = delete_account(
- ($_COOKIE['role_id'] <= 2 && $_COOKIE['user_id'] != $_POST['user_id'] ? $_POST['user_id'] : $_COOKIE['user_id']),
+ ($_SESSION['role_id'] <= 2 && $_SESSION['user_id'] != $_POST['user_id'] ? $_POST['user_id'] : $_SESSION['user_id']),
$_POST['delete_password'],
$_POST['delete_verify_password']
);