<?php






error_reporting(0);
define("DEBUG",1);
define("CUR_DIR",dirname(__FILE__)); 
define('ROOT_DIR', substr(CUR_DIR,0,strrpos(CUR_DIR,DIRECTORY_SEPARATOR)+1));
define('COMMON_DIR', ROOT_DIR . DIRECTORY_SEPARATOR . 'common' . DIRECTORY_SEPARATOR);


require_once(COMMON_DIR . "Config.inc.php");
require_once(COMMON_DIR . "MailTemplate.class.php");
require_once(COMMON_DIR . "MyDB.class.php");
require_once(COMMON_DIR . "MySmarty.class.php");
require_once(COMMON_DIR . "Util.inc.php");
require_once(COMMON_DIR . "Common.funcs.php");
require_once(COMMON_DIR . "Const.inc.php");
require_once(COMMON_DIR . "API.class.php");
require_once(COMMON_DIR . "Order.class.php");
require_once(COMMON_DIR . "ProductType.class.php");
require_once(COMMON_DIR . "HostImpl.class.php");

require_once(COMMON_DIR . "api.inc.php");


//处理php.ini一些设置
if(DEBUG==1){
	@ini_set("display_errors","On");
	error_reporting(E_ALL & ~E_NOTICE);
}

@ini_set("display_errors","On");
@error_reporting(E_ALL & ~E_NOTICE);

/* 对用户传入的变量进行转义操作。*/
if (!get_magic_quotes_gpc())
{
    if (!empty($_GET))
    {
        $_GET  = addslashes_deep($_GET);
    }
    if (!empty($_POST))
    {
        $_POST = addslashes_deep($_POST);
    }

    $_COOKIE   = addslashes_deep($_COOKIE);
    $_REQUEST  = addslashes_deep($_REQUEST);
}

CheckMysqlHackWords();

if(DB_SERVER == '' || DB_NAME == ''){
	echo("<script>alert('您还没执行安装程序');location='../install/index.php'</script>");
}



/* 初始化数据库类 */
$db = new cls_mysql(DB_SERVER, DB_LOGIN, DB_PW, DB_NAME);
$db->root_path = ROOT_DIR;
$db->cache_data_dir = "cache/";
$DB = $db;

/* 载入系统参数 */
$_CFG = load_config();


function arrayRecursive(&$array, $function, $apply_to_keys_also = false) 
{ 
    static $recursive_counter = 0; 
    if (++$recursive_counter > 1000) { 
        die('possible deep recursion attack'); 
    } 
if($array){
    foreach ($array as $key => $value) { 
        if (is_array($value)) { 
            arrayRecursive($array[$key], $function, $apply_to_keys_also); 
        } else { 
            $array[$key] = $function($value); 
        } 
 
        if ($apply_to_keys_also && is_string($key)) { 
            $new_key = $function($key); 
            if ($new_key != $key) { 
                $array[$new_key] = $array[$key]; 
                unset($array[$key]); 
            } 
        } 
    } 
 }
    $recursive_counter--; 
} 
 
/************************************************************** 
 * 
 *    将数组转换为JSON字符串（兼容中文） 
 *    @param    array    $array        要转换的数组 
 *    @return string        转换得到的json字符串 
 *    @access public 
 * 
 *************************************************************/ 
function JSON($array) { 
    arrayRecursive($array, 'urlencode', true); 
    $json = json_encode($array); 
    return urldecode($json); 
} 
 


?>