<?php

//$_SESSION['user_agent'] != $_SERVER['HTTP_USER_AGENT']
if (!ISSET($_SESSION['admin_login']) && !ISSET($_SESSION['user_num'])){
    session_destroy();
    $extra = "index";
    $host = $_SERVER['HTTP_HOST'];
    $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    echo '<script type="text/javascript">';
    echo "window.location.href='http://$host$uri/$extra'";
    echo '</script>';
    exit();
} else if( $_SESSION['admin_login'] != 'true') {
    session_destroy();
    $extra = "index";
    $host = $_SERVER['HTTP_HOST'];
    $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    echo '<script type="text/javascript">';
    echo "window.location.href='http://$host$uri/$extra'";
    echo '</script>';
    exit();
} else {
    $user_id = $_SESSION['user_num'];
    $qry = mysqli_query($_app_conn_db, "SELECT * FROM my_admin where id = '$user_id'");
    $dataCount = mysqli_num_rows($qry);
    if($dataCount > 0) {

    } else {
        session_start();
        $extra="index";
        $host=$_SERVER['HTTP_HOST'];
        $uri=rtrim(dirname($_SERVER['PHP_SELF']),'/\\');
        echo '<script type="text/javascript">';
        echo "window.location.href='http://$host$uri/$extra'";
        echo '</script>';
        exit();
    }
}
?>