diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-05-13 15:36:20 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-05-13 15:36:20 +0200 |
commit | ed0594f8f73c6eee8c6eca6ecf6208952ea26cdc (patch) | |
tree | 188fb61811a67a9f3d69e7429e45e9b6fa198237 /lib | |
parent | d99d91293fe9e9ad683bbd079848df4031f0a77a (diff) |
add products working (no image upload working yet)
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(); |