terms_accepted == false) { Core::addAlert("danger", "You must accept Terms and Conditions to view this page."); http::redirect("/account"); } } public static function requireAdmin() { Core::requireLogIn(); if(Core::$user->canAdmin() === false) { throw new Exception("No permission to access this page."); } } public static function requireUserLevel($level) { Core::requireLogIn(); if(Core::$user->level < $level) { throw new Exception("No permission to access this page."); } } public static function isLoggedIn() { return !empty($_SESSION["user_id"]); } public static function validateCSRFToken($token) { if($_SESSION["csrf_token"] !== $token) throw new Exception("CSRF attempt blocked."); return true; } public static function refuseAJAX() { if(HTTP::isAJAX()) { header("HTTP/1.1 403 Forbidden"); throw new Exception("AJAX calls not allowed."); } } } ?>