Example #1
0
     $message = urlencode("Something went wrong with logging in.");
     header("Location: error.php?error={$message}");
     exit;
 }
 /*
 	response is in the format:
 		Yes\nNetID\n
 	or:
 		No\nNot valid
 */
 $response = explode("\n", $response);
 //if the first line of the request is the word yes, then the next line will be the username
 if ($response[0] === "yes") {
     //if the username received from the request is allowed to login as an admin,
     //	then save their username in the session
     if (Session::loginUser($response[1])) {
         //redirect to this page afterwards, should then show way to upload blog post/agenda/roster
         header("Location: login.php");
         exit;
     } else {
         //the username received isn't in the whitelist of users, so show them an error
         $message = urlencode("{$response[1]} does not have permission to view this page.");
         header("Location: error.php?error={$message}");
         exit;
     }
 } else {
     //the response showed an invalid ticket, show an error
     $message = urlencode("A problem went wrong with logging in.");
     header("Location: error.php?error={$message}");
     exit;
 }