function authenticate_user($required_authority_level) { $cookie_handler = new CookieHandler(); $color = "hsla(360, 100%, 50%, 0.9)"; if ($cookie_handler->cookie_exists("compsec") == true) { $user_cookie = $cookie_handler->get_cookie("compsec"); if ($cookie_handler->validate_cookie($user_cookie) == true) { // Fetch user data $results = get_user_data($user_cookie->get_uuid()); $user_authority_level = $results[4]; // Check authentication level if ($user_authority_level < $required_authority_level) { print "<div class=\"box\" style=\"background-color:" . $color . ";margin-top:25px;\">You are not authorized to view this page.</div>"; exit; } } else { print "<div class=\"box\" style=\"background-color:" . $color . ";margin-top:25px;\">Invalid cookie. You need a valid login with the appropriate permissions in order to access this page.</div>"; exit; } } else { print "<div class=\"box\" style=\"background-color:" . $color . ";margin-top:25px;\">You need to be logged in to access this resource.</div>"; exit; } }
<head> <meta charset="ISO-8859-1"> <title>Password Change Results</title> <link rel="stylesheet" type="text/css" href="styles.css" title="Default Styles" media="screen"/> <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Open+Sans" title="Font Styles"/> <?php include "CookieHandler.php"; include "helper_functions.php"; ?> </head> <body link="#E2E2E2" vlink="#ADABAB"> <center><div class="container"> <?php $cookie_handler = new CookieHandler(); $cookie_name = $cookie_handler->get_cookie_name(); ?> <header> <div class="logoContainer"> <!-- <img src="logo-bar.png"> --> </div> <div class="button"> <p><a href ="index.php">Index</a></p> </div> <div class="button"> <?php
<head> <meta charset="ISO-8859-1"> <title>Login</title> <link rel="stylesheet" type="text/css" href="styles.css" title="Default Styles" media="screen"/> <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Open+Sans" title="Font Styles"/> <?php include "CookieHandler.php"; include "helper_functions.php"; ?> </head> <body link="#E2E2E2" vlink="#ADABAB"> <center><div class="container"> <?php $cookie_handler = new CookieHandler(); $cookie_name = $cookie_handler->get_cookie_name(); ?> <header> <div class="logoContainer"> <!-- <img src="logo-bar.png"> --> </div> <div class="button"> <p><a href ="index.php">Index</a></p> </div> <div class="button"> <?php