20 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
33 function substr($str,
$start, $length, $trimmarker =
'...')
36 return (strlen($str) -
$start <= $length) ? substr($str,
$start, $length) : substr($str,
$start, $length - strlen($trimmarker)) . $trimmarker;
38 if (function_exists(
'mb_internal_encoding') && @mb_internal_encoding(
_CHARSET)) {
39 $str2 = mb_strcut($str,
$start, $length - strlen($trimmarker));
40 return $str2 . (mb_strlen($str) != mb_strlen($str2) ? $trimmarker :
'');
52 function utf8_encode($text)
55 if (function_exists(
'mb_convert_encoding')) {
56 return mb_convert_encoding($text,
'UTF-8',
'auto');
59 return utf8_encode($text);
70 function convert_encoding($text, $to =
'utf-8', $from =
'')
78 if (empty($to) || ! strcasecmp($to, $from)) {
83 $converted_text = @mb_convert_encoding($text, $to, $from);
84 } elseif (function_exists(
'iconv')) {
85 $converted_text = @iconv($from, $to .
"//TRANSLIT", $text);
86 } elseif (
'utf-8' == $to) {
87 $converted_text = utf8_encode($text);
89 $text = empty($converted_text) ? $text : $converted_text;
108 function getTimeFormatDesc()
122 $format_copy = $format;
123 $format = strtolower($format);
125 if ($format ==
'rss' || $format ==
'r') {
127 if (isset(
$GLOBALS[
'xoopsConfig'][
'server_TZ'])) {
128 $server_TZ = abs(intval(
$GLOBALS[
'xoopsConfig'][
'server_TZ'] * 3600.0));
129 $prefix = (
$GLOBALS[
'xoopsConfig'][
'server_TZ'] < 0) ?
' -' :
' +';
130 $TIME_ZONE = $prefix . date(
'Hi', $server_TZ);
132 $date = gmdate(
'D, d M Y H:i:s', intval(
$time)) . $TIME_ZONE;
136 if (($format ==
'elapse' || $format ==
'e') &&
$time < time()) {
137 $elapse = time() -
$time;
138 if ($days = floor($elapse / (24 * 3600))) {
140 } elseif ($hours = floor(($elapse % (24 * 3600)) / 3600)) {
142 } elseif ($minutes = floor(($elapse % 3600) / 60)) {
145 $seconds = $elapse % 60;
153 if ($timeoffset === null) {
154 $timeoffset = ($xoopsConfig[
'default_TZ'] ==
'') ?
'0.0' : $xoopsConfig[
'default_TZ'];
167 $datestring =
'Y-m-d H:i:s';
176 static $current_timestamp, $today_timestamp, $monthy_timestamp;
177 if (!isset($current_timestamp)) {
180 if (!isset($today_timestamp)) {
181 $today_timestamp = mktime(0, 0, 0, date(
'm', $current_timestamp), date(
'd', $current_timestamp), date(
'Y', $current_timestamp));
184 if (abs($elapse_today = $usertimestamp - $today_timestamp) < 24 * 60 * 60) {
187 if (!isset($monthy_timestamp)) {
188 $monthy_timestamp[0] = mktime(0, 0, 0, 0, 0, date(
'Y', $current_timestamp));
189 $monthy_timestamp[1] = mktime(0, 0, 0, 0, 0, date(
'Y', $current_timestamp) + 1);
191 if ($usertimestamp >= $monthy_timestamp[0] && $usertimestamp < $monthy_timestamp[1]) {
201 $datestring = $format_copy;
208 return ucfirst(date($datestring, $usertimestamp));
217 function number_format($number)
229 function money_format($format, $number)
241 function __call($name, $args)
243 if (function_exists($name)) {
244 return call_user_func_array($name, $args);