<?php
error_reporting(7);
ini_set("display_errors",true);

session_start();

//================ 定义站点根目录 ================//
define('WEB_ROOT', dirname(__FILE__));
define('WEB_TEMPLATE',WEB_ROOT.'/template');
define('WEB_SHTML',WEB_ROOT.'/shtml');
define('WEB_MODULE',WEB_ROOT.'/module');
define('WEB_SCRIPT',WEB_ROOT.'/script');
define('WEB_MODEL',WEB_ROOT.'/model');
define('WEB_MODULE',WEB_ROOT.'/module');
define('WEB_IMAGES',WEB_ROOT.'/images');
define('WEB_CSS',WEB_ROOT.'/css');


//================ 定义整站站点目录 ================//
define('CORE_ROOT', WEB_ROOT.'/../core/');
define('CORE_CONF',CORE_ROOT.'conf');
define('CORE_COMMON',CORE_ROOT.'common');
define('CORE_LIB',CORE_ROOT.'lib');
define('CORE_STATIC',CORE_ROOT.'static');


//================ 定义常量 ================//
define('FRAME_URL', "http://esfadmin.house365.com/");
define('FRAME_MODULE', FRAME_URL."module");
define("FRAME_LOGIN", FRAME_URL."login.php");
define("FRAME_LOGOUT", FRAME_URL."login.php?submit_flag=logout");
define("FRAME_INDEX", FRAME_URL."index.php");
define("FRAME_DEFAULT", FRAME_MODULE."/default/default.php");


/****载入配置类库、方法库开始****/
include_once(CORE_LIB . "/class_spell.php");      //基本拼音类
include_once(CORE_LIB . "/ip/ip.php");            //包含IP文件
include_once(CORE_LIB . "/class_adodb.php");      //包含配置变量文件
include_once(CORE_LIB . "/class_server.php");     //中间件
include_once(CORE_LIB . "/class_dao.php");        //数据库类
include_once(CORE_LIB . "/class_uploadfile.php"); //中间件
include_once(CORE_LIB . "/class_page.php"); //中间件
include_once(CORE_LIB . "/UserBehavior.class.php"); //个人会员用户行为轨迹分析类
/****载入配置类库、方法库结束****/

/*** 载入基本函数文件***/
include_once(CORE_COMMON . "/func_tony.php");   //标签函数集合
include_once(CORE_COMMON . "/func_template.php"); //模板函数集合
/*** 载入基本函数文件结束***/

//================ 载入后台本站通用文件 ================//
include_once(WEB_MODEL."/func_base.php");	//本站公用函数
if($directory != ""){
	include_once(WEB_MODEL."/".$directory."_base_func.php");//模块公用集合
}

//================ 框架系统标识 ================//
$web_auth = "esfadmin";

//================ 载入基础配置文件 ================//
include_once(CORE_CONF."/conf_base.php");
include_once(CORE_CONF."/conf_esfadmin.php");

//================ 设置框架风格 ================//
$dwz_theme = $_COOKIE['dwz_theme'] != '' ? $_COOKIE['dwz_theme'] : 'default';


//================ 城市判断 ================//
$conf_cityflag = $_SESSION[$web_auth]["now_city"] != "" ? $_SESSION[$web_auth]["now_city"] : "";


//================ 基础库开通 ================//
/****实例化Dao FISHER 2013-7-18****/
//不确定是否配置了从库
$conf_dbback_host = $conf_dbback_host != "" ? $conf_dbback_host : $conf_db_host;
$dao_sys = new Dao();
$dao_sys->initDb(CORE_LIB."/class_adodb.php", array('conf_db_type'=>$conf_db_type,'conf_db_host'=>$conf_db_host,'conf_db_user'=>$conf_db_user,'conf_db_password'=>$conf_db_password,'conf_db_name'=>$conf_db_name,'conf_db_charset'=>$conf_db_charset,'conf_db_debug'=>$conf_db_debug,'conf_db_connect'=>$conf_db_connect), array('conf_db_type'=>$conf_db_type,'conf_db_host'=>$conf_dbback_host,'conf_db_user'=>$conf_db_user,'conf_db_password'=>$conf_db_password,'conf_db_name'=>$conf_db_name,'conf_db_charset'=>$conf_db_charset,'conf_db_debug'=>$conf_db_debug,'conf_db_connect'=>$conf_db_connect));
$dao_sys->initMc('172.17.1.51', 1122);

$db_sys = $dao_sys->db;//数据库主库
$dbback_sys = $dao_sys->dbback;//数据库从库

//个人会员中心数据库连接
$conf_dbuser_type = "mysql";
$conf_dbuser_host = "master_nj_esf";//master_nj_esf
$conf_dbuserback_host = "172.17.1.41";//master_nj_esf_back
$conf_dbuser_user = "root";
$conf_dbuser_password = "idontcare";
$conf_dbuser_debug = false;
$conf_dbuser_charset = "gbk";
$conf_dbuser_connect = "0";
$conf_dbuser_name = "user";

$dao_user = new Dao();
$dao_user->initDb(CORE_LIB."/class_adodb.php", array('conf_db_type'=>$conf_dbuser_type,'conf_db_host'=>$conf_dbuser_host,'conf_db_user'=>$conf_dbuser_user,'conf_db_password'=>$conf_dbuser_password,'conf_db_name'=>$conf_dbuser_name,'conf_db_charset'=>$conf_dbuser_charset,'conf_db_debug'=>$conf_dbuser_debug,'conf_db_connect'=>$conf_dbuser_connect), array('conf_db_type'=>$conf_dbuser_type,'conf_db_host'=>$conf_dbuserback_host,'conf_db_user'=>$conf_dbuser_user,'conf_db_password'=>$conf_dbuser_password,'conf_db_name'=>$conf_dbuser_name,'conf_db_charset'=>$conf_dbuser_charset,'conf_db_debug'=>$conf_dbuser_debug,'conf_db_connect'=>$conf_dbuser_connect));

$db_user = $dao_user->db;//数据库主库
$dbback_user = $dao_user->dbback;//数据库从库

$mc = $dao_sys->mc;//初始化Memcache
/*********************************/

//================ 初始化特定角色权限 ================//
$global_purview = array("super"=>1,"admin"=>2);

//===================== 已开通站点 ===================//
$global_admin_citys = array_merge(array('super'=>'系统管理','admin'=>'系统管理'), $esfadmin_citys);

//================ 初始化菜单 ================//
$_SESSION[$web_auth]["purview"] = $_SESSION[$web_auth]["purview_arr"][$conf_cityflag];
if($_SESSION[$web_auth]["purview"] != "")
{
    $_SESSION[$web_auth]["group_purview"] = get_group_purview($_SESSION[$web_auth]["purview"]);
    $_SESSION[$web_auth]["menu_purview"] = frame_menu_create($_SESSION[$web_auth]["group_purview"]);
}

//================ 载入城市配置文件 ================//
if($conf_cityflag != "" && $esfadmin_citys[$conf_cityflag] != "")
{
	/****实例化各站Dao FISHER 2013-7-24****/
	include_once(CORE_CONF."/conf_".$conf_cityflag.".php");

	//不确定是否配置了从库
	$conf_dbback_host = $conf_dbback_host != "" ? $conf_dbback_host : $conf_db_host;
	$dao = new Dao();
	$dao->initDb(CORE_LIB."/class_adodb.php", array('conf_db_type'=>$conf_db_type,'conf_db_host'=>$conf_db_host,'conf_db_user'=>$conf_db_user,'conf_db_password'=>$conf_db_password,'conf_db_name'=>$conf_db_name,'conf_db_charset'=>$conf_db_charset,'conf_db_debug'=>$conf_db_debug,'conf_db_connect'=>$conf_db_connect), array('conf_db_type'=>$conf_db_type,'conf_db_host'=>$conf_dbback_host,'conf_db_user'=>$conf_db_user,'conf_db_password'=>$conf_db_password,'conf_db_name'=>$conf_db_name,'conf_db_charset'=>$conf_db_charset,'conf_db_debug'=>$conf_db_debug,'conf_db_connect'=>$conf_db_connect));

	$db = $dao->db;//数据库主库
	$dbback = $dao->dbback;//数据库从库
}
/*********************************/
//@author sun
if ($conf_city == 'nj') {
	define(NS_STACTICS,"172.17.1.76:100/datamining");//旧统计
	define(NS_STACTICS_BAK,"172.17.1.37:100/datamining");//新统计
	define(NS_STACTICS_PLUS,"172.17.1.76:7777/datamining/HTTP/?service=");//旧统计
} else {
	define(NS_STACTICS, "172.17.1.37:100/fzdatamining");//新统计
	define(NS_STACTICS_BAK,"172.17.1.76:100/fzdatamining");//旧统计
	define(NS_STACTICS_PLUS,"172.17.1.37:7778/fzdatamining/HTTP?service=");//内网地址
}

//初始化统计类
if($conf_server == 'statistics' ){
    include_once(CORE_LIB . "/class_statistics.php"); //包含统计接口文件
    //include_once(CORE_LIB . "/class_statistics_plus.php"); //包含新的统计接口文件
    $statistics = new statistics(NS_STACTICS, $conf_city);
    //$statistics_plus = new statistics_plus(NS_STACTICS_PLUS, $conf_city);
}

define("GROWTH_DIR",WEB_MODULE."/growth/");
if(file_exists(GROWTH_DIR.'base.inc.php')) {
    include_once GROWTH_DIR.'base.inc.php';   
}

//================ 合并整站和模块的相应配置 ================//
$house = array_merge($house,$conf_house);
//var_dump($conf_house);
unset($conf_house);
?>