XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
func.inc.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 
9 if(!defined('__XE__'))
10 {
11  exit();
12 }
13 
14 // define an empty function to avoid errors when iconv function doesn't exist
15 if(!function_exists('iconv'))
16 {
17  eval('
18  function iconv($in_charset, $out_charset, $str)
19  {
20  return $str;
21  }
22  ');
23 }
24 
29 $time_zone = array(
30  '-1200' => '[GMT -12:00] Baker Island Time',
31  '-1100' => '[GMT -11:00] Niue Time, Samoa Standard Time',
32  '-1000' => '[GMT -10:00] Hawaii-Aleutian Standard Time, Cook Island Time',
33  '-0930' => '[GMT -09:30] Marquesas Islands Time',
34  '-0900' => '[GMT -09:00] Alaska Standard Time, Gambier Island Time',
35  '-0800' => '[GMT -08:00] Pacific Standard Time',
36  '-0700' => '[GMT -07:00] Mountain Standard Time',
37  '-0600' => '[GMT -06:00] Central Standard Time',
38  '-0500' => '[GMT -05:00] Eastern Standard Time',
39  '-0400' => '[GMT -04:00] Atlantic Standard Time',
40  '-0330' => '[GMT -03:30] Newfoundland Standard Time',
41  '-0300' => '[GMT -03:00] Amazon Standard Time, Central Greenland Time',
42  '-0200' => '[GMT -02:00] Fernando de Noronha Time, South Georgia &amp; the South Sandwich Islands Time',
43  '-0100' => '[GMT -01:00] Azores Standard Time, Cape Verde Time, Eastern Greenland Time',
44  '0000' => '[GMT 00:00] Western European Time, Greenwich Mean Time',
45  '+0100' => '[GMT +01:00] Central European Time, West African Time',
46  '+0200' => '[GMT +02:00] Eastern European Time, Central African Time',
47  '+0300' => '[GMT +03:00] Moscow Standard Time, Eastern African Time',
48  '+0330' => '[GMT +03:30] Iran Standard Time',
49  '+0400' => '[GMT +04:00] Gulf Standard Time, Samara Standard Time',
50  '+0430' => '[GMT +04:30] Afghanistan Time',
51  '+0500' => '[GMT +05:00] Pakistan Standard Time, Yekaterinburg Standard Time',
52  '+0530' => '[GMT +05:30] Indian Standard Time, Sri Lanka Time',
53  '+0545' => '[GMT +05:45] Nepal Time',
54  '+0600' => '[GMT +06:00] Bangladesh Time, Bhutan Time, Novosibirsk Standard Time',
55  '+0630' => '[GMT +06:30] Cocos Islands Time, Myanmar Time',
56  '+0700' => '[GMT +07:00] Indochina Time, Krasnoyarsk Standard Time',
57  '+0800' => '[GMT +08:00] China Standard Time, Australian Western Standard Time, Irkutsk Standard Time',
58  '+0845' => '[GMT +08:45] Southeastern Western Australia Standard Time',
59  '+0900' => '[GMT +09:00] Korea Standard Time, Japan Standard Time',
60  '+0930' => '[GMT +09:30] Australian Central Standard Time',
61  '+1000' => '[GMT +10:00] Australian Eastern Standard Time, Vladivostok Standard Time',
62  '+1030' => '[GMT +10:30] Lord Howe Standard Time',
63  '+1100' => '[GMT +11:00] Solomon Island Time, Magadan Standard Time',
64  '+1130' => '[GMT +11:30] Norfolk Island Time',
65  '+1200' => '[GMT +12:00] New Zealand Time, Fiji Time, Kamchatka Standard Time',
66  '+1245' => '[GMT +12:45] Chatham Islands Time',
67  '+1300' => '[GMT +13:00] Tonga Time, Phoenix Islands Time',
68  '+1400' => '[GMT +14:00] Line Island Time'
69 );
70 
79 function getModule($module_name, $type = 'view', $kind = '')
80 {
81  return ModuleHandler::getModuleInstance($module_name, $type, $kind);
82 }
83 
90 function getController($module_name)
91 {
92  return getModule($module_name, 'controller');
93 }
94 
101 function getAdminController($module_name)
102 {
103  return getModule($module_name, 'controller', 'admin');
104 }
105 
112 function getView($module_name)
113 {
114  return getModule($module_name, 'view');
115 }
116 
123 function &getMobile($module_name)
124 {
125  return getModule($module_name, 'mobile');
126 }
127 
134 function getAdminView($module_name)
135 {
136  return getModule($module_name, 'view', 'admin');
137 }
138 
145 function getModel($module_name)
146 {
147  return getModule($module_name, 'model');
148 }
149 
156 function getAdminModel($module_name)
157 {
158  return getModule($module_name, 'model', 'admin');
159 }
160 
167 function getAPI($module_name)
168 {
169  return getModule($module_name, 'api');
170 }
171 
178 function getWAP($module_name)
179 {
180  return getModule($module_name, 'wap');
181 }
182 
189 function getClass($module_name)
190 {
191  return getModule($module_name, 'class');
192 }
193 
203 function executeQuery($query_id, $args = NULL, $arg_columns = NULL)
204 {
205  $oDB = DB::getInstance();
206  return $oDB->executeQuery($query_id, $args, $arg_columns);
207 }
208 
219 function executeQueryArray($query_id, $args = NULL, $arg_columns = NULL)
220 {
221  $oDB = DB::getInstance();
222  $output = $oDB->executeQuery($query_id, $args, $arg_columns);
223  if(!is_array($output->data) && count($output->data) > 0)
224  {
225  $output->data = array($output->data);
226  }
227  return $output;
228 }
229 
236 function getNextSequence()
237 {
238  $oDB = DB::getInstance();
239  $seq = $oDB->getNextSequence();
240  setUserSequence($seq);
241  return $seq;
242 }
243 
250 function setUserSequence($seq)
251 {
252  $arr_seq = array();
253  if(isset($_SESSION['seq']))
254  {
255  if(!is_array($_SESSION['seq'])) {
256  $_SESSION['seq'] = array($_SESSION['seq']);
257  }
258  $arr_seq = $_SESSION['seq'];
259  }
260  $arr_seq[] = $seq;
261  $_SESSION['seq'] = $arr_seq;
262 }
263 
270 function checkUserSequence($seq)
271 {
272  if(!isset($_SESSION['seq']))
273  {
274  return false;
275  }
276  if(!in_array($seq, $_SESSION['seq']))
277  {
278  return false;
279  }
280 
281  return true;
282 }
283 
297 function getUrl()
298 {
299  $num_args = func_num_args();
300  $args_list = func_get_args();
301 
302  if($num_args)
303  $url = Context::getUrl($num_args, $args_list);
304  else
305  $url = Context::getRequestUri();
306 
307  return preg_replace('@\berror_return_url=[^&]*|\w+=(?:&|$)@', '', $url);
308 }
309 
317 {
318  $num_args = func_num_args();
319  $args_list = func_get_args();
320 
321  if($num_args)
322  {
323  $url = Context::getUrl($num_args, $args_list, NULL, FALSE);
324  }
325  else
326  {
327  $url = Context::getRequestUri();
328  }
329 
330  return preg_replace('@\berror_return_url=[^&]*|\w+=(?:&|$)@', '', $url);
331 }
332 
340 {
341  $num_args = func_num_args();
342  $args_list = func_get_args();
343 
344  if($num_args)
345  {
346  $url = Context::getUrl($num_args, $args_list, NULL, TRUE, TRUE);
347  }
348  else
349  {
350  $url = Context::getRequestUri();
351  }
352 
353  return preg_replace('@\berror_return_url=[^&]*|\w+=(?:&|$)@', '', $url);
354 }
355 
361 function getFullUrl()
362 {
363  $num_args = func_num_args();
364  $args_list = func_get_args();
365  $request_uri = Context::getRequestUri();
366  if(!$num_args)
367  {
368  return $request_uri;
369  }
370 
371  $url = Context::getUrl($num_args, $args_list);
372  if(strncasecmp('http', $url, 4) !== 0)
373  {
374  preg_match('/^(http|https):\/\/([^\/]+)\//', $request_uri, $match);
375  return substr($match[0], 0, -1) . $url;
376  }
377  return $url;
378 }
379 
386 {
387  $num_args = func_num_args();
388  $args_list = func_get_args();
389  $request_uri = Context::getRequestUri();
390  if(!$num_args)
391  {
392  return $request_uri;
393  }
394 
395  $url = Context::getUrl($num_args, $args_list, NULL, FALSE);
396  if(strncasecmp('http', $url, 4) !== 0)
397  {
398  preg_match('/^(http|https):\/\/([^\/]+)\//', $request_uri, $match);
399  $url = Context::getUrl($num_args, $args_list, NULL, FALSE);
400  return substr($match[0], 0, -1) . $url;
401  }
402  return $url;
403 }
404 
411 function getSiteUrl()
412 {
413  $num_args = func_num_args();
414  $args_list = func_get_args();
415 
416  if(!$num_args)
417  {
418  return Context::getRequestUri();
419  }
420 
421  $domain = array_shift($args_list);
422  $num_args = count($args_list);
423 
424  return Context::getUrl($num_args, $args_list, $domain);
425 }
426 
434 {
435  $num_args = func_num_args();
436  $args_list = func_get_args();
437 
438  if(!$num_args)
439  {
440  return Context::getRequestUri();
441  }
442 
443  $domain = array_shift($args_list);
444  $num_args = count($args_list);
445 
446  return Context::getUrl($num_args, $args_list, $domain, FALSE);
447 }
448 
454 function getFullSiteUrl()
455 {
456  $num_args = func_num_args();
457  $args_list = func_get_args();
458 
459  $request_uri = Context::getRequestUri();
460  if(!$num_args)
461  {
462  return $request_uri;
463  }
464 
465  $domain = array_shift($args_list);
466  $num_args = count($args_list);
467 
468  $url = Context::getUrl($num_args, $args_list, $domain);
469  if(strncasecmp('http', $url, 4) !== 0)
470  {
471  preg_match('/^(http|https):\/\/([^\/]+)\//', $request_uri, $match);
472  return substr($match[0], 0, -1) . $url;
473  }
474  return $url;
475 }
476 
483 {
484  $protocol = $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://';
485  $url = $protocol . $_SERVER['HTTP_HOST'] . preg_replace('/[<>"]/', '', $_SERVER['REQUEST_URI']);
486  return htmlspecialchars($url, ENT_COMPAT, 'UTF-8', FALSE);
487 }
488 
495 function isSiteID($domain)
496 {
497  return preg_match('/^([a-zA-Z0-9\_]+)$/', $domain);
498 }
499 
508 function cut_str($string, $cut_size = 0, $tail = '...')
509 {
510  if($cut_size < 1 || !$string)
511  {
512  return $string;
513  }
514 
515  if($GLOBALS['use_mb_strimwidth'] || function_exists('mb_strimwidth'))
516  {
517  $GLOBALS['use_mb_strimwidth'] = TRUE;
518  return mb_strimwidth($string, 0, $cut_size + 4, $tail, 'utf-8');
519  }
520 
521  $chars = array(12, 4, 3, 5, 7, 7, 11, 8, 4, 5, 5, 6, 6, 4, 6, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 4, 8, 6, 8, 6, 10, 8, 8, 9, 8, 8, 7, 9, 8, 3, 6, 7, 7, 11, 8, 9, 8, 9, 8, 8, 7, 8, 8, 10, 8, 8, 8, 6, 11, 6, 6, 6, 4, 7, 7, 7, 7, 7, 3, 7, 7, 3, 3, 6, 3, 9, 7, 7, 7, 7, 4, 7, 3, 7, 6, 10, 6, 6, 7, 6, 6, 6, 9);
522  $max_width = $cut_size * $chars[0] / 2;
523  $char_width = 0;
524 
525  $string_length = strlen($string);
526  $char_count = 0;
527 
528  $idx = 0;
529  while($idx < $string_length && $char_count < $cut_size && $char_width <= $max_width)
530  {
531  $c = ord(substr($string, $idx, 1));
532  $char_count++;
533  if($c < 128)
534  {
535  $char_width += (int) $chars[$c - 32];
536  $idx++;
537  }
538  else if(191 < $c && $c < 224)
539  {
540  $char_width += $chars[4];
541  $idx += 2;
542  }
543  else
544  {
545  $char_width += $chars[0];
546  $idx += 3;
547  }
548  }
549 
550  $output = substr($string, 0, $idx);
551  if(strlen($output) < $string_length)
552  {
553  $output .= $tail;
554  }
555 
556  return $output;
557 }
558 
564 function zgap()
565 {
566  $time_zone = $GLOBALS['_time_zone'];
567  if($time_zone < 0)
568  {
569  $to = -1;
570  }
571  else
572  {
573  $to = 1;
574  }
575 
576  $t_hour = substr($time_zone, 1, 2) * $to;
577  $t_min = substr($time_zone, 3, 2) * $to;
578 
579  $server_time_zone = date("O");
580  if($server_time_zone < 0)
581  {
582  $so = -1;
583  }
584  else
585  {
586  $so = 1;
587  }
588 
589  $c_hour = substr($server_time_zone, 1, 2) * $so;
590  $c_min = substr($server_time_zone, 3, 2) * $so;
591 
592  $g_min = $t_min - $c_min;
593  $g_hour = $t_hour - $c_hour;
594 
595  $gap = $g_min * 60 + $g_hour * 60 * 60;
596  return $gap;
597 }
598 
605 function ztime($str)
606 {
607  if(!$str)
608  {
609  return;
610  }
611  if (strlen($str) === 9 || (strlen($str) === 10 && $str <= 2147483647))
612  {
613  return intval($str);
614  }
615 
616  $hour = (int) substr($str, 8, 2);
617  $min = (int) substr($str, 10, 2);
618  $sec = (int) substr($str, 12, 2);
619  $year = (int) substr($str, 0, 4);
620  $month = (int) substr($str, 4, 2);
621  $day = (int) substr($str, 6, 2);
622  if(strlen($str) <= 8)
623  {
624  $gap = 0;
625  }
626  else
627  {
628  $gap = zgap();
629  }
630 
631  return mktime($hour, $min, $sec, $month ? $month : 1, $day ? $day : 1, $year) + $gap;
632 }
633 
641 function getTimeGap($date, $format = 'Y.m.d')
642 {
643  $gap = $_SERVER['REQUEST_TIME'] + zgap() - ztime($date);
644 
645  $lang_time_gap = Context::getLang('time_gap');
646  if($gap < 60)
647  {
648  $buff = sprintf($lang_time_gap['min'], (int) ($gap / 60) + 1);
649  }
650  elseif($gap < 60 * 60)
651  {
652  $buff = sprintf($lang_time_gap['mins'], (int) ($gap / 60) + 1);
653  }
654  elseif($gap < 60 * 60 * 2)
655  {
656  $buff = sprintf($lang_time_gap['hour'], (int) ($gap / 60 / 60) + 1);
657  }
658  elseif($gap < 60 * 60 * 24)
659  {
660  $buff = sprintf($lang_time_gap['hours'], (int) ($gap / 60 / 60) + 1);
661  }
662  else
663  {
664  $buff = zdate($date, $format);
665  }
666 
667  return $buff;
668 }
669 
677 function getMonthName($month, $short = TRUE)
678 {
679  $short_month = array('', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
680  $long_month = array('', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
681  return !$short ? $long_month[$month] : $short_month[$month];
682 }
683 
692 function zdate($str, $format = 'Y-m-d H:i:s', $conversion = TRUE)
693 {
694  // return null if no target time is specified
695  if(!$str)
696  {
697  return;
698  }
699  // convert the date format according to the language
700  if($conversion == TRUE)
701  {
702  switch(Context::getLangType())
703  {
704  case 'en' :
705  case 'es' :
706  if($format == 'Y-m-d')
707  {
708  $format = 'M d, Y';
709  }
710  elseif($format == 'Y-m-d H:i:s')
711  {
712  $format = 'M d, Y H:i:s';
713  }
714  elseif($format == 'Y-m-d H:i')
715  {
716  $format = 'M d, Y H:i';
717  }
718  break;
719  case 'vi' :
720  if($format == 'Y-m-d')
721  {
722  $format = 'd-m-Y';
723  }
724  elseif($format == 'Y-m-d H:i:s')
725  {
726  $format = 'H:i:s d-m-Y';
727  }
728  elseif($format == 'Y-m-d H:i')
729  {
730  $format = 'H:i d-m-Y';
731  }
732  break;
733  }
734  }
735 
736  // If year value is less than 1970, handle it separately.
737  if((int) substr($str, 0, 4) < 1970)
738  {
739  $hour = (int) substr($str, 8, 2);
740  $min = (int) substr($str, 10, 2);
741  $sec = (int) substr($str, 12, 2);
742  $year = (int) substr($str, 0, 4);
743  $month = (int) substr($str, 4, 2);
744  $day = (int) substr($str, 6, 2);
745 
746  $trans = array(
747  'Y' => $year,
748  'y' => sprintf('%02d', $year % 100),
749  'm' => sprintf('%02d', $month),
750  'n' => $month,
751  'd' => sprintf('%02d', $day),
752  'j' => $day,
753  'G' => $hour,
754  'H' => sprintf('%02d', $hour),
755  'g' => $hour % 12,
756  'h' => sprintf('%02d', $hour % 12),
757  'i' => sprintf('%02d', $min),
758  's' => sprintf('%02d', $sec),
759  'M' => getMonthName($month),
760  'F' => getMonthName($month, FALSE)
761  );
762 
763  $string = strtr($format, $trans);
764  }
765  else
766  {
767  // if year value is greater than 1970, get unixtime by using ztime() for date() function's argument.
768  $string = date($format, ztime($str));
769  }
770  // change day and am/pm for each language
771  $unit_week = Context::getLang('unit_week');
772  $unit_meridiem = Context::getLang('unit_meridiem');
773  $string = str_replace(array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'), $unit_week, $string);
774  $string = str_replace(array('am', 'pm', 'AM', 'PM'), $unit_meridiem, $string);
775  return $string;
776 }
777 
784 function getEncodeEmailAddress($email)
785 {
786  $return = '';
787  for($i = 0, $c = strlen($email); $i < $c; $i++)
788  {
789  $return .= '&#' . (rand(0, 1) == 0 ? ord($email[$i]) : 'X' . dechex(ord($email[$i]))) . ';';
790  }
791  return $return;
792 }
793 
805 function debugPrint($debug_output = NULL, $display_option = TRUE, $file = '_debug_message.php')
806 {
807  static $debug_file;
808 
809  if(!(__DEBUG__ & 1))
810  {
811  return;
812  }
813 
814  static $firephp;
815  $bt = debug_backtrace();
816  if(is_array($bt))
817  {
818  $bt_debug_print = array_shift($bt);
819  $bt_called_function = array_shift($bt);
820  }
821  $file_name = str_replace(_XE_PATH_, '', $bt_debug_print['file']);
822  $line_num = $bt_debug_print['line'];
823  $function = $bt_called_function['class'] . $bt_called_function['type'] . $bt_called_function['function'];
824 
825  if(__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '6.0.0') === -1)
826  {
827  if(!isset($firephp))
828  {
829  $firephp = FirePHP::getInstance(TRUE);
830  }
831  $type = FirePHP::INFO;
832 
833  $label = sprintf('[%s:%d] %s() (Memory usage: current=%s, peak=%s)', $file_name, $line_num, $function, FileHandler::filesize(memory_get_usage()), FileHandler::filesize(memory_get_peak_usage()));
834 
835  // Check a FirePHP option
836  if($display_option === 'TABLE')
837  {
838  $label = $display_option;
839  }
840  if($display_option === 'ERROR')
841  {
842  $type = $display_option;
843  }
844  // Check if the IP specified by __DEBUG_PROTECT__ option is same as the access IP.
845  if(__DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
846  {
847  $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';
848  $label = NULL;
849  }
850 
851  $firephp->fb($debug_output, $label, $type);
852  }
853  else
854  {
855  if(__DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
856  {
857  return;
858  }
859 
860  $print = array();
861  if(!$debug_file)
862  {
863  $debug_file = _XE_PATH_ . 'files/' . $file;
864  }
865  if(!file_exists($debug_file)) $print[] = '<?php exit() ?>';
866 
867  if($display_option === TRUE || $display_option === 'ERROR')
868  {
869  $print[] = sprintf("[%s %s:%d] %s() - mem(%s)", date('Y-m-d H:i:s'), $file_name, $line_num, $function, FileHandler::filesize(memory_get_usage()));;
870  $print[] = str_repeat('=', 80);
871  }
872  $type = gettype($debug_output);
873  if(!in_array($type, array('array', 'object', 'resource')))
874  {
875  if($display_option === 'ERROR')
876  {
877  $print[] = 'ERROR : ' . var_export($debug_output, TRUE);
878  }
879  else
880  {
881  $print[] = 'DEBUG : ' . $type . '(' . var_export($debug_output, TRUE) . ')';
882  }
883  }
884  else
885  {
886  $print[] = 'DEBUG : ' . trim(preg_replace('/\r?\n/', "\n" . ' ', print_r($debug_output, true)));
887  }
888  $backtrace_args = defined('\DEBUG_BACKTRACE_IGNORE_ARGS') ? \DEBUG_BACKTRACE_IGNORE_ARGS : 0;
889  $backtrace = debug_backtrace($backtrace_args);
890 
891  if(count($backtrace) > 1 && $backtrace[1]['function'] === 'debugPrint' && !$backtrace[1]['class'])
892  {
893  array_shift($backtrace);
894  }
895  foreach($backtrace as $val)
896  {
897  $print[] = ' - ' . $val['file'] . ' : ' . $val['line'];
898  }
899  $print[] = PHP_EOL;
900  @file_put_contents($debug_file, implode(PHP_EOL, $print), FILE_APPEND|LOCK_EX);
901  }
902 }
903 
909 function writeSlowlog($type, $elapsed_time, $obj)
910 {
911  if(!__LOG_SLOW_TRIGGER__ && !__LOG_SLOW_ADDON__ && !__LOG_SLOW_WIDGET__ && !__LOG_SLOW_QUERY__) return;
912 
913  static $log_filename = array(
914  'query' => 'files/_slowlog_query.php',
915  'trigger' => 'files/_slowlog_trigger.php',
916  'addon' => 'files/_slowlog_addon.php',
917  'widget' => 'files/_slowlog_widget.php'
918  );
919  $write_file = true;
920 
921  $log_file = _XE_PATH_ . $log_filename[$type];
922 
923  $buff = array();
924  $buff[] = '<?php exit(); ?>';
925  $buff[] = date('c');
926 
927  if($type == 'trigger' && __LOG_SLOW_TRIGGER__ > 0 && $elapsed_time > __LOG_SLOW_TRIGGER__)
928  {
929  $buff[] = "\tCaller : " . $obj->caller;
930  $buff[] = "\tCalled : " . $obj->called;
931  }
932  else if($type == 'addon' && __LOG_SLOW_ADDON__ > 0 && $elapsed_time > __LOG_SLOW_ADDON__)
933  {
934  $buff[] = "\tAddon : " . $obj->called;
935  $buff[] = "\tCalled position : " . $obj->caller;
936  }
937  else if($type == 'widget' && __LOG_SLOW_WIDGET__ > 0 && $elapsed_time > __LOG_SLOW_WIDGET__)
938  {
939  $buff[] = "\tWidget : " . $obj->called;
940  }
941  else if($type == 'query' && __LOG_SLOW_QUERY__ > 0 && $elapsed_time > __LOG_SLOW_QUERY__)
942  {
943 
944  $buff[] = $obj->query;
945  $buff[] = "\tQuery ID : " . $obj->query_id;
946  $buff[] = "\tCaller : " . $obj->caller;
947  $buff[] = "\tConnection : " . $obj->connection;
948  }
949  else
950  {
951  $write_file = false;
952  }
953 
954  if($write_file)
955  {
956  $buff[] = sprintf("\t%0.6f sec", $elapsed_time);
957  $buff[] = PHP_EOL . PHP_EOL;
958  file_put_contents($log_file, implode(PHP_EOL, $buff), FILE_APPEND);
959  }
960 
961  if($type != 'query')
962  {
963  $trigger_args = $obj;
964  $trigger_args->_log_type = $type;
965  $trigger_args->_elapsed_time = $elapsed_time;
966  ModuleHandler::triggerCall('XE.writeSlowlog', 'after', $trigger_args);
967  }
968 }
969 
973 function flushSlowlog()
974 {
975  $trigger_args = new stdClass();
976  $trigger_args->_log_type = 'flush';
977  $trigger_args->_elapsed_time = 0;
978  ModuleHandler::triggerCall('XE.writeSlowlog', 'after', $trigger_args);
979 }
980 
986 function getMicroTime()
987 {
988  list($time1, $time2) = explode(' ', microtime());
989  return (float) $time1 + (float) $time2;
990 }
991 
999 function delObjectVars($target_obj, $del_obj)
1000 {
1001  if(!is_object($target_obj))
1002  {
1003  return;
1004  }
1005  if(!is_object($del_obj))
1006  {
1007  return;
1008  }
1009 
1010  $target_vars = get_object_vars($target_obj);
1011  $del_vars = get_object_vars($del_obj);
1012 
1013  $target = array_keys($target_vars);
1014  $del = array_keys($del_vars);
1015  if(!count($target) || !count($del))
1016  {
1017  return $target_obj;
1018  }
1019 
1020  $return_obj = new stdClass();
1021 
1022  $target_count = count($target);
1023  for($i = 0; $i < $target_count; $i++)
1024  {
1025  $target_key = $target[$i];
1026  if(!in_array($target_key, $del))
1027  {
1028  $return_obj->{$target_key} = $target_obj->{$target_key};
1029  }
1030  }
1031 
1032  return $return_obj;
1033 }
1034 
1035 function getDestroyXeVars(&$vars)
1036 {
1037  $del_vars = array('error_return_url', 'success_return_url', 'ruleset', 'xe_validator_id');
1038 
1039  foreach($del_vars as $var)
1040  {
1041  if(is_array($vars)) unset($vars[$var]);
1042  else if(is_object($vars)) unset($vars->$var);
1043  }
1044 
1045  return $vars;
1046 }
1047 
1057 function handleError($errno, $errstr, $file, $line)
1058 {
1059  if(!__DEBUG__)
1060  {
1061  return;
1062  }
1063  $errors = array(E_USER_ERROR, E_ERROR, E_PARSE);
1064  if(!in_array($errno, $errors))
1065  {
1066  return;
1067  }
1068 
1069  $output = sprintf("Fatal error : %s - %d", $file, $line);
1070  $output .= sprintf("%d - %s", $errno, $errstr);
1071 
1073 }
1074 
1081 function getNumberingPath($no, $size = 3)
1082 {
1083  $mod = pow(10, $size);
1084  $output = sprintf('%0' . $size . 'd/', $no % $mod);
1085  if($no >= $mod)
1086  {
1087  $output .= getNumberingPath((int) $no / $mod, $size);
1088  }
1089  return $output;
1090 }
1091 
1098 function url_decode($str)
1099 {
1100  return preg_replace('/%u([[:alnum:]]{4})/', '&#x\\1;', $str);
1101 }
1102 
1103 function purifierHtml(&$content)
1104 {
1105  require_once(_XE_PATH_ . 'classes/security/Purifier.class.php');
1106  $oPurifier = Purifier::getInstance();
1107 
1108  // @see https://github.com/xpressengine/xe-core/issues/2278
1109  $logged_info = Context::get('logged_info');
1110  if($logged_info->is_admin !== 'Y') {
1111  $oPurifier->setConfig('HTML.Nofollow', true);
1112  }
1113 
1114  $oPurifier->purify($content);
1115 }
1116 
1123 function removeHackTag($content)
1124 {
1125  require_once(_XE_PATH_ . 'classes/security/EmbedFilter.class.php');
1126  $oEmbedFilter = EmbedFilter::getInstance();
1127  $oEmbedFilter->check($content);
1128 
1129  purifierHtml($content);
1130 
1131  // change the specific tags to the common texts
1132  $content = preg_replace('@<(\/?(?:html|body|head|title|meta|base|link|script|style|applet)(/*).*?>)@i', '&lt;$1', $content);
1133 
1138  $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);
1139 
1140  $content = checkXmpTag($content);
1141  $content = blockWidgetCode($content);
1142 
1143  return $content;
1144 }
1145 
1152 function blockWidgetCode($content)
1153 {
1154  $content = preg_replace('/(<(?:img|div)(?:[^>]*))(widget)(?:(=([^>]*?)>))/is', '$1blocked-widget$3', $content);
1155 
1156  return $content;
1157 }
1158 
1165 function checkUploadedFile($file)
1166 {
1167  require_once(_XE_PATH_ . 'classes/security/UploadFileFilter.class.php');
1168  return UploadFileFilter::check($file);
1169 }
1170 
1177 function checkXmpTag($content)
1178 {
1179  $content = preg_replace('@<(/?)xmp.*?>@i', '<\1xmp>', $content);
1180 
1181  if(($start_xmp = strrpos($content, '<xmp>')) !== FALSE)
1182  {
1183  if(($close_xmp = strrpos($content, '</xmp>')) === FALSE)
1184  {
1185  $content .= '</xmp>';
1186  }
1187  else if($close_xmp < $start_xmp)
1188  {
1189  $content .= '</xmp>';
1190  }
1191  }
1192 
1193  return $content;
1194 }
1195 
1202 function removeSrcHack($match)
1203 {
1204  $tag = strtolower($match[2]);
1205 
1206  // xmp tag ?뺣━
1207  if($tag == 'xmp')
1208  {
1209  return "<{$match[1]}xmp>";
1210  }
1211  if($match[1])
1212  {
1213  return $match[0];
1214  }
1215  if($match[4])
1216  {
1217  $match[4] = ' ' . $match[4];
1218  }
1219 
1220  $attrs = array();
1221  if(preg_match_all('/([\w:-]+)\s*=(?:\s*(["\']))?(?(2)(.*?)\2|([^ ]+))/s', $match[3], $m))
1222  {
1223  foreach($m[1] as $idx => $name)
1224  {
1225  if(strlen($name) >= 2 && substr_compare($name, 'on', 0, 2) === 0)
1226  {
1227  continue;
1228  }
1229 
1230  $val = preg_replace_callback('/&#(?:x([a-fA-F0-9]+)|0*(\d+));/', function($n) {return chr($n[1] ? ('0x00' . $n[1]) : ($n[2] + 0)); }, $m[3][$idx] . $m[4][$idx]);
1231  $val = preg_replace('/^\s+|[\t\n\r]+/', '', $val);
1232 
1233  if(preg_match('/^[a-z]+script:/i', $val))
1234  {
1235  continue;
1236  }
1237 
1238  $attrs[$name] = $val;
1239  }
1240  }
1241 
1242  $filter_arrts = array('style', 'src', 'href');
1243 
1244  if($tag === 'object') array_push($filter_arrts, 'data');
1245  if($tag === 'param') array_push($filter_arrts, 'value');
1246 
1247  foreach($filter_arrts as $attr)
1248  {
1249  if(!isset($attrs[$attr])) continue;
1250 
1251  $attr_value = rawurldecode($attrs[$attr]);
1252  $attr_value = htmlspecialchars_decode($attr_value, ENT_COMPAT);
1253  $attr_value = preg_replace('/\s+|[\t\n\r]+/', '', $attr_value);
1254  if(preg_match('@(\?|&|;)(act=(\w+))@i', $attr_value, $m) && $m[3] !== 'procFileDownload')
1255  {
1256  unset($attrs[$attr]);
1257  }
1258  }
1259 
1260  if(isset($attrs['style']) && preg_match('@(?:/\*|\*/|\n|:\s*expression\s*\()@i', $attrs['style']))
1261  {
1262  unset($attrs['style']);
1263  }
1264 
1265  $attr = array();
1266  foreach($attrs as $name => $val)
1267  {
1268  if($tag == 'object' || $tag == 'embed' || $tag == 'a')
1269  {
1270  $attribute = strtolower(trim($name));
1271  if($attribute == 'data' || $attribute == 'src' || $attribute == 'href')
1272  {
1273  if(stripos($val, 'data:') === 0)
1274  {
1275  continue;
1276  }
1277  }
1278  }
1279 
1280  if($tag == 'img')
1281  {
1282  $attribute = strtolower(trim($name));
1283  if(stripos($val, 'data:') === 0)
1284  {
1285  continue;
1286  }
1287  }
1288  $val = str_replace('"', '&quot;', $val);
1289  $attr[] = $name . "=\"{$val}\"";
1290  }
1291  $attr = count($attr) ? ' ' . implode(' ', $attr) : '';
1292 
1293  return "<{$match[1]}{$tag}{$attr}{$match[4]}>";
1294 }
1295 
1296 // convert hexa value to RGB
1297 if(!function_exists('hexrgb'))
1298 {
1299 
1306  function hexrgb($hexstr)
1307  {
1308  $int = hexdec($hexstr);
1309 
1310  return array('red' => 0xFF & ($int >> 0x10),
1311  'green' => 0xFF & ($int >> 0x8),
1312  'blue' => 0xFF & $int);
1313  }
1314 
1315 }
1316 
1325 function mysql_pre4_hash_password($password)
1326 {
1327  $nr = 1345345333;
1328  $add = 7;
1329  $nr2 = 0x12345671;
1330 
1331  settype($password, "string");
1332 
1333  for($i = 0; $i < strlen($password); $i++)
1334  {
1335  if($password[$i] == ' ' || $password[$i] == '\t')
1336  {
1337  continue;
1338  }
1339  $tmp = ord($password[$i]);
1340  $nr ^= ((($nr & 63) + $add) * $tmp) + ($nr << 8);
1341  $nr2 += ($nr2 << 8) ^ $nr;
1342  $add += $tmp;
1343  }
1344  $result1 = sprintf("%08lx", $nr & ((1 << 31) - 1));
1345  $result2 = sprintf("%08lx", $nr2 & ((1 << 31) - 1));
1346 
1347  if($result1 == '80000000')
1348  {
1349  $nr += 0x80000000;
1350  }
1351  if($result2 == '80000000')
1352  {
1353  $nr2 += 0x80000000;
1354  }
1355 
1356  return sprintf("%08lx%08lx", $nr, $nr2);
1357 }
1358 
1364 function getScriptPath()
1365 {
1366  static $url = NULL;
1367  if($url == NULL)
1368  {
1369  $script_path = filter_var($_SERVER['SCRIPT_NAME'], FILTER_SANITIZE_STRING);
1370  $url = str_ireplace('/tools/', '/', preg_replace('/index.php.*/i', '', str_replace('\\', '/', $script_path)));
1371  }
1372  return $url;
1373 }
1374 
1381 {
1382  return str_replace('<', '&lt;', preg_replace('/[<>"]/', '', $_SERVER['REQUEST_URI']));
1383 }
1384 
1393 function utf8RawUrlDecode($source)
1394 {
1395  $decodedStr = '';
1396  $pos = 0;
1397  $len = strlen($source);
1398  while($pos < $len)
1399  {
1400  $charAt = substr($source, $pos, 1);
1401  if($charAt == '%')
1402  {
1403  $pos++;
1404  $charAt = substr($source, $pos, 1);
1405  if($charAt == 'u')
1406  {
1407  // we got a unicode character
1408  $pos++;
1409  $unicodeHexVal = substr($source, $pos, 4);
1410  $unicode = hexdec($unicodeHexVal);
1411  $decodedStr .= _code2utf($unicode);
1412  $pos += 4;
1413  }
1414  else
1415  {
1416  // we have an escaped ascii character
1417  $hexVal = substr($source, $pos, 2);
1418  $decodedStr .= chr(hexdec($hexVal));
1419  $pos += 2;
1420  }
1421  }
1422  else
1423  {
1424  $decodedStr .= $charAt;
1425  $pos++;
1426  }
1427  }
1428  return $decodedStr;
1429 }
1430 
1437 function _code2utf($num)
1438 {
1439  if($num < 128)
1440  {
1441  return chr($num);
1442  }
1443  if($num < 2048)
1444  {
1445  return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
1446  }
1447  if($num < 65536)
1448  {
1449  return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
1450  }
1451  if($num < 2097152)
1452  {
1453  return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
1454  }
1455  return '';
1456 }
1457 
1466 function detectUTF8($string, $return_convert = FALSE, $urldecode = TRUE)
1467 {
1468  if($urldecode)
1469  {
1470  $string = urldecode($string);
1471  }
1472 
1473  $sample = iconv('utf-8', 'utf-8', $string);
1474  $is_utf8 = (md5($sample) === md5($string));
1475 
1476  if(!$urldecode)
1477  {
1478  $string = urldecode($string);
1479  }
1480 
1481  if($return_convert)
1482  {
1483  return ($is_utf8) ? $string : iconv('euc-kr', 'utf-8', $string);
1484  }
1485 
1486  return $is_utf8;
1487 }
1488 
1495 function json_encode2($data)
1496 {
1497  switch(gettype($data))
1498  {
1499  case 'boolean':
1500  return $data ? 'true' : 'false';
1501  case 'integer':
1502  case 'double':
1503  return $data;
1504  case 'string':
1505  return '"' . strtr($data, array('\\' => '\\\\', '"' => '\\"')) . '"';
1506  case 'object':
1507  $data = get_object_vars($data);
1508  case 'array':
1509  $rel = FALSE; // relative array?
1510  $key = array_keys($data);
1511  foreach($key as $v)
1512  {
1513  if(!is_int($v))
1514  {
1515  $rel = TRUE;
1516  break;
1517  }
1518  }
1519 
1520  $arr = array();
1521  foreach($data as $k => $v)
1522  {
1523  $arr[] = ($rel ? '"' . strtr($k, array('\\' => '\\\\', '"' => '\\"')) . '":' : '') . json_encode2($v);
1524  }
1525 
1526  return $rel ? '{' . join(',', $arr) . '}' : '[' . join(',', $arr) . ']';
1527  default:
1528  return '""';
1529  }
1530 }
1531 
1538 function isCrawler($agent = NULL)
1539 {
1540  if(!$agent)
1541  {
1542  $agent = $_SERVER['HTTP_USER_AGENT'];
1543  }
1544 
1545  $check_agent = array('bot', 'spider', 'spyder', 'crawl', 'http://', 'google', 'yahoo', 'slurp', 'yeti', 'daum', 'teoma', 'fish', 'hanrss', 'facebook', 'yandex', 'infoseek', 'askjeeves', 'stackrambler');
1546  $check_ip = array(
1547  /*'211.245.21.110-211.245.21.119' mixsh is closed */
1548  );
1549 
1550  foreach($check_agent as $str)
1551  {
1552  if(stristr($agent, $str) != FALSE)
1553  {
1554  return TRUE;
1555  }
1556  }
1557 
1558  return IpFilter::filter($check_ip);
1559 }
1560 
1568 function stripEmbedTagForAdmin(&$content, $writer_member_srl)
1569 {
1570  if(!Context::get('is_logged'))
1571  {
1572  return;
1573  }
1574 
1575  $oModuleModel = getModel('module');
1576  $logged_info = Context::get('logged_info');
1577 
1578  if($writer_member_srl != $logged_info->member_srl && ($logged_info->is_admin == "Y" || $oModuleModel->isSiteAdmin($logged_info)))
1579  {
1580  if($writer_member_srl)
1581  {
1582  $oMemberModel = getModel('member');
1583  $member_info = $oMemberModel->getMemberInfoByMemberSrl($writer_member_srl);
1584  if($member_info->is_admin == "Y")
1585  {
1586  return;
1587  }
1588  }
1589  $security_msg = "<div style='border: 1px solid #DDD; background: #FAFAFA; text-align:center; margin: 1em 0;'><p style='margin: 1em;'>" . Context::getLang('security_warning_embed') . "</p></div>";
1590  $content = preg_replace('/<object[^>]+>(.*?<\/object>)?/is', $security_msg, $content);
1591  $content = preg_replace('/<embed[^>]+>(\s*<\/embed>)?/is', $security_msg, $content);
1592  $content = preg_replace('/<img[^>]+editor_component="multimedia_link"[^>]*>(\s*<\/img>)?/is', $security_msg, $content);
1593  }
1594 
1595  return;
1596 }
1597 
1603 function requirePear()
1604 {
1605  static $required = false;
1606  if($required)
1607  {
1608  return;
1609  }
1610 
1611  if(version_compare(PHP_VERSION, "5.3.0") < 0)
1612  {
1613  set_include_path(_XE_PATH_ . "libs/PEAR" . PATH_SEPARATOR . get_include_path());
1614  }
1615  else
1616  {
1617  set_include_path(_XE_PATH_ . "libs/PEAR.1.9.5" . PATH_SEPARATOR . get_include_path());
1618  }
1619 
1620  $required = true;
1621 }
1622 
1623 function checkCSRF()
1624 {
1625  if($_SERVER['REQUEST_METHOD'] != 'POST')
1626  {
1627  return FALSE;
1628  }
1629 
1630  $default_url = Context::getDefaultUrl();
1631  $referer = $_SERVER["HTTP_REFERER"];
1632 
1633  if(strpos($default_url, 'xn--') !== FALSE && strpos($referer, 'xn--') === FALSE)
1634  {
1635  require_once(_XE_PATH_ . 'libs/idna_convert/idna_convert.class.php');
1636  $IDN = new idna_convert(array('idn_version' => 2008));
1637  $referer = $IDN->encode($referer);
1638  }
1639 
1640  $default_url = parse_url($default_url);
1641  $referer = parse_url($referer);
1642 
1643  $oModuleModel = getModel('module');
1644  $siteModuleInfo = $oModuleModel->getDefaultMid();
1645 
1646  if($siteModuleInfo->site_srl == 0)
1647  {
1648  if($default_url['host'] !== $referer['host'])
1649  {
1650  return FALSE;
1651  }
1652  }
1653  else
1654  {
1655  $virtualSiteInfo = $oModuleModel->getSiteInfo($siteModuleInfo->site_srl);
1656  if(strtolower($virtualSiteInfo->domain) != strtolower(Context::get('vid')) && !strstr(strtolower($virtualSiteInfo->domain), strtolower($referer['host'])))
1657  {
1658  return FALSE;
1659  }
1660  }
1661 
1662  return TRUE;
1663 }
1664 
1670 function recurciveExposureCheck(&$menu)
1671 {
1672  if(is_array($menu))
1673  {
1674  foreach($menu AS $key=>$value)
1675  {
1676  if(!$value['isShow'])
1677  {
1678  unset($menu[$key]);
1679  }
1680  if(is_array($value['list']) && count($value['list']) > 0)
1681  {
1682  recurciveExposureCheck($menu[$key]['list']);
1683  }
1684  }
1685  }
1686 }
1687 
1688 function changeValueInUrl($key, $requestKey, $dbKey, $urlName = 'success_return_url')
1689 {
1690  if($requestKey != $dbKey)
1691  {
1692  $arrayUrl = parse_url(Context::get('success_return_url'));
1693  if($arrayUrl['query'])
1694  {
1695  parse_str($arrayUrl['query'], $parsedStr);
1696 
1697  if(isset($parsedStr[$key]))
1698  {
1699  $parsedStr[$key] = $requestKey;
1700  $successReturnUrl .= $arrayUrl['path'].'?'.http_build_query($parsedStr);
1701  Context::set($urlName, $successReturnUrl);
1702  }
1703  }
1704  }
1705 }
1706 
1712 function htmlHeader()
1713 {
1714  echo '<!DOCTYPE html>
1715 <html lang="ko">
1716 <head>
1717 <meta charset="utf-8" />
1718 </head>
1719 <body>';
1720 }
1721 
1727 function htmlFooter()
1728 {
1729  echo '</body></html>';
1730 }
1731 
1738 function alertScript($msg)
1739 {
1740  if(!$msg)
1741  {
1742  return;
1743  }
1744 
1745  echo '<script type="text/javascript">
1746 //<![CDATA[
1747 alert("' . $msg . '");
1748 //]]>
1749 </script>';
1750 }
1751 
1758 {
1759  echo '<script type="text/javascript">
1760 //<![CDATA[
1761 window.close();
1762 //]]>
1763 </script>';
1764 }
1765 
1772 function reload($isOpener = FALSE)
1773 {
1774  $reloadScript = $isOpener ? 'window.opener.location.reload()' : 'document.location.reload()';
1775 
1776  echo '<script type="text/javascript">
1777 //<![CDATA[
1778 ' . $reloadScript . '
1779 //]]>
1780 </script>';
1781 }
1782 
1783 
1784 function isDefinedLangCode($str)
1785 {
1786  return preg_match('!\$user_lang->([a-z0-9\_]+)$!is', trim($str));
1787 }
1788 
1799 function escape($str, $double_escape = true, $escape_defined_lang_code = false)
1800 {
1801  if(!$escape_defined_lang_code && isDefinedLangCode($str)) return $str;
1802 
1803  $flags = ENT_QUOTES | ENT_SUBSTITUTE;
1804  return htmlspecialchars($str, $flags, 'UTF-8', $double_escape);
1805 }
1806 
1816 function escape_css($str)
1817 {
1818  return preg_replace('/[^a-zA-Z0-9_.#\/-]/', '', $str);
1819 }
1820 
1830 function escape_js($str)
1831 {
1832  $flags = JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_UNESCAPED_UNICODE;
1833  $str = json_encode((string)$str, $flags);
1834  return substr($str, 1, strlen($str) - 2);
1835 }
1836 
1847 function escape_sqstr($str)
1848 {
1849  return str_replace(array('\\0', '\\"'), array('', '"'), addslashes($str));
1850 }
1851 
1862 function escape_dqstr($str)
1863 {
1864  return str_replace(array('\\0', "\\'", '$'), array('', "'", '\\$'), addslashes($str));
1865 }
1866 
1881 function explode_with_escape($delimiter, $str, $limit = 0, $escape_char = '\\')
1882 {
1883  if ($limit < 1) $limit = null;
1884  $result = array();
1885  $split = preg_split('/(?<!' . preg_quote($escape_char, '/') . ')' . preg_quote($delimiter, '/') . '/', $str, $limit);
1886  foreach ($split as $piece)
1887  {
1888  if (trim($piece) !== '')
1889  {
1890  $result[] = trim(str_replace($escape_char . $delimiter, $delimiter, $piece));
1891  }
1892  }
1893  return $result;
1894 }
1895 
1896 
1897 /* End of file func.inc.php */
1898 /* Location: ./config/func.inc.php */
explode_with_escape($delimiter, $str, $limit=0, $escape_char= '\\')
Definition: func.inc.php:1881
getUrl($num_args=0, $args_list=array(), $domain=null, $encode=TRUE, $autoEncode=FALSE)
$oModuleModel
Definition: ko.install.php:236
$IDN
Definition: example.php:7
& getModuleInstance($module, $type= 'view', $kind= '')
getController($module_name)
Definition: func.inc.php:90
getNumberingPath($no, $size=3)
Definition: func.inc.php:1081
checkXmpTag($content)
Definition: func.inc.php:1177
handleError($errno, $errstr, $file, $line)
Definition: func.inc.php:1057
zdate($str, $format= 'Y-m-d H:i:s', $conversion=TRUE)
Definition: func.inc.php:692
json_encode2($data)
Definition: func.inc.php:1495
changeValueInUrl($key, $requestKey, $dbKey, $urlName= 'success_return_url')
Definition: func.inc.php:1688
recurciveExposureCheck(&$menu)
Definition: func.inc.php:1670
if(!function_exists('hexrgb')) mysql_pre4_hash_password($password)
Definition: func.inc.php:1325
getAutoEncodedUrl()
Definition: func.inc.php:339
$obj
Definition: ko.install.php:262
getMicroTime()
Definition: func.inc.php:986
blockWidgetCode($content)
Definition: func.inc.php:1152
stripEmbedTagForAdmin(&$content, $writer_member_srl)
Definition: func.inc.php:1568
if(file_exists(_XE_PATH_. 'config/config.user.inc.php')) if(!defined('__DEBUG__')) if(!defined('__DEBUG_OUTPUT__')) if(!defined('__DEBUG_PROTECT__')) if(!defined('__DEBUG_PROTECT_IP__')) if(!defined('__DEBUG_DB_OUTPUT__')) if(!defined('__LOG_SLOW_QUERY__')) if(!defined('__LOG_SLOW_TRIGGER__')) if(!defined('__LOG_SLOW_ADDON__')) if(!defined('__LOG_SLOW_WIDGET__')) if(!defined('__DEBUG_QUERY__')) if(!defined('__OB_GZHANDLER_ENABLE__')) if(!defined('__ENABLE_PHPUNIT_TEST__')) if(!defined('__PROXY_SERVER__')) if(!defined('__ERROR_LOG__')) if(!defined('__DISABLE_DEFAULT_CSS__')) if(!defined('__AUTO_OPCACHE_INVALIDATE__')) if((__DEBUG_OUTPUT__==2)&&version_compare(PHP_VERSION, '6.0.0')===-1) if(version_compare(PHP_VERSION, '5.3.0') >=0) $GLOBALS['__xe_autoload_file_map']
Definition: config.inc.php:324
debugPrint($debug_output=NULL, $display_option=TRUE, $file= '_debug_message.php')
Definition: func.inc.php:805
$output
Definition: ko.install.php:193
escape_dqstr($str)
Definition: func.inc.php:1862
purifierHtml(&$content)
Definition: func.inc.php:1103
set($key, $val, $set_to_get_vars=0)
getNotEncodedUrl()
Definition: func.inc.php:316
getRequestUriByServerEnviroment()
Definition: func.inc.php:1380
delObjectVars($target_obj, $del_obj)
Definition: func.inc.php:999
closePopupScript()
Definition: func.inc.php:1757
reload($isOpener=FALSE)
Definition: func.inc.php:1772
getMonthName($month, $short=TRUE)
Definition: func.inc.php:677
getNotEncodedFullUrl()
Definition: func.inc.php:385
filter($ip_list, $ip=NULL)
& getMobile($module_name)
Definition: func.inc.php:123
getView($module_name)
Definition: func.inc.php:112
$args
Definition: ko.install.php:185
escape_sqstr($str)
Definition: func.inc.php:1847
isDefinedLangCode($str)
Definition: func.inc.php:1784
requirePear()
Definition: func.inc.php:1603
ztime($str)
Definition: func.inc.php:605
checkCSRF()
Definition: func.inc.php:1623
isSiteID($domain)
Definition: func.inc.php:495
getScriptPath()
Definition: func.inc.php:1364
getEncodeEmailAddress($email)
Definition: func.inc.php:784
$time_zone
Definition: func.inc.php:29
flushSlowlog()
Definition: func.inc.php:973
getNotEncodedSiteUrl()
Definition: func.inc.php:433
getAdminModel($module_name)
Definition: func.inc.php:156
alertScript($msg)
Definition: func.inc.php:1738
getInstance($db_type=NULL)
Definition: DB.class.php:142
getAPI($module_name)
Definition: func.inc.php:167
htmlFooter()
Definition: func.inc.php:1727
getWAP($module_name)
Definition: func.inc.php:178
getLang($code)
const _XE_PATH_
Definition: config.inc.php:49
checkUserSequence($seq)
Definition: func.inc.php:270
removeHackTag($content)
Definition: func.inc.php:1123
getAdminView($module_name)
Definition: func.inc.php:134
getNextSequence()
Definition: func.inc.php:236
getRequestUri($ssl_mode=FOLLOW_REQUEST_SSL, $domain=null)
detectUTF8($string, $return_convert=FALSE, $urldecode=TRUE)
Definition: func.inc.php:1466
getModel($module_name)
Definition: func.inc.php:145
htmlHeader()
Definition: func.inc.php:1712
removeSrcHack($match)
Definition: func.inc.php:1202
getFullSiteUrl()
Definition: func.inc.php:454
getDestroyXeVars(&$vars)
Definition: func.inc.php:1035
executeQueryArray($query_id, $args=NULL, $arg_columns=NULL)
Definition: func.inc.php:219
getTimeGap($date, $format= 'Y.m.d')
Definition: func.inc.php:641
zgap()
Definition: func.inc.php:564
getAdminController($module_name)
Definition: func.inc.php:101
cut_str($string, $cut_size=0, $tail= '...')
Definition: func.inc.php:508
executeQuery($query_id, $args=NULL, $arg_columns=NULL)
Definition: func.inc.php:203
writeSlowlog($type, $elapsed_time, $obj)
Definition: func.inc.php:909
utf8RawUrlDecode($source)
Definition: func.inc.php:1393
getUrl()
Definition: func.inc.php:297
getSiteUrl()
Definition: func.inc.php:411
escape($str, $double_escape=true, $escape_defined_lang_code=false)
Definition: func.inc.php:1799
isCrawler($agent=NULL)
Definition: func.inc.php:1538
getFullUrl()
Definition: func.inc.php:361
escape_css($str)
Definition: func.inc.php:1816
getModule($module_name, $type= 'view', $kind= '')
Definition: func.inc.php:79
getCurrentPageUrl()
Definition: func.inc.php:482
triggerCall($trigger_name, $called_position, &$obj)
setUserSequence($seq)
Definition: func.inc.php:250
escape_js($str)
Definition: func.inc.php:1830
static check($file, $filename=null)
getClass($module_name)
Definition: func.inc.php:189
checkUploadedFile($file)
Definition: func.inc.php:1165
_code2utf($num)
Definition: func.inc.php:1437
url_decode($str)
Definition: func.inc.php:1098