<?php
Function adminlogin(){ //检测管理员是否登录
    global $db;
	global $tablepre;
	session_start();
	$AdminName=$_SESSION["admin_user"];
	$admin_pwd=$_SESSION["admin_pwd"];
    if ($AdminName!=""){
        $sql="select * from {$tablepre}scuser where UserName='".$AdminName."'";
		$rs   = $db->get_row($sql);
		if (!empty($rs)){
		   $dbpwd=$rs["Password"];
		   if ($dbpwd==$admin_pwd){
		      $adminlogin="Y";
		   }
		   else
		   {
		      $adminlogin="N";
		   }
		}
		else{
		   $adminlogin="N";
		  }
	  }
	 else{
	 $adminlogin="N";
	 }
	 return $adminlogin;
}
$adminlogin=adminlogin();
if ($adminlogin=="N"){
   //redirectorUrl("/admin.php");
   header("content-type:text/html; charset=utf-8");
   echo "<script language='javascript'>";
   //echo "alert('非法登录或登录超时!');";
   echo "window.parent.location.href='/admin.php';";
   echo "</script>";
   exit;
}
?>