<?php 

require realpath( __DIR__ . "/../" ) . "/connections/config.php";

define( 'PANEL_DIR', __DIR__ );
define( '_SDIR', __DIR__ . '/server' );

$admin = call_user_func(function() {
	if( empty($_SESSION['_admin']) ) return;
	global $link;
	$token = $_SESSION['_admin']['token'] ?? null;
	$email = $_SESSION['_admin']['email'] ?? null;
	$SQL = sQuery::select( 'admin', "token = '{$token}' AND email = '{$email}'" );
	$admin = $link->query( $SQL )->fetch_assoc();
	return $admin;
});


if( !$admin && PERMISSION_TYPE !== NULL ):
	header("location: " . help::url( PANEL_DIR ));
	exit;
endif;

$email = $_GET['email'] ?? null;

