mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
Added redirect() function for page redirects and updated credit system fields to include credit_note, credit_invoice_id and type for better reporting
This commit is contained in:
@@ -1670,4 +1670,21 @@ function sanitize_url($url) {
|
||||
|
||||
// Safe schemes: return escaped original URL
|
||||
return htmlspecialchars($url ?? '', ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
function redirect($url = null, $permanent = false) {
|
||||
// Use referer if no URL is provided
|
||||
if (!$url) {
|
||||
$url = $_SERVER['HTTP_REFERER'] ?? 'index.php';
|
||||
}
|
||||
|
||||
if (!headers_sent()) {
|
||||
header('Location: ' . $url, true, $permanent ? 301 : 302);
|
||||
exit;
|
||||
} else {
|
||||
// Fallback for headers already sent
|
||||
echo "<script>window.location.href = '" . addslashes($url) . "';</script>";
|
||||
echo '<noscript><meta http-equiv="refresh" content="0;url=' . htmlspecialchars($url) . '"></noscript>';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user