<?php
include(dirname(__FILE__)."/./includes/function.php");
include(dirname(__FILE__)."/./includes/libs.php");
include(dirname(__FILE__)."/./includes/class.inc.php");
include(dirname(__FILE__)."/./configs/config.php");
include(dirname(__FILE__)."/./configs/db_config.php");
include(dirname(__FILE__)."/./configs/email.php");
date_default_timezone_set('PRC');
header('Content-Type:text/html;charset=utf-8');
if($core_baropen==0 || (strtotime($core_opentime1) > (strtotime(date('H:i'))+$core_time*60*60) || strtotime($core_opentime2) < (strtotime(date('H:i'))+$core_time*60*60) && $core_opentime1!=$core_opentime2)){
  echo $core_closed;
  exit();}
if (!file_exists('install/install.lock')){
  Header("Location: install/");
  exit();}
session_start();
$tpl -> assign("core_style", $core_style);
$tpl -> assign("core_barname", $core_barname);
$tpl -> assign("core_bar_url", $core_url);
$tpl -> assign("core_keyword", $core_keyword);
$tpl -> assign("core_description", $core_description);
$tpl -> assign("core_icp", $core_icp);
$tpl -> assign("core_flow", $core_flow);
$tpl -> assign("core_rewrite", $core_rewrite);
$phpcolor = new mysql();
$phpcolor->open($core_mysql_host,$core_mysql_user,$core_mysql_pw,$core_mysql_dbname);
$phpcolor->table=$core_mysql_prefix."ad";
$phpcolor->field="name,site,type,theme,picture,link,code";
$phpcolor->where="site = 1 order by rand()";
$rs[1]=$phpcolor->assignment();
for ($count=0;$count<count($rs[1]);$count++)
{
  if($rs[1][$count]['type']==1)
    $ad[1][$count]="<a href=".$rs[1][$count]['link']." target='_blank'><img src=".$rs[1][$count]['picture']." width='468' height='60' style='border:0px;'></a>";
  elseif($rs[1][$count]['type']==2)
    $ad[1][$count]="<a href=".$rs[1][$count]['link']." target='_blank'>".$rs[1][$count]['theme']."</a>";
  else
    $ad[1][$count]=$rs[1][$count]['code'];
}
$phpcolor->where="site = 2 order by rand()";
$rs[2]=$phpcolor->assignment();
for ($count=0;$count<count($rs[2]);$count++)
{
  if($rs[2][$count]['type']==1)
    $ad[2][$count]="<a href=".$rs[2][$count]['link']." target='_blank'><img src=".$rs[2][$count]['picture']." width='760' height='60' style='border:0px;'></a>";
  elseif($rs[2][$count]['type']==2)
    $ad[2][$count]="<a href=".$rs[2][$count]['link']." target='_blank'>".$rs[2][$count]['theme']."</a>";
  else
    $ad[2][$count]=$rs[2][$count]['code'];
}
$tpl -> assign("ad", $ad);
if(isset($_COOKIE['core_user_name']))
{
  $_COOKIE['core_user_name']=submitfilter(2,$_COOKIE['core_user_name']);
  $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'])
  {
    echo "请不要非法操作，您可以清除cookies后重新访问本站";
	exit();
  }
  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);
	setcookie("core_user_long", $_COOKIE["core_user_long"], time()+$core_time*60*60+3600);
	if($_COOKIE["core_user_long"]=="1")
	{
	  setcookie("core_user_name", $_COOKIE["core_user_name"], time()+$core_time*60*60+604800);
      setcookie("core_user_passwd", $_COOKIE["core_user_passwd"], time()+$core_time*60*60+604800);
	  setcookie("core_user_rank", $_COOKIE["core_user_rank"], time()+$core_time*60*60+604800);
	  setcookie("core_user_long", $_COOKIE["core_user_long"], time()+$core_time*60*60+604800);
	}
    $phpcolor->table=$core_mysql_prefix."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=$core_mysql_prefix."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"]);
  }
}
$last=GetCurUrl();
$tpl -> assign("last", $last);
?>