issue 2119. supporting php 5.4. config

git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12698 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
flyskyko 2013-02-05 04:36:52 +00:00
parent ba9800ff34
commit 9f0e24d59b
3 changed files with 483 additions and 271 deletions

View file

@ -1,14 +1,24 @@
<?php <?php
/** /**
* set the include of the class file and other environment configurations * set the include of the class file and other environment configurations
* *
* @file config/config.inc.php * @file config/config.inc.php
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
*/ */
if(version_compare(PHP_VERSION, '5.4.0', '<'))
{
@error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED); @error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED);
}
else
{
@error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT);
}
if(!defined('__ZBXE__')) exit(); if(!defined('__XE__'))
{
exit();
}
/** /**
* Display XE's full version. * Display XE's full version.
@ -215,7 +225,7 @@ if(!defined('__PROXY_SERVER__'))
* __PROXY_SERVER__ has server information to request to the external through the target server * __PROXY_SERVER__ has server information to request to the external through the target server
* FileHandler:: getRemoteResource uses the constant * FileHandler:: getRemoteResource uses the constant
*/ */
define('__PROXY_SERVER__', null); define('__PROXY_SERVER__', NULL);
} }
if(!defined('__XE_CDN_PREFIX__')) if(!defined('__XE_CDN_PREFIX__'))
@ -251,11 +261,13 @@ 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');
if(__DEBUG__) define('__StartTime__', getMicroTime()); if(__DEBUG__)
define('__StartTime__', getMicroTime());
// include the class files // include the class files
//TODO When _autoload() can be used for PHP5 based applications, it will be removed. //TODO When _autoload() can be used for PHP5 based applications, it will be removed.
if(__DEBUG__) define('__ClassLoadStartTime__', getMicroTime()); if(__DEBUG__)
define('__ClassLoadStartTime__', getMicroTime());
require(_XE_PATH_ . 'classes/object/Object.class.php'); require(_XE_PATH_ . 'classes/object/Object.class.php');
require(_XE_PATH_ . 'classes/extravar/Extravar.class.php'); require(_XE_PATH_ . 'classes/extravar/Extravar.class.php');
require(_XE_PATH_ . 'classes/handler/Handler.class.php'); require(_XE_PATH_ . 'classes/handler/Handler.class.php');
@ -279,7 +291,8 @@ if(!defined('__XE_LOADED_CLASS__'))
require(_XE_PATH_ . 'classes/validator/Validator.class.php'); require(_XE_PATH_ . 'classes/validator/Validator.class.php');
require(_XE_PATH_ . 'classes/frontendfile/FrontEndFileHandler.class.php'); require(_XE_PATH_ . 'classes/frontendfile/FrontEndFileHandler.class.php');
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 */ /* End of file config.inc.php */
/* Location: ./config/config.inc.php */ /* Location: ./config/config.inc.php */

View file

@ -1,24 +1,18 @@
<?php <?php
/** /**
* function library files for convenience * function library files for convenience
* *
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
*/ */
if(!defined('__XE__'))
if(!defined('__XE__') && !defined('__ZBXE__')) exit();
// define clone for php5
if (version_compare(phpversion(), '5.0') < 0) {
eval('
function clone($object)
{ {
return $object; exit();
}
');
} }
// 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)
{ {
@ -29,6 +23,7 @@ if(!function_exists('iconv')) {
if(!function_exists('htmlspecialchars_decode')) if(!function_exists('htmlspecialchars_decode'))
{ {
/** /**
* Decode html special characters * Decode html special characters
* *
@ -39,6 +34,7 @@ if( !function_exists('htmlspecialchars_decode') )
{ {
return strtr($text, array_flip(get_html_translation_table(HTML_SPECIALCHARS))); return strtr($text, array_flip(get_html_translation_table(HTML_SPECIALCHARS)));
} }
} }
/** /**
@ -219,9 +215,9 @@ function &getClass($module_name)
* @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);
} }
@ -235,9 +231,9 @@ function executeQuery($query_id, $args = null, $arg_columns = null)
* @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)
{ {
@ -254,7 +250,7 @@ function executeQueryArray($query_id, $args = null, $arg_columns = null)
*/ */
function getNextSequence() function getNextSequence()
{ {
$oDB = &DB::getInstance(); $oDB = DB::getInstance();
return $oDB->getNextSequence(); return $oDB->getNextSequence();
} }
@ -276,8 +272,10 @@ function getUrl()
$num_args = func_num_args(); $num_args = func_num_args();
$args_list = func_get_args(); $args_list = func_get_args();
if($num_args) $url = Context::getUrl($num_args, $args_list); if($num_args)
else $url = Context::getRequestUri(); $url = Context::getUrl($num_args, $args_list);
else
$url = Context::getRequestUri();
return preg_replace('@\berror_return_url=[^&]*|\w+=(?:&|$)@', '', $url); return preg_replace('@\berror_return_url=[^&]*|\w+=(?:&|$)@', '', $url);
} }
@ -293,8 +291,14 @@ function getNotEncodedUrl()
$num_args = func_num_args(); $num_args = func_num_args();
$args_list = func_get_args(); $args_list = func_get_args();
if($num_args) $url = Context::getUrl($num_args, $args_list, null, false); if($num_args)
else $url = Context::getRequestUri(); {
$url = Context::getUrl($num_args, $args_list, NULL, FALSE);
}
else
{
$url = Context::getRequestUri();
}
return preg_replace('@\berror_return_url=[^&]*|\w+=(?:&|$)@', '', $url); return preg_replace('@\berror_return_url=[^&]*|\w+=(?:&|$)@', '', $url);
} }
@ -310,8 +314,14 @@ function getAutoEncodedUrl()
$num_args = func_num_args(); $num_args = func_num_args();
$args_list = func_get_args(); $args_list = func_get_args();
if($num_args) $url = Context::getUrl($num_args, $args_list, null, true, true); if($num_args)
else $url = Context::getRequestUri(); {
$url = Context::getUrl($num_args, $args_list, NULL, TRUE, TRUE);
}
else
{
$url = Context::getRequestUri();
}
return preg_replace('@\berror_return_url=[^&]*|\w+=(?:&|$)@', '', $url); return preg_replace('@\berror_return_url=[^&]*|\w+=(?:&|$)@', '', $url);
} }
@ -326,7 +336,10 @@ 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))
@ -347,13 +360,16 @@ 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;
} }
return $url; return $url;
@ -370,7 +386,10 @@ function getSiteUrl()
$num_args = func_num_args(); $num_args = func_num_args();
$args_list = func_get_args(); $args_list = func_get_args();
if(!$num_args) return Context::getRequestUri(); if(!$num_args)
{
return Context::getRequestUri();
}
$domain = array_shift($args_list); $domain = array_shift($args_list);
$num_args = count($args_list); $num_args = count($args_list);
@ -389,12 +408,15 @@ function getNotEncodedSiteUrl()
$num_args = func_num_args(); $num_args = func_num_args();
$args_list = func_get_args(); $args_list = func_get_args();
if(!$num_args) return Context::getRequestUri(); if(!$num_args)
{
return Context::getRequestUri();
}
$domain = array_shift($args_list); $domain = array_shift($args_list);
$num_args = count($args_list); $num_args = count($args_list);
return Context::getUrl($num_args, $args_list, $domain, false); return Context::getUrl($num_args, $args_list, $domain, FALSE);
} }
/** /**
@ -408,7 +430,10 @@ function getFullSiteUrl()
$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;
}
$domain = array_shift($args_list); $domain = array_shift($args_list);
$num_args = count($args_list); $num_args = count($args_list);
@ -443,7 +468,10 @@ function isSiteID($domain)
*/ */
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;
}
if($GLOBALS['use_mb_strimwidth'] || function_exists('mb_strimwidth')) if($GLOBALS['use_mb_strimwidth'] || function_exists('mb_strimwidth'))
{ {
@ -497,12 +525,28 @@ function cut_str($string, $cut_size = 0, $tail = '...')
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;
$t_min = substr($time_zone, 3, 2) * $to; $t_min = substr($time_zone, 3, 2) * $to;
$server_time_zone = date("O"); $server_time_zone = date("O");
if($server_time_zone < 0) $so = -1; else $so = 1; if($server_time_zone < 0)
{
$so = -1;
}
else
{
$so = 1;
}
$c_hour = substr($server_time_zone, 1, 2) * $so; $c_hour = substr($server_time_zone, 1, 2) * $so;
$c_min = substr($server_time_zone, 3, 2) * $so; $c_min = substr($server_time_zone, 3, 2) * $so;
@ -521,7 +565,11 @@ function zgap()
*/ */
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);
$sec = (int) substr($str, 12, 2); $sec = (int) substr($str, 12, 2);
@ -552,11 +600,27 @@ 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');
if($gap<60) $buff = sprintf($lang_time_gap['min'], (int)($gap / 60)+1); if($gap < 60)
elseif($gap<60*60) $buff = sprintf($lang_time_gap['mins'], (int)($gap / 60)+1); {
elseif($gap<60*60*2) $buff = sprintf($lang_time_gap['hour'], (int)($gap / 60 /60)+1); $buff = sprintf($lang_time_gap['min'], (int) ($gap / 60) + 1);
elseif($gap<60*60*24) $buff = sprintf($lang_time_gap['hours'], (int)($gap / 60 /60)+1); }
else $buff = zdate($date, $format); elseif($gap < 60 * 60)
{
$buff = sprintf($lang_time_gap['mins'], (int) ($gap / 60) + 1);
}
elseif($gap < 60 * 60 * 2)
{
$buff = sprintf($lang_time_gap['hour'], (int) ($gap / 60 / 60) + 1);
}
elseif($gap < 60 * 60 * 24)
{
$buff = sprintf($lang_time_gap['hours'], (int) ($gap / 60 / 60) + 1);
}
else
{
$buff = zdate($date, $format);
}
return $buff; return $buff;
} }
@ -567,7 +631,7 @@ function getTimeGap($date, $format = 'Y.m.d')
* @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');
@ -582,25 +646,46 @@ function getMonthName($month, $short = true)
* @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')
elseif($format == 'Y-m-d H:i:s') $format = 'M d, Y H:i:s'; {
elseif($format == 'Y-m-d H:i') $format = 'M d, Y H:i'; $format = 'M d, Y';
}
elseif($format == 'Y-m-d H:i:s')
{
$format = 'M d, Y H:i:s';
}
elseif($format == 'Y-m-d H:i')
{
$format = 'M d, Y H:i';
}
break; break;
case 'vi' : case 'vi' :
if($format == 'Y-m-d') $format = 'd-m-Y'; if($format == 'Y-m-d')
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'; $format = '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';
}
break; break;
} }
} }
@ -632,7 +717,7 @@ function zdate($str, $format = 'Y-m-d H:i:s', $conversion=true)
'i' => $lz($min), 'i' => $lz($min),
's' => $lz($sec), 's' => $lz($sec),
'M' => getMonthName($month), 'M' => getMonthName($month),
'F'=>getMonthName($month,false) 'F' => getMonthName($month, FALSE)
); );
$string = strtr($format, $trans); $string = strtr($format, $trans);
@ -677,19 +762,28 @@ function getEncodeEmailAddress($email)
* @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;
$bt = debug_backtrace(); $bt = debug_backtrace();
if(is_array($bt)) $first = array_shift($bt); if(is_array($bt))
{
$first = array_shift($bt);
}
$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"))
{ {
$label = sprintf('[%s:%d] (m:%s)', $file_name, $line_num, FileHandler::filesize(memory_get_usage())); $label = sprintf('[%s:%d] (m:%s)', $file_name, $line_num, FileHandler::filesize(memory_get_usage()));
@ -699,16 +793,18 @@ function debugPrint($debug_output = null, $display_option = true, $file = '_debu
$label = sprintf('[%s:%d] ', $file_name, $line_num); $label = sprintf('[%s:%d] ', $file_name, $line_num);
} }
// 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 else
{ {
@ -719,17 +815,23 @@ function debugPrint($debug_output = null, $display_option = true, $file = '_debu
$debug_file = _XE_PATH_ . 'files/' . $file; $debug_file = _XE_PATH_ . 'files/' . $file;
if(function_exists("memory_get_usage")) if(function_exists("memory_get_usage"))
{ {
$debug_output = sprintf("[%s %s:%d] - mem(%s)\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, FileHandler::filesize(memory_get_usage()), print_r($debug_output, true)); $debug_output = sprintf("[%s %s:%d] - mem(%s)\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, FileHandler::filesize(memory_get_usage()), print_r($debug_output, TRUE));
} }
else else
{ {
$debug_output = sprintf("[%s %s:%d]\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($debug_output, true)); $debug_output = sprintf("[%s %s:%d]\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($debug_output, TRUE));
} }
if($display_option === true) $debug_output = str_repeat('=', 40)."\n".$debug_output.str_repeat('-', 40); if($display_option === TRUE)
{
$debug_output = str_repeat('=', 40) . "\n" . $debug_output . str_repeat('-', 40);
}
$debug_output = "\n<?php\n/*" . $debug_output . "*/\n?>\n"; $debug_output = "\n<?php\n/*" . $debug_output . "*/\n?>\n";
if(@!$fp = fopen($debug_file, 'a')) return; if(@!$fp = fopen($debug_file, 'a'))
{
return;
}
fwrite($fp, $debug_output); fwrite($fp, $debug_output);
fclose($fp); fclose($fp);
} }
@ -755,15 +857,24 @@ function getMicroTime()
*/ */
function delObjectVars($target_obj, $del_obj) function delObjectVars($target_obj, $del_obj)
{ {
if(!is_object($target_obj)) return; if(!is_object($target_obj))
if(!is_object($del_obj)) return; {
return;
}
if(!is_object($del_obj))
{
return;
}
$target_vars = get_object_vars($target_obj); $target_vars = get_object_vars($target_obj);
$del_vars = get_object_vars($del_obj); $del_vars = get_object_vars($del_obj);
$target = array_keys($target_vars); $target = array_keys($target_vars);
$del = array_keys($del_vars); $del = array_keys($del_vars);
if(!count($target)||!count($del)) return $target_obj; if(!count($target) || !count($del))
{
return $target_obj;
}
$return_obj = NULL; $return_obj = NULL;
@ -771,7 +882,10 @@ function delObjectVars($target_obj, $del_obj)
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};
}
} }
return $return_obj; return $return_obj;
@ -788,9 +902,15 @@ function delObjectVars($target_obj, $del_obj)
*/ */
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;
}
$output = sprintf("Fatal error : %s - %d", $file, $line); $output = sprintf("Fatal error : %s - %d", $file, $line);
$output .= sprintf("%d - %s", $errno, $errstr); $output .= sprintf("%d - %s", $errno, $errstr);
@ -808,7 +928,10 @@ 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);
}
return $output; return $output;
} }
@ -853,7 +976,7 @@ function removeHackTag($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); $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 ?뺤씤 è«??°ë¶½? // xmp tag ?뺤씤 <20>??<3F>?
$content = checkXmpTag($content); $content = checkXmpTag($content);
return $content; return $content;
} }
@ -868,10 +991,16 @@ 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)
else if($close_xmp < $start_xmp) $content .= '</xmp>'; {
$content .= '</xmp>';
}
else if($close_xmp < $start_xmp)
{
$content .= '</xmp>';
}
} }
return $content; return $content;
@ -888,21 +1017,36 @@ function removeSrcHack($match)
$tag = strtolower($match[2]); $tag = strtolower($match[2]);
// xmp tag ?뺣━ // xmp tag ?뺣━
if($tag=='xmp') return "<{$match[1]}xmp>"; if($tag == 'xmp')
if($match[1]) return $match[0]; {
if($match[4]) $match[4] = ' '.$match[4]; return "<{$match[1]}xmp>";
}
if($match[1])
{
return $match[0];
}
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]);
$val = preg_replace('/^\s+|[\t\n\r]+/', '', $val); $val = preg_replace('/^\s+|[\t\n\r]+/', '', $val);
if(preg_match('/^[a-z]+script:/i', $val)) continue; if(preg_match('/^[a-z]+script:/i', $val))
{
continue;
}
$attrs[$name] = $val; $attrs[$name] = $val;
} }
@ -947,6 +1091,7 @@ function removeSrcHack($match)
// 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
* *
@ -961,6 +1106,7 @@ if(!function_exists('hexrgb'))
'green' => 0xFF & ($int >> 0x8), 'green' => 0xFF & ($int >> 0x8),
'blue' => 0xFF & $int); 'blue' => 0xFF & $int);
} }
} }
/** /**
@ -981,7 +1127,10 @@ function mysql_pre4_hash_password($password)
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);
$nr2 += ($nr2 << 8) ^ $nr; $nr2 += ($nr2 << 8) ^ $nr;
@ -990,8 +1139,14 @@ function mysql_pre4_hash_password($password)
$result1 = sprintf("%08lx", $nr & ((1 << 31) - 1)); $result1 = sprintf("%08lx", $nr & ((1 << 31) - 1));
$result2 = sprintf("%08lx", $nr2 & ((1 << 31) - 1)); $result2 = sprintf("%08lx", $nr2 & ((1 << 31) - 1));
if($result1 == '80000000') $nr += 0x80000000; if($result1 == '80000000')
if($result2 == '80000000') $nr2 += 0x80000000; {
$nr += 0x80000000;
}
if($result2 == '80000000')
{
$nr2 += 0x80000000;
}
return sprintf("%08lx%08lx", $nr, $nr2); return sprintf("%08lx%08lx", $nr, $nr2);
} }
@ -1003,8 +1158,11 @@ function mysql_pre4_hash_password($password)
*/ */
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;
} }
@ -1072,10 +1230,22 @@ function utf8RawUrlDecode ($source)
*/ */
function _code2utf($num) function _code2utf($num)
{ {
if($num<128)return chr($num); if($num < 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); return chr($num);
if($num<2097152)return chr(($num>>18)+240).chr((($num>>12)&63)+128).chr((($num>>6)&63)+128) .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 < 2097152)
{
return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
}
return ''; return '';
} }
@ -1087,16 +1257,25 @@ function _code2utf($num)
* @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);
$is_utf8 = (md5($sample) == md5($string)); $is_utf8 = (md5($sample) == md5($string));
if(!$urldecode) $string = urldecode($string); if(!$urldecode)
{
$string = urldecode($string);
}
if($return_convert) return ($is_utf8) ? $string : iconv('euc-kr', 'utf-8', $string); if($return_convert)
{
return ($is_utf8) ? $string : iconv('euc-kr', 'utf-8', $string);
}
return $is_utf8; return $is_utf8;
} }
@ -1121,13 +1300,13 @@ function json_encode2($data)
case 'object': case 'object':
$data = get_object_vars($data); $data = get_object_vars($data);
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;
} }
} }
@ -1150,8 +1329,12 @@ function json_encode2($data)
* @param string $agent if set, use this value instead HTTP_USER_AGENT * @param string $agent if set, use this value instead HTTP_USER_AGENT
* @return bool * @return bool
*/ */
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(
@ -1160,7 +1343,10 @@ function isCrawler($agent = null) {
foreach($check_agent as $str) foreach($check_agent as $str)
{ {
if(stristr($agent, $str) != FALSE) return true; if(stristr($agent, $str) != FALSE)
{
return TRUE;
}
} }
$check_ip = '/^(' . implode($check_ip, '|') . ')/'; $check_ip = '/^(' . implode($check_ip, '|') . ')/';
@ -1168,9 +1354,12 @@ function isCrawler($agent = null) {
$check_ip = str_replace('*', '.+', $check_ip); $check_ip = str_replace('*', '.+', $check_ip);
$check_ip = str_replace('?', '.?', $check_ip); $check_ip = str_replace('?', '.?', $check_ip);
if(preg_match($check_ip, $_SERVER['REMOTE_ADDR'], $matches)) return true; if(preg_match($check_ip, $_SERVER['REMOTE_ADDR'], $matches))
{
return TRUE;
}
return false; return FALSE;
} }
/** /**
@ -1182,15 +1371,19 @@ function isCrawler($agent = null) {
*/ */
function stripEmbedTagForAdmin(&$content, $writer_member_srl) function stripEmbedTagForAdmin(&$content, $writer_member_srl)
{ {
if(!Context::get('is_logged')) return; if(!Context::get('is_logged'))
$oModuleModel = &getModel('module'); {
return;
}
$oModuleModel = getModel('module');
$logged_info = Context::get('logged_info'); $logged_info = Context::get('logged_info');
if($writer_member_srl != $logged_info->member_srl && ($logged_info->is_admin == "Y" || $oModuleModel->isSiteAdmin($logged_info))) if($writer_member_srl != $logged_info->member_srl && ($logged_info->is_admin == "Y" || $oModuleModel->isSiteAdmin($logged_info)))
{ {
if($writer_member_srl) if($writer_member_srl)
{ {
$oMemberModel =& getModel('member'); $oMemberModel = getModel('member');
$member_info = $oMemberModel->getMemberInfoByMemberSrl($writer_member_srl); $member_info = $oMemberModel->getMemberInfoByMemberSrl($writer_member_srl);
if($member_info->is_admin == "Y") if($member_info->is_admin == "Y")
{ {
@ -1227,20 +1420,20 @@ function requirePear()
{ {
if($_SERVER['REQUEST_METHOD'] != 'POST') if($_SERVER['REQUEST_METHOD'] != 'POST')
{ {
return false; return FALSE;
} }
$defaultUrl = Context::getDefaultUrl(); $defaultUrl = Context::getDefaultUrl();
$referer = parse_url($_SERVER["HTTP_REFERER"]); $referer = parse_url($_SERVER["HTTP_REFERER"]);
$oModuleModel = &getModel('module'); $oModuleModel = getModel('module');
$siteModuleInfo = $oModuleModel->getDefaultMid(); $siteModuleInfo = $oModuleModel->getDefaultMid();
if($siteModuleInfo->site_srl == 0) if($siteModuleInfo->site_srl == 0)
{ {
if(!strstr(strtolower($defaultUrl), strtolower($referer['host']))) if(!strstr(strtolower($defaultUrl), strtolower($referer['host'])))
{ {
return false; return FALSE;
} }
} }
else else
@ -1248,11 +1441,11 @@ function requirePear()
$virtualSiteInfo = $oModuleModel->getSiteInfo($siteModuleInfo->site_srl); $virtualSiteInfo = $oModuleModel->getSiteInfo($siteModuleInfo->site_srl);
if(strtolower($virtualSiteInfo->domain) != strtolower(Context::get('vid')) && !strstr(strtolower($virtualSiteInfo->domain), strtolower($referer['host']))) if(strtolower($virtualSiteInfo->domain) != strtolower(Context::get('vid')) && !strstr(strtolower($virtualSiteInfo->domain), strtolower($referer['host'])))
{ {
return false; return FALSE;
} }
} }
return true; return TRUE;
} }
/** /**
@ -1290,7 +1483,11 @@ function htmlFooter()
*/ */
function alertScript($msg) function alertScript($msg)
{ {
if(!$msg) return; if(!$msg)
{
return;
}
echo '<script>alert("' . $msg . '");</script>'; echo '<script>alert("' . $msg . '");</script>';
} }
@ -1310,11 +1507,12 @@ function closePopupScript()
* @param bool $isOpener * @param bool $isOpener
* @return void * @return void
*/ */
function reload($isOpener = false) function reload($isOpener = FALSE)
{ {
$reloadScript = $isOpener ? 'window.opener.location.reload()' : 'document.location.reload()'; $reloadScript = $isOpener ? 'window.opener.location.reload()' : 'document.location.reload()';
echo '<script>' . $reloadScript . '</script>'; echo '<script>' . $reloadScript . '</script>';
} }
/* End of file func.inc.php */ /* End of file func.inc.php */
/* Location: ./config/func.inc.php */ /* Location: ./config/func.inc.php */

View file

@ -1,4 +1,5 @@
<?php <?php
define('_XE_PACKAGE_', 'XE'); define('_XE_PACKAGE_', 'XE');
define('_XE_LOCATION_', 'ko'); define('_XE_LOCATION_', 'ko');
define('_XE_LOCATION_SITE_', 'http://www.xpressengine.com/'); define('_XE_LOCATION_SITE_', 'http://www.xpressengine.com/');