adds comments for phpDoc

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10745 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
flyskyko 2012-05-29 03:26:40 +00:00
parent 72f657f443
commit 86296c899e
2 changed files with 453 additions and 202 deletions

View file

@ -1,8 +1,9 @@
<?php <?php
/** /**
* 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)
* @brief set the include of the class file and other environment configurations
**/ **/
@error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED); @error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED);
@ -10,35 +11,52 @@
if(!defined('__ZBXE__')) exit(); if(!defined('__ZBXE__')) exit();
/** /**
* @brief display XE's full version * Display XE's full version
* Even The file should be revised when releasing altough no change is made * Even The file should be revised when releasing altough no change is made
**/ */
define('__XE_VERSION__', '1.5.2.5'); define('__XE_VERSION__', '1.5.2.5');
define('__ZBXE_VERSION__', __XE_VERSION__); // deprecated : __ZBXE_VERSION__ will be removed. Use __XE_VERSION__ instead.
/**
* @deprecated __ZBXE_VERSION__ will be removed. Use __XE_VERSION__ instead.
*/
define('__ZBXE_VERSION__', __XE_VERSION__);
/** /**
* @brief The base path to where you installed zbXE Wanted * The base path to where you installed zbXE Wanted
**/ */
define('_XE_PATH_', str_replace('config/config.inc.php', '', str_replace('\\', '/', __FILE__))); define('_XE_PATH_', str_replace('config/config.inc.php', '', str_replace('\\', '/', __FILE__)));
/** // Set can use other method instead cookie to store session id(for file upload)
* @brief 쿠키 이외의 값에서도 세션을 인식할 있도록 (파일업로드 등에서의 문제 수정)
**/
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
*/
define('_XE_PACKAGE_','XE'); define('_XE_PACKAGE_','XE');
/**
* Location
*/
define('_XE_LOCATION_','en'); define('_XE_LOCATION_','en');
/**
* Location site
*/
define('_XE_LOCATION_SITE_','http://www.xpressengine.org/'); define('_XE_LOCATION_SITE_','http://www.xpressengine.org/');
/**
* Download server
*/
define('_XE_DOWNLOAD_SERVER_','http://en.download.xpressengine.org/'); define('_XE_DOWNLOAD_SERVER_','http://en.download.xpressengine.org/');
} }
/** /*
* @brief user configuration files which override the default settings * user configuration files which override the default settings
* save the following information into config/config.user.inc.php * save the following information into config/config.user.inc.php
* <?php * <?php
* define('__DEBUG__', 0); * define('__DEBUG__', 0);
@ -57,111 +75,167 @@
require _XE_PATH_.'config/config.user.inc.php'; require _XE_PATH_.'config/config.user.inc.php';
} }
/** if(!defined('__DEBUG__'))
* @brief output debug message(bit value) {
* 0: generate debug messages/not display /**
* 1: display messages through debugPrint() function * output debug message(bit value)
* 2: output execute time, Request/Response info *
* 4: output DB query history * <pre>
**/ * 0: generate debug messages/not display
if(!defined('__DEBUG__')) define('__DEBUG__', 0); * 1: display messages through debugPrint() function
* 2: output execute time, Request/Response info
* 4: output DB query history
* </pre>
*/
define('__DEBUG__', 0);
}
/** if(!defined('__DEBUG_OUTPUT__'))
* @brief output location of debug message {
* 0: connect to the files/_debug_message.php and output /**
* 1: HTML output as a comment on the bottom (when response method is the HTML) * output location of debug message
* 2: Firebug console output (PHP 4 & 5. Firebug/FirePHP plug-in required) *
**/ * <pre>
if(!defined('__DEBUG_OUTPUT__')) define('__DEBUG_OUTPUT__', 0); * 0: connect to the files/_debug_message.php and output
* 1: HTML output as a comment on the bottom (when response method is the HTML)
* 2: Firebug console output (PHP 4 & 5. Firebug/FirePHP plug-in required)
* </pre>
*/
define('__DEBUG_OUTPUT__', 0);
}
/** if(!defined('__DEBUG_PROTECT__'))
* @brief output comments of the firePHP console and browser {
* 0: No limit (not recommended) /**
* 1: Allow only specified IP addresses * output comments of the firePHP console and browser
**/ *
if(!defined('__DEBUG_PROTECT__')) define('__DEBUG_PROTECT__', 1); * <pre>
if(!defined('__DEBUG_PROTECT_IP__')) define('__DEBUG_PROTECT_IP__', '127.0.0.1'); * 0: No limit (not recommended)
* 1: Allow only specified IP addresses
* </pre>
*/
define('__DEBUG_PROTECT__', 1);
}
/** if(!defined('__DEBUG_PROTECT_IP__'))
* @brief DB error message definition {
* 0: No output /**
* 1: files/_debug_db_query.php connected to the output * Set a ip address to allow debug
**/ */
if(!defined('__DEBUG_DB_OUTPUT__')) define('__DEBUG_DB_OUTPUT__', 0); define('__DEBUG_PROTECT_IP__', '127.0.0.1');
}
/** if(!defined('__DEBUG_DB_OUTPUT__'))
* @brief Query log for only timeout query among DB queries {
* 0: Do not leave a log /**
* = 0: leave a log when the slow query takes over specified seconds * DB error message definition
* Log file is saved as ./files/_db_slow_query.php file *
**/ * <pre>
if(!defined('__LOG_SLOW_QUERY__')) define('__LOG_SLOW_QUERY__', 0); * 0: No output
* 1: files/_debug_db_query.php connected to the output
* </pre>
*/
define('__DEBUG_DB_OUTPUT__', 0);
}
/** if(!defined('__LOG_SLOW_QUERY__'))
* @brief Leave DB query information {
* 0: Do not add information to the query /**
* 1: Comment the XML Query ID * Query log for only timeout query among DB queries
**/ *
if(!defined('__DEBUG_QUERY__')) define('__DEBUG_QUERY__', 0); * <pre>
* 0: Do not leave a log
* = 0: leave a log when the slow query takes over specified seconds
* Log file is saved as ./files/_db_slow_query.php file
* </pre>
*/
define('__LOG_SLOW_QUERY__', 0);
}
/** if(!defined('__DEBUG_QUERY__'))
* @brief option to enable/disable a compression feature using ob_gzhandler {
* 0: Not used /**
* 1: Enabled * Leave DB query information
* Only particular servers may have a problem in IE browser when sending a compression *
**/ * <pre>
if(!defined('__OB_GZHANDLER_ENABLE__')) define('__OB_GZHANDLER_ENABLE__', 1); * 0: Do not add information to the query
* 1: Comment the XML Query ID
* </pre>
*/
define('__DEBUG_QUERY__', 0);
}
/** if(!defined('__OB_GZHANDLER_ENABLE__'))
* @brief decide to use/not use the php unit test (Path/tests/index.php) {
* 0: Not used /**
* 1: Enabled * option to enable/disable a compression feature using ob_gzhandler
**/ *
if(!defined('__ENABLE_PHPUNIT_TEST__')) define('__ENABLE_PHPUNIT_TEST__', 0); * <pre>
* 0: Not used
* 1: Enabled
* Only particular servers may have a problem in IE browser when sending a compression
* </pre>
*/
define('__OB_GZHANDLER_ENABLE__', 1);
}
/** if(!defined('__ENABLE_PHPUNIT_TEST__'))
* @brief __PROXY_SERVER__ has server information to request to the external through the target server {
* FileHandler:: getRemoteResource uses the constant /**
**/ * decide to use/not use the php unit test (Path/tests/index.php)
if(!defined('__PROXY_SERVER__')) define('__PROXY_SERVER__', null); *
* <pre>
* 0: Not used
* 1: Enabled
* </pre>
*/
define('__ENABLE_PHPUNIT_TEST__', 0);
}
/** if(!defined('__PROXY_SERVER__'))
* @brief CDN prefix {
**/ /**
if(!defined('__XE_CDN_PREFIX__')) define('__XE_CDN_PREFIX__', 'http://static.xpressengine.com/core/'); * __PROXY_SERVER__ has server information to request to the external through the target server
* FileHandler:: getRemoteResource uses the constant
*/
define('__PROXY_SERVER__', null);
}
/** if(!defined('__XE_CDN_PREFIX__'))
* @brief CDN version {
**/ /**
if(!defined('__XE_CDN_VERSION__')) define('__XE_CDN_VERSION__', '%__XE_CDN_VERSION__%'); * CDN prefix
*/
define('__XE_CDN_PREFIX__', 'http://static.xpressengine.com/core/');
}
/** if(!defined('__XE_CDN_VERSION__'))
* @brief Require specific files when using Firebug console output {
**/ /**
* CDN version
*/
define('__XE_CDN_VERSION__', '%__XE_CDN_VERSION__%');
}
// 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';
} }
/** // Set Timezone as server time
* @brief Set Timezone as server time
**/
if(version_compare(PHP_VERSION, '5.3.0') >= 0) if(version_compare(PHP_VERSION, '5.3.0') >= 0)
{ {
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
* @brief 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
* @brief 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');

View file

@ -1,15 +1,13 @@
<?php <?php
/** /**
* @file config/func.inc.php * function library files for convenience
*
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
* @brief function library files for convenience
**/ **/
if(!defined('__XE__') && !defined('__ZBXE__')) exit(); if(!defined('__XE__') && !defined('__ZBXE__')) exit();
/** // define clone for php5
* @brief 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) {
@ -18,9 +16,7 @@
'); ');
} }
/** // define an empty function to avoid errors when iconv function doesn't exist
* @brief 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) {
@ -31,13 +27,22 @@
if ( !function_exists('htmlspecialchars_decode') ) if ( !function_exists('htmlspecialchars_decode') )
{ {
/**
* Decode html special characters
*
* @param string $text
* @return string
*/
function htmlspecialchars_decode($text) function htmlspecialchars_decode($text)
{ {
return strtr($text, array_flip(get_html_translation_table(HTML_SPECIALCHARS))); return strtr($text, array_flip(get_html_translation_table(HTML_SPECIALCHARS)));
} }
} }
// time zone /**
* Time zone
* @var array
*/
$time_zone = array( $time_zone = array(
'-1200' => '[GMT -12:00] Baker Island Time', '-1200' => '[GMT -12:00] Baker Island Time',
'-1100' => '[GMT -11:00] Niue Time, Samoa Standard Time', '-1100' => '[GMT -11:00] Niue Time, Samoa Standard Time',
@ -81,111 +86,125 @@
) ; ) ;
/** /**
* @brief define a function to use ModuleHandler::getModuleObject ($module_name, $type) * Define a function to use {@see ModuleHandler::getModuleObject()} ($module_name, $type)
* @param module_name *
* @param type disp, proc, controller, class * @param string $module_name The module name to get a instance
* @param kind admin, null * @param string $type disp, proc, controller, class
* @return module instance * @param string $kind admin, null
**/ * @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);
} }
/** /**
* @brief create a controller instance of the module * Create a controller instance of the module
* @param module_name *
* @return module controller instance * @param string $module_name The module name to get a 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');
} }
/** /**
* @brief create a controller instance of the module * Create a admin controller instance of the module
* @param module_name *
* @return module admin controller instance * @param string $module_name The module name to get a 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');
} }
/** /**
* @brief create a view instance of the module * Create a view instance of the module
* @param module_name *
* @return module view instance * @param string $module_name The module name to get a 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');
} }
/** /**
* @brief create a view instance of the module * Create a mobile instance of the module
* @param module_name *
* @return module mobile instance * @param string $module_name The module name to get a 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');
} }
/** /**
* @brief module의 admin view 객체 생성용 * Create a admin view instance of the module
* @param module_name 모듈이름 *
* @return module admin view instance * @param string $module_name The module name to get a 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');
} }
/** /**
* @brief create a model instance of the module * Create a model instance of the module
* @param module_name *
* @return module model instance * @param string $module_name The module name to get a 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');
} }
/** /**
* @brief create an admin model instance of the module * Create an admin model instance of the module
* @param module_name *
* @return module admin model instance * @param string $module_name The module name to get a 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');
} }
/** /**
* @brief create an api instance of the module * Create an api instance of the module
* @param module_name *
* @return module api class instance * @param string $module_name The module name to get a api 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');
} }
/** /**
* @brief create a wap instance of the module * Create a wap instance of the module
* @param module_name *
* @return module wap class instance * @param string $module_name The module name to get a wap 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');
} }
/** /**
* @brief create a class instance of the module * Create a class instance of the module
* @param module_name *
* @return module class instance * @param string $module_name The module name to get a 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');
} }
/** /**
* @brief the alias of DB::executeQuery() * The alias of DB::executeQuery()
* @param query_id (module name.query XML file) *
* @param argument values of args object * @see DB::executeQuery()
* @return results * @param string $query_id (module name.query XML file)
* @param object $args values of args object
* @param string[] $arg_columns Column list
* @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();
@ -193,10 +212,14 @@
} }
/** /**
* @brief function to handle the result of DB::executeQuery() as an array * Function to handle the result of DB::executeQuery() as an array
* @param query_id(module name.query XML file) *
* @param argument values of args object * @see DB::executeQuery()
* @return results * @see executeQuery()
* @param string $query_id (module name.query XML file)
* @param object $args values of args object
* @param string[] $arg_columns Column list
* @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();
@ -208,8 +231,10 @@
} }
/** /**
* @brief DB:: alias of getNextSequence() * Alias of DB::getNextSequence()
* @return big int *
* @see DB::getNextSequence()
* @return int
**/ **/
function getNextSequence() { function getNextSequence() {
$oDB = &DB::getInstance(); $oDB = &DB::getInstance();
@ -217,14 +242,17 @@
} }
/** /**
* @brief define a function to use Context::getUrl() * Get a encoded url. Define a function to use Context::getUrl()
*
* getUrl() returns the URL transformed from given arguments of RequestURI
* <ol>
* <li>argument format follows as (key, value).
* ex) getUrl('key1', 'val1', 'key2',''): transform key1 and key2 to val1 and '' respectively</li>
* <li>returns URL without the argument if no argument is given.</li>
* <li>URL made of args_list added to RequestUri if the first argument value is ''.</li>
* </ol>
*
* @return string * @return string
*
* getUrl() returns the URL transformed from given arguments of RequestURI\n
* 1. argument format follows as (key, value).\.
* ex) getUrl('key1', 'val1', 'key2',''): transform key1 and key2 to val1 and '' respectively\n
* 2. returns URL without the argument if no argument is given.
* 3. URL made of args_list added to RequestUri if the first argument value is ''.
**/ **/
function getUrl() { function getUrl() {
$num_args = func_num_args(); $num_args = func_num_args();
@ -236,6 +264,12 @@
return preg_replace('@\berror_return_url=[^&]*|\w+=(?:&|$)@', '', $url); return preg_replace('@\berror_return_url=[^&]*|\w+=(?:&|$)@', '', $url);
} }
/**
* Get a not encoded(html entity) url
*
* @see getUrl()
* @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();
@ -246,6 +280,12 @@
return preg_replace('@\berror_return_url=[^&]*|\w+=(?:&|$)@', '', $url); return preg_replace('@\berror_return_url=[^&]*|\w+=(?:&|$)@', '', $url);
} }
/**
* Get a encoded url. If url is encoded, not encode. Otherwise html encode the url.
*
* @see getUrl()
* @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();
@ -255,9 +295,11 @@
return preg_replace('@\berror_return_url=[^&]*|\w+=(?:&|$)@', '', $url); return preg_replace('@\berror_return_url=[^&]*|\w+=(?:&|$)@', '', $url);
} }
/** /**
* @brief return the value adding request uri to getUrl() * Return the value adding request uri to getUrl() to get the full url
* to get the full url *
* @return string
**/ **/
function getFullUrl() { function getFullUrl() {
$num_args = func_num_args(); $num_args = func_num_args();
@ -273,6 +315,11 @@
return $url; return $url;
} }
/**
* Return the value adding request uri to getUrl() to get the not encoded full url
*
* @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();
@ -289,12 +336,10 @@
} }
/** /**
* @brief Context:: getUrl() function is declared as easier to write * getSiteUrl() returns the URL by transforming the given argument value of domain
* @return string
*
* getSiteUrl() returns the URL by transforming the given argument value of domain\n
* 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
**/ **/
function getSiteUrl() { function getSiteUrl() {
$num_args = func_num_args(); $num_args = func_num_args();
@ -308,6 +353,12 @@
return Context::getUrl($num_args, $args_list, $domain); return Context::getUrl($num_args, $args_list, $domain);
} }
/**
* getSiteUrl() returns the not encoded URL by transforming the given argument value of domain
* The first argument should consist of domain("http://" not included) and path
*
* @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();
@ -321,8 +372,9 @@
} }
/** /**
* @brief return the value adding request uri to the getSiteUrl() * Return the value adding request uri to the getSiteUrl() To get the full url
* To get the full url *
* @return string
**/ **/
function getFullSiteUrl() { function getFullSiteUrl() {
$num_args = func_num_args(); $num_args = func_num_args();
@ -343,17 +395,21 @@
} }
/** /**
* @brief return if domain of the virtual site is url type or id type * Return if domain of the virtual site is url type or id type
*
* @param string $domain
* @return bool
**/ **/
function isSiteID($domain) { function isSiteID($domain) {
return preg_match('/^([a-z0-9\_]+)$/i', $domain); return preg_match('/^([a-z0-9\_]+)$/i', $domain);
} }
/** /**
* @brief put a given tail after trimming string to the specified size * Put a given tail after trimming string to the specified size
* @param the original string to trim *
* @param cut_size: the size to be * @param string $string The original string to trim
* @param tail: tail to put in the end of the string after trimming * @param int $cut_size The size to be
* @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 = '...')
@ -403,6 +459,11 @@
return $output; return $output;
} }
/**
* Get a time gap between server's timezone and XE's timezone
*
* @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;
@ -422,8 +483,9 @@
} }
/** /**
* @brief YYYYMMDDHHIISS format changed to unix time value * YYYYMMDDHHIISS format changed to unix time value
* @param 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) {
@ -444,7 +506,11 @@
} }
/** /**
* @brief If the recent post within a day, output format of YmdHis is "min/hours ago from now". If not within a day, it return format string. * If the recent post within a day, output format of YmdHis is "min/hours ago from now". If not within a day, it return format string.
*
* @param string $date Time value in format of YYYYMMDDHHIISS
* @param string $format If gap is within a day, returns this format.
* @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);
@ -459,7 +525,11 @@
} }
/** /**
* @brief Name of the month return * Name of the month return
*
* @param int $month Month
* @param boot $short If set, returns short 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');
@ -468,10 +538,11 @@
} }
/** /**
* @brief change the time format YYYYMMDDHHIISS to the user defined format * Change the time format YYYYMMDDHHIISS to the user defined format
* @param string|int str is YYYYMMDDHHIISS format time values *
* @param string format is time format of php date() function * @param string|int $str YYYYMMDDHHIISS format time values
* @param bool conversion means whether to convert automatically according to the language * @param string $format Time format of php date() function
* @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) {
@ -537,6 +608,12 @@
return $string; return $string;
} }
/**
* Returns encoded value of given email address for email scraping
*
* @param string $email The email
* @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++) {
@ -546,13 +623,15 @@
} }
/** /**
* @brief prints debug messages * Prints debug messages
* @param debug_output target object to be printed *
* @param display_line boolean flag whether to print seperator (default:true)
* @return none
*
* Display $buff contents into the file ./files/_debug_message.php. * Display $buff contents into the file ./files/_debug_message.php.
* You can see the file on your prompt by command: tail-f./files/_debug_message.php * You can see the file on your prompt by command: tail-f./files/_debug_message.php
*
* @param mixed $debug_output Target object to be printed
* @param bool $display_option boolean Flag whether to print seperator (default:true)
* @param string $file Target file name
* @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;
@ -608,7 +687,8 @@
/** /**
* @brief microtime() return * microtime() return
*
* @return float * @return float
**/ **/
function getMicroTime() { function getMicroTime() {
@ -617,9 +697,10 @@
} }
/** /**
* @brief Delete the second object vars from the first argument * Delete the second object vars from the first argument
* @param target_obj is an original object *
* @param del_obj is object vars to delete from the original object * @param object $target_obj An 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) {
@ -645,11 +726,13 @@
} }
/** /**
* @brief change error_handing to debugPrint on php5 higher * Change error_handing to debugPrint on php5 higher
* @param errno *
* @param errstr * @param int $errno
* @return file * @param string $errstr
* @return line * @param string $file
* @param int $line
* @return void
**/ **/
function handleError($errno, $errstr, $file, $line) { function handleError($errno, $errstr, $file, $line) {
if(!__DEBUG__) return; if(!__DEBUG__) return;
@ -663,9 +746,10 @@
} }
/** /**
* @brief Trim a given number to a fiven size recursively * Trim a given number to a fiven size recursively
* @param no : a given number *
* @param size : a given digits * @param int $no A given number
* @param int $size A given digits
**/ **/
function getNumberingPath($no, $size=3) { function getNumberingPath($no, $size=3) {
$mod = pow(10, $size); $mod = pow(10, $size);
@ -675,14 +759,20 @@
} }
/** /**
* @brief decode the URL in Korean * Decode the URL in Korean
*
* @param string $str The url
* @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);
} }
/** /**
* @brief Pre-block the codes which may be hacking attempts * Pre-block the codes which may be hacking attempts
*
* @param string $content Taget content
* @return string
**/ **/
function removeHackTag($content) { function removeHackTag($content) {
// change the specific tags to the common texts // change the specific tags to the common texts
@ -700,7 +790,10 @@
} }
/** /**
* @brief xmp tag 확인 닫히지 않은 경우 추가 * Check xmp tag, close it.
*
* @param string $content Target content
* @return string
**/ **/
function checkXmpTag($content) { function checkXmpTag($content) {
$content = preg_replace('@<(/?)xmp.*?>@i', '<\1xmp>', $content); $content = preg_replace('@<(/?)xmp.*?>@i', '<\1xmp>', $content);
@ -713,6 +806,12 @@
return $content; return $content;
} }
/**
* Remove src hack(preg_replace_callback)
*
* @param array $match
* @return string
*/
function removeSrcHack($match) { function removeSrcHack($match) {
$tag = strtolower($match[2]); $tag = strtolower($match[2]);
@ -762,6 +861,12 @@
// convert hexa value to RGB // convert hexa value to RGB
if(!function_exists('hexrgb')) { if(!function_exists('hexrgb')) {
/**
* Convert hexa value to RGB
*
* @param string $hexstr
* @return array
*/
function hexrgb($hexstr) { function hexrgb($hexstr) {
$int = hexdec($hexstr); $int = hexdec($hexstr);
@ -772,9 +877,12 @@
} }
/** /**
* @brief php function for mysql old_password() * Php function for mysql old_password()
* provides backward compatibility for zero board4 which uses old_password() of mysql 4.1 earlier versions. * provides backward compatibility for zero board4 which uses old_password() of mysql 4.1 earlier versions.
* the function implemented by referring to the source codes of password.c file in mysql * the function implemented by referring to the source codes of password.c file in mysql
*
* @param string $password
* @return string
**/ **/
function mysql_pre4_hash_password($password) { function mysql_pre4_hash_password($password) {
$nr = 1345345333; $nr = 1345345333;
@ -800,7 +908,9 @@
} }
/** /**
* return the requested script path * Return the requested script path
*
* @return string
**/ **/
function getScriptPath() { function getScriptPath() {
static $url = null; static $url = null;
@ -809,7 +919,9 @@
} }
/** /**
* return the requested script path * Return the requested script path
*
* @return string
**/ **/
function getRequestUriByServerEnviroment() function getRequestUriByServerEnviroment()
{ {
@ -817,9 +929,12 @@
} }
/** /**
* php unescape function of javascript's escape * PHP unescape function of javascript's escape
* Function converts an Javascript escaped string back into a string with specified charset (default is UTF-8). * Function converts an Javascript escaped string back into a string with specified charset (default is UTF-8).
* Modified function from http://pure-essence.net/stuff/code/utf8RawUrlDecode.phps * Modified function from http://pure-essence.net/stuff/code/utf8RawUrlDecode.phps
*
* @param string $source
* @return string
**/ **/
function utf8RawUrlDecode ($source) { function utf8RawUrlDecode ($source) {
$decodedStr = ''; $decodedStr = '';
@ -852,6 +967,12 @@
return $decodedStr; return $decodedStr;
} }
/**
* Returns utf-8 string of given code
*
* @param int $num
* @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);
@ -860,7 +981,14 @@
return ''; return '';
} }
/**
* Get whether utf8 or not given string
*
* @param string $string
* @param bool $return_convert If set, returns converted string
* @param bool $urldecode
* @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);
@ -874,7 +1002,12 @@
return $is_utf8; return $is_utf8;
} }
/**
* get json encoded string of data
*
* @param mixed $data
* @return string
*/
function json_encode2($data) { function json_encode2($data) {
switch (gettype($data)) { switch (gettype($data)) {
case 'boolean': case 'boolean':
@ -907,7 +1040,12 @@
} }
} }
/**
* Get is current user crawler
*
* @param string $agent if set, use this value instead HTTP_USER_AGENT
* @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');
@ -929,6 +1067,13 @@
return false; return false;
} }
/**
* Remove embed media for admin
*
* @param string $content
* @param int $writer_member_srl
* @return void
*/
function stripEmbedTagForAdmin(&$content, $writer_member_srl) function stripEmbedTagForAdmin(&$content, $writer_member_srl)
{ {
if(!Context::get('is_logged')) return; if(!Context::get('is_logged')) return;
@ -955,6 +1100,11 @@
return; return;
} }
/**
* Require pear
*
* @return void
*/
function requirePear() function requirePear()
{ {
if(version_compare(PHP_VERSION, "5.3.0") < 0) if(version_compare(PHP_VERSION, "5.3.0") < 0)
@ -968,6 +1118,11 @@
} }
} }
/**
* Print raw html header
*
* @return void
*/
function htmlHeader() function htmlHeader()
{ {
echo <<<HTMLHEADER echo <<<HTMLHEADER
@ -980,22 +1135,44 @@
HTMLHEADER; HTMLHEADER;
} }
/**
* Print raw html footer
*
* @return void
*/
function htmlFooter() function htmlFooter()
{ {
echo '</body></html>'; echo '</body></html>';
} }
/**
* Print raw alert message script
*
* @param string $msg
* @return void
*/
function alertScript($msg) function alertScript($msg)
{ {
if(!$msg) return; if(!$msg) return;
echo '<script type="text/javascript">alert("'.$msg.'");</script>'; echo '<script type="text/javascript">alert("'.$msg.'");</script>';
} }
/**
* Print raw close window script
*
* @return void
*/
function closePopupScript() function closePopupScript()
{ {
echo '<script type="text/javascript">window.close();</script>'; echo '<script type="text/javascript">window.close();</script>';
} }
/**
* Print raw reload script
*
* @param bool $isOpener
* @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()';