Add new function called flash_alert() to repace the alerting in posts, updated accounts post to use new function
This commit is contained in:
@@ -1672,6 +1672,7 @@ function sanitize_url($url) {
|
|||||||
return htmlspecialchars($url ?? '', ENT_QUOTES, 'UTF-8');
|
return htmlspecialchars($url ?? '', ENT_QUOTES, 'UTF-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Redirect Function
|
||||||
function redirect($url = null, $permanent = false) {
|
function redirect($url = null, $permanent = false) {
|
||||||
// Use referer if no URL is provided
|
// Use referer if no URL is provided
|
||||||
if (!$url) {
|
if (!$url) {
|
||||||
@@ -1687,4 +1688,10 @@ function redirect($url = null, $permanent = false) {
|
|||||||
echo '<noscript><meta http-equiv="refresh" content="0;url=' . htmlspecialchars($url) . '"></noscript>';
|
echo '<noscript><meta http-equiv="refresh" content="0;url=' . htmlspecialchars($url) . '"></noscript>';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Flash Alert Function
|
||||||
|
function flash_alert(string $message, string $type = 'success'): void {
|
||||||
|
$_SESSION['alert_type'] = $type;
|
||||||
|
$_SESSION['alert_message'] = $message;
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@ if (isset($_POST['add_account'])) {
|
|||||||
// Logging
|
// Logging
|
||||||
logAction("Account", "Create", "$session_name created account $name");
|
logAction("Account", "Create", "$session_name created account $name");
|
||||||
|
|
||||||
$_SESSION['alert_message'] = "Account <strong>$name</strong> created ";
|
flash_alert("Account <strong>$name</strong> created");
|
||||||
|
|
||||||
redirect();
|
redirect();
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ if (isset($_POST['edit_account'])) {
|
|||||||
// Logging
|
// Logging
|
||||||
logAction("Account", "Edit", "$session_name edited account $name");
|
logAction("Account", "Edit", "$session_name edited account $name");
|
||||||
|
|
||||||
$_SESSION['alert_message'] = "Account <strong>$name</strong> edited";
|
flash_alert("Account <strong>$name</strong> edited");
|
||||||
|
|
||||||
redirect();
|
redirect();
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ if (isset($_GET['archive_account'])) {
|
|||||||
// Logging
|
// Logging
|
||||||
logAction("Account", "Archive", "$session_name archived account $account_name");
|
logAction("Account", "Archive", "$session_name archived account $account_name");
|
||||||
|
|
||||||
$_SESSION['alert_message'] = "Account <strong>$account_name</strong> archived";
|
flash_alert("Account <strong>$account_name</strong> archived");
|
||||||
|
|
||||||
redirect();
|
redirect();
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ if (isset($_GET['delete_account'])) {
|
|||||||
//Logging
|
//Logging
|
||||||
logAction("Account", "Delete", "$session_name deleted account $account_name");
|
logAction("Account", "Delete", "$session_name deleted account $account_name");
|
||||||
|
|
||||||
$_SESSION['alert_message'] = "Account <strong>$account_name</strong> deleted";
|
flash_alert("Account <strong>$account_name</strong> deleted", 'error');
|
||||||
|
|
||||||
redirect();
|
redirect();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user