<?php
error_reporting(E_ALL ^ E_NOTICE);
if(!file_exists("config/install.lock")){
	header("Location:install");exit;
};
header("Content-type:text/html; charset=utf-8");
define("ROOT_PATH",  str_replace("\\", "/", dirname(__FILE__))."/");
@include_once("config/site_list.php");
@include_once("config/version.php");
@include_once("config/setconfig.php");
define("SITEID",isset($SITELIST[$_SERVER['HTTP_HOST']])?$SITELIST[$_SERVER['HTTP_HOST']]:1);
require("config/rewriterule.php");
require("config/config.php");
require("config/const.php");

define("CONTROL_DIR","source/admin");
define("MODEL_DIR","source/model");
/*视图模版配置*/
$cache_dir="";//模版缓存文件夹
$template_dir="skins/admin";//模版风格文件夹
$compiled_dir="";//模版编译文件夹
$html_dir="";//生成静态文件夹
$rewrite_on=REWRITE_ON;//是否开启伪静态 0不开 1开启
$smarty_caching=true;//是否开启缓存
$smarty_cache_lifetime=3600;//缓存时间
require("./skymvc/skymvc.php");
//用户自定义初始化函数
function userinit(&$base){
	
	if(isset($_SESSION["ssuser"]["userid"])){
		$base->ssuser=$_SESSION["ssuser"];//当前登录用户的信息
		$base->smarty->assign("ssuser",$base->ssuser);
	}
	//关闭session防止session死锁
	if(!in_array(get('m'),array('admin_login',"checkcode","backup"))){
		session_write_close();
	}
	$m=get('m','h'); 
	if(!in_array(strtolower($m),array('admin_login',"admin_main","index"))){
		if(!isset($_SESSION['ssadmin']['id'])){
			$base->gomsg("请先登录",APPADMIN."?m=admin_login");
		}
		 
		if(!$base->checkpermission($_SESSION['ssadmin']['permission']) && !$_SESSION['ssadmin']['isfounder'] ){			 
		 //  print_r($_SESSION['ssadmin']['permission']);exit;
		   //$base->gomsg("您无权限",APPADMIN."?m=admin_login");
			
		}
	}
	$base->loadConfig("table");		
	$base->smarty->assign("skins","/skins/admin/");
	$base->smarty->assign("appindex",APPINDEX);
	$base->smarty->assign("appadmin",APPADMIN);
}

?>