issue 2662 conding convention in config

git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12232 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ovclas 2012-11-15 08:04:47 +00:00
parent f324540321
commit 7928ad163b
2 changed files with 1488 additions and 1396 deletions

View file

@ -4,7 +4,7 @@
* *
* @file config/config.inc.php * @file config/config.inc.php
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
**/ */
@error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED); @error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED);
@ -44,9 +44,12 @@
ini_set('session.use_only_cookies', 0); ini_set('session.use_only_cookies', 0);
if(file_exists(_XE_PATH_.'config/package.inc.php')) { if(file_exists(_XE_PATH_.'config/package.inc.php'))
{
require _XE_PATH_.'config/package.inc.php'; require _XE_PATH_.'config/package.inc.php';
} else { }
else
{
/** /**
* Package type * Package type
*/ */
@ -84,7 +87,8 @@
* define('__XE_CDN_PREFIX__', 'http://yourCdnDomain.com/path/'); * define('__XE_CDN_PREFIX__', 'http://yourCdnDomain.com/path/');
* define('__XE_CDN_VERSION__', 'yourCdnVersion'); * define('__XE_CDN_VERSION__', 'yourCdnVersion');
*/ */
if(file_exists(_XE_PATH_.'config/config.user.inc.php')) { if(file_exists(_XE_PATH_.'config/config.user.inc.php'))
{
require _XE_PATH_.'config/config.user.inc.php'; require _XE_PATH_.'config/config.user.inc.php';
} }
@ -231,7 +235,8 @@
} }
// Require specific files when using Firebug console output // Require specific files when using Firebug console output
if((__DEBUG_OUTPUT__ == 2) && version_compare(PHP_VERSION, '6.0.0') === -1) { if((__DEBUG_OUTPUT__ == 2) && version_compare(PHP_VERSION, '6.0.0') === -1)
{
require _XE_PATH_.'libs/FirePHPCore/FirePHP.class.php'; require _XE_PATH_.'libs/FirePHPCore/FirePHP.class.php';
} }
@ -241,7 +246,8 @@
date_default_timezone_set(@date_default_timezone_get()); date_default_timezone_set(@date_default_timezone_get());
} }
if(!defined('__XE_LOADED_CLASS__')){ if(!defined('__XE_LOADED_CLASS__'))
{
// Require a function-defined-file for simple use // Require a function-defined-file for simple use
require(_XE_PATH_.'config/func.inc.php'); require(_XE_PATH_.'config/func.inc.php');
@ -275,4 +281,5 @@
require(_XE_PATH_.'classes/security/Security.class.php'); require(_XE_PATH_.'classes/security/Security.class.php');
if(__DEBUG__) $GLOBALS['__elapsed_class_load__'] = getMicroTime() - __ClassLoadStartTime__; if(__DEBUG__) $GLOBALS['__elapsed_class_load__'] = getMicroTime() - __ClassLoadStartTime__;
} }
?> /* End of file config.inc.php */
/* Location: ./config/config.inc.php */

View file

@ -3,14 +3,15 @@
* function library files for convenience * function library files for convenience
* *
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
**/ */
if(!defined('__XE__') && !defined('__ZBXE__')) exit(); if(!defined('__XE__') && !defined('__ZBXE__')) exit();
// define clone for php5 // define clone for php5
if (version_compare(phpversion(), '5.0') < 0) { if (version_compare(phpversion(), '5.0') < 0) {
eval(' eval('
function clone($object) { function clone($object)
{
return $object; return $object;
} }
'); ');
@ -19,7 +20,8 @@
// define an empty function to avoid errors when iconv function doesn't exist // define an empty function to avoid errors when iconv function doesn't exist
if(!function_exists('iconv')) { if(!function_exists('iconv')) {
eval(' eval('
function iconv($in_charset, $out_charset, $str) { function iconv($in_charset, $out_charset, $str)
{
return $str; return $str;
} }
'); ');
@ -93,7 +95,8 @@
* @param string $kind admin, null * @param string $kind admin, null
* @return mixed Module instance * @return mixed Module instance
*/ */
function &getModule($module_name, $type = 'view', $kind = '') { function &getModule($module_name, $type = 'view', $kind = '')
{
return ModuleHandler::getModuleInstance($module_name, $type, $kind); return ModuleHandler::getModuleInstance($module_name, $type, $kind);
} }
@ -103,7 +106,8 @@
* @param string $module_name The module name to get a controller instance * @param string $module_name The module name to get a controller instance
* @return mixed Module controller instance * @return mixed Module controller instance
*/ */
function &getController($module_name) { function &getController($module_name)
{
return getModule($module_name, 'controller'); return getModule($module_name, 'controller');
} }
@ -112,8 +116,9 @@
* *
* @param string $module_name The module name to get a admin controller instance * @param string $module_name The module name to get a admin controller instance
* @return mixed Module admin controller instance * @return mixed Module admin controller instance
**/ */
function &getAdminController($module_name) { function &getAdminController($module_name)
{
return getModule($module_name, 'controller','admin'); return getModule($module_name, 'controller','admin');
} }
@ -122,8 +127,9 @@
* *
* @param string $module_name The module name to get a view instance * @param string $module_name The module name to get a view instance
* @return mixed Module view instance * @return mixed Module view instance
**/ */
function &getView($module_name) { function &getView($module_name)
{
return getModule($module_name, 'view'); return getModule($module_name, 'view');
} }
@ -132,8 +138,9 @@
* *
* @param string $module_name The module name to get a mobile instance * @param string $module_name The module name to get a mobile instance
* @return mixed Module mobile instance * @return mixed Module mobile instance
**/ */
function &getMobile($module_name) { function &getMobile($module_name)
{
return getModule($module_name, 'mobile'); return getModule($module_name, 'mobile');
} }
@ -142,8 +149,9 @@
* *
* @param string $module_name The module name to get a admin view instance * @param string $module_name The module name to get a admin view instance
* @return mixed Module admin view instance * @return mixed Module admin view instance
**/ */
function &getAdminView($module_name) { function &getAdminView($module_name)
{
return getModule($module_name, 'view','admin'); return getModule($module_name, 'view','admin');
} }
@ -152,8 +160,9 @@
* *
* @param string $module_name The module name to get a model instance * @param string $module_name The module name to get a model instance
* @return mixed Module model instance * @return mixed Module model instance
**/ */
function &getModel($module_name) { function &getModel($module_name)
{
return getModule($module_name, 'model'); return getModule($module_name, 'model');
} }
@ -162,8 +171,9 @@
* *
* @param string $module_name The module name to get a admin model instance * @param string $module_name The module name to get a admin model instance
* @return mixed Module admin model instance * @return mixed Module admin model instance
**/ */
function &getAdminModel($module_name) { function &getAdminModel($module_name)
{
return getModule($module_name, 'model','admin'); return getModule($module_name, 'model','admin');
} }
@ -172,8 +182,9 @@
* *
* @param string $module_name The module name to get a api instance * @param string $module_name The module name to get a api instance
* @return mixed Module api class instance * @return mixed Module api class instance
**/ */
function &getAPI($module_name) { function &getAPI($module_name)
{
return getModule($module_name, 'api'); return getModule($module_name, 'api');
} }
@ -182,8 +193,9 @@
* *
* @param string $module_name The module name to get a wap instance * @param string $module_name The module name to get a wap instance
* @return mixed Module wap class instance * @return mixed Module wap class instance
**/ */
function &getWAP($module_name) { function &getWAP($module_name)
{
return getModule($module_name, 'wap'); return getModule($module_name, 'wap');
} }
@ -192,8 +204,9 @@
* *
* @param string $module_name The module name to get a class instance * @param string $module_name The module name to get a class instance
* @return mixed Module class instance * @return mixed Module class instance
**/ */
function &getClass($module_name) { function &getClass($module_name)
{
return getModule($module_name, 'class'); return getModule($module_name, 'class');
} }
@ -205,8 +218,9 @@
* @param object $args values of args object * @param object $args values of args object
* @param string[] $arg_columns Column list * @param string[] $arg_columns Column list
* @return object Query result data * @return object Query result data
**/ */
function executeQuery($query_id, $args = null, $arg_columns = null) { function executeQuery($query_id, $args = null, $arg_columns = null)
{
$oDB = &DB::getInstance(); $oDB = &DB::getInstance();
return $oDB->executeQuery($query_id, $args, $arg_columns); return $oDB->executeQuery($query_id, $args, $arg_columns);
} }
@ -220,11 +234,13 @@
* @param object $args values of args object * @param object $args values of args object
* @param string[] $arg_columns Column list * @param string[] $arg_columns Column list
* @return object Query result data * @return object Query result data
**/ */
function executeQueryArray($query_id, $args = null, $arg_columns = null) { function executeQueryArray($query_id, $args = null, $arg_columns = null)
{
$oDB = &DB::getInstance(); $oDB = &DB::getInstance();
$output = $oDB->executeQuery($query_id, $args, $arg_columns); $output = $oDB->executeQuery($query_id, $args, $arg_columns);
if(!is_array($output->data) && count($output->data) > 0){ if(!is_array($output->data) && count($output->data) > 0)
{
$output->data = array($output->data); $output->data = array($output->data);
} }
return $output; return $output;
@ -235,8 +251,9 @@
* *
* @see DB::getNextSequence() * @see DB::getNextSequence()
* @return int * @return int
**/ */
function getNextSequence() { function getNextSequence()
{
$oDB = &DB::getInstance(); $oDB = &DB::getInstance();
return $oDB->getNextSequence(); return $oDB->getNextSequence();
} }
@ -253,8 +270,9 @@
* </ol> * </ol>
* *
* @return string * @return string
**/ */
function getUrl() { function getUrl()
{
$num_args = func_num_args(); $num_args = func_num_args();
$args_list = func_get_args(); $args_list = func_get_args();
@ -270,7 +288,8 @@
* @see getUrl() * @see getUrl()
* @return string * @return string
*/ */
function getNotEncodedUrl() { function getNotEncodedUrl()
{
$num_args = func_num_args(); $num_args = func_num_args();
$args_list = func_get_args(); $args_list = func_get_args();
@ -286,7 +305,8 @@
* @see getUrl() * @see getUrl()
* @return string * @return string
*/ */
function getAutoEncodedUrl() { function getAutoEncodedUrl()
{
$num_args = func_num_args(); $num_args = func_num_args();
$args_list = func_get_args(); $args_list = func_get_args();
@ -300,15 +320,17 @@
* Return the value adding request uri to getUrl() to get the full url * Return the value adding request uri to getUrl() to get the full url
* *
* @return string * @return string
**/ */
function getFullUrl() { function getFullUrl()
{
$num_args = func_num_args(); $num_args = func_num_args();
$args_list = func_get_args(); $args_list = func_get_args();
$request_uri = Context::getRequestUri(); $request_uri = Context::getRequestUri();
if(!$num_args) return $request_uri; if(!$num_args) return $request_uri;
$url = Context::getUrl($num_args, $args_list); $url = Context::getUrl($num_args, $args_list);
if(!preg_match('/^http/i',$url)){ if(!preg_match('/^http/i',$url))
{
preg_match('/^(http|https):\/\/([^\/]+)\//',$request_uri,$match); preg_match('/^(http|https):\/\/([^\/]+)\//',$request_uri,$match);
return substr($match[0],0,-1).$url; return substr($match[0],0,-1).$url;
} }
@ -319,15 +341,17 @@
* Return the value adding request uri to getUrl() to get the not encoded full url * Return the value adding request uri to getUrl() to get the not encoded full url
* *
* @return string * @return string
**/ */
function getNotEncodedFullUrl() { function getNotEncodedFullUrl()
{
$num_args = func_num_args(); $num_args = func_num_args();
$args_list = func_get_args(); $args_list = func_get_args();
$request_uri = Context::getRequestUri(); $request_uri = Context::getRequestUri();
if(!$num_args) return $request_uri; if(!$num_args) return $request_uri;
$url = Context::getUrl($num_args, $args_list, null, false); $url = Context::getUrl($num_args, $args_list, null, false);
if(!preg_match('/^http/i',$url)){ if(!preg_match('/^http/i',$url))
{
preg_match('/^(http|https):\/\/([^\/]+)\//',$request_uri,$match); preg_match('/^(http|https):\/\/([^\/]+)\//',$request_uri,$match);
$url = Context::getUrl($num_args, $args_list, null, false); $url = Context::getUrl($num_args, $args_list, null, false);
return substr($match[0],0,-1).$url; return substr($match[0],0,-1).$url;
@ -340,8 +364,9 @@
* The first argument should consist of domain("http://" not included) and path * The first argument should consist of domain("http://" not included) and path
* *
* @return string * @return string
**/ */
function getSiteUrl() { function getSiteUrl()
{
$num_args = func_num_args(); $num_args = func_num_args();
$args_list = func_get_args(); $args_list = func_get_args();
@ -358,8 +383,9 @@
* The first argument should consist of domain("http://" not included) and path * The first argument should consist of domain("http://" not included) and path
* *
* @return string * @return string
**/ */
function getNotEncodedSiteUrl() { function getNotEncodedSiteUrl()
{
$num_args = func_num_args(); $num_args = func_num_args();
$args_list = func_get_args(); $args_list = func_get_args();
@ -375,8 +401,9 @@
* Return the value adding request uri to the getSiteUrl() To get the full url * Return the value adding request uri to the getSiteUrl() To get the full url
* *
* @return string * @return string
**/ */
function getFullSiteUrl() { function getFullSiteUrl()
{
$num_args = func_num_args(); $num_args = func_num_args();
$args_list = func_get_args(); $args_list = func_get_args();
@ -387,7 +414,8 @@
$num_args = count($args_list); $num_args = count($args_list);
$url = Context::getUrl($num_args, $args_list, $domain); $url = Context::getUrl($num_args, $args_list, $domain);
if(!preg_match('/^http/i',$url)){ if(!preg_match('/^http/i',$url))
{
preg_match('/^(http|https):\/\/([^\/]+)\//',$request_uri,$match); preg_match('/^(http|https):\/\/([^\/]+)\//',$request_uri,$match);
return substr($match[0],0,-1).$url; return substr($match[0],0,-1).$url;
} }
@ -399,8 +427,9 @@
* *
* @param string $domain * @param string $domain
* @return bool * @return bool
**/ */
function isSiteID($domain) { function isSiteID($domain)
{
return preg_match('/^([a-z0-9\_]+)$/i', $domain); return preg_match('/^([a-z0-9\_]+)$/i', $domain);
} }
@ -411,7 +440,7 @@
* @param int $cut_size The size to be * @param int $cut_size The size to be
* @param string $tail Tail to put in the end of the string after trimming * @param string $tail Tail to put in the end of the string after trimming
* @return string * @return string
**/ */
function cut_str($string, $cut_size = 0, $tail = '...') function cut_str($string, $cut_size = 0, $tail = '...')
{ {
if($cut_size < 1 || !$string) return $string; if($cut_size < 1 || !$string) return $string;
@ -430,7 +459,8 @@
$char_count = 0; $char_count = 0;
$idx = 0; $idx = 0;
while($idx < $string_length && $char_count < $cut_size && $char_width <= $max_width) { while($idx < $string_length && $char_count < $cut_size && $char_width <= $max_width)
{
$c = ord(substr($string, $idx,1)); $c = ord(substr($string, $idx,1));
$char_count++; $char_count++;
if($c < 128) if($c < 128)
@ -464,7 +494,8 @@
* *
* @return int * @return int
*/ */
function zgap() { function zgap()
{
$time_zone = $GLOBALS['_time_zone']; $time_zone = $GLOBALS['_time_zone'];
if($time_zone < 0) $to = -1; else $to = 1; if($time_zone < 0) $to = -1; else $to = 1;
$t_hour = substr($time_zone, 1, 2) * $to; $t_hour = substr($time_zone, 1, 2) * $to;
@ -487,8 +518,9 @@
* *
* @param string $str Time value in format of YYYYMMDDHHIISS * @param string $str Time value in format of YYYYMMDDHHIISS
* @return int * @return int
**/ */
function ztime($str) { function ztime($str)
{
if(!$str) return; if(!$str) return;
$hour = (int)substr($str,8,2); $hour = (int)substr($str,8,2);
$min = (int)substr($str,10,2); $min = (int)substr($str,10,2);
@ -496,9 +528,12 @@
$year = (int)substr($str,0,4); $year = (int)substr($str,0,4);
$month = (int)substr($str,4,2); $month = (int)substr($str,4,2);
$day = (int)substr($str,6,2); $day = (int)substr($str,6,2);
if(strlen($str) <= 8) { if(strlen($str) <= 8)
{
$gap = 0; $gap = 0;
} else { }
else
{
$gap = zgap(); $gap = zgap();
} }
@ -511,8 +546,9 @@
* @param string $date Time value in format of YYYYMMDDHHIISS * @param string $date Time value in format of YYYYMMDDHHIISS
* @param string $format If gap is within a day, returns this format. * @param string $format If gap is within a day, returns this format.
* @return string * @return string
**/ */
function getTimeGap($date, $format = 'Y.m.d') { function getTimeGap($date, $format = 'Y.m.d')
{
$gap = time() + zgap() - ztime($date); $gap = time() + zgap() - ztime($date);
$lang_time_gap = Context::getLang('time_gap'); $lang_time_gap = Context::getLang('time_gap');
@ -530,8 +566,9 @@
* @param int $month Month * @param int $month Month
* @param boot $short If set, returns short string * @param boot $short If set, returns short string
* @return string * @return string
**/ */
function getMonthName($month, $short = true) { function getMonthName($month, $short = true)
{
$short_month = array('','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); $short_month = array('','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
$long_month = array('','January','February','March','April','May','June','July','August','September','October','November','December'); $long_month = array('','January','February','March','April','May','June','July','August','September','October','November','December');
return !$short?$long_month[$month]:$short_month[$month]; return !$short?$long_month[$month]:$short_month[$month];
@ -544,13 +581,16 @@
* @param string $format Time format of php date() function * @param string $format Time format of php date() function
* @param bool $conversion Means whether to convert automatically according to the language * @param bool $conversion Means whether to convert automatically according to the language
* @return string * @return string
**/ */
function zdate($str, $format = 'Y-m-d H:i:s', $conversion=true) { function zdate($str, $format = 'Y-m-d H:i:s', $conversion=true)
{
// return null if no target time is specified // return null if no target time is specified
if(!$str) return; if(!$str) return;
// convert the date format according to the language // convert the date format according to the language
if($conversion == true) { if($conversion == true)
switch(Context::getLangType()) { {
switch(Context::getLangType())
{
case 'en' : case 'en' :
case 'es' : case 'es' :
if($format == 'Y-m-d') $format = 'M d, Y'; if($format == 'Y-m-d') $format = 'M d, Y';
@ -562,12 +602,12 @@
elseif($format == 'Y-m-d H:i:s') $format = 'H:i:s d-m-Y'; elseif($format == 'Y-m-d H:i:s') $format = 'H:i:s d-m-Y';
elseif($format == 'Y-m-d H:i') $format = 'H:i d-m-Y'; elseif($format == 'Y-m-d H:i') $format = 'H:i d-m-Y';
break; break;
} }
} }
// If year value is less than 1970, handle it separately. // If year value is less than 1970, handle it separately.
if((int)substr($str,0,4) < 1970) { if((int)substr($str,0,4) < 1970)
{
$hour = (int)substr($str,8,2); $hour = (int)substr($str,8,2);
$min = (int)substr($str,10,2); $min = (int)substr($str,10,2);
$sec = (int)substr($str,12,2); $sec = (int)substr($str,12,2);
@ -596,7 +636,9 @@
); );
$string = strtr($format, $trans); $string = strtr($format, $trans);
} else { }
else
{
// if year value is greater than 1970, get unixtime by using ztime() for date() function's argument. // if year value is greater than 1970, get unixtime by using ztime() for date() function's argument.
$string = date($format, ztime($str)); $string = date($format, ztime($str));
} }
@ -614,9 +656,11 @@
* @param string $email The email * @param string $email The email
* @return string * @return string
*/ */
function getEncodeEmailAddress($email) { function getEncodeEmailAddress($email)
{
$return = ''; $return = '';
for ($i=0,$c=strlen($email);$i<$c;$i++) { for ($i=0,$c=strlen($email);$i<$c;$i++)
{
$return .= '&#' . (rand(0,1)==0 ? ord($email[$i]) : 'X'.dechex(ord($email[$i]))) . ';'; $return .= '&#' . (rand(0,1)==0 ? ord($email[$i]) : 'X'.dechex(ord($email[$i]))) . ';';
} }
return $return; return $return;
@ -632,8 +676,9 @@
* @param bool $display_option boolean Flag whether to print seperator (default:true) * @param bool $display_option boolean Flag whether to print seperator (default:true)
* @param string $file Target file name * @param string $file Target file name
* @return void * @return void
**/ */
function debugPrint($debug_output = null, $display_option = true, $file = '_debug_message.php') { function debugPrint($debug_output = null, $display_option = true, $file = '_debug_message.php')
{
if(!(__DEBUG__ & 1)) return; if(!(__DEBUG__ & 1)) return;
static $firephp; static $firephp;
@ -642,7 +687,8 @@
$file_name = array_pop(explode(DIRECTORY_SEPARATOR, $first['file'])); $file_name = array_pop(explode(DIRECTORY_SEPARATOR, $first['file']));
$line_num = $first['line']; $line_num = $first['line'];
if(__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '6.0.0') === -1) { if(__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '6.0.0') === -1)
{
if(!isset($firephp)) $firephp = FirePHP::getInstance(true); if(!isset($firephp)) $firephp = FirePHP::getInstance(true);
if(function_exists("memory_get_usage")) if(function_exists("memory_get_usage"))
{ {
@ -655,15 +701,19 @@
// Check a FirePHP option // Check a FirePHP option
if($display_option === 'TABLE') $label = $display_option; if($display_option === 'TABLE') $label = $display_option;
// Check if the IP specified by __DEBUG_PROTECT__ option is same as the access IP. // Check if the IP specified by __DEBUG_PROTECT__ option is same as the access IP.
if(__DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) { if(__DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
{
$debug_output = 'The IP address is not allowed. Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php'; $debug_output = 'The IP address is not allowed. Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php';
$label = null; $label = null;
} }
$firephp->fb($debug_output, $label); $firephp->fb($debug_output, $label);
} else { }
if(__DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) { else
{
if(__DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
{
return; return;
} }
$debug_file = _XE_PATH_.'files/'.$file; $debug_file = _XE_PATH_.'files/'.$file;
@ -685,13 +735,13 @@
} }
} }
/** /**
* microtime() return * microtime() return
* *
* @return float * @return float
**/ */
function getMicroTime() { function getMicroTime()
{
list($time1, $time2) = explode(' ', microtime()); list($time1, $time2) = explode(' ', microtime());
return (float)$time1 + (float)$time2; return (float)$time1 + (float)$time2;
} }
@ -702,8 +752,9 @@
* @param object $target_obj An original object * @param object $target_obj An original object
* @param object $del_obj Object vars to delete from the original object * @param object $del_obj Object vars to delete from the original object
* @return object * @return object
**/ */
function delObjectVars($target_obj, $del_obj) { function delObjectVars($target_obj, $del_obj)
{
if(!is_object($target_obj)) return; if(!is_object($target_obj)) return;
if(!is_object($del_obj)) return; if(!is_object($del_obj)) return;
@ -717,7 +768,8 @@
$return_obj = NULL; $return_obj = NULL;
$target_count = count($target); $target_count = count($target);
for($i = 0; $i < $target_count; $i++) { for($i = 0; $i < $target_count; $i++)
{
$target_key = $target[$i]; $target_key = $target[$i];
if(!in_array($target_key, $del)) $return_obj->{$target_key} = $target_obj->{$target_key}; if(!in_array($target_key, $del)) $return_obj->{$target_key} = $target_obj->{$target_key};
} }
@ -733,8 +785,9 @@
* @param string $file * @param string $file
* @param int $line * @param int $line
* @return void * @return void
**/ */
function handleError($errno, $errstr, $file, $line) { function handleError($errno, $errstr, $file, $line)
{
if(!__DEBUG__) return; if(!__DEBUG__) return;
$errors = array(E_USER_ERROR, E_ERROR, E_PARSE); $errors = array(E_USER_ERROR, E_ERROR, E_PARSE);
if(!in_array($errno, $errors)) return; if(!in_array($errno, $errors)) return;
@ -750,8 +803,9 @@
* *
* @param int $no A given number * @param int $no A given number
* @param int $size A given digits * @param int $size A given digits
**/ */
function getNumberingPath($no, $size=3) { function getNumberingPath($no, $size=3)
{
$mod = pow(10, $size); $mod = pow(10, $size);
$output = sprintf('%0'.$size.'d/', $no%$mod); $output = sprintf('%0'.$size.'d/', $no%$mod);
if($no >= $mod) $output .= getNumberingPath((int)$no/$mod, $size); if($no >= $mod) $output .= getNumberingPath((int)$no/$mod, $size);
@ -763,8 +817,9 @@
* *
* @param string $str The url * @param string $str The url
* @return string * @return string
**/ */
function url_decode($str) { function url_decode($str)
{
return preg_replace('/%u([[:alnum:]]{4})/', '&#x\\1;',$str); return preg_replace('/%u([[:alnum:]]{4})/', '&#x\\1;',$str);
} }
@ -780,8 +835,9 @@
* *
* @param string $content Taget content * @param string $content Taget content
* @return string * @return string
**/ */
function removeHackTag($content) { function removeHackTag($content)
{
require_once(_XE_PATH_.'classes/security/EmbedFilter.class.php'); require_once(_XE_PATH_.'classes/security/EmbedFilter.class.php');
$oEmbedFilter = EmbedFilter::getInstance(); $oEmbedFilter = EmbedFilter::getInstance();
$oEmbedFilter->check($content); $oEmbedFilter->check($content);
@ -794,7 +850,7 @@
/** /**
* Remove codes to abuse the admin session in src by tags of imaages and video postings * Remove codes to abuse the admin session in src by tags of imaages and video postings
* - Issue reported by Sangwon Kim * - Issue reported by Sangwon Kim
**/ */
$content = preg_replace_callback('@<(/?)([a-z]+[0-9]?)((?>"[^"]*"|\'[^\']*\'|[^>])*?\b(?:on[a-z]+|data|style|background|href|(?:dyn|low)?src)\s*=[\s\S]*?)(/?)($|>|<)@i', 'removeSrcHack', $content); $content = preg_replace_callback('@<(/?)([a-z]+[0-9]?)((?>"[^"]*"|\'[^\']*\'|[^>])*?\b(?:on[a-z]+|data|style|background|href|(?:dyn|low)?src)\s*=[\s\S]*?)(/?)($|>|<)@i', 'removeSrcHack', $content);
// xmp tag ?•ì<E280A2>¸ ë°?ì¶”ê? // xmp tag ?•ì<E280A2>¸ ë°?ì¶”ê?
@ -807,11 +863,13 @@
* *
* @param string $content Target content * @param string $content Target content
* @return string * @return string
**/ */
function checkXmpTag($content) { function checkXmpTag($content)
{
$content = preg_replace('@<(/?)xmp.*?>@i', '<\1xmp>', $content); $content = preg_replace('@<(/?)xmp.*?>@i', '<\1xmp>', $content);
if(($start_xmp = strrpos($content, '<xmp>')) !==false) { if(($start_xmp = strrpos($content, '<xmp>')) !==false)
{
if(($close_xmp = strrpos($content, '</xmp>')) === false) $content .= '</xmp>'; if(($close_xmp = strrpos($content, '</xmp>')) === false) $content .= '</xmp>';
else if($close_xmp < $start_xmp) $content .= '</xmp>'; else if($close_xmp < $start_xmp) $content .= '</xmp>';
} }
@ -825,7 +883,8 @@
* @param array $match * @param array $match
* @return string * @return string
*/ */
function removeSrcHack($match) { function removeSrcHack($match)
{
$tag = strtolower($match[2]); $tag = strtolower($match[2]);
// xmp tag ?•리 // xmp tag ?•리
@ -834,8 +893,10 @@
if($match[4]) $match[4] = ' '.$match[4]; if($match[4]) $match[4] = ' '.$match[4];
$attrs = array(); $attrs = array();
if(preg_match_all('/([\w:-]+)\s*=(?:\s*(["\']))?(?(2)(.*?)\2|([^ ]+))/s', $match[3], $m)) { if(preg_match_all('/([\w:-]+)\s*=(?:\s*(["\']))?(?(2)(.*?)\2|([^ ]+))/s', $match[3], $m))
foreach($m[1] as $idx=>$name){ {
foreach($m[1] as $idx=>$name)
{
if(substr($name,0,2) == 'on') continue; if(substr($name,0,2) == 'on') continue;
$val = preg_replace('/&#(?:x([a-fA-F0-9]+)|0*(\d+));/e','chr("\\1"?0x00\\1:\\2+0)',$m[3][$idx].$m[4][$idx]); $val = preg_replace('/&#(?:x([a-fA-F0-9]+)|0*(\d+));/e','chr("\\1"?0x00\\1:\\2+0)',$m[3][$idx].$m[4][$idx]);
@ -847,12 +908,14 @@
} }
} }
if(isset($attrs['style']) && preg_match('@(?:/\*|\*/|\n|:\s*expression\s*\()@i', $attrs['style'])) { if(isset($attrs['style']) && preg_match('@(?:/\*|\*/|\n|:\s*expression\s*\()@i', $attrs['style']))
{
unset($attrs['style']); unset($attrs['style']);
} }
$attr = array(); $attr = array();
foreach($attrs as $name=>$val) { foreach($attrs as $name=>$val)
{
if($tag == 'object' || $tag == 'embed' || $tag == 'a') if($tag == 'object' || $tag == 'embed' || $tag == 'a')
{ {
$attribute = strtolower(trim($name)); $attribute = strtolower(trim($name));
@ -882,14 +945,16 @@
} }
// convert hexa value to RGB // convert hexa value to RGB
if(!function_exists('hexrgb')) { if(!function_exists('hexrgb'))
{
/** /**
* Convert hexa value to RGB * Convert hexa value to RGB
* *
* @param string $hexstr * @param string $hexstr
* @return array * @return array
*/ */
function hexrgb($hexstr) { function hexrgb($hexstr)
{
$int = hexdec($hexstr); $int = hexdec($hexstr);
return array('red' => 0xFF & ($int >> 0x10), return array('red' => 0xFF & ($int >> 0x10),
@ -905,15 +970,17 @@
* *
* @param string $password * @param string $password
* @return string * @return string
**/ */
function mysql_pre4_hash_password($password) { function mysql_pre4_hash_password($password)
{
$nr = 1345345333; $nr = 1345345333;
$add = 7; $add = 7;
$nr2 = 0x12345671; $nr2 = 0x12345671;
settype($password, "string"); settype($password, "string");
for ($i=0; $i<strlen($password); $i++) { for ($i=0; $i<strlen($password); $i++)
{
if ($password[$i] == ' ' || $password[$i] == '\t') continue; if ($password[$i] == ' ' || $password[$i] == '\t') continue;
$tmp = ord($password[$i]); $tmp = ord($password[$i]);
$nr ^= ((($nr & 63) + $add) * $tmp) + ($nr << 8); $nr ^= ((($nr & 63) + $add) * $tmp) + ($nr << 8);
@ -933,8 +1000,9 @@
* Return the requested script path * Return the requested script path
* *
* @return string * @return string
**/ */
function getScriptPath() { function getScriptPath()
{
static $url = null; static $url = null;
if($url == null) $url = preg_replace('/\/tools\//i','/',preg_replace('/index.php$/i','',str_replace('\\','/',$_SERVER['SCRIPT_NAME']))); if($url == null) $url = preg_replace('/\/tools\//i','/',preg_replace('/index.php$/i','',str_replace('\\','/',$_SERVER['SCRIPT_NAME'])));
return $url; return $url;
@ -944,7 +1012,7 @@
* Return the requested script path * Return the requested script path
* *
* @return string * @return string
**/ */
function getRequestUriByServerEnviroment() function getRequestUriByServerEnviroment()
{ {
return str_replace('<', '&lt;', $_SERVER['REQUEST_URI']); return str_replace('<', '&lt;', $_SERVER['REQUEST_URI']);
@ -957,17 +1025,21 @@
* *
* @param string $source * @param string $source
* @return string * @return string
**/ */
function utf8RawUrlDecode ($source) { function utf8RawUrlDecode ($source)
{
$decodedStr = ''; $decodedStr = '';
$pos = 0; $pos = 0;
$len = strlen ($source); $len = strlen ($source);
while ($pos < $len) { while($pos < $len)
{
$charAt = substr ($source, $pos, 1); $charAt = substr ($source, $pos, 1);
if ($charAt == '%') { if($charAt == '%')
{
$pos++; $pos++;
$charAt = substr ($source, $pos, 1); $charAt = substr ($source, $pos, 1);
if ($charAt == 'u') { if($charAt == 'u')
{
// we got a unicode character // we got a unicode character
$pos++; $pos++;
$unicodeHexVal = substr ($source, $pos, 4); $unicodeHexVal = substr ($source, $pos, 4);
@ -975,13 +1047,16 @@
$decodedStr .= _code2utf($unicode); $decodedStr .= _code2utf($unicode);
$pos += 4; $pos += 4;
} }
else { else
{
// we have an escaped ascii character // we have an escaped ascii character
$hexVal = substr ($source, $pos, 2); $hexVal = substr ($source, $pos, 2);
$decodedStr .= chr (hexdec ($hexVal)); $decodedStr .= chr (hexdec ($hexVal));
$pos += 2; $pos += 2;
} }
} else { }
else
{
$decodedStr .= $charAt; $decodedStr .= $charAt;
$pos++; $pos++;
} }
@ -995,7 +1070,8 @@
* @param int $num * @param int $num
* @return string * @return string
*/ */
function _code2utf($num){ function _code2utf($num)
{
if($num<128)return chr($num); if($num<128)return chr($num);
if($num<2048)return chr(($num>>6)+192).chr(($num&63)+128); if($num<2048)return chr(($num>>6)+192).chr(($num&63)+128);
if($num<65536)return chr(($num>>12)+224).chr((($num>>6)&63)+128).chr(($num&63)+128); if($num<65536)return chr(($num>>12)+224).chr((($num>>6)&63)+128).chr(($num&63)+128);
@ -1011,7 +1087,8 @@
* @param bool $urldecode * @param bool $urldecode
* @return bool|string * @return bool|string
*/ */
function detectUTF8($string, $return_convert = false, $urldecode = true) { function detectUTF8($string, $return_convert = false, $urldecode = true)
{
if($urldecode) $string = urldecode($string); if($urldecode) $string = urldecode($string);
$sample = iconv('utf-8', 'utf-8', $string); $sample = iconv('utf-8', 'utf-8', $string);
@ -1030,8 +1107,10 @@
* @param mixed $data * @param mixed $data
* @return string * @return string
*/ */
function json_encode2($data) { function json_encode2($data)
switch (gettype($data)) { {
switch (gettype($data))
{
case 'boolean': case 'boolean':
return $data?'true':'false'; return $data?'true':'false';
case 'integer': case 'integer':
@ -1044,15 +1123,18 @@
case 'array': case 'array':
$rel = false; // relative array? $rel = false; // relative array?
$key = array_keys($data); $key = array_keys($data);
foreach ($key as $v) { foreach($key as $v)
if (!is_int($v)) { {
if(!is_int($v))
{
$rel = true; $rel = true;
break; break;
} }
} }
$arr = array(); $arr = array();
foreach ($data as $k=>$v) { foreach ($data as $k=>$v)
{
$arr[] = ($rel?'"'.strtr($k, array('\\'=>'\\\\','"'=>'\\"')).'":':'').json_encode2($v); $arr[] = ($rel?'"'.strtr($k, array('\\'=>'\\\\','"'=>'\\"')).'":':'').json_encode2($v);
} }
@ -1070,12 +1152,14 @@
*/ */
function isCrawler($agent = null) { function isCrawler($agent = null) {
if(!$agent) $agent = $_SERVER['HTTP_USER_AGENT']; if(!$agent) $agent = $_SERVER['HTTP_USER_AGENT'];
$check_agent = array('bot', 'spider', 'google', 'yahoo', 'daum', 'teoma', 'fish', 'hanrss', 'facebook'); $check_agent = array('bot', 'spider', 'google', 'yahoo', 'daum', 'teoma', 'fish', 'hanrss', 'facebook');
$check_ip = array( $check_ip = array(
'211.245.21.11*' /* mixsh */ '211.245.21.11*' /* mixsh */
); );
foreach($check_agent as $str) { foreach($check_agent as $str)
{
if(stristr($agent, $str) != FALSE) return true; if(stristr($agent, $str) != FALSE) return true;
} }
@ -1136,7 +1220,6 @@
else else
{ {
set_include_path(_XE_PATH_."libs/PEAR.1.9"); set_include_path(_XE_PATH_."libs/PEAR.1.9");
} }
} }
@ -1201,3 +1284,5 @@ HTMLHEADER;
echo '<script>'.$reloadScript.'</script>'; echo '<script>'.$reloadScript.'</script>';
} }
/* End of file func.inc.php */
/* Location: ./config/func.inc.php */