<?php
include("libs.php");
include(dirname(dirname(__FILE__))."/./configs/config.php");
include(dirname(dirname(__FILE__))."/./configs/db_config.php");
include(dirname(dirname(__FILE__))."/./configs/uc.config.php");
include(dirname(dirname(__FILE__))."/./configs/email.php");
include(dirname(dirname(__FILE__))."/./includes/base.php");
include(dirname(dirname(__FILE__))."/./configs/ranking.php");
include(dirname(dirname(__FILE__))."/./configs/shop.php");
header("Content-Type:text/html;charset=GB2312");
session_start();
date_default_timezone_set('PRC');
$tpl -> assign("core_bartype", $core_bartype);
$tpl -> assign("core_bar_url", $core_url);
$phpcolor = new mysql();
$phpcolor->open();
$phpcolor->newranking($int_jczr,$core_time);
/* 过滤所有GET过来变量 */
foreach ($_GET as $get_key=>$get_var)      
{
  $get_var=trim($get_var);
  $get_var=str_replace("　","",$get_var);
  $get_var=str_replace(",","，",$get_var);
  $get_var=str_replace("(","（",$get_var);
  $get_var=str_replace(")","）",$get_var);
  $get_var=str_replace("%20","％20",$get_var);
  $get_var=str_replace("%27","％27",$get_var);
  $get_var=str_replace("&","&amp;",$get_var);
  $get_var=str_replace("<","&lt;",$get_var);
  $get_var=str_replace(">","&gt;",$get_var);
  $get_var=str_replace("'","&#39;",$get_var);
  $_GET[strtolower($get_key)]=$get_var;
}
/* 过滤所有POST过来的变量 */
foreach ($_POST as $post_key=>$post_var)
{
  if(is_array($post_var))
  {
    foreach($post_var as $post_vars)
	{
      $post_vars=trim($post_vars);
      $post_vars=str_replace("　","",$post_vars);
      $post_vars=str_replace(",","，",$post_vars);
      $post_vars=str_replace("(","（",$post_vars);
      $post_vars=str_replace(")","）",$post_vars);
      $post_vars=str_replace("%20","％20",$post_vars);
      $post_vars=str_replace("%27","％27",$post_vars);  
      $post_vars=str_replace("&","&amp;",$post_vars);
      $post_vars=str_replace("<","&lt;",$post_vars);
      $post_vars=str_replace(">","&gt;",$post_vars);
      $post_vars=str_replace("'","&#39;",$post_vars);
	  $_POST[strtolower($post_key)][]=$post_vars;
    }
  }
  else
  {
    $post_var=trim($post_var);
    $post_var=str_replace("　","",$post_var);
    $post_var=str_replace(",","，",$post_var);
    $post_var=str_replace("(","（",$post_var);
    $post_var=str_replace(")","）",$post_var);
    $post_var=str_replace("%20","％20",$post_var);
    $post_var=str_replace("%27","％27",$post_var);  
    $post_var=str_replace("&","&amp;",$post_var);
    $post_var=str_replace("<","&lt;",$post_var);
    $post_var=str_replace(">","&gt;",$post_var);
    $post_var=str_replace("'","&#39;",$post_var);
    $_POST[strtolower($post_key)]=$post_var;
  }
}
if(isset($_COOKIE['core_user_name']) && $_COOKIE['core_user_rank']=="2")
{
  $_COOKIE['core_user_name']=html_replace($_COOKIE['core_user_name']);
  $phpcolor->table="user";
  $phpcolor->field="id,passwd,rank,state";
  $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'] || $userv['state']==0)
  {
    echo "对不起，您的ID验证失败，原因可能但不仅限于：1、在核对您密码时发生错误。2、您的ID已被封锁，请您清除cookies后重新访问本站";
	exit();
  }
  else
  {
    setcookie("core_user_name", $_COOKIE["core_user_name"], time()+$core_time*3600+3600);
    setcookie("core_user_passwd", $_COOKIE["core_user_passwd"], time()+$core_time*3600+3600);
	setcookie("core_user_rank", $_COOKIE["core_user_rank"], time()+$core_time*3600+3600);
	setcookie("core_user_long", $_COOKIE["core_user_long"], time()+$core_time*3600+3600);
	if($_COOKIE["core_user_long"]=="1")
	{
	  setcookie("core_user_name", $_COOKIE["core_user_name"], time()+$core_time*3600+604800);
      setcookie("core_user_passwd", $_COOKIE["core_user_passwd"], time()+$core_time*3600+604800);
	  setcookie("core_user_rank", $_COOKIE["core_user_rank"], time()+$core_time*3600+604800);
	  setcookie("core_user_long", $_COOKIE["core_user_long"], time()+$core_time*3600+604800);
	}
	$phpcolor->table="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|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54";
    $prs1 = split("\|", $prs['purview']);
    for($i=0;$i<count($prs1);$i++)
    {
      $ppurview[$prs1[$i]]="1";
    }
    $tpl -> assign("core_user_name", $_COOKIE["core_user_name"]);
	$tpl -> assign("core_version", version);
  }
}
else
  jump("login.php?action=login");
?>