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

define("CHANNEL_PRODUCT_ID",1);
define("CHANNEL_DOWNLOAD_ID",2);
define("CHANNEL_PURCHASE_ID",3);
define("CHANNEL_ARTICLE_LIST_ID",4);
define("CHANNEL_SUPPORT_ID",5);
define("CHANNEL_ABOUT_ID",6);

//timezone
	if(function_exists('date_default_timezone_set')) {
	  date_default_timezone_set('Asia/Shanghai');
	}	
$glo_domain_name	 		=		'http://'.$_SERVER['SERVER_NAME'];
$glo_domain_directory	=		preg_replace('|[^\/]*$|si','',$_SERVER['REQUEST_URI']);


@ini_set('memory_limit',          '64M');
@ini_set('session.cache_expire',  180);
@ini_set('session.use_trans_sid', 0);
@ini_set('session.use_cookies',   1);
@ini_set('session.auto_start',    0);
@ini_set('display_errors',        1);

define('ROOT_PATH', str_replace('includes/init.php', '', str_replace('\\', '/', __FILE__)));
define('LIB_DIR', ROOT_PATH . 'lib/');
define('DATA_DIR', ROOT_PATH . 'data/');
define('SMARTY_DIR', ROOT_PATH . '/lib/Smarty/');
define('UPLOAD_DIR', ROOT_PATH . 'upload/');
define('SIT_CHARSET','utf-8');

if (isset($_SERVER['PHP_SELF'])){
    define('PHP_SELF', $_SERVER['PHP_SELF']);
}
else{
    define('PHP_SELF', $_SERVER['SCRIPT_NAME']);
}

if (!file_exists(DATA_DIR.'config.php')||!file_exists(DATA_DIR.'install.lock')){
	 header("Location: ".$glo_domain_directory."install/index.php\n");
  	 exit;
}else{
	require_once(DATA_DIR. 'config.php');
}


if (DIRECTORY_SEPARATOR == '\\')
{
    @ini_set('include_path', '.;' . ROOT_PATH);
}
else
{
    @ini_set('include_path', '.:' . ROOT_PATH);
}

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);
   	} 
	}
}


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

require_once(ROOT_PATH.'includes/database.php');
$db_obj	 =	 new Database(TRUE);
if (!$db_obj->connect($glo_db_host, $glo_db_user, $glo_db_pass, $glo_db_name)){
        die("Not Connect!");
}
$db_obj->query('set names utf8');
$db_obj->db_pre	=	$glo_db_pre;

$glo_hook_arr	=	array();

$glo_config_res		=		$db_obj->getRecords("SELECT * FROM {$db_obj->db_pre}site_config");
$glo_config_arr		=		array();

foreach($glo_config_res as  $val){
	$glo_config_arr[trim($val['name'])]	=	$val;
}
unset($glo_config_res);

if(!($glo_proscenium_lang=$glo_config_arr['glo_proscenium_lang']['value'])){
	$glo_proscenium_lang	=	'en_UTF-8';
}
require_once(ROOT_PATH.'lang/'.$glo_proscenium_lang.'.php');
require_once(ROOT_PATH.'includes/software.php');
require_once(ROOT_PATH.'includes/glo_category.php');
require_once(ROOT_PATH.'includes/article.php');
require_once(ROOT_PATH.'includes/channel.php');
$glo_category_obj	=	new glo_category();
