<?php
include("libs.php");
include(dirname(dirname(__FILE__))."/./configs/config.php");
include(dirname(dirname(__FILE__))."/./configs/db_config.php");
include(dirname(dirname(__FILE__))."/./includes/class.inc.php");
include(dirname(dirname(__FILE__))."/./includes/function.php");
header("Content-Type:text/html;charset=utf-8");
session_start();
date_default_timezone_set('PRC');
$phpcolor = new mysql();
$phpcolor->open($core_mysql_host,$core_mysql_user,$core_mysql_pw,$core_mysql_dbname);
if(isset($_COOKIE['core_user_name']) && $_COOKIE['core_user_rank']=="2")
{
  $phpcolor->table=$core_mysql_prefix."user";
  $phpcolor->field="id,passwd,rank";
  $phpcolor->where="username='".$_COOKIE['core_user_name']."'";
  $userv=$phpcolor->exist(1);
  if($_COOKIE["core_user_passwd"]!=md5($userv['passwd'].$core_scode) || $_COOKIE["core_user_rank"]!=$userv['rank'])
    Header("Location: login.php?action=quit");
  else
  {
    setcookie("core_user_name", $_COOKIE["core_user_name"], time()+$core_time*60*60+3600);
    setcookie("core_user_passwd", $_COOKIE["core_user_passwd"], time()+$core_time*60*60+3600);
	setcookie("core_user_rank", $_COOKIE["core_user_rank"], time()+$core_time*60*60+3600);
	$phpcolor->table=$core_mysql_prefix."admin";
    $phpcolor->field="purview";
    $phpcolor->where="uid = '".$userv['id']."'";
    $prs=$phpcolor->exist(1);
	if($prs['purview']=="")
	  $prs['purview']="1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36";
    $prs1 = split("\|", $prs['purview']);
    for($i=0;$i<count($prs1);$i++)
    {
      $ppurview[$prs1[$i]]="1";
    }
    $tpl -> assign("core_user_name", $_COOKIE["core_user_name"]);
  }
}
else
{
  Header("Location: login.php?action=login");
  exit();
}
$tpl -> assign("ppurview", $ppurview);
$tpl -> display("left.htm");
?>