<?
if (!defined('SOFTPUBS_IN')){
    die('Hacking attempt');
}
define('ECS_ADMIN', true);
error_reporting(E_ALL & ~E_NOTICE);
if (__FILE__ == ''){
    die('Fatal error code: 0');
}

// timezone
	if(function_exists('date_default_timezone_set')) {
	  date_default_timezone_set('Asia/Shanghai');
	}	


// root path
define('ROOT_PATH', str_replace('admin/includes/init.php', '', str_replace('\\', '/', __FILE__)));
define('DATA_DIR', ROOT_PATH . 'data/');
define('SIT_CHARSET','utf-8');
define('SIT_DB_CHARSET','utf8');
$glo_domain_name	 		=		'http://'.$_SERVER['SERVER_NAME'];
$glo_domain_directory	=		preg_replace('|admin\/[^\/]*$|si','',$_SERVER['REQUEST_URI']);

// get config
if(!file_exists(DATA_DIR.'/config.php')||!file_exists(DATA_DIR.'/install.lock')){
   header("Location: ".$glo_domain_directory."install/index.php");
}else{
	require_once(DATA_DIR.'config.php');
}
if(!$glo_lang){
	$glo_lang	=	'zh_cn_UTF-8';
}

define('UPLOAD_DIR', ROOT_PATH . 'upload/');
define('SMARTY_DIR', ROOT_PATH . 'lib/Smarty/');
define('TEMPLATE_DIR',ROOT_PATH.'admin/tpl_'.$glo_lang);
define('TEMPLATE_C_DIR',ROOT_PATH.'admin/compiler_tpl');
define('CLASS_DIR', ROOT_PATH . 'admin/includes/');
define('TEMPLATE_COMPILATION_DIR',ROOT_PATH.'tpls/');
define('TEMPLATE_COMPILATION_URL',$glo_domain_directory.'tpls/');

define('TEMPLATE_COMPILATION_C_DIR',ROOT_PATH.'/compiler_tpl');
define('MODULES_DIR',ROOT_PATH.'modules/');


header('Content-type: text/html; charset='.SIT_CHARSET);

session_start();
if(!empty($_GET)){
    $_GET   =    array_map('stripslashes_deep',$_GET);
}
if(!empty($_COOKIE)){
    $_COOKIE   =    array_map('stripslashes_deep',$_COOKIE);
}
if(!empty($_POST)){
    $_POST   =    array_map('stripslashes_deep',$_POST);
}	
function  stripslashes_deep($value)
{
    if(empty($value)){
       return $value;
    }else{
       if(is_array($value)){
			 return array_map('stripslashes_deep', $value);
		 }else{
			 if(get_magic_quotes_gpc()){
				$value	=	stripslashes($value);	
			 }
			 return trim($value);
   	} 
	}
}

@set_time_limit(360);

require_once(ROOT_PATH.'includes/function.php');
