Skip to content

Instantly share code, notes, and snippets.

@Damian96
Created May 6, 2019 09:44
Show Gist options
  • Save Damian96/195c926e6c81b478bb46fcecaac065ac to your computer and use it in GitHub Desktop.
Save Damian96/195c926e6c81b478bb46fcecaac065ac to your computer and use it in GitHub Desktop.
Damian User Check
<?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