Created
May 6, 2019 09:44
-
-
Save Damian96/195c926e6c81b478bb46fcecaac065ac to your computer and use it in GitHub Desktop.
Damian User Check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (session_status() != PHP_SESSION_ACTIVE) | |
session_start(); | |
if ( ! isset($_SESSION['u_email']) ): | |
header($_SERVER["SERVER_PROTOCOL"] . "401 Unauthorized"); | |
header('Location: login.php'); | |
exit; | |
endif; | |
require_once( $basePath . '/includes/user.php'); | |
// Retrieve project object from database | |
$user = getUserByEmail($_SESSION['u_email']); | |
if ($user == FALSE || is_int($user)): | |
header($_SERVER["SERVER_PROTOCOL"] . "404 Not Found"); | |
header('Location: ../404.php'); | |
exit; | |
endif; | |
if ($user->is_admin == 0): | |
header($_SERVER["SERVER_PROTOCOL"] . "403 Unauthorized"); | |
header('Location: ../403.php'); | |
exit; | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment