XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
ModuleHandler.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 
13 class ModuleHandler extends Handler
14 {
15 
16  var $module = NULL;
17  var $act = NULL;
18  var $mid = NULL;
19  var $document_srl = NULL;
20  var $module_srl = NULL;
21  var $module_info = NULL;
22  var $error = NULL;
23  var $httpStatusCode = NULL;
24 
35  function __construct($module = '', $act = '', $mid = '', $document_srl = '', $module_srl = '')
36  {
37  // If XE has not installed yet, set module as install
39  {
40  $this->module = 'install';
41  $this->act = Context::get('act');
42  return;
43  }
44 
46  if($oContext->isSuccessInit == FALSE)
47  {
48  // @see https://github.com/xpressengine/xe-core/issues/2304
49  $this->error = 'msg_invalid_request';
50  return;
51  }
52 
53  // Set variables from request arguments
54  $this->module = $module ? $module : Context::get('module');
55  $this->act = $act ? $act : Context::get('act');
56  $this->mid = $mid ? $mid : Context::get('mid');
57  $this->document_srl = $document_srl ? (int) $document_srl : (int) Context::get('document_srl');
58  $this->module_srl = $module_srl ? (int) $module_srl : (int) Context::get('module_srl');
59  if($entry = Context::get('entry'))
60  {
61  $this->entry = Context::convertEncodingStr($entry);
62  }
63 
64  // Validate variables to prevent XSS
65  $isInvalid = NULL;
66  if($this->module && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->module))
67  {
68  $isInvalid = TRUE;
69  }
70  if($this->mid && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->mid))
71  {
72  $isInvalid = TRUE;
73  }
74  if($this->act && !preg_match("/^([a-z0-9\_\-]+)$/i", $this->act))
75  {
76  $isInvalid = TRUE;
77  }
78  if($isInvalid)
79  {
80  htmlHeader();
81  echo Context::getLang("msg_invalid_request");
82  htmlFooter();
84  exit;
85  }
86 
87  if(isset($this->act) && (strlen($this->act) >= 4 && substr_compare($this->act, 'disp', 0, 4) === 0))
88  {
89  if(Context::get('_use_ssl') == 'optional' && Context::isExistsSSLAction($this->act) && $_SERVER['HTTPS'] != 'on')
90  {
91  if(Context::get('_https_port')!=null) {
92  header('location:https://' . $_SERVER['HTTP_HOST'] . ':' . Context::get('_https_port') . $_SERVER['REQUEST_URI']);
93  } else {
94  header('location:https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
95  }
96  return;
97  }
98  }
99 
100  // call a trigger before moduleHandler init
101  ModuleHandler::triggerCall('moduleHandler.init', 'before', $this);
102  if(__ERROR_LOG__ == 1 && __DEBUG_OUTPUT__ == 0)
103  {
104  if(__DEBUG_PROTECT__ === 0 || __DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ == $_SERVER['REMOTE_ADDR'])
105  {
106  set_error_handler(array($this, 'xeErrorLog'), E_WARNING);
107  register_shutdown_function(array($this, 'shutdownHandler'));
108  }
109  }
110 
111  // execute addon (before module initialization)
112  $called_position = 'before_module_init';
113  $oAddonController = getController('addon');
114  $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? 'mobile' : 'pc');
115  if(file_exists($addon_file)) include($addon_file);
116  }
117 
118  public static function xeErrorLog($errnumber, $errormassage, $errorfile, $errorline, $errorcontext)
119  {
120  if(($errnumber & 3) == 0 || error_reporting() == 0)
121  {
122  return false;
123  }
124 
125  set_error_handler(function() { }, ~0);
126 
127  $debug_file = _XE_PATH_ . 'files/_debug_message.php';
128  if(!file_exists($debug_file))
129  {
130  $print[] = '<?php exit() ?>';
131  }
132 
133  $errorname = self::getErrorType($errnumber);
134  $print[] = '['.date('Y-m-d H:i:s').'] ' . $errorname . ' : ' . $errormassage;
135  $backtrace_args = defined('DEBUG_BACKTRACE_IGNORE_ARGS') ? \DEBUG_BACKTRACE_IGNORE_ARGS : 0;
136  $backtrace = debug_backtrace($backtrace_args);
137  if(count($backtrace) > 1 && $backtrace[1]['function'] === 'xeErrorLog' && !$backtrace[1]['class'])
138  {
139  array_shift($backtrace);
140  }
141 
142  foreach($backtrace as $key => $value)
143  {
144  $message = ' - ' . $value['file'] . ' : ' . $value['line'];
145  $print[] = $message;
146  }
147  $print[] = PHP_EOL;
148  @file_put_contents($debug_file, implode(PHP_EOL, $print), FILE_APPEND|LOCK_EX);
149  restore_error_handler();
150 
151  return true;
152  }
153 
154  function shutdownHandler()
155  {
156  $errinfo = error_get_last();
157  if ($errinfo === null || ($errinfo['type'] != 1 && $errinfo['type'] != 4))
158  {
159  return false;
160  }
161 
162  set_error_handler(function() { }, ~0);
163 
164  $debug_file = _XE_PATH_ . 'files/_debug_message.php';
165  if(!file_exists($debug_file))
166  {
167  $print[] = '<?php exit() ?>';
168  }
169 
170  $errorname = self::getErrorType($errinfo['type']);
171  $print[] = '['.date('Y-m-d H:i:s').']';
172  $print[] = $errorname . ' : ' . $errinfo['message'];
173 
174  $message = ' - ' . $errinfo['file'] . ' : ' . $errinfo['line'];
175  $print[] = $message;
176 
177  $print[] = PHP_EOL;
178  @file_put_contents($debug_file, implode(PHP_EOL, $print), FILE_APPEND|LOCK_EX);
179  set_error_handler(array($this, 'dummyHandler'), ~0);
180 
181  return true;
182  }
183 
184  public static function getErrorType($errno)
185  {
186  switch ($errno)
187  {
188  case E_ERROR: return 'Fatal Error';
189  case E_WARNING: return 'Warning';
190  case E_NOTICE: return 'Notice';
191  case E_CORE_ERROR: return 'Core Error';
192  case E_CORE_WARNING: return 'Core Warning';
193  case E_COMPILE_ERROR: return 'Compile Error';
194  case E_COMPILE_WARNING: return 'Compile Warning';
195  case E_USER_ERROR: return 'User Error';
196  case E_USER_WARNING: return 'User Warning';
197  case E_USER_NOTICE: return 'User Notice';
198  case E_STRICT: return 'Strict Standards';
199  case E_PARSE: return 'Parse Error';
200  case E_DEPRECATED: return 'Deprecated';
201  case E_USER_DEPRECATED: return 'User Deprecated';
202  case E_RECOVERABLE_ERROR: return 'Catchable Fatal Error';
203  default: return 'Error';
204  }
205  }
206 
211  function init()
212  {
213  $oModuleModel = getModel('module');
214  $site_module_info = Context::get('site_module_info');
215 
216  // if success_return_url and error_return_url is incorrect
217  $urls = array(Context::get('success_return_url'), Context::get('error_return_url'));
218  $dbInfo = Context::getDBInfo();
219  $defaultUrlInfo = parse_url($dbInfo->default_url);
220  $defaultHost = $defaultUrlInfo['host'];
221 
222  foreach($urls as $url)
223  {
224  if(empty($url))
225  {
226  continue;
227  }
228 
229  $urlInfo = parse_url($url);
230  $host = $urlInfo['host'];
231 
232  if($host && ($host != $defaultHost && $host != $site_module_info->domain))
233  {
234  throw new Exception('msg_default_url_is_null');
235  }
236  }
237 
238  if(!$this->document_srl && $this->mid && $this->entry)
239  {
240  $oDocumentModel = getModel('document');
241  $this->document_srl = $oDocumentModel->getDocumentSrlByAlias($this->mid, $this->entry);
242  if($this->document_srl)
243  {
244  Context::set('document_srl', $this->document_srl);
245  }
246  }
247 
248  // Get module's information based on document_srl, if it's specified
249  if($this->document_srl)
250  {
251 
252  $module_info = $oModuleModel->getModuleInfoByDocumentSrl($this->document_srl);
253  // If the document does not exist, remove document_srl
254  if(!$module_info)
255  {
256  unset($this->document_srl);
257  }
258  else
259  {
260  // If it exists, compare mid based on the module information
261  // if mids are not matching, set it as the document's mid
262  if(!$this->mid || ($this->mid != $module_info->mid))
263  {
264 
265  if(Context::getRequestMethod() == 'GET')
266  {
267  $this->mid = $module_info->mid;
268  header('location:' . getNotEncodedSiteUrl($site_module_info->domain, 'mid', $this->mid, 'document_srl', $this->document_srl));
269  return FALSE;
270  }
271  else
272  {
273  $this->mid = $module_info->mid;
274  Context::set('mid', $this->mid);
275  }
276 
277  }
278  // if requested module is different from one of the document, remove the module information retrieved based on the document number
279  if($this->module && $module_info->module != $this->module)
280  {
281  unset($module_info);
282  }
283  }
284 
285  }
286 
287  // If module_info is not set yet, and there exists mid information, get module information based on the mid
288  if(!$module_info && $this->mid)
289  {
290  $module_info = $oModuleModel->getModuleInfoByMid($this->mid, $site_module_info->site_srl);
291  //if($this->module && $module_info->module != $this->module) unset($module_info);
292  }
293 
294  // redirect, if module_site_srl and site_srl are different
295  if(!$this->module && !$module_info && $site_module_info->site_srl == 0 && $site_module_info->module_site_srl > 0)
296  {
297  $site_info = $oModuleModel->getSiteInfo($site_module_info->module_site_srl);
298  header("location:" . getNotEncodedSiteUrl($site_info->domain, 'mid', $site_module_info->mid));
299  return FALSE;
300  }
301 
302  // If module_info is not set still, and $module does not exist, find the default module
303  if(!$module_info && !$this->module && !$this->mid)
304  {
305  $module_info = $site_module_info;
306  }
307 
308  if(!$module_info && !$this->module && $site_module_info->module_site_srl)
309  {
310  $module_info = $site_module_info;
311  }
312 
313  // redirect, if site_srl of module_info is different from one of site's module_info
314  if($module_info && $module_info->site_srl != $site_module_info->site_srl && !isCrawler())
315  {
316  // If the module is of virtual site
317  if($module_info->site_srl)
318  {
319  $site_info = $oModuleModel->getSiteInfo($module_info->site_srl);
320  $redirect_url = getNotEncodedSiteUrl($site_info->domain, 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry'));
321  // If it's called from a virtual site, though it's not a module of the virtual site
322  }
323  else
324  {
325  $db_info = Context::getDBInfo();
326  if(!$db_info->default_url)
327  {
328  return Context::getLang('msg_default_url_is_not_defined');
329  }
330  else
331  {
332  $redirect_url = getNotEncodedSiteUrl($db_info->default_url, 'mid', Context::get('mid'), 'document_srl', Context::get('document_srl'), 'module_srl', Context::get('module_srl'), 'entry', Context::get('entry'));
333  }
334  }
335  header("location:" . $redirect_url);
336  return FALSE;
337  }
338 
339  // If module info was set, retrieve variables from the module information
340  if($module_info)
341  {
342  $this->module = $module_info->module;
343  $this->mid = $module_info->mid;
344  $this->module_info = $module_info;
345  Context::setBrowserTitle($module_info->browser_title);
346 
347  $viewType = (Mobile::isFromMobilePhone()) ? 'M' : 'P';
348  $targetSrl = (Mobile::isFromMobilePhone()) ? 'mlayout_srl' : 'layout_srl';
349 
350  // use the site default layout.
351  if($module_info->{$targetSrl} == -1)
352  {
353  $oLayoutAdminModel = getAdminModel('layout');
354  $layoutSrl = $oLayoutAdminModel->getSiteDefaultLayout($viewType, $module_info->site_srl);
355  }
356  else
357  {
358  $layoutSrl = $module_info->{$targetSrl};
359  }
360 
361  // reset a layout_srl in module_info.
362  $module_info->{$targetSrl} = $layoutSrl;
363 
364  $part_config = $oModuleModel->getModulePartConfig('layout', $layoutSrl);
365  Context::addHtmlHeader($part_config->header_script);
366  }
367 
368  // Set module and mid into module_info
369  if(!isset($this->module_info))
370  {
371  $this->module_info = new stdClass();
372  }
373  $this->module_info->module = $this->module;
374  $this->module_info->mid = $this->mid;
375 
376  // Set site_srl add 2011 08 09
377  $this->module_info->site_srl = $site_module_info->site_srl;
378 
379  // Still no module? it's an error
380  if(!$this->module)
381  {
382  $this->error = 'msg_module_is_not_exists';
383  $this->httpStatusCode = '404';
384  }
385 
386  // If mid exists, set mid into context
387  if($this->mid)
388  {
389  Context::set('mid', $this->mid, TRUE);
390  }
391 
392  // Call a trigger after moduleHandler init
393  $output = ModuleHandler::triggerCall('moduleHandler.init', 'after', $this->module_info);
394  if(!$output->toBool())
395  {
396  $this->error = $output->getMessage();
397  return TRUE;
398  }
399 
400  // Set current module info into context
401  Context::set('current_module_info', $this->module_info);
402 
403  return TRUE;
404  }
405 
410  function procModule()
411  {
412  $oModuleModel = getModel('module');
413  $display_mode = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
414 
415  // If error occurred while preparation, return a message instance
416  if($this->error)
417  {
418  $this->_setInputErrorToContext();
419  $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
420  $oMessageObject->setError(-1);
421  $oMessageObject->setMessage($this->error);
422  $oMessageObject->dispMessage();
423  if($this->httpStatusCode)
424  {
425  $oMessageObject->setHttpStatusCode($this->httpStatusCode);
426  }
427  return $oMessageObject;
428  }
429 
430  // Get action information with conf/module.xml
431  $xml_info = $oModuleModel->getModuleActionXml($this->module);
432 
433  // If not installed yet, modify act
434  if($this->module == "install")
435  {
436  if(!$this->act || !$xml_info->action->{$this->act})
437  {
438  $this->act = $xml_info->default_index_act;
439  }
440  }
441 
442  // if act exists, find type of the action, if not use default index act
443  if(!$this->act)
444  {
445  $this->act = $xml_info->default_index_act;
446  }
447 
448  // still no act means error
449  if(!$this->act)
450  {
451  $this->error = 'msg_module_is_not_exists';
452  $this->httpStatusCode = '404';
453 
454  $this->_setInputErrorToContext();
455  $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
456  $oMessageObject->setError(-1);
457  $oMessageObject->setMessage($this->error);
458  $oMessageObject->dispMessage();
459  if($this->httpStatusCode)
460  {
461  $oMessageObject->setHttpStatusCode($this->httpStatusCode);
462  }
463  return $oMessageObject;
464  }
465 
466  // get type, kind
467  $type = $xml_info->action->{$this->act}->type;
468  $ruleset = $xml_info->action->{$this->act}->ruleset;
469  $meta_noindex = $xml_info->action->{$this->act}->meta_noindex;
470  $kind = stripos($this->act, 'admin') !== FALSE ? 'admin' : '';
471 
472  if ($meta_noindex === 'true')
473  {
474  Context::addMetaTag('robots', 'noindex');
475  }
476 
477  if(!$kind && $this->module == 'admin')
478  {
479  $kind = 'admin';
480  }
481 
482  // check REQUEST_METHOD in controller
483  if($type == 'controller')
484  {
485  $allowedMethod = $xml_info->action->{$this->act}->method;
486 
487  if(!$allowedMethod)
488  {
489  $allowedMethodList[0] = 'POST';
490  }
491  else
492  {
493  $allowedMethodList = explode('|', strtoupper($allowedMethod));
494  }
495 
496  if(!in_array(strtoupper($_SERVER['REQUEST_METHOD']), $allowedMethodList))
497  {
498  $this->error = "msg_invalid_request";
499  $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
500  $oMessageObject->setError(-1);
501  $oMessageObject->setMessage($this->error);
502  $oMessageObject->dispMessage();
503  return $oMessageObject;
504  }
505  }
506 
507  if($this->module_info->use_mobile != "Y")
508  {
509  Mobile::setMobile(FALSE);
510  }
511 
512  $logged_info = Context::get('logged_info');
513 
514  // check CSRF for non-GET actions
515  $use_check_csrf = isset($xml_info->action->{$this->act}) && $xml_info->action->{$this->act}->check_csrf !== 'false';
516  if($use_check_csrf && $_SERVER['REQUEST_METHOD'] !== 'GET' && Context::isInstalled() && !checkCSRF())
517  {
518  $this->error = 'msg_invalid_request';
519  $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
520  $oMessageObject->setError(-1);
521  $oMessageObject->setMessage($this->error);
522  $oMessageObject->dispMessage();
523  return $oMessageObject;
524  }
525 
526  // Admin ip
527  if($kind == 'admin' && $_SESSION['denied_admin'] == 'Y')
528  {
529  $this->_setInputErrorToContext();
530  $this->error = "msg_not_permitted_act";
531  $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
532  $oMessageObject->setError(-1);
533  $oMessageObject->setMessage($this->error);
534  $oMessageObject->dispMessage();
535  return $oMessageObject;
536  }
537 
538  // if(type == view, and case for using mobilephone)
539  if($type == "view" && Mobile::isFromMobilePhone() && Context::isInstalled())
540  {
541  $orig_type = "view";
542  $type = "mobile";
543  // create a module instance
544  $oModule = $this->getModuleInstance($this->module, $type, $kind);
545  if(!is_object($oModule) || !method_exists($oModule, $this->act))
546  {
547  $type = $orig_type;
548  Mobile::setMobile(FALSE);
549  $oModule = $this->getModuleInstance($this->module, $type, $kind);
550  }
551  }
552  else
553  {
554  // create a module instance
555  $oModule = $this->getModuleInstance($this->module, $type, $kind);
556  }
557 
558  if(!is_object($oModule))
559  {
560  $this->_setInputErrorToContext();
561  $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
562  $oMessageObject->setError(-1);
563  $oMessageObject->setMessage($this->error);
564  $oMessageObject->dispMessage();
565  if($this->httpStatusCode)
566  {
567  $oMessageObject->setHttpStatusCode($this->httpStatusCode);
568  }
569  return $oMessageObject;
570  }
571 
572  // If there is no such action in the module object
573  if(!isset($xml_info->action->{$this->act}) || !method_exists($oModule, $this->act))
574  {
575 
576  if(!Context::isInstalled())
577  {
578  $this->_setInputErrorToContext();
579  $this->error = 'msg_invalid_request';
580  $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
581  $oMessageObject->setError(-1);
582  $oMessageObject->setMessage($this->error);
583  $oMessageObject->dispMessage();
584  if($this->httpStatusCode)
585  {
586  $oMessageObject->setHttpStatusCode($this->httpStatusCode);
587  }
588  return $oMessageObject;
589  }
590 
591  $forward = NULL;
592  // 1. Look for the module with action name
593  if(preg_match('/^([a-z]+)([A-Z])([a-z0-9\_]+)(.*)$/', $this->act, $matches))
594  {
595  $module = strtolower($matches[2] . $matches[3]);
596  $xml_info = $oModuleModel->getModuleActionXml($module);
597 
598  if($xml_info->action->{$this->act} && ((stripos($this->act, 'admin') !== FALSE) || $xml_info->action->{$this->act}->standalone != 'false'))
599  {
600  $forward = new stdClass();
601  $forward->module = $module;
602  $forward->type = $xml_info->action->{$this->act}->type;
603  $forward->ruleset = $xml_info->action->{$this->act}->ruleset;
604  $forward->meta_noindex = $xml_info->action->{$this->act}->meta_noindex;
605  $forward->act = $this->act;
606  }
607  else
608  {
609  $this->error = 'msg_invalid_request';
610  $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
611  $oMessageObject->setError(-1);
612  $oMessageObject->setMessage($this->error);
613  $oMessageObject->dispMessage();
614 
615  return $oMessageObject;
616  }
617  }
618 
619  if(!$forward)
620  {
621  $forward = $oModuleModel->getActionForward($this->act);
622  }
623 
624  if($forward->module && $forward->type && $forward->act && $forward->act == $this->act)
625  {
626  $kind = stripos($forward->act, 'admin') !== FALSE ? 'admin' : '';
627  $type = $forward->type;
628  $ruleset = $forward->ruleset;
629  $tpl_path = $oModule->getTemplatePath();
630  $orig_module = $oModule;
631 
632  if($forward->meta_noindex === 'true') {
633  Context::addMetaTag('robots', 'noindex');
634  }
635 
636  $xml_info = $oModuleModel->getModuleActionXml($forward->module);
637 
638  // check CSRF for non-GET actions
639  $use_check_csrf = isset($xml_info->action->{$this->act}) && $xml_info->action->{$this->act}->check_csrf !== 'false';
640  if($use_check_csrf && $_SERVER['REQUEST_METHOD'] !== 'GET' && Context::isInstalled() && !checkCSRF())
641  {
642  $this->error = 'msg_invalid_request';
643  $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
644  $oMessageObject->setError(-1);
645  $oMessageObject->setMessage($this->error);
646  $oMessageObject->dispMessage();
647  return $oMessageObject;
648  }
649 
650  // SECISSUE also check foward act method
651  // check REQUEST_METHOD in controller
652  if($type == 'controller')
653  {
654  $allowedMethod = $xml_info->action->{$forward->act}->method;
655 
656  if(!$allowedMethod)
657  {
658  $allowedMethodList[0] = 'POST';
659  }
660  else
661  {
662  $allowedMethodList = explode('|', strtoupper($allowedMethod));
663  }
664 
665  if(!in_array(strtoupper($_SERVER['REQUEST_METHOD']), $allowedMethodList))
666  {
667  $this->error = "msg_invalid_request";
668  $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
669  $oMessageObject->setError(-1);
670  $oMessageObject->setMessage($this->error);
671  $oMessageObject->dispMessage();
672  return $oMessageObject;
673  }
674  }
675 
676  if($type == "view" && Mobile::isFromMobilePhone())
677  {
678  $orig_type = "view";
679  $type = "mobile";
680  // create a module instance
681  $oModule = $this->getModuleInstance($forward->module, $type, $kind);
682  if(!is_object($oModule) || !method_exists($oModule, $this->act))
683  {
684  $type = $orig_type;
685  Mobile::setMobile(FALSE);
686  $oModule = $this->getModuleInstance($forward->module, $type, $kind);
687  }
688  }
689  else
690  {
691  $oModule = $this->getModuleInstance($forward->module, $type, $kind);
692  }
693 
694  if(!is_object($oModule))
695  {
696  $this->_setInputErrorToContext();
697  $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
698  $oMessageObject->setError(-1);
699  $oMessageObject->setMessage('msg_module_is_not_exists');
700  $oMessageObject->dispMessage();
701  if($this->httpStatusCode)
702  {
703  $oMessageObject->setHttpStatusCode($this->httpStatusCode);
704  }
705  return $oMessageObject;
706  }
707 
708  if($this->module == "admin" && $type == "view")
709  {
710  if($logged_info->is_admin == 'Y')
711  {
712  if($this->act != 'dispLayoutAdminLayoutModify')
713  {
714  $oAdminView = getAdminView('admin');
715  $oAdminView->makeGnbUrl($forward->module);
716  $oModule->setLayoutPath("./modules/admin/tpl");
717  $oModule->setLayoutFile("layout.html");
718  }
719  }
720  else
721  {
722  $this->_setInputErrorToContext();
723 
724  $this->error = 'msg_is_not_administrator';
725  $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
726  $oMessageObject->setError(-1);
727  $oMessageObject->setMessage($this->error);
728  $oMessageObject->dispMessage();
729  return $oMessageObject;
730  }
731  }
732  if($kind == 'admin')
733  {
734  $grant = $oModuleModel->getGrant($this->module_info, $logged_info);
735  if(!$grant->manager)
736  {
737  $this->_setInputErrorToContext();
738  $this->error = 'msg_is_not_manager';
739  $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
740  $oMessageObject->setError(-1);
741  $oMessageObject->setMessage($this->error);
742  $oMessageObject->dispMessage();
743  return $oMessageObject;
744  }
745  else
746  {
747  if(!$grant->is_admin && $this->module != $this->orig_module->module && $xml_info->permission->{$this->act} != 'manager')
748  {
749  $this->_setInputErrorToContext();
750  $this->error = 'msg_is_not_administrator';
751  $oMessageObject = ModuleHandler::getModuleInstance('message', $display_mode);
752  $oMessageObject->setError(-1);
753  $oMessageObject->setMessage($this->error);
754  $oMessageObject->dispMessage();
755  return $oMessageObject;
756  }
757  }
758  }
759  }
760  else if($xml_info->default_index_act && method_exists($oModule, $xml_info->default_index_act))
761  {
762  $this->act = $xml_info->default_index_act;
763  }
764  else
765  {
766  $this->error = 'msg_invalid_request';
767  $oModule->setError(-1);
768  $oModule->setMessage($this->error);
769  return $oModule;
770  }
771  }
772 
773  // ruleset check...
774  if(!empty($ruleset))
775  {
776  $rulesetModule = $forward->module ? $forward->module : $this->module;
777  $rulesetFile = $oModuleModel->getValidatorFilePath($rulesetModule, $ruleset, $this->mid);
778  if(!empty($rulesetFile))
779  {
780  if($_SESSION['XE_VALIDATOR_ERROR_LANG'])
781  {
782  $errorLang = $_SESSION['XE_VALIDATOR_ERROR_LANG'];
783  foreach($errorLang as $key => $val)
784  {
785  Context::setLang($key, $val);
786  }
787  unset($_SESSION['XE_VALIDATOR_ERROR_LANG']);
788  }
789 
790  $Validator = new Validator($rulesetFile);
791  $result = $Validator->validate();
792  if(!$result)
793  {
794  $lastError = $Validator->getLastError();
795  $returnUrl = Context::get('error_return_url');
796  $errorMsg = $lastError['msg'] ? $lastError['msg'] : 'validation error';
797 
798  //for xml response
799  $oModule->setError(-1);
800  $oModule->setMessage($errorMsg);
801  //for html redirect
802  $this->error = $errorMsg;
803  $_SESSION['XE_VALIDATOR_ERROR'] = -1;
804  $_SESSION['XE_VALIDATOR_MESSAGE'] = $this->error;
805  $_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = 'error';
806  $_SESSION['XE_VALIDATOR_RETURN_URL'] = $returnUrl;
807  $_SESSION['XE_VALIDATOR_ID'] = Context::get('xe_validator_id');
808  $this->_setInputValueToSession();
809  return $oModule;
810  }
811  }
812  }
813 
814  $oModule->setAct($this->act);
815 
816  $this->module_info->module_type = $type;
817  $oModule->setModuleInfo($this->module_info, $xml_info);
818 
819  $skipAct = array(
820  'dispEditorConfigPreview' => 1,
821  'dispLayoutPreviewWithModule' => 1
822  );
823  $db_use_mobile = Mobile::isMobileEnabled();
824  if($type == "view" && $this->module_info->use_mobile == "Y" && Mobile::isMobileCheckByAgent() && !isset($skipAct[Context::get('act')]) && $db_use_mobile === true)
825  {
826  global $lang;
827  $header = '<style>div.xe_mobile{opacity:0.7;margin:1em 0;padding:.5em;background:#333;border:1px solid #666;border-left:0;border-right:0}p.xe_mobile{text-align:center;margin:1em 0}a.xe_mobile{color:#ff0;font-weight:bold;font-size:24px}@media only screen and (min-width:500px){a.xe_mobile{font-size:15px}}</style>';
828  $footer = '<div class="xe_mobile"><p class="xe_mobile"><a class="xe_mobile" href="' . getUrl('m', '1') . '">' . $lang->msg_pc_to_mobile . '</a></p></div>';
829  Context::addHtmlHeader($header);
830  Context::addHtmlFooter($footer);
831  }
832 
833  if(($type == 'view' || $type == 'mobile') && $kind != 'admin')
834  {
835  $module_config = $oModuleModel->getModuleConfig('module');
836  if($module_config->htmlFooter)
837  {
838  Context::addHtmlFooter($module_config->htmlFooter);
839  }
840  if($module_config->siteTitle)
841  {
842  $siteTitle = Context::getBrowserTitle();
843  if(!$siteTitle)
844  {
845  Context::setBrowserTitle($module_config->siteTitle);
846  }
847  }
848  }
849 
850  if ($kind === 'admin') {
851  Context::addMetaTag('robots', 'noindex');
852  }
853 
854  // if failed message exists in session, set context
855  $this->_setInputErrorToContext();
856 
857  $procResult = $oModule->proc();
858 
859  $methodList = array('XMLRPC' => 1, 'JSON' => 1, 'JS_CALLBACK' => 1);
860  if(!$oModule->stop_proc && !isset($methodList[Context::getRequestMethod()]))
861  {
862  $error = $oModule->getError();
863  $message = $oModule->getMessage();
864  $messageType = $oModule->getMessageType();
865  $redirectUrl = $oModule->getRedirectUrl();
866  if($messageType == 'error') debugPrint($message, 'ERROR');
867 
868  if(!$procResult)
869  {
870  $this->error = $message;
871  if(!$redirectUrl && Context::get('error_return_url'))
872  {
873  $redirectUrl = Context::get('error_return_url');
874  }
875  $this->_setInputValueToSession();
876  }
877  else
878  {
879 
880  }
881 
882  $_SESSION['XE_VALIDATOR_ERROR'] = $error;
883  $_SESSION['XE_VALIDATOR_ID'] = Context::get('xe_validator_id');
884  if($message != 'success')
885  {
886  $_SESSION['XE_VALIDATOR_MESSAGE'] = $message;
887  }
888  $_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = $messageType;
889 
890  if(Context::get('xeVirtualRequestMethod') != 'xml')
891  {
892  $_SESSION['XE_VALIDATOR_RETURN_URL'] = $redirectUrl;
893  }
894  }
895 
896  unset($logged_info);
897  return $oModule;
898  }
899 
905  {
906  if($_SESSION['XE_VALIDATOR_ERROR'] && !Context::get('XE_VALIDATOR_ERROR'))
907  {
908  Context::set('XE_VALIDATOR_ERROR', $_SESSION['XE_VALIDATOR_ERROR']);
909  }
910  if($_SESSION['XE_VALIDATOR_MESSAGE'] && !Context::get('XE_VALIDATOR_MESSAGE'))
911  {
912  Context::set('XE_VALIDATOR_MESSAGE', $_SESSION['XE_VALIDATOR_MESSAGE']);
913  }
914  if($_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] && !Context::get('XE_VALIDATOR_MESSAGE_TYPE'))
915  {
916  Context::set('XE_VALIDATOR_MESSAGE_TYPE', $_SESSION['XE_VALIDATOR_MESSAGE_TYPE']);
917  }
918  if($_SESSION['XE_VALIDATOR_RETURN_URL'] && !Context::get('XE_VALIDATOR_RETURN_URL'))
919  {
920  Context::set('XE_VALIDATOR_RETURN_URL', $_SESSION['XE_VALIDATOR_RETURN_URL']);
921  }
922  if($_SESSION['XE_VALIDATOR_ID'] && !Context::get('XE_VALIDATOR_ID'))
923  {
924  Context::set('XE_VALIDATOR_ID', $_SESSION['XE_VALIDATOR_ID']);
925  }
926  if(count($_SESSION['INPUT_ERROR']))
927  {
928  Context::set('INPUT_ERROR', $_SESSION['INPUT_ERROR']);
929  }
930 
931  $this->_clearErrorSession();
932  }
933 
939  {
940  $_SESSION['XE_VALIDATOR_ERROR'] = '';
941  $_SESSION['XE_VALIDATOR_MESSAGE'] = '';
942  $_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = '';
943  $_SESSION['XE_VALIDATOR_RETURN_URL'] = '';
944  $_SESSION['XE_VALIDATOR_ID'] = '';
945  $_SESSION['INPUT_ERROR'] = '';
946  }
947 
953  {
954  $requestVars = Context::getRequestVars();
955  unset($requestVars->act, $requestVars->mid, $requestVars->vid, $requestVars->success_return_url, $requestVars->error_return_url);
956  foreach($requestVars AS $key => $value)
957  {
958  $_SESSION['INPUT_ERROR'][$key] = $value;
959  }
960  }
961 
967  function displayContent($oModule = NULL)
968  {
969  // If the module is not set or not an object, set error
970  if(!$oModule || !is_object($oModule))
971  {
972  $this->error = 'msg_module_is_not_exists';
973  $this->httpStatusCode = '404';
974  }
975 
976  // If connection to DB has a problem even though it's not install module, set error
977  if($this->module != 'install' && isset($GLOBALS['__DB__']) && $GLOBALS['__DB__'][Context::getDBType()]->isConnected() == FALSE)
978  {
979  $this->error = 'msg_dbconnect_failed';
980  }
981 
982  // Call trigger after moduleHandler proc
983  $output = ModuleHandler::triggerCall('moduleHandler.proc', 'after', $oModule);
984  if(!$output->toBool())
985  {
986  $this->error = $output->getMessage();
987  }
988 
989  // Use message view object, if HTML call
990  $methodList = array('XMLRPC' => 1, 'JSON' => 1, 'JS_CALLBACK' => 1);
991  if(!isset($methodList[Context::getRequestMethod()]))
992  {
993 
994  if($_SESSION['XE_VALIDATOR_RETURN_URL'])
995  {
996  $display_handler = new DisplayHandler();
997  $display_handler->_debugOutput();
998 
999  header('location:' . $_SESSION['XE_VALIDATOR_RETURN_URL']);
1000  return;
1001  }
1002 
1003  // If error occurred, handle it
1004  if($this->error)
1005  {
1006  // display content with message module instance
1007  $type = Mobile::isFromMobilePhone() ? 'mobile' : 'view';
1008  $oMessageObject = ModuleHandler::getModuleInstance('message', $type);
1009  $oMessageObject->setError(-1);
1010  $oMessageObject->setMessage($this->error);
1011  $oMessageObject->dispMessage();
1012 
1013  if($oMessageObject->getHttpStatusCode() && $oMessageObject->getHttpStatusCode() != '200')
1014  {
1015  $this->_setHttpStatusMessage($oMessageObject->getHttpStatusCode());
1016  $oMessageObject->setTemplateFile('http_status_code');
1017  }
1018 
1019  // If module was called normally, change the templates of the module into ones of the message view module
1020  if($oModule)
1021  {
1022  $oModule->setTemplatePath($oMessageObject->getTemplatePath());
1023  $oModule->setTemplateFile($oMessageObject->getTemplateFile());
1024  // Otherwise, set message instance as the target module
1025  }
1026  else
1027  {
1028  $oModule = $oMessageObject;
1029  }
1030 
1031  $this->_clearErrorSession();
1032  }
1033 
1034  // Check if layout_srl exists for the module
1036  {
1037  $layout_srl = $oModule->module_info->mlayout_srl;
1038  }
1039  else
1040  {
1041  $layout_srl = $oModule->module_info->layout_srl;
1042  }
1043 
1044  // if layout_srl is rollback by module, set default layout
1045  if($layout_srl == -1)
1046  {
1047  $viewType = (Mobile::isFromMobilePhone()) ? 'M' : 'P';
1048  $oLayoutAdminModel = getAdminModel('layout');
1049  $layout_srl = $oLayoutAdminModel->getSiteDefaultLayout($viewType, $oModule->module_info->site_srl);
1050  }
1051 
1052  if($layout_srl && !$oModule->getLayoutFile())
1053  {
1054 
1055  // If layout_srl exists, get information of the layout, and set the location of layout_path/ layout_file
1056  $oLayoutModel = getModel('layout');
1057  $layout_info = $oLayoutModel->getLayout($layout_srl);
1058  if($layout_info)
1059  {
1060 
1061  // Input extra_vars into $layout_info
1062  if($layout_info->extra_var_count)
1063  {
1064 
1065  foreach($layout_info->extra_var as $var_id => $val)
1066  {
1067  if($val->type == 'image')
1068  {
1069  if(strncmp('./files/attach/images/', $val->value, 22) === 0)
1070  {
1071  $val->value = Context::getRequestUri() . substr($val->value, 2);
1072  }
1073  }
1074  $layout_info->{$var_id} = $val->value;
1075  }
1076  }
1077  // Set menus into context
1078  if($layout_info->menu_count)
1079  {
1080  foreach($layout_info->menu as $menu_id => $menu)
1081  {
1082  // set default menu set(included home menu)
1083  if(!$menu->menu_srl || $menu->menu_srl == -1)
1084  {
1086  $homeMenuCacheFile = $oMenuAdminController->getHomeMenuCacheFile();
1087 
1088  if(FileHandler::exists($homeMenuCacheFile))
1089  {
1090  include($homeMenuCacheFile);
1091  }
1092 
1093  if(!$menu->menu_srl)
1094  {
1095  $menu->xml_file = str_replace('.xml.php', $homeMenuSrl . '.xml.php', $menu->xml_file);
1096  $menu->php_file = str_replace('.php', $homeMenuSrl . '.php', $menu->php_file);
1097  $layout_info->menu->{$menu_id}->menu_srl = $homeMenuSrl;
1098  }
1099  else
1100  {
1101  $menu->xml_file = str_replace($menu->menu_srl, $homeMenuSrl, $menu->xml_file);
1102  $menu->php_file = str_replace($menu->menu_srl, $homeMenuSrl, $menu->php_file);
1103  }
1104  }
1105 
1106  $php_file = FileHandler::exists($menu->php_file);
1107  if($php_file)
1108  {
1109  include($php_file);
1110  }
1111  Context::set($menu_id, $menu);
1112  }
1113  }
1114 
1115  // Set layout information into context
1116  Context::set('layout_info', $layout_info);
1117 
1118  $oModule->setLayoutPath($layout_info->path);
1119  $oModule->setLayoutFile('layout');
1120 
1121  // If layout was modified, use the modified version
1122  $edited_layout = $oLayoutModel->getUserLayoutHtml($layout_info->layout_srl);
1123  if(file_exists($edited_layout))
1124  {
1125  $oModule->setEditedLayoutFile($edited_layout);
1126  }
1127  }
1128  }
1129  $isLayoutDrop = Context::get('isLayoutDrop');
1130  if($isLayoutDrop)
1131  {
1132  $kind = stripos($this->act, 'admin') !== FALSE ? 'admin' : '';
1133  if($kind == 'admin')
1134  {
1135  $oModule->setLayoutFile('popup_layout');
1136  }
1137  else
1138  {
1139  $oModule->setLayoutPath('common/tpl');
1140  $oModule->setLayoutFile('default_layout');
1141  }
1142  }
1143  }
1144 
1145  // Display contents
1146  $oDisplayHandler = new DisplayHandler();
1147  $oDisplayHandler->printContent($oModule);
1148  }
1149 
1155  function getModulePath($module)
1156  {
1157  return sprintf('./modules/%s/', $module);
1158  }
1159 
1168  function &getModuleInstance($module, $type = 'view', $kind = '')
1169  {
1170 
1171  if(__DEBUG__ == 3)
1172  {
1173  $start_time = getMicroTime();
1174  }
1175 
1176  $parent_module = $module;
1177  $kind = strtolower($kind);
1178  $type = strtolower($type);
1179 
1180  $kinds = array('svc' => 1, 'admin' => 1);
1181  if(!isset($kinds[$kind]))
1182  {
1183  $kind = 'svc';
1184  }
1185 
1186  $key = $module . '.' . ($kind != 'admin' ? '' : 'admin') . '.' . $type;
1187 
1188  if(is_array($GLOBALS['__MODULE_EXTEND__']) && array_key_exists($key, $GLOBALS['__MODULE_EXTEND__']))
1189  {
1190  $module = $extend_module = $GLOBALS['__MODULE_EXTEND__'][$key];
1191  }
1192 
1193  // if there is no instance of the module in global variable, create a new one
1194  if(!isset($GLOBALS['_loaded_module'][$module][$type][$kind]))
1195  {
1196  ModuleHandler::_getModuleFilePath($module, $type, $kind, $class_path, $high_class_file, $class_file, $instance_name);
1197 
1198  if($extend_module && (!is_readable($high_class_file) || !is_readable($class_file)))
1199  {
1200  $module = $parent_module;
1201  ModuleHandler::_getModuleFilePath($module, $type, $kind, $class_path, $high_class_file, $class_file, $instance_name);
1202  }
1203 
1204  // Check if the base class and instance class exist
1205  if(!class_exists($module, true))
1206  {
1207  return NULL;
1208  }
1209  if(!class_exists($instance_name, true))
1210  {
1211  return NULL;
1212  }
1213 
1214  // Create an instance
1215  $oModule = new $instance_name();
1216  if(!is_object($oModule))
1217  {
1218  return NULL;
1219  }
1220 
1221  // Load language files for the class
1222  Context::loadLang($class_path . 'lang');
1223  if($extend_module)
1224  {
1225  Context::loadLang(ModuleHandler::getModulePath($parent_module) . 'lang');
1226  }
1227 
1228  // Set variables to the instance
1229  $oModule->setModule($module);
1230  $oModule->setModulePath($class_path);
1231 
1232  // If the module has a constructor, run it.
1233  if(!isset($GLOBALS['_called_constructor'][$instance_name]))
1234  {
1235  $GLOBALS['_called_constructor'][$instance_name] = TRUE;
1236  if(@method_exists($oModule, $instance_name))
1237  {
1238  $oModule->{$instance_name}();
1239  }
1240  }
1241 
1242  // Store the created instance into GLOBALS variable
1243  $GLOBALS['_loaded_module'][$module][$type][$kind] = $oModule;
1244  }
1245 
1246  if(__DEBUG__ == 3)
1247  {
1248  $GLOBALS['__elapsed_class_load__'] += getMicroTime() - $start_time;
1249  }
1250 
1251  // return the instance
1252  return $GLOBALS['_loaded_module'][$module][$type][$kind];
1253  }
1254 
1255  function _getModuleFilePath($module, $type, $kind, &$classPath, &$highClassFile, &$classFile, &$instanceName)
1256  {
1257  $classPath = ModuleHandler::getModulePath($module);
1258 
1259  $highClassFile = sprintf('%s%s%s.class.php', _XE_PATH_, $classPath, $module);
1260  $highClassFile = FileHandler::getRealPath($highClassFile);
1261 
1262  $types = array('view','controller','model','api','wap','mobile','class');
1263  if(!in_array($type, $types))
1264  {
1265  $type = $types[0];
1266  }
1267  if($type == 'class')
1268  {
1269  $instanceName = '%s';
1270  $classFile = '%s%s.%s.php';
1271  }
1272  elseif($kind == 'admin' && array_search($type, $types) < 3)
1273  {
1274  $instanceName = '%sAdmin%s';
1275  $classFile = '%s%s.admin.%s.php';
1276  }
1277  else
1278  {
1279  $instanceName = '%s%s';
1280  $classFile = '%s%s.%s.php';
1281  }
1282 
1283  $instanceName = sprintf($instanceName, $module, ucfirst($type));
1284  $classFile = FileHandler::getRealPath(sprintf($classFile, $classPath, $module, $type));
1285  }
1286 
1294  function triggerCall($trigger_name, $called_position, &$obj)
1295  {
1296  // skip if not installed
1297  if(!Context::isInstalled())
1298  {
1299  return new BaseObject();
1300  }
1301 
1302  $oModuleModel = getModel('module');
1303  $triggers = $oModuleModel->getTriggers($trigger_name, $called_position);
1304  if(!$triggers || count($triggers) < 1)
1305  {
1306  return new BaseObject();
1307  }
1308 
1309  //store before trigger call time
1310  $before_trigger_time = NULL;
1311  if(__LOG_SLOW_TRIGGER__> 0)
1312  {
1313  $before_trigger_time = microtime(true);
1314  }
1315 
1316  foreach($triggers as $item)
1317  {
1318  $module = $item->module;
1319  $type = $item->type;
1320  $called_method = $item->called_method;
1321 
1322  // todo why don't we call a normal class object ?
1323  $oModule = getModule($module, $type);
1324  if(!$oModule || !method_exists($oModule, $called_method))
1325  {
1326  continue;
1327  }
1328 
1329  $before_each_trigger_time = microtime(true);
1330 
1331  $output = $oModule->{$called_method}($obj);
1332 
1333  $after_each_trigger_time = microtime(true);
1334  $elapsed_time_trigger = $after_each_trigger_time - $before_each_trigger_time;
1335 
1336  $slowlog = new stdClass;
1337  $slowlog->caller = $trigger_name . '.' . $called_position;
1338  $slowlog->called = $module . '.' . $called_method;
1339  $slowlog->called_extension = $module;
1340  if($trigger_name != 'XE.writeSlowlog') writeSlowlog('trigger', $elapsed_time_trigger, $slowlog);
1341 
1342  if(is_object($output) && method_exists($output, 'toBool') && !$output->toBool())
1343  {
1344  return $output;
1345  }
1346  unset($oModule);
1347  }
1348 
1349  return new BaseObject();
1350  }
1351 
1357  function _setHttpStatusMessage($code)
1358  {
1359  $statusMessageList = array(
1360  // 1×× Informational
1361  '100' => 'Continue',
1362  '101' => 'Switching Protocols',
1363  '102' => 'Processing',
1364  // 2×× Success
1365  '200' => 'OK',
1366  '201' => 'Created',
1367  '202' => 'Accepted',
1368  '203' => 'Non-authoritative Information',
1369  '204' => 'No Content',
1370  '205' => 'Reset Content',
1371  '206' => 'Partial Content',
1372  '207' => 'Multi-Status',
1373  '208' => 'Already Reported',
1374  '226' => 'IM Used',
1375  // 3×× Redirection
1376  '300' => 'Multiple Choices',
1377  '301' => 'Moved Permanently',
1378  '302' => 'Found',
1379  '303' => 'See Other',
1380  '304' => 'Not Modified',
1381  '305' => 'Use Proxy',
1382  '307' => 'Temporary Redirect',
1383  '308' => 'Permanent Redirect',
1384  // 4×× Client Error
1385  '400' => 'Bad Request',
1386  '401' => 'Unauthorized',
1387  '402' => 'Payment Required',
1388  '403' => 'Forbidden',
1389  '404' => 'Not Found',
1390  '405' => 'Method Not Allowed',
1391  '406' => 'Not Acceptable',
1392  '407' => 'Proxy Authentication Required',
1393  '408' => 'Request Timeout',
1394  '409' => 'Conflict',
1395  '410' => 'Gone',
1396  '411' => 'Length Required',
1397  '412' => 'Precondition Failed',
1398  '413' => 'Payload Too Large',
1399  '414' => 'Request-URI Too Long',
1400  '415' => 'Unsupported Media Type',
1401  '416' => 'Requested Range Not Satisfiable',
1402  '417' => 'Expectation Failed',
1403  '418' => 'I\'m a teapot',
1404  '421' => 'Misdirected Request',
1405  '422' => 'Unprocessable Entity',
1406  '423' => 'Locked',
1407  '424' => 'Failed Dependency',
1408  '426' => 'Upgrade Required',
1409  '428' => 'Precondition Required',
1410  '429' => 'Too Many Requests',
1411  '431' => 'Request Header Fields Too Large',
1412  '451' => 'Unavailable For Legal Reasons',
1413  // 5×× Server Error
1414  '500' => 'Internal Server Error',
1415  '501' => 'Not Implemented',
1416  '502' => 'Bad Gateway',
1417  '503' => 'Service Unavailable',
1418  '504' => 'Gateway Timeout',
1419  '505' => 'HTTP Version Not Supported',
1420  '506' => 'Variant Also Negotiates',
1421  '507' => 'Insufficient Storage',
1422  '508' => 'Loop Detected',
1423  '510' => 'Not Extended',
1424  '511' => 'Network Authentication Required',
1425  );
1426  $statusMessage = $statusMessageList[$code];
1427  if(!$statusMessage)
1428  {
1429  $statusMessage = 'HTTP ' . $code;
1430  }
1431 
1432  Context::set('http_status_code', $code);
1433  Context::set('http_status_message', $statusMessage);
1434  }
1435 
1436 }
1437 /* End of file ModuleHandler.class.php */
1438 /* Location: ./classes/module/ModuleHandler.class.php */
setMobile($ismobile)
$oModuleModel
Definition: ko.install.php:236
& getModuleInstance($module, $type= 'view', $kind= '')
getController($module_name)
Definition: func.inc.php:90
displayContent($oModule=NULL)
$oMenuAdminController
Definition: ko.install.php:7
$obj
Definition: ko.install.php:262
getMicroTime()
Definition: func.inc.php:986
loadLang($path)
$module_info
Module Info. Object.
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
addHtmlHeader($header)
debugPrint($debug_output=NULL, $display_option=TRUE, $file= '_debug_message.php')
Definition: func.inc.php:805
$output
Definition: ko.install.php:193
$document_srl
Document Number.
isMobileCheckByAgent()
$layout_srl
Definition: ko.install.php:186
set($key, $val, $set_to_get_vars=0)
setBrowserTitle($site_title)
$error
an error code.
$oContext
Include the necessary configuration files.
Definition: index.php:45
setLang($code, $val)
checkCSRF()
Definition: func.inc.php:1623
__construct($module= '', $act= '', $mid= '', $document_srl= '', $module_srl= '')
getNotEncodedSiteUrl()
Definition: func.inc.php:433
getAdminModel($module_name)
Definition: func.inc.php:156
$oDocumentModel
Definition: ko.install.php:259
isFromMobilePhone()
htmlFooter()
Definition: func.inc.php:1727
getRealPath($source)
getLang($code)
$httpStatusCode
http status code.
const _XE_PATH_
Definition: config.inc.php:49
_getModuleFilePath($module, $type, $kind, &$classPath, &$highClassFile, &$classFile, &$instanceName)
getAdminView($module_name)
Definition: func.inc.php:134
$obj module_srl
Definition: ko.install.php:270
getRequestUri($ssl_mode=FOLLOW_REQUEST_SSL, $domain=null)
& getInstance()
getModel($module_name)
Definition: func.inc.php:145
htmlHeader()
Definition: func.inc.php:1712
convertEncodingStr($str)
$module_srl
Module Number.
getAdminController($module_name)
Definition: func.inc.php:101
isMobileEnabled()
writeSlowlog($type, $elapsed_time, $obj)
Definition: func.inc.php:909
static getErrorType($errno)
static xeErrorLog($errnumber, $errormassage, $errorfile, $errorline, $errorcontext)
getUrl()
Definition: func.inc.php:297
isCrawler($agent=NULL)
Definition: func.inc.php:1538
addMetaTag($name, $content, $is_http_equiv=FALSE)
getModule($module_name, $type= 'view', $kind= '')
Definition: func.inc.php:79
addHtmlFooter($footer)
triggerCall($trigger_name, $called_position, &$obj)
high class of the module module
Definition: module.class.php:8
if(isset($_REQUEST['encode'])) if(isset($_REQUEST['decode'])) $lang
Definition: example.php:23
isExistsSSLAction($action)