Add missing CSRF Checks in admin area and settings

This commit is contained in:
johnnyq
2026-03-02 22:15:36 -05:00
parent 6da8821f2c
commit 918b40afbe
48 changed files with 160 additions and 45 deletions

View File

@@ -8,6 +8,8 @@ defined('FROM_POST_HANDLER') || die("Direct file access is not allowed");
if (isset($_POST['add_category'])) {
validateCSRFToken($_POST['csrf_token']);
require_once 'category_model.php';
mysqli_query($mysqli,"INSERT INTO categories SET category_name = '$name', category_type = '$type', category_color = '$color'");
@@ -24,6 +26,8 @@ if (isset($_POST['add_category'])) {
if (isset($_POST['edit_category'])) {
validateCSRFToken($_POST['csrf_token']);
require_once 'category_model.php';
$category_id = intval($_POST['category_id']);
@@ -40,6 +44,8 @@ if (isset($_POST['edit_category'])) {
if (isset($_GET['archive_category'])) {
validateCSRFToken($_GET['csrf_token']);
$category_id = intval($_GET['archive_category']);
// Get Category Name and Type for logging
@@ -58,9 +64,11 @@ if (isset($_GET['archive_category'])) {
}
if (isset($_GET['unarchive_category'])) {
if (isset($_GET['restore_category'])) {
$category_id = intval($_GET['unarchive_category']);
validateCSRFToken($_GET['csrf_token']);
$category_id = intval($_GET['retore_category']);
// Get Category Name and Type for logging
$sql = mysqli_query($mysqli,"SELECT category_name, category_type FROM categories WHERE category_id = $category_id");
@@ -70,9 +78,9 @@ if (isset($_GET['unarchive_category'])) {
mysqli_query($mysqli,"UPDATE categories SET category_archived_at = NULL WHERE category_id = $category_id");
logAction("Category", "Unarchive", "$session_name unarchived category $category_type $category_name", 0, $category_id);
logAction("Category", "Restore", "$session_name retored category $category_type $category_name", 0, $category_id);
flash_alert("Category $category_type <strong>$category_name</strong> unarchived");
flash_alert("Category $category_type <strong>$category_name</strong> restored");
redirect();
@@ -80,6 +88,8 @@ if (isset($_GET['unarchive_category'])) {
if (isset($_GET['delete_category'])) {
validateCSRFToken($_GET['csrf_token']);
$category_id = intval($_GET['delete_category']);
// Get Category Name and Type for logging