diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/login.php | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/lib/login.php b/lib/login.php index 45d4c83..0683031 100644 --- a/lib/login.php +++ b/lib/login.php @@ -52,14 +52,26 @@ function get_cart_count() { $logged_in = check_login($username, $password); $cart_count = get_cart_count(); +// hansel and gretel crumbs +function leave_crumb() { + $prev = $_SERVER['HTTP_REFERER']; + $ONE_HOUR = time() + (60 * 60); + setcookie("prev", $prev, $ONE_HOUR, "/"); +} + function if_logged_in($is, $redirect, $back = false) { global $logged_in; if ($logged_in != $is) return; - if ($back) { - $prev = $_SERVER['HTTP_REFERER']; - $ONE_HOUR = time() + (60 * 60); - setcookie("prev", $prev, $ONE_HOUR, "/"); - } + if ($back) leave_crumb(); + http_response_code(302); + header("Location: ".$redirect); + die(); +} + +function if_privileged($level, $redirect, $back = false) { + global $user_privileges; + if (($user_privileges & $level) > 0) return; + if ($back) leave_crumb(); http_response_code(302); header("Location: ".$redirect); die(); |