<?php
//error_reporting(E_ALL);
error_reporting(E_ERROR);
set_magic_quotes_runtime(0);
$mTime = explode(' ', microtime());
$kuwebsStartTime = $mTime[1] + $mTime[0];
$nowTime = date("Y-m-d H:i:s");        //获取当前时间

if(function_exists('date_default_timezone_set')){date_default_timezone_set('Hongkong');}

//过滤不安全的字符和函数
function filterChar($array)
{
  foreach($array as $key => $value)
  {
    if(!is_array($value))
    {
      $value = str_replace("&#x", "& # x", $value);                          //过滤不安全的字符
      $value = preg_replace("/eval/i", 'eva l', $value);                    //过滤不安全的函数
      !get_magic_quotes_gpc() && $value = addslashes($value);
      $array[$key] = $value;
    }
    else
    {
      $array[$key] = filterChar($array[$key]);
    }
  }
  return $array;
}


if(PHP_VERSION < '4.1.0') {
  $_GET = &$HTTP_GET_VARS;
  $_POST = &$HTTP_POST_VARS;
  $_COOKIE = &$HTTP_COOKIE_VARS;
  $_SERVER = &$HTTP_SERVER_VARS;
  $_ENV = &$HTTP_ENV_VARS;
  $_FILES = &$HTTP_POST_FILES;
}


$_POST = filterChar($_POST);
$_GET = filterChar($_GET);
$_COOKIE = filterChar($_COOKIE);

if(!ini_get('register_globals'))
{
  @extract($_COOKIE, EXTR_SKIP);
  @extract($_FILES, EXTR_SKIP);
}


$adminServerRoot = substr(dirname(__FILE__), 0, -4).'/';            
define('KUWEBS_ADMIN_PATH', $adminServerRoot);                      
$adminHostName = $_SERVER['HTTP_HOST'];                             
$websiteHttpPath = "http://$adminHostName/";                         
$supportUrl = "http://www.kuwebs.com";
 
$rootLen = strlen($_SERVER['DOCUMENT_ROOT']);
if(substr($_SERVER['DOCUMENT_ROOT'], $rootLen-1, 1) == '/')$rootLen = $rootLen-1;
$adminServerRelativPath = substr($adminServerRoot, $rootLen, strlen($adminServerRoot)-$rootLen);

$adminHttpPath = str_replace('\\', '/', "http://$adminHostName$adminServerRelativPath");
$kuHttpPathUrl = str_replace('\\', '/', "http://$adminHostName$adminServerRelativPath".'../');
$adminAdminPath = str_replace("\\", '/', $adminServerRoot);
$kuWebAbsolutePath = realpath($adminAdminPath.'../');



require_once(KUWEBS_ADMIN_PATH.'../config/configsys.inc.php');
require_once(KUWEBS_ADMIN_PATH.'../config/config.db.php');
require_once(KUWEBS_ADMIN_PATH.'../config/config.inc.php');

$kuWebsiteEditVersionLanguage = (isset($_GET['lang']) ? $_GET['lang'] : 'cn');

require_once(KUWEBS_ADMIN_PATH.'../config/config.'.$kuWebsiteEditVersionLanguage.'.inc.php');
require_once(KUWEBS_ADMIN_PATH.'config/config.admin.php');
require_once(KUWEBS_ADMIN_PATH.'config/admin.inc.php');
require_once(KUWEBS_ADMIN_PATH.'config/prompt.'.$kuWebsiteEditVersionLanguage.'.inc.php');
require_once(KUWEBS_ADMIN_PATH.'config/left.'.$kuWebsiteEditVersionLanguage.'.inc.php');
require_once(KUWEBS_ADMIN_PATH.'config/label.'.$kuWebsiteEditVersionLanguage.'.inc.php');
require_once(KUWEBS_ADMIN_PATH.'inc/mysql.class.php');
include_once(KUWEBS_ADMIN_PATH.'../inc/pages.class.php');
require_once(KUWEBS_ADMIN_PATH.'inc/commonfunc.inc.php');

$globalEditVersionLanguage = $kuWebsiteEditVersionLanguage;  


$adminTemplatePath = 'template/'.$adminTemplateName.'/';
$adminCssPath = 'template/'.$adminTemplateName.'/css/';
$adminJsPath = 'template/'.$adminTemplateName.'/js/';
$adminImgPath = 'template/'.$adminTemplateName.'/images/';

$adminHttpTemplatePath = $adminHttpPath.'template/'.$adminTemplateName.'/';
$adminHttpCssPath = $adminHttpPath.'template/'.$adminTemplateName.'/css/';
$adminHttpJsPath = $adminHttpPath.'template/'.$adminTemplateName.'/js/';
$adminHttpImgPath = $adminHttpPath.'template/'.$adminTemplateName.'/images/';

$kuUploadPath = $websiteHttpPath."uploadfiles/";   
$adminDebugFile = $adminServerRoot.'debug.txt';


$dbInstance = new DatabaseMysql();
$dbInstance->connect($configDBHost, $configDBUser, $configDBPassword, $configDBName);


$kuWebsiteEditVersionLanguageFlag[$kuWebsiteEditVersionLanguage] = "checked='checked'"; 


function daddslashes($string, $force = 0) 
{
  !defined('MAGIC_QUOTES_GPC') && define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
  if(!MAGIC_QUOTES_GPC || $force) {
    if(is_array($string)) 
    {
      foreach($string as $key => $val) 
      {
        $string[$key] = daddslashes($val, $force);
      }
    } 
    else 
    {
      $string = addslashes($string);
    }
  }
  return $string;
}


foreach(array('_COOKIE', '_POST', '_GET') as $_request) 
{
  foreach($$_request as $_key => $_value) 
  {
    $_key{0} != '_' && $$_key = daddslashes($_value);
  }
} 



$kuWebsiteHeader = stripslashes($kuWebsiteHeader);
$kuWebsiteFootText = stripslashes($kuWebsiteFootText);
$kuWebsiteFootRight = stripslashes($kuWebsiteFootRight);
$kuWebsiteFootPostAddress = stripslashes($kuWebsiteFootPostAddress);
$kuWebsiteFootContact = stripslashes($kuWebsiteFootContact);
$kuWebsiteFootOtherInfo = stripslashes($kuWebsiteFootOtherInfo);


$arrAllModule = array("1"=>"about", "2"=>"news", "3"=>"product", "4"=>"img", "5"=>"download", "6"=>"job", "7"=>"message", "8"=>"faq"); 


$sql = "select * from {$configTableHead}skin order by id";
$result = $dbInstance->query($sql);
while($row = $dbInstance->fetchArray($result))
{
  $skinList[] = $row;
}


$sql = "select id, menutitle from {$configTableHead}menu order by id asc;";
$result = $dbInstance->query($sql);
while($row = $dbInstance->fetchArray($result))
{
  $menuList[$row['id']] = $row['menutitle'];
}


$sql = "select id, menuhtmlname from {$configTableHead}menu where menutype=1 and menumodule=1 order by id asc;";
$result = $dbInstance->query($sql);
while($row = $dbInstance->fetchArray($result))
{
  $menuHtmlList[$row['id']] = $row['menuhtmlname'];
}

//print_r($skinList);
?>