<?php
    function redirect($url=NULL)
    {
        if(is_null($url)) $url=curPageURL();
        if(headers_sent())
        {
            echo "<script>window.location='".$url."'</script>";
        }
        else
        {
            header("Location:".$url);
        }
        exit;
    }

    function checkSession(){
        if(!isset($_SESSION["admin"]["uid"])){
            echo "<script>window.location='adminlogin.php'</script>";
        }
    }

    function checkUserSession(){
        if(!isset($_SESSION["admin"]["uid"])){
            echo "<script>window.location='login.php'</script>";
        }
    }
?>