converted from standard mysqli to mysqli prepared statements for security against sql injection

This commit is contained in:
2025-04-01 15:03:01 -06:00
parent e8ac27b5d5
commit cec9091ee0
7 changed files with 190 additions and 175 deletions
+69 -49
View File
@@ -3,32 +3,17 @@ require_once 'db_functions.php';
function user_id_exists($user_id)
{
$query = 'SELECT user_id FROM user WHERE user_id = ' . $user_id . ';';
$result = query_one_result($query);
$conn = get_connection();
$stmt = $conn->prepare('SELECT user_id FROM user WHERE user_id = ?');
$stmt->bind_param('i', $user_id);
$stmt->execute();
$result = $stmt->get_result()->fetch_assoc();
if ($result == null)
return false;
return true;
}
function auth_level($user_id)
{
$query = 'SELECT role_id FROM user WHERE user_id = ' . $user_id . ';';
$result = query_one_result($query);
$role = $result['role_id'];
return $role;
}
function modify_self()
{
return -1;
}
function delete_self()
{
return -1;
}
function cookies($user, $time)
{
setcookie('user_id', $user['user_id'], $time);
@@ -79,8 +64,12 @@ function login_form($error_msg = '')
function login($username, $password, $stay_logged_in)
{
$password_hash = hash('sha256', $password);
$query = 'SELECT user_id, username, email, role_id, profile_picture FROM user WHERE username ="' . $username . '" AND password_hash = "' . $password_hash . '";';
$user = query_one_result($query);
$conn = get_connection();
$stmt = $conn->prepare('SELECT user_id, username, email, role_id, profile_picture FROM user WHERE username = ? OR email = ? AND password_hash = ?');
$stmt->bind_param('sss', $username, $username, $password_hash);
$stmt->execute();
$user = $stmt->get_result()->fetch_assoc();
if ($user == null) {
$error_msg = '
@@ -101,8 +90,9 @@ function login($username, $password, $stay_logged_in)
// echo strlen($token);
setcookie('remember_user', $token, time() + 60 * 60 * 24 * 30, '/', '', true, true);
$stmt = 'INSERT INTO remember_user (token, user_id, remote_addr' . (isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? ', http_forward' : '') . ') VALUES ("' . $token . '", ' . $user['user_id'] . ', "' . hash('sha256', $_SERVER['REMOTE_ADDR']) . '"' . (isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? ', "' . hash('sha256', $_SERVER['HTTP_X_FORWARDED_FOR']) . '"' : '') . ');';
exec_statement($stmt, 1);
$stmt = $conn->prepare('INSERT INTO remember_user (token, user_id, remote_addr, http_forward) VALUES (?, ?, ?, ?)');
$stmt->bind_param('siss', $token, $user['user_id'], hash('sha256', $_SERVER['REMOTE_ADDR']), (isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? hash('sha256', $_SERVER['HTTP_X_FORWARDED_FOR']) : null));
$stmt->execute();
}
return true;
@@ -176,7 +166,7 @@ function create_user($username, $email, $password, $verify_password, $role_id, $
while (user_id_exists($id))
$id = rand(1000, 999999999);
if (!empty($upload)) {
if (!empty($upload['profile_picture']['tmp_name'])) {
$orig_size = getimagesize($upload['profile_picture']['tmp_name']);
$orig_width = $orig_size[0];
$orig_height = $orig_size[1];
@@ -187,8 +177,13 @@ function create_user($username, $email, $password, $verify_password, $role_id, $
$target = upload($upload['profile_picture'], $_ENV['PROFILE_IMAGES_FQ_PATH'], $id);
}
$stmt = 'INSERT INTO user (user_id, username, email, password_hash, role_id' . (!empty($target) ? ', profile_picture' : '') . ') VALUES (' . $id . ', "' . $username . '", "' . $email . '", "' . $password_hash . '", ' . $role_id . (!empty($target) ? ', "' . $target . '"' : '') . ');';
exec_statement($stmt, 0);
$conn = get_connection();
$stmt = $conn->prepare('INSERT INTO user (user_id, username, email, password_hash, role_id, profile_picture) VALUES (?, ?, ?, ?, ?, ?)');
$asdf = (isset($target) ? $target : null);
$stmt->bind_param('isssis', $id, $username, $email, $password_hash, $role_id, $asdf);
$stmt->execute();
return true;
}
function profile_cropper()
@@ -250,8 +245,10 @@ function reset_password($user_id, $new_password, $verify_new_password)
}
$password_hash = hash('sha256', $new_password);
$stmt = 'UPDATE user SET password_hash = "' . $password_hash . '" WHERE user_id = ' . $user_id . ';';
exec_statement($stmt, 0);
$conn = get_connection();
$stmt = $conn->prepare('UPDATE user SET password_hash = ? WHERE user_id = ?');
$stmt->bind_param('si', $password_hash, $user_id);
$stmt->execute();
}
function update_email_form()
@@ -290,8 +287,10 @@ function update_email($user_id, $new_email, $verify_new_email)
return $error_msg;
}
$stmt = 'UPDATE user SET email = "' . $new_email . '" WHERE user_id = ' . $user_id . ';';
exec_statement($stmt, 0);
$conn = get_connection();
$stmt = $conn->prepare('UPDATE user SET email = ? WHERE user_id = ?');
$stmt->bind_param('si', $new_email, $user_id);
$stmt->execute();
}
function update_username_form()
@@ -330,8 +329,13 @@ function update_username($user_id, $new_username, $verify_new_username)
return $error_msg;
}
$query = 'SELECT username FROM user WHERE username = "' . $new_username . '";';
if (query_one_result($query) != null) {
$conn = get_connection();
$stmt = $conn->prepare('SELECT username FROM user WHERE username = ?');
$stmt->bind_param('s', $new_username);
$stmt->execute();
$result = $stmt->get_result()->fetch_assoc();
if ($result != null) {
$error_msg = '
<div class="error">
Usernames is taken!
@@ -341,17 +345,18 @@ function update_username($user_id, $new_username, $verify_new_username)
return $error_msg;
}
$stmt = 'UPDATE user SET username = "' . $new_username . '" WHERE user_id = ' . $user_id . ';';
exec_statement($stmt, 0);
$stmt = $conn->prepare('UPDATE user SET username = ? WHERE user_id = ?');
$stmt->bind_param('si', $new_username, $user_id);
$stmt->execute();
}
function request_role_change_form()
{
$query = 'SELECT * FROM roles WHERE role_id <> 1;';
$results = query_one_or_more_results($query);
$conn = get_connection();
$result = $conn->query('SELECT * FROM roles WHERE role_id <> 1');
$roles = '<div class="checkboxes">';
while ($row = mysqli_fetch_array($results)) {
while ($row = $result->fetch_assoc()) {
$roles .= '
<label class="form_checkbox_container">' . $row['role'] . '
<input name="requested_role" value="' . $row['role_id'] . '" type="checkbox"' . ($row['role_id'] == $_COOKIE['role_id'] ? ' checked' : '') . '>
@@ -429,10 +434,15 @@ function delete_account($user_id, $password = null, $verify_password = null)
return $error_msg;
}
$conn = get_connection();
if ($password && $verify_password) {
$password_hash = hash('sha256', $password);
$query = 'SELECT user_id, profile_picture FROM user WHERE user_id = ' . $user_id . ' AND password_hash = "' . $password_hash . '";';
$user = query_one_result($query);
$stmt = $conn->prepare('SELECT user_id, profile_picture FROM user WHERE user_id = ? AND password_hash = ?');
$stmt->bind_param('is', $user_id, $password_hash);
$stmt->execute();
$user = $stmt->get_result()->fetch_assoc();
if ($user == null) {
$error_msg = '
@@ -445,15 +455,19 @@ function delete_account($user_id, $password = null, $verify_password = null)
}
// Hardcoded prevention of deleting the owner's profile picture
if ($user['profile_picture'] != '2025.jpg')
if (!empty($user['profile_picture']) && $user['profile_picture'] != '2025.jpg')
delete_file($_ENV['PROFILE_IMAGES_FQ_PATH'] . $user['profile_picture']);
$stmt = 'DELETE FROM user WHERE user_id = ' . $user_id . ';';
exec_statement($stmt, 1);
$stmt = $conn->prepare('DELETE FROM user WHERE user_id = ?');
$stmt->bind_param('i', $user_id);
$stmt->execute();
logout();
} else if ($_COOKIE['role_id'] < 3) {
$query = 'SELECT user_id, profile_picture FROM user WHERE user_id = ' . $user_id . ';';
$user = query_one_result($query);
} else if ($_COOKIE['role_id'] <= 2) {
$stmt = $conn->prepare('SELECT user_id, profile_picture FROM user WHERE user_id = ?');
$stmt->bind_param('i', $user_id);
$stmt->execute();
$user = $stmt->get_result()->fetch_assoc();
if ($user['user_id'] == 2025) {
$error_msg = '
@@ -466,11 +480,13 @@ function delete_account($user_id, $password = null, $verify_password = null)
}
// Hardcoded prevention of deleting the owner's profile picture
if ($user['profile_picture'] != '2025.jpg')
if (!empty($user['profile_picture']) && $user['profile_picture'] != '2025.jpg')
delete_file($_ENV['PROFILE_IMAGES_FQ_PATH'] . $user['profile_picture']);
$stmt = 'DELETE FROM user WHERE user_id = ' . $user_id . ';';
exec_statement($stmt, 1);
$stmt = $conn->prepare('DELETE FROM user WHERE user_id = ?');
$stmt->bind_param('i', $user_id);
$stmt->execute();
}
}
@@ -479,8 +495,12 @@ function user_view($user_id)
if (!isset($_COOKIE['role_id']) || ($_COOKIE['role_id'] > 2 && $_COOKIE['user_id'] != $user_id))
header('Location: articles.php');
$query = 'SELECT user_id, username, email, role_id, created_at, last_active, is_active, profile_picture FROM user WHERE user_id = ' . $user_id . ';';
$user = query_one_result($query);
$conn = get_connection();
$stmt = $conn->prepare('SELECT user_id, username, email, role_id, created_at, last_active, is_active, profile_picture FROM user WHERE user_id = ?');
$stmt->bind_param('i', $user_id);
$stmt->execute();
$user = $stmt->get_result()->fetch_assoc();
if ($user == null)
header('Location: articles.php');
+4 -6
View File
@@ -61,9 +61,8 @@ function admin_article_view()
</thead>
<tbody>
';
$query = 'SELECT article_id, username, title, read_count, article.created_at, updated_at, published_at, excerpt FROM article INNER JOIN user ON article.author_id = user.user_id;';
$results = query_one_or_more_results($query);
$conn = get_connection();
$results = $conn->query('SELECT article_id, username, title, read_count, article.created_at, updated_at, published_at, excerpt FROM article INNER JOIN user ON article.author_id = user.user_id;');
foreach ($results as $key => $result) {
$display .= '
@@ -133,9 +132,8 @@ function admin_user_view()
<th>Profile Picture</th>
</tr>
';
$query = 'SELECT user_id, username, email, last_active, role, created_at, is_active, profile_picture FROM user INNER JOIN roles ON user.role_id = roles.role_id;';
$results = query_one_or_more_results($query);
$conn = get_connection();
$results = $conn->query('SELECT user_id, username, email, last_active, role, created_at, is_active, profile_picture FROM user INNER JOIN roles ON user.role_id = roles.role_id;');
foreach ($results as $key => $result) {
$display .= '
+73 -45
View File
@@ -3,12 +3,12 @@ require_once 'db_functions.php';
function article_ids_by_recency()
{
$query = 'SELECT article_id FROM article ORDER BY published_at DESC;';
$results = query_one_or_more_results($query);
$conn = get_connection();
$results = $conn->query('SELECT article_id FROM article ORDER BY published_at DESC');
$ids = [];
while ($row = mysqli_fetch_array($results))
while ($row = $results->fetch_assoc())
$ids[] = $row['article_id'];
return $ids;
@@ -16,12 +16,15 @@ function article_ids_by_recency()
function articles_ids_by_author($author_id)
{
$query = 'SELECT article_id FROM article WHERE author_id = ' . $author_id . ' ORDER BY published_at DESC;';
$results = query_one_or_more_results($query);
$conn = get_connection();
$stmt = $conn->prepare('SELECT article_id FROM article WHERE author_id = ? ORDER BY published_at DESC');
$stmt->bind_param('i', $author_id);
$stmt->execute();
$results = $stmt->get_result();
$ids = [];
while ($row = mysqli_fetch_array($results))
while ($row = $results->fetch_assoc())
$ids[] = $row['article_id'];
return $ids;
@@ -29,24 +32,27 @@ function articles_ids_by_author($author_id)
function article_tags()
{
$query = 'SELECT * FROM tags;';
$results = query_one_or_more_results($query);
$conn = get_connection();
$results = $conn->query('SELECT * FROM tags');
$tags = [];
while ($row = mysqli_fetch_array($results))
while ($row = $results->fetch_assoc())
$tags[] = $row;
return $tags;
}
function article_ids_by_tag($tag_id)
function article_ids_by_tag($tag)
{
$query = 'SELECT article_id FROM article WHERE article.article_id IN ( SELECT article_tags.article_id FROM article_tags INNER JOIN tags ON article_tags.tag_id = tags.tag_id WHERE tag = "' . $tag_id . '") ORDER BY published_at DESC;';
$results = query_one_or_more_results($query);
$conn = get_connection();
$stmt = $conn->prepare('SELECT article_id FROM article WHERE article.article_id IN ( SELECT article_tags.article_id FROM article_tags INNER JOIN tags ON article_tags.tag_id = tags.tag_id WHERE tag = ?) ORDER BY published_at DESC');
$stmt->bind_param('s', $tag);
$stmt->execute();
$results = $stmt->get_result();
$ids = [];
while ($row = mysqli_fetch_array($results))
while ($row = $results->fetch_assoc())
$ids[] = $row['article_id'];
return $ids;
@@ -57,11 +63,16 @@ function article_ids_by_tag($tag_id)
*/
function article_page_from_markdown($article_id)
{
$query = 'SELECT * FROM article WHERE article_id = ' . $article_id . ';';
$article = query_one_result($query);
$conn = get_connection();
$stmt = $conn->prepare('SELECT * FROM article WHERE article_id = ?');
$stmt->bind_param('i', $article_id);
$stmt->execute();
$article = $stmt->get_result()->fetch_assoc();
$query = 'SELECT user_id, username, profile_picture FROM user WHERE user_id = ' . $article['author_id'] . ';';
$author = query_one_result($query);
$stmt = $conn->prepare('SELECT user_id, username, profile_picture FROM user WHERE user_id = ?');
$stmt->bind_param('i', $article['author_id']);
$stmt->execute();
$author = $stmt->get_result()->fetch_assoc();
$markdown = read_file_one_string($_ENV['ARTICLES_FQ_PATH'] . $article_id . '/article.md');
@@ -93,23 +104,31 @@ function article_page_from_markdown($article_id)
*/
function article_card($article_id)
{
$article_query = 'SELECT * FROM article WHERE article_id = ' . $article_id . ';';
$article = query_one_result($article_query);
$conn = get_connection();
$stmt = $conn->prepare('SELECT * FROM article WHERE article_id = ?');
$stmt->bind_param('i', $article_id);
$stmt->execute();
$article = $stmt->get_result()->fetch_assoc();
$stmt = $conn->prepare('SELECT tag FROM article_tags INNER JOIN tags ON article_tags.tag_id = tags.tag_id WHERE article_id = ?');
$stmt->bind_param('i', $article_id);
$stmt->execute();
$tags_results = $stmt->get_result();
$article_tags_query = 'SELECT tag FROM article_tags INNER JOIN tags ON article_tags.tag_id = tags.tag_id WHERE article_id = ' . $article_id . ';';
$tags_results = query_one_or_more_results($article_tags_query);
$tags_html = '';
if ($tags_results != null) {
$tags_html .= '<div class="tag_row">';
while ($row = mysqli_fetch_array($tags_results))
while ($row = $tags_results->fetch_assoc())
$tags_html .= '<a href="/articles.php?tag=' . $row['tag'] . '" class="tag">#' . $row['tag'] . '</a>';
$tags_html .= '</div>';
}
$author_query = 'SELECT user_id, username, profile_picture FROM user WHERE user_id = ' . $article['author_id'] . ';';
$author = query_one_result($author_query);
$stmt = $conn->prepare('SELECT user_id, username, profile_picture FROM user WHERE user_id = ?');
$stmt->bind_param('i', $article['author_id']);
$stmt->execute();
$author = $stmt->get_result()->fetch_assoc();
$card = '
<div class="article_card">
@@ -139,53 +158,62 @@ function article_card($article_id)
function create_article($author_id, $title, $excerpt, $tags, $markdown_file_contents)
{
$stmt = 'INSERT INTO article (author_id, title, excerpt, published_at) VALUES (' . $author_id . ', "' . $title . '", "' . $excerpt . '", CURRENT_TIMESTAMP);';
$id = exec_statement($stmt, 0);
$conn = get_connection();
$stmt = $conn->prepare('INSERT INTO article (author_id, title, excerpt, published_at) VALUES (?, ?, ?, CURRENT_TIMESTAMP)');
$stmt->bind_param('iss', $author_id, $title, $excerpt);
$stmt->execute();
$id = mysqli_insert_id($conn);
$path = $_ENV['ARTICLES_FQ_PATH'] . $id . '/';
mkdir($path);
echo '<p>created ' . $path . '</p>';
$fs = fopen($path . 'article.md', 'a');
fwrite($fs, $markdown_file_contents);
fclose($fs);
$stmt = 'INSERT INTO article_tags (article_id, tag_id) VALUES ';
for ($i = 0; $i < count($tags); $i++) {
$stmt .= '(' . $id . ', ' . $tags[$i] . ')';
if (count($tags) > 0) {
$tag_insert_stmt = 'INSERT INTO article_tags (article_id, tag_id) VALUES ';
for ($i = 0; $i < count($tags); $i++) {
$tag_insert_stmt .= '(' . $id . ', ?)';
if ($i < count($tags) - 1)
$stmt .= ', ';
if ($i < count($tags) - 1)
$tag_insert_stmt .= ', ';
}
if ($i == count($tags) - 1)
$stmt .= ';';
$stmt = $conn->prepare($tag_insert_stmt);
$stmt->bind_param('i', ...$tags);
$stmt->execute();
}
if (count($tags) > 0)
exec_statement($stmt, 0);
return $id;
}
function delete_article($article_id)
{
$stmt = 'DELETE FROM article_tags WHERE article_id = ' . $article_id . ';';
exec_statement($stmt, 1);
$conn = get_connection();
$stmt = $conn->prepare('DELETE FROM article_tags WHERE article_id = ?');
$stmt->bind_param('i', $article_id);
$stmt->execute();
$stmt = 'DELETE FROM article WHERE article_id = ' . $article_id . ';';
exec_statement($stmt, 1);
$stmt = $conn->prepare('DELETE FROM article WHERE article_id = ?');
$stmt->bind_param('i', $article_id);
$stmt->execute();
delete_dir($_ENV['ARTICLES_FQ_PATH'] . $article_id . '/');
}
function delete_articles_by_author($author_id)
{
$stmt = 'DELETE FROM article WHERE author_id = "' . $author_id . '";';
return exec_statement($stmt, 1);
$conn = get_connection();
$stmt = $conn->prepare('DELETE FROM article WHERE author_id = ?');
$stmt->bind_param('i', $author_id);
$stmt->execute();
}
function increment_read_counter($article_id)
{
$stmt = 'UPDATE article SET read_count = read_count + 1 WHERE article_id = ' . $article_id . ';';
return exec_statement($stmt, 1);
$conn = get_connection();
$stmt = $conn->prepare('UPDATE article SET read_count = read_count + 1 WHERE article_id = ?');
$stmt->bind_param('i', $article_id);
$stmt->execute();
}
+1 -47
View File
@@ -22,54 +22,8 @@ if ($_SERVER['HTTP_HOST'] == 'localhost') {
define('DB', 'vintagecoding');
}
/*
* Handles any queries that should have only one row results.
*/
function query_one_result($query_stmt)
{
$conn = get_connection();
$results = mysqli_query($conn, $query_stmt);
mysqli_close($conn);
if (mysqli_num_rows($results) == 0 || mysqli_num_rows($results) > 1)
return null;
else
return mysqli_fetch_assoc($results);
}
function query_one_or_more_results($query_stmt)
{
$conn = get_connection();
$results = mysqli_query($conn, $query_stmt);
mysqli_close($conn);
if (mysqli_num_rows($results) == 0)
return null;
else
return $results;
}
/*
* Executes a statement. Type is typically either 0 or 1, where 0 is an INSERT or UPDATE,
* and 1 is DELETE. This is to determine whether a boolean value should be returned or
* the ID of the row(s).
*/
function exec_statement($stmt, $type)
{
$conn = get_connection();
$results = mysqli_query($conn, $stmt);
if ($type == 0)
$results = mysqli_insert_id($conn);
mysqli_close($conn);
return $results;
}
function get_connection()
{
// Connect to the DB
$conn = mysqli_connect(HOST, USER, PASS, DB);
$conn = new mysqli(HOST, USER, PASS, DB);
return $conn;
}
+38 -12
View File
@@ -23,22 +23,48 @@ if ($_SESSION['initialized'] && isset($_POST['theme'])) {
// Update the database and cookies to keep the user logged in.
if (isset($_COOKIE['user_id'])) {
exec_statement('UPDATE user SET is_active = true WHERE user_id = ' . $_COOKIE['user_id'] . ';', 1);
exec_statement('UPDATE user SET last_active = CURRENT_TIMESTAMP WHERE user_id = ' . $_COOKIE['user_id'] . ';', 1);
$conn = get_connection();
$stmt = $conn->prepare('UPDATE user SET is_active = true WHERE user_id = ?');
$stmt->bind_param('i', $_COOKIE['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->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();
$query = 'SELECT user_id, username, email, role_id, profile_picture FROM user WHERE user_id = ' . $_COOKIE['user_id'] . ';';
$user = query_one_result($query);
$time = time() + 60 * 60 * 1;
cookies($user, $time);
} else if (isset($_COOKIE['remember_user'])) {
$query = 'SELECT * FROM remember_user WHERE token = "' . $_COOKIE['remember_user'] . '";';
$remember = query_one_result($query);
$query = 'SELECT user_id, username, email, role_id, profile_picture FROM user WHERE user_id = ' . $remember['user_id'] . ';';
$user = query_one_result($query);
$conn = get_connection();
$stmt = $conn->prepare('SELECT * FROM remember_user WHERE token = ?');
$stmt->bind_param('s', $_COOKIE['remember_user']);
$stmt->execute();
$remember = $stmt->get_result()->fetch_assoc();
exec_statement('UPDATE user SET is_active = true WHERE user_id = ' . $user['user_id'] . ';', 1);
exec_statement('UPDATE user SET last_active = CURRENT_TIMESTAMP WHERE user_id = ' . $user['user_id'] . ';', 1);
if (hash('sha256', $_SERVER['REMOTE_ADDR']) != $remember['remote_addr'] || (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && hash('sha256', $_SERVER['HTTP_X_FORWARDED_FOR']) != $remember['forwarded_for'])) {
// 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->bind_param('s', $remember['user_id']);
$stmt->execute();
$user = $stmt->get_result()->fetch_assoc();
$time = time() + 60 * 60 * 1;
cookies($user, $time);
$conn = get_connection();
$stmt = $conn->prepare('UPDATE user SET is_active = true WHERE user_id = ?');
$stmt->bind_param('i', $_COOKIE['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->execute();
$time = time() + 60 * 60 * 1;
cookies($user, $time);
}
}
-16
View File
@@ -26,9 +26,6 @@ if (isset($_POST['form_id'])) {
header('Location: user.php?action=view&user_id=' . $_COOKIE['user_id']);
}
break;
case 'login_form':
$msg = login(
$_POST['username'],
@@ -39,9 +36,6 @@ if (isset($_POST['form_id'])) {
if ($msg === true)
header('Location: .');
break;
case 'reset_pw_form':
$msg = reset_password(
($_COOKIE['role_id'] <= 2 && $_COOKIE['user_id'] != $_POST['user_id'] ? $_POST['user_id'] : $_COOKIE['user_id']),
@@ -50,9 +44,6 @@ 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']),
@@ -61,20 +52,13 @@ 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']),
$_POST['new_username'],
$_POST['verify_new_username']
);
break;
case 'delete_account_form':
$msg = delete_account(
($_COOKIE['role_id'] <= 2 && $_COOKIE['user_id'] != $_POST['user_id'] ? $_POST['user_id'] : $_COOKIE['user_id']),
+5
View File
@@ -1,5 +1,10 @@
### vintagecoding.net
#### Content:
- [ ] Setting up CI/CD with GitHub Actions
- [ ] General
- [x] Ensure a consistent design & UX aesthetic --- v0.1.0
- [ ] Sensible CSS class names for a modular styling approach --- v0.2.0