<?php
include(dirname(__FILE__)."/./includes/libs.php");
include(dirname(__FILE__)."/./includes/base.php");
include(dirname(__FILE__)."/./configs/config.php");
include(dirname(__FILE__)."/./configs/db_config.php");
include(dirname(__FILE__)."/./configs/uc.config.php");
include(dirname(__FILE__)."/./configs/email.php");
include(dirname(__FILE__)."/./configs/ranking.php");
include(dirname(__FILE__)."/./configs/shop.php");
date_default_timezone_set('PRC');
header('Content-Type:text/html;charset=GB2312');
if($_COOKIE['core_user_rank']!="2" && ($core_baropen==0 || (strtotime($core_opentime1) > (strtotime(date('H:i'))+$core_time*3600) || strtotime($core_opentime2) < (strtotime(date('H:i'))+$core_time*3600) && $core_opentime1!=$core_opentime2)))
  jump("close.php");
if (!file_exists('install/install.lock'))
  jump("install/");
session_start();
$tpl -> assign("core_bartype", $core_bartype);
$tpl -> assign("core_style", $core_style);
$tpl -> assign("core_barname", $core_barname);
$tpl -> assign("core_bar_url", $core_url);
$tpl -> assign("core_icp", $core_icp);
$core_flow=str_replace('*','"',$core_flow);
$tpl -> assign("core_flow", $core_flow);
$tpl -> assign("core_version", version);
$phpcolor = new mysql();
$phpcolor->open();
$phpcolor->newranking($int_jczr,$core_time);
$ad[1]["code"]=$phpcolor->adshow(1,0);
$ad[2]["code"]=$phpcolor->adshow(2,0);
$tpl -> assign("ad", $ad);
if(isset($_GET['onlyone']))
  unset($_GET['onlyone']);
/* 过滤所有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_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
  {
	$cookieurl=str_replace("http://www.","",$core_url);
    $cookieurl=str_replace("/","",$cookieurl);
	if($_COOKIE["core_user_long"]=="1")
	{
      setcookie("core_user_name", $_COOKIE["core_user_name"], time()+$core_time*3600+604800,"/",$cookieurl);
      setcookie("core_user_passwd",$_COOKIE["core_user_passwd"], time()+$core_time*3600+604800,"/",$cookieurl);
      setcookie("core_user_rank", $_COOKIE["core_user_rank"], time()+$core_time*3600+604800,"/",$cookieurl);
      setcookie("core_user_long", $_COOKIE["core_user_long"], time()+$core_time*3600+604800,"/",$cookieurl);
	  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);
	}
	else
	{
      setcookie("core_user_name", $_COOKIE["core_user_name"], time()+$core_time*3600+3600,"/",$cookieurl);
      setcookie("core_user_passwd", $_COOKIE["core_user_passwd"], time()+$core_time*3600+3600,"/",$cookieurl);
      setcookie("core_user_rank", $_COOKIE["core_user_rank"], time()+$core_time*3600+3600,"/",$cookieurl);
      setcookie("core_user_long", $_COOKIE["core_user_long"], time()+$core_time*3600+3600,"/",$cookieurl);
      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);
    }
    $phpcolor->table="message";
    $phpcolor->field="*";
    $phpcolor->where="addressee='".$_COOKIE["core_user_name"]."' and isread ='0'";
    if($phpcolor->exist(2))
      $tpl -> assign("core_user_news", "1");
    else
      $tpl -> assign("core_user_news", "0");
	$phpcolor->table="apply_user";
    $phpcolor->field="*";
    $phpcolor->where="object = '".$_COOKIE["core_user_name"]."' and type = '2'";
	if($phpcolor->exist(2))
      $tpl -> assign("core_user_apply", "1");
    else
      $tpl -> assign("core_user_apply", "0");
    $tpl -> assign("core_user_name", $_COOKIE["core_user_name"]);
    $tpl -> assign("core_user_rank", $_COOKIE["core_user_rank"]);
	$tpl -> assign("core_user_id", $userv["id"]);
  }
}
//头部导航
$phpcolor->table="nav";
$phpcolor->field="*";
$phpcolor->where="type='1' order by queue";
$navhead=$phpcolor->assignment();
$tpl -> assign("navhead", $navhead);
//底部导航
$phpcolor->table="nav";
$phpcolor->field="*";
$phpcolor->where="type='2' order by queue";
$navfoot=$phpcolor->assignment();
$tpl -> assign("navfoot", $navfoot);
$last=GetCurUrl();
$tpl -> assign("last", $last);
$gfyzurl="";
if($core_gfbarid!="" and $core_gfbarm!="")
  $gfyzurl="plugin.php?id=1&gfbarid=".$core_gfbarid."&gfbarm=".$core_gfbarm;
$tpl -> assign("gfyzurl", $gfyzurl);
?>