XOOPS  2.6.0
Xoops.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
14 
26 class Xoops
27 {
28  const VERSION = 'XOOPS 2.6.0-Alpha 3';
29 
33  public $sessionManager = null;
34 
38  public $module = null;
39 
43  public $config = array();
44 
48  public $moduleConfig = array();
49 
53  public $moduleDirname = '';
54 
58  public $user = '';
59 
63  public $userIsAdmin = false;
64 
68  public $option = array();
69 
73  private $tpl = null;
74 
78  private $theme = null;
79 
83  public $paths = array(
84  'XOOPS' => array(), 'www' => array(), 'var' => array(), 'lib' => array(), 'modules' => array(),
85  'themes' => array(), 'media' => array()
86  );
87 
91  public $tpl_name = '';
92 
96  private $kernelHandlers = array();
97 
101  private $moduleHandlers = array();
102 
106  private $activeModules = null;
107 
111  private $moduleConfigs = array();
112 
116  public $isAdminSide = false;
117 
121  private function __construct()
122  {
123  $root = \XoopsBaseConfig::get('root-path');
124  $lib = \XoopsBaseConfig::get('lib-path');
125  $var = \XoopsBaseConfig::get('var-path');
126 
127  $url = \XoopsBaseConfig::get('url');
128 
129  $this->paths['www'] = array($root, $url);
130  $this->paths['var'] = array($var, null);
131  $this->paths['lib'] = array($lib, $url . '/browse.php');
132  $this->paths['XOOPS'] = array($lib, $url . '/browse.php');
133 
134  $this->paths['assets'] = array(\XoopsBaseConfig::get('asset-path'), \XoopsBaseConfig::get('asset-url'));
135  $this->paths['images'] = array($root . '/images', $url . '/images');
136  $this->paths['install'] = array($root . '/install', $url . '/install');
137  $this->paths['language'] = array($root . '/language', $url . '/language');
138  $this->paths['locale'] = array($root . '/locale', $url . '/locale');
139  $this->paths['media'] = array(\XoopsBaseConfig::get('media-path'), \XoopsBaseConfig::get('media-url'));
140  $this->paths['modules'] = array($root . '/modules', $url . '/modules');
141  $this->paths['themes'] = array(\XoopsBaseConfig::get('themes-path'), \XoopsBaseConfig::get('themes-url'));
142  $this->paths['uploads'] = array(\XoopsBaseConfig::get('uploads-path'), \XoopsBaseConfig::get('uploads-url'));
143 
144  $this->paths['XOOPS'] = array(\XoopsBaseConfig::get('lib-path'), \XoopsBaseConfig::get('url') . '/browse.php');
145  $this->paths['www'] = array(\XoopsBaseConfig::get('root-path'), \XoopsBaseConfig::get('url'));
146  $this->paths['var'] = array(\XoopsBaseConfig::get('var-path'), null);
147  $this->paths['lib'] = array(\XoopsBaseConfig::get('lib-path'), \XoopsBaseConfig::get('url') . '/browse.php');
148  $this->paths['modules'] = array(\XoopsBaseConfig::get('root-path') . '/modules', \XoopsBaseConfig::get('url') . '/modules');
149  $this->paths['themes'] = array(\XoopsBaseConfig::get('root-path') . '/themes', \XoopsBaseConfig::get('url') . '/themes');
150  $this->paths['media'] = array(\XoopsBaseConfig::get('root-path') . '/media', \XoopsBaseConfig::get('url') . '/media');
151  $this->paths['assets'] = array(\XoopsBaseConfig::get('root-path') . '/assets', \XoopsBaseConfig::get('url') . '/assets');
152  $this->pathTranslation();
153  }
154 
160  public static function getInstance()
161  {
162  static $instance;
163  if (!isset($instance)) {
164  $class = __CLASS__;
165  $instance = new $class();
166  }
167  return $instance;
168  }
169 
175  public function db()
176  {
177  return \Xoops\Core\Database\Factory::getConnection();
178  }
179 
187  public function cache($cacheName = 'default')
188  {
189  static $cacheManager;
190 
191  if (!isset($cacheManager)) {
192  $cacheManager = new \Xoops\Core\Cache\CacheManager();
193  }
194 
195  return $cacheManager->getCache($cacheName);
196  }
197 
203  public function logger()
204  {
205  return \Xoops\Core\Logger::getInstance();
206  }
207 
208 
214  public function events()
215  {
216  return \Xoops\Core\Events::getInstance();
217  }
218 
224  public function preload()
225  {
226  return $this->events();
227  }
228 
234  public function assets()
235  {
236  static $instance;
237  if (!isset($instance)) {
238  $instance = new \Xoops\Core\Assets;
239  }
240  return $instance;
241  }
242 
250  public function service($service)
251  {
252  static $instance;
253  if (!isset($instance)) {
254  $instance = \Xoops\Core\Service\Manager::getInstance();
255  }
256  return $instance->locate($service);
257  }
258 
264  public function registry()
265  {
266  static $instance;
267  if (!isset($instance)) {
268  $instance = new \Xoops\Core\Registry();
269  }
270  return $instance;
271  }
272 
278  public function security()
279  {
280  static $instance;
281  if (!isset($instance)) {
282  $instance = new \Xoops\Core\Security();
283  }
284  return $instance;
285  }
286 
292  public function tpl()
293  {
294  return $this->tpl;
295  }
296 
304  public function setTpl(XoopsTpl $tpl)
305  {
306  return $this->tpl = $tpl;
307  }
308 
314  public function theme($tpl_name = null)
315  {
316  if (!isset($this->theme)) {
317  if ($tpl_name) {
318  $tpl_info = $this->getTplInfo($tpl_name);
319  $this->tpl_name = $tpl_info['tpl_name'];
320  } else {
321  $tpl_name = 'module:system/system_dummy.tpl';
322  $tpl_info = $this->getTplInfo($tpl_name);
323  $this->tpl_name = $tpl_info['tpl_name'];
324  }
325  if (!$this->isAdminSide) {
326  $xoopsThemeFactory = null;
327  $xoopsThemeFactory = new XoopsThemeFactory();
328  $xoopsThemeFactory->allowedThemes = $this->getConfig('theme_set_allowed');
329  $xoopsThemeFactory->defaultTheme = $this->getConfig('theme_set');
330  $this->setTheme($xoopsThemeFactory->createInstance(array('contentTemplate' => $this->tpl_name)));
331  } else {
332  $adminThemeFactory = new XoopsAdminThemeFactory();
333  $this->setTheme($adminThemeFactory->createInstance(array(
334  'folderName' => 'default', 'themesPath' => 'modules/system/themes',
335  'contentTemplate' => $this->tpl_name
336  )));
337  //$this->theme()->loadLocalization('admin');
338  list($cssAssets, $jsAssets) = $this->theme()->getLocalizationAssets('admin');
339  if (!empty($cssAssets)) {
340  $this->theme()->addBaseStylesheetAssets($cssAssets);
341  }
342  if (!empty($jsAssets)) {
343  $this->theme()->addBaseScriptAssets($jsAssets);
344  }
345  }
346  } else {
347  if ($tpl_name) {
348  $tpl_info = $this->getTplInfo($tpl_name);
349  $this->tpl_name = $tpl_info['tpl_name'];
350  $this->theme->contentTemplate = $this->tpl_name;
351  }
352  }
353  $GLOBALS['xoTheme'] = $this->theme;
354  return $this->theme;
355  }
356 
364  public function setTheme(XoopsTheme $theme)
365  {
366  return $this->theme = $theme;
367  }
368 
377  public function path($url, $virtual = false)
378  {
379  $url = $this->normalizePath($url);
380  $rootPath = $this->normalizePath(\XoopsBaseConfig::get('root-path') . '/');
381  if (0 === strpos($url, $rootPath)) {
382  $url = substr($url, strlen($rootPath));
383  }
384  //$url = ltrim($url, '/');
385  $parts = explode('/', $url, 2);
386  $root = isset($parts[0]) ? $parts[0] : '';
387  $path = isset($parts[1]) ? $parts[1] : '';
388  if (!isset($this->paths[$root])) {
389  list($root, $path) = array('www', $url);
390  }
391  if (!$virtual) { // Returns a physical path
392  $path = $this->paths[$root][0] . '/' . $path;
393  //$path = str_replace('/', DIRECTORY_SEPARATOR, $path);
394  return $path;
395  }
396  return !isset($this->paths[$root][1]) ? '' : ($this->paths[$root][1] . '/' . $path);
397  }
398 
406  public function normalizePath($path)
407  {
408  return str_replace('\\', '/', $path);
409  }
410 
418  public function url($url)
419  {
420  return (false !== strpos($url, '://') ? $url : $this->path($url, true));
421  }
422 
431  public function buildUrl($url, $params = array())
432  {
433  if ($url == '.') {
434  $url = $_SERVER['REQUEST_URI'];
435  }
436  $split = explode('?', $url);
437  if (count($split) > 1) {
438  list($url, $query) = $split;
439  parse_str($query, $query);
440  $params = array_merge($query, $params);
441  }
442  if (!empty($params)) {
443  foreach ($params as $k => $v) {
444  $params[$k] = $k . '=' . rawurlencode($v);
445  }
446  $url .= '?' . implode('&', $params);
447  }
448  return $url;
449  }
450 
459  public function pathExists($path, $error_type)
460  {
462  return $path;
463  } else {
464  $this->logger()->log(
465  \Psr\Log\LogLevel::WARNING,
467  array($path, $error_type)
468  );
469 
470  //trigger_error(XoopsLocale::E_FILE_NOT_FOUND, $error_type);
471  return false;
472  }
473  }
474 
480  public function gzipCompression()
481  {
485  if (empty($_SERVER['SERVER_NAME']) || substr(PHP_SAPI, 0, 3) == 'cli') {
486  $this->setConfig('gzip_compression', 0);
487  }
488 
489  if ($this->getConfig('gzip_compression') == 1 && extension_loaded('zlib') && !ini_get('zlib.output_compression')) {
490  if (@ini_get('zlib.output_compression_level') < 0) {
491  ini_set('zlib.output_compression_level', 6);
492  }
493  ob_start('ob_gzhandler');
494  }
495  }
496 
502  public function pathTranslation()
503  {
508  if (!isset($_SERVER['PATH_TRANSLATED']) && isset($_SERVER['SCRIPT_FILENAME'])) {
509  $_SERVER['PATH_TRANSLATED'] = $_SERVER['SCRIPT_FILENAME']; // For Apache CGI
510  } else {
511  if (isset($_SERVER['PATH_TRANSLATED']) && !isset($_SERVER['SCRIPT_FILENAME'])) {
512  $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; // For IIS/2K now I think :-(
513  }
514  }
518  if (empty($_SERVER['REQUEST_URI'])) { // Not defined by IIS
519  // Under some configs, IIS makes SCRIPT_NAME point to php.exe :-(
520  if (!($_SERVER['REQUEST_URI'] = @$_SERVER['PHP_SELF'])) {
521  $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
522  }
523  if (isset($_SERVER['QUERY_STRING'])) {
524  $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
525  }
526  }
527  }
528 
534  public function themeSelect()
535  {
536  $xoopsThemeSelect = Request::getString('xoops_theme_select', '', 'POST');
537  if (!empty($xoopsThemeSelect) && in_array($xoopsThemeSelect, $this->getConfig('theme_set_allowed'))) {
538  $this->setConfig('theme_set', $xoopsThemeSelect);
539  $_SESSION['xoopsUserTheme'] = $xoopsThemeSelect;
540  } else {
541  if (!empty($_SESSION['xoopsUserTheme']) && in_array($_SESSION['xoopsUserTheme'], $this->getConfig('theme_set_allowed'))) {
542  $this->setConfig('theme_set', $_SESSION['xoopsUserTheme']);
543  }
544  }
545  }
546 
555  public function getTplInfo($tpl_name)
556  {
557  $parts = array();
558  $ret = false;
559  $matched = preg_match('#(\w+):(\w+)/(.*)$#', $tpl_name, $parts);
560  if ($matched) {
561  $names = array('tpl_name', 'type', 'module', 'file');
562  $ret = array();
563  for ($i=0; $i<4; ++$i) {
564  $ret[$names[$i]] = $parts[$i];
565  }
566  } else {
567  // this should be eleminated
568  $this->events()->triggerEvent('debug.log', "Sloppy template: " . $tpl_name);
569  $ret = array();
570  $ret['type'] = $this->isAdminSide ? 'admin' : 'module';
571  $info = explode(':', $tpl_name);
572  if (count($info) == 2) {
573  $ret['type'] = $info[0];
574  $tpl_name = str_replace($ret['type'] . ':', '', $tpl_name);
575  }
576 
577  if ($ret['type'] == 'db') {
578  //For legacy compatibility
579  $ret['type'] = $this->isAdminSide ? 'admin' : 'module';
580  }
581 
582  $info = explode('|', $tpl_name);
583  if (count($info) == 2) {
584  $ret['module'] = $info[0];
585  $ret['file'] = $info[1];
586  } else {
587  $ret['module'] = 'system';
588  $ret['file'] = $tpl_name;
589  if ($this->isModule()) {
590  $ret['module'] = $this->module->getVar('dirname', 'n');
591  }
592  }
593  $ret['tpl_name'] = $ret['type'] . ':' . $ret['module'] . '/' . $ret['file'];
594  }
595 
596  return $ret;
597  }
598 
606  public function header($tpl_name = null)
607  {
608  static $included = false;
609  if ($included) {
610  return false;
611  }
612  $included = true;
613 
614  $this->events()->triggerEvent('core.header.start');
615 
616  //For legacy
617  if (!$tpl_name && isset($this->option['template_main'])) {
618  $tpl_name = $this->option['template_main'];
619  $this->deprecated('XoopsOption \'template_main\' is deprecated, please use $xoops->header(\'templatename.tpl\') instead');
620  }
621  $this->theme($tpl_name);
622  $this->tpl()->assign('xoops', $this);
623 
624  if ($this->isAdminSide) {
625  $this->events()->triggerEvent('system.class.gui.header');
626  include_once $this->path('modules/system/themes/default/default.php');
627  $gui = new XoopsGuiDefault();
628  $gui->header();
629  } else {
630  $this->events()->triggerEvent('core.header.addmeta');
631  // Temporary solution for start page redirection
632  if (defined("XOOPS_STARTPAGE_REDIRECTED")) {
633  $smarty = $repeat = null;
634  $this->theme()
635  ->headContent(null, "<base href='" . \XoopsBaseConfig::get('url') . '/modules/' . $this->getConfig('startpage') . "/' />", $smarty, $repeat);
636  }
637 
638  if (@is_object($this->theme()->plugins['XoopsThemeBlocksPlugin'])) {
639  $aggreg = $this->theme()->plugins['XoopsThemeBlocksPlugin'];
640  // Backward compatibility code for pre 2.0.14 themes
641  $this->tpl()->assignByRef('xoops_lblocks', $aggreg->blocks['canvas_left']);
642  $this->tpl()->assignByRef('xoops_rblocks', $aggreg->blocks['canvas_right']);
643  $this->tpl()->assignByRef('xoops_ccblocks', $aggreg->blocks['page_topcenter']);
644  $this->tpl()->assignByRef('xoops_clblocks', $aggreg->blocks['page_topleft']);
645  $this->tpl()->assignByRef('xoops_crblocks', $aggreg->blocks['page_topright']);
646  $this->tpl()->assign('xoops_showlblock', !empty($aggreg->blocks['canvas_left']));
647  $this->tpl()->assign('xoops_showrblock', !empty($aggreg->blocks['canvas_right']));
648  $this->tpl()
649  ->assign('xoops_showcblock', !empty($aggreg->blocks['page_topcenter']) || !empty($aggreg->blocks['page_topleft']) || !empty($aggreg->blocks['page_topright']));
650  }
651 
652  // Sets cache time
653  if ($this->isModule()) {
654  $cache_times = $this->getConfig('module_cache');
655  $this->theme()->contentCacheLifetime = isset($cache_times[$this->module->getVar('mid')]) ? $cache_times[$this->module->getVar('mid')] : 0;
656  // Tricky solution for setting cache time for homepage
657  } else {
658  if ($this->tpl_name == 'module:system/system_homepage.tpl') {
659  // $this->theme->contentCacheLifetime = 604800;
660  }
661  }
662  $this->events()->triggerEvent('core.header.checkcache');
663  if ($this->theme()->checkCache()) {
664  exit();
665  }
666  }
667 
668  if (!isset($this->tpl_name) && $this->isModule()) {
669  ob_start();
670  }
671 
672  $this->events()->triggerEvent('core.header.end');
673  return true;
674  }
675 
681  public function footer()
682  {
683  static $included = false;
684  if ($included) {
685  return false;
686  }
687  $included = true;
688 
689  $this->events()->triggerEvent('core.footer.start');
690 
691  if (!headers_sent()) {
692  header('Content-Type:text/html; charset=' . XoopsLocale::getCharset());
693  header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
694  header('Cache-Control: private, no-cache');
695  header('Pragma: no-cache');
696  }
697 
698  if (isset($this->option['template_main']) && $this->option['template_main'] != $this->theme()->contentTemplate) {
699  trigger_error("xoopsOption[template_main] should be defined before including header.php", E_USER_WARNING);
700  $this->theme()->contentTemplate = $this->tpl_name;
701  }
702  $this->theme()->render();
703  $this->events()->triggerEvent('core.footer.end');
704  exit();
705  }
706 
712  public function isModule()
713  {
714  return $this->module instanceof XoopsModule ? true : false;
715  }
716 
722  public function isUser()
723  {
724  return $this->user instanceof XoopsUser ? true : false;
725  }
726 
732  public function isAdmin()
733  {
734  return $this->userIsAdmin;
735  }
736 
744  public function getHandlerBlock($optional = false)
745  {
746  return $this->getHandler('block', $optional);
747  }
748 
756  public function getHandlerBlockmodulelink($optional = false)
757  {
758  return $this->getHandler('blockmodulelink', $optional);
759  }
760 
768  public function getHandlerConfig($optional = false)
769  {
770  return $this->getHandler('config', $optional);
771  }
772 
780  public function getHandlerConfigitem($optional = false)
781  {
782  return $this->getHandler('configitem', $optional);
783  }
784 
792  public function getHandlerConfigoption($optional = false)
793  {
794  return $this->getHandler('configoption', $optional);
795  }
796 
804  public function getHandlerGroup($optional = false)
805  {
806  return $this->getHandler('group', $optional);
807  }
808 
816  public function getHandlerGroupperm($optional = false)
817  {
818  return $this->getHandler('groupperm', $optional);
819  }
820 
828  public function getHandlerMember($optional = false)
829  {
830  return $this->getHandler('member', $optional);
831  }
832 
840  public function getHandlerMembership($optional = false)
841  {
842  return $this->getHandler('membership', $optional);
843  }
844 
852  public function getHandlerModule($optional = false)
853  {
854  return $this->getHandler('module', $optional);
855  }
856 
864  public function getHandlerOnline($optional = false)
865  {
866  return $this->getHandler('online', $optional);
867  }
868 
876  public function getHandlerPrivmessage($optional = false)
877  {
878  return $this->getHandler('privmessage', $optional);
879  }
880 
888  public function getHandlerRanks($optional = false)
889  {
890  return $this->getHandler('ranks', $optional);
891  }
892 
898  public function session()
899  {
900  if ($this->sessionManager === null) {
901  $this->sessionManager = new \Xoops\Core\Session\Manager();
902  }
903  return $this->sessionManager;
904  }
905 
913  public function getHandlerTplfile($optional = false)
914  {
915  return $this->getHandler('tplfile', $optional);
916  }
917 
925  public function getHandlerTplset($optional = false)
926  {
927  return $this->getHandler('tplset', $optional);
928  }
929 
937  public function getHandlerUser($optional = false)
938  {
939  return $this->getHandler('user', $optional);
940  }
941 
950  public function getHandler($name, $optional = false)
951  {
952  $name = strtolower(trim($name));
953  $class = '';
954  if (!isset($this->kernelHandlers[$name])) {
955  $class = 'Xoops' . ucfirst($name) . 'Handler';
956  if (class_exists($class)) {
957  $this->kernelHandlers[$name] = new $class($this->db());
958  }
959  }
960  if (!isset($this->kernelHandlers[$name])) {
961  $this->logger()->log(
962  $optional ? \Psr\Log\LogLevel::WARNING : \Psr\Log\Loglevel::ERROR,
963  'Class <strong>' . $class . '</strong> does not exist<br />Handler Name: ' . $name
964  );
965  } else {
966  return $this->kernelHandlers[$name];
967  }
968  return false;
969  }
970 
980  public function getModuleHandler($name = null, $module_dir = null, $optional = false)
981  {
982  // if $module_dir is not specified
983  if (!isset($module_dir)) {
984  // if a module is loaded
985  if ($this->module instanceof XoopsModule) {
986  $module_dir = $this->module->getVar('dirname', 'n');
987  } else {
988  trigger_error('No Module is loaded', E_USER_ERROR);
989  }
990  } else {
991  $module_dir = trim($module_dir);
992  }
993  $name = (!isset($name)) ? $module_dir : trim($name);
994  if (!isset($this->moduleHandlers[$module_dir][$name])) {
995  if (XoopsLoad::fileExists($hnd_file = \XoopsBaseConfig::get('root-path') . "/modules/{$module_dir}/class/{$name}.php")) {
996  include_once $hnd_file;
997  }
998  $class = ucfirst(strtolower($module_dir)) . ucfirst($name) . 'Handler';
999  if (class_exists($class)) {
1000  $this->moduleHandlers[$module_dir][$name] = new $class($this->db());
1001  }
1002  }
1003  if (!isset($this->moduleHandlers[$module_dir][$name])) {
1004  trigger_error('Handler does not exist<br />Module: ' . $module_dir . '<br />Name: ' . $name, $optional ? E_USER_WARNING : E_USER_ERROR);
1005  }
1006  if (isset($this->moduleHandlers[$module_dir][$name])) {
1007  return $this->moduleHandlers[$module_dir][$name];
1008  }
1009  return false;
1010  }
1011 
1021  public function getModuleForm($obj, $name, $module_dir = null)
1022  {
1023  if (empty($name)) {
1024  return false;
1025  }
1026  if (empty($module_dir)) {
1027  if ($this->isModule()) {
1028  $module_dir = $this->module->getVar('dirname', 'n');
1029  } else {
1030  return false;
1031  }
1032  }
1033  if (XoopsLoad::fileExists($hnd_file = \XoopsBaseConfig::get('root-path') . "/modules/{$module_dir}/class/form/{$name}.php")) {
1034  include_once $hnd_file;
1035  $class = ucfirst(strtolower($module_dir)) . ucfirst($name) . 'Form';
1036  if (class_exists($class)) {
1037  $instance = new $class($obj);
1038  if ($instance instanceof \Xoops\Form\Form) {
1039  return $instance;
1040  }
1041  }
1042  }
1043  return false;
1044  }
1045 
1053  public function getModuleHelper($dirname)
1054  {
1055  return \Xoops\Module\Helper::getHelper($dirname);
1056  }
1057 
1070  public function loadLanguage($name, $domain = '', $language = null)
1071  {
1072  if (empty($name)) {
1073  return false;
1074  }
1075 
1077  // expanded domain to multiple categories, e.g. module:Fsystem, framework:filter, etc.
1078  if ((empty($domain) || 'global' == $domain)) {
1079  $path = '';
1080  } else {
1081  $path = (is_array($domain)) ? array_shift($domain) . '/' : "modules/{$domain}/";
1082  }
1083  $path .= 'language';
1084 
1085  if (!XoopsLoad::fileExists($file = $this->path("{$path}/{$language}/{$name}.php"))) {
1086  if (!XoopsLoad::fileExists($file = $this->path("{$path}/english/{$name}.php"))) {
1087  return false;
1088  }
1089  }
1090  $ret = include_once $file;
1091  return $ret;
1092  }
1093 
1102  public static function loadLocale($domain = 'xoops', $locale = null)
1103  {
1104  return Xoops_Locale::loadLocale($domain, $locale);
1105  }
1106 
1115  public function translate($key, $dirname = 'xoops')
1116  {
1117  return Xoops_Locale::translate($key, $dirname);
1118  }
1119 
1125  public function getActiveModules()
1126  {
1127  if (is_array($this->activeModules)) {
1128  return $this->activeModules;
1129  }
1130 
1131  try {
1132  if (!$this->activeModules = $this->cache()->read('system/modules/active')) {
1133  $this->activeModules = $this->setActiveModules();
1134  }
1135  } catch (\Exception $e) {
1136  $this->activeModules = array();
1137  }
1138  return $this->activeModules;
1139  }
1140 
1146  public function setActiveModules()
1147  {
1148  $module_handler = $this->getHandlerModule();
1149  $modules_array = $module_handler->getAll(new Criteria('isactive', 1), array('dirname'), false, false);
1150  $modules_active = array();
1151  foreach ($modules_array as $module) {
1152  $modules_active[$module['mid']] = $module['dirname'];
1153  }
1154  $this->cache()->write('system/modules/active', $modules_active);
1155  return $modules_active;
1156  }
1157 
1165  public function isActiveModule($dirname)
1166  {
1167  if (isset($dirname) && in_array($dirname, $this->getActiveModules())) {
1168  return true;
1169  }
1170  return false;
1171  }
1172 
1178  public function getModuleByDirname($dirname)
1179  {
1180  $key = "system/module/dirname/{$dirname}";
1181  if (!$module = $this->cache()->read($key)) {
1182  $module = $this->getHandlerModule()->getByDirname($dirname);
1183  $this->cache()->write($key, $module);
1184  }
1185  return $module;
1186  }
1187 
1195  public function getModuleById($id)
1196  {
1197  $key = "system/module/id/{$id}";
1198  if (!$module = $this->cache()->read($key)) {
1199  $module = $this->getHandlerModule()->getById($id);
1200  $this->cache()->write($key, $module);
1201  }
1202  return $module;
1203  }
1204 
1212  public function simpleHeader($closehead = true)
1213  {
1214  $this->events()->triggerEvent('core.header.start');
1215  $this->theme();
1216  $xoopsConfigMetaFooter = $this->getConfigs();
1218 
1219  if (!headers_sent()) {
1220  header('Content-Type:text/html; charset=' . XoopsLocale::getCharset());
1221  header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
1222  header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
1223  header('Cache-Control: no-store, no-cache, max-age=1, s-maxage=1, must-revalidate, post-check=0, pre-check=0');
1224  header("Pragma: no-cache");
1225  }
1226 
1227  echo "<!DOCTYPE html>\n";
1229  echo '<html lang="' . XoopsLocale::getLangCode() . '">
1230  <head>
1231  <meta http-equiv="content-type" content="text/html; charset=' . XoopsLocale::getCharset() . '" />
1232  <meta name="robots" content="' . htmlspecialchars($xoopsConfigMetaFooter['meta_robots']) . '" />
1233  <meta name="keywords" content="' . htmlspecialchars($xoopsConfigMetaFooter['meta_keywords']) . '" />
1234  <meta name="description" content="' . htmlspecialchars($xoopsConfigMetaFooter['meta_description']) . '" />
1235  <meta name="rating" content="' . htmlspecialchars($xoopsConfigMetaFooter['meta_rating']) . '" />
1236  <meta name="author" content="' . htmlspecialchars($xoopsConfigMetaFooter['meta_author']) . '" />
1237  <meta name="generator" content="XOOPS" />
1238  <title>' . htmlspecialchars($this->getConfig('sitename')) . '</title>
1239  <script type="text/javascript" src="' . $xoops_url . '/include/xoops.js"></script>
1240  <script type="text/javascript" src="' . $xoops_url . '/media/jquery/jquery.js"></script>
1241  <script type="text/javascript" src="' . $xoops_url . '/media/bootstrap/js/bootstrap.min.js"></script>';
1242  $themecss = $this->getCss($this->getConfig('theme_set'));
1243  echo '<link rel="stylesheet" type="text/css" media="all" href="' . $xoops_url . '/xoops.css" />';
1244  $locale = $this->getConfig('locale');
1245  if (XoopsLoad::fileExists($this->path('locale/' . $locale . '/style.css'))) {
1246  echo '<link rel="stylesheet" type="text/css" media="all" href="' . $xoops_url . '/locale/' . $locale . '/style.css" />';
1247  }
1248  if ($themecss) {
1249  echo '<link rel="stylesheet" type="text/css" media="all" href="' . $themecss . '" />';
1250  //echo '<link rel="stylesheet" type="text/css" media="screen" href="' . $this->url('themes/' . $this->getConfig('theme_set') . '/media/bootstrap/css/bootstrap.css') .'" />';
1251  echo '<link rel="stylesheet" type="text/css" media="screen" href="' . $this->url('themes/' . $this->getConfig('theme_set') . '/media/bootstrap/css/xoops.bootstrap.css') .'" />';
1252  }
1253  if ($closehead) {
1254  echo '</head><body>';
1255  }
1256  }
1257 
1263  public function simpleFooter()
1264  {
1265  $this->events()->triggerEvent('core.header.footer');
1266  echo '</body></html>';
1267  ob_end_flush();
1268  }
1278  public function alert($type, $msg, $title = '/')
1279  {
1280  $tpl = new \XoopsTpl();
1281  $alert_msg = '';
1282  switch ($type) {
1283  case 'info':
1284  default:
1285  $tpl->assign('alert_type', 'alert-info');
1286  if ($title == '/') {
1287  $title = XoopsLocale::INFORMATION;
1288  }
1289  break;
1290 
1291  case 'error':
1292  $tpl->assign('alert_type', 'alert-error');
1293  if ($title == '/') {
1294  $title = XoopsLocale::ERROR;
1295  }
1296  break;
1297 
1298  case 'success':
1299  $tpl->assign('alert_type', 'alert-success');
1300  if ($title == '/') {
1301  $title = XoopsLocale::SUCCESS;
1302  }
1303  break;
1304 
1305  case 'warning':
1306  $tpl->assign('alert_type', '');
1307  if ($title == '/') {
1308  $title = XoopsLocale::WARNING;
1309  }
1310  break;
1311  }
1312 
1313  if ($title != '') {
1314  $tpl->assign('alert_title', $title);
1315  }
1316  if (!is_scalar($msg) && !is_array($msg)) {
1317  $msg = ''; // don't know what to do with this, so make it blank
1318  }
1319  if (is_array($msg)) {
1320  // if this is not a simple array of strings, this might not work
1321  $alert_msg = @implode("<br />", $msg);
1322  } else {
1323  $alert_msg = $msg;
1324  }
1325  if ($alert_msg == '') {
1326  return '';
1327  } else {
1328  $tpl->assign('alert_msg', $alert_msg);
1329  $ret = $tpl->fetch('module:system/system_alert.tpl');
1330  return $ret;
1331  }
1332  }
1333 
1345  public function confirm($hiddens, $action, $msg, $submit = '', $addtoken = true)
1346  {
1347  $tpl = new \XoopsTpl();
1348  $submit = ($submit != '') ? trim($submit) : XoopsLocale::A_SUBMIT;
1349  $tpl->assign('msg', $msg);
1350  $tpl->assign('action', $action);
1351  $tpl->assign('submit', $submit);
1352  $str_hiddens = '';
1353  foreach ($hiddens as $name => $value) {
1354  if (is_array($value)) {
1355  foreach ($value as $caption => $newvalue) {
1356  $str_hiddens .= '<input type="radio" name="' . $name . '" value="' . htmlspecialchars($newvalue) . '" > ' . $caption . NWLINE;
1357  }
1358  $str_hiddens .= '<br />' . NWLINE;
1359  } else {
1360  $str_hiddens .= '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($value) . '" />' . NWLINE;
1361  }
1362  }
1363  if ($addtoken != false) {
1364  $tpl->assign('token', $this->security()->getTokenHTML());
1365  }
1366  $tpl->assign('hiddens', $str_hiddens);
1367  return $tpl->fetch('module:system/system_confirm.tpl');
1368  }
1369 
1378  public function getUserTimestamp($time, $timeoffset = '')
1379  {
1380  if ($timeoffset == '') {
1381  if ($this->isUser()) {
1382  $timeoffset = $this->user->getVar('timezone_offset');
1383  } else {
1384  $timeoffset = $this->getConfig('default_TZ');
1385  }
1386  }
1387  $usertimestamp = intval($time) + (floatval($timeoffset) - $this->getConfig('server_TZ')) * 3600;
1388  return (int)$usertimestamp;
1389  }
1390 
1399  public function userTimeToServerTime($timestamp, $userTZ = null)
1400  {
1401  if (!isset($userTZ)) {
1402  $userTZ = $this->getConfig('default_TZ');
1403  }
1404  $timestamp = $timestamp - (($userTZ - $this->getConfig('server_TZ')) * 3600);
1405  return (int)$timestamp;
1406  }
1407 
1411  public function getUserGroups()
1412  {
1413  $groups = $this->isUser() ? $this->user->getGroups() : array(FixedGroups::ANONYMOUS);
1414 
1415  return $groups;
1416  }
1417 
1421  public function makePass()
1422  {
1423  $makepass = '';
1424  $syllables = array(
1425  'er', 'in', 'tia', 'wol', 'fe', 'pre', 'vet', 'jo', 'nes', 'al', 'len', 'son', 'cha', 'ir', 'ler', 'bo',
1426  'ok', 'tio', 'nar', 'sim', 'ple', 'bla', 'ten', 'toe', 'cho', 'co', 'lat', 'spe', 'ak', 'er', 'po', 'co',
1427  'lor', 'pen', 'cil', 'li', 'ght', 'wh', 'at', 'the', 'he', 'ck', 'is', 'mam', 'bo', 'no', 'fi', 've', 'any',
1428  'way', 'pol', 'iti', 'cs', 'ra', 'dio', 'sou', 'rce', 'sea', 'rch', 'pa', 'per', 'com', 'bo', 'sp', 'eak',
1429  'st', 'fi', 'rst', 'gr', 'oup', 'boy', 'ea', 'gle', 'tr', 'ail', 'bi', 'ble', 'brb', 'pri', 'dee', 'kay',
1430  'en', 'be', 'se'
1431  );
1432  for ($count = 1; $count <= 4; ++$count) {
1433  if (1 == rand() % 10) {
1434  $makepass .= sprintf('%0.0f', (rand() % 50) + 1);
1435  } else {
1436  $makepass .= sprintf('%s', $syllables[rand() % 62]);
1437  }
1438  }
1439  return $makepass;
1440  }
1441 
1450  public function checkEmail($email, $antispam = false)
1451  {
1452  if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
1453  return false;
1454  }
1455  if ($antispam) {
1456  $email = str_replace("@", " at ", $email);
1457  $email = str_replace(".", " dot ", $email);
1458  }
1459  return $email;
1460  }
1461 
1469  public function formatURL($url)
1470  {
1471  $url = trim($url);
1472  if ($url != '') {
1473  if (!preg_match('/^(https?|ftps?|ed2k)\:\/\//i', $url)) {
1474  $url = 'http://' . $url;
1475  }
1476  }
1477  return $url;
1478  }
1479 
1485  public function getBanner()
1486  {
1487  $options = '';
1488  $this->events()->triggerEvent('core.banner.display', array(&$options));
1489  return $options;
1490  }
1491 
1503  public function redirect($url, $time = 3, $message = '', $addredirect = true, $allowExternalLink = false)
1504  {
1505  $this->events()->triggerEvent('core.include.functions.redirectheader.start', array(
1506  $url, $time, $message, $addredirect, $allowExternalLink
1507  ));
1508  // if conditions are right, system preloads will exit on this call
1509  // so don't use it if you want to be called, use start version above.
1510  $this->events()->triggerEvent('core.include.functions.redirectheader', array(
1511  $url, $time, $message, $addredirect, $allowExternalLink
1512  ));
1513 
1515 
1516  if (preg_match("/[\\0-\\31]|about:|script:/i", $url)) {
1517  if (!preg_match('/^\b(java)?script:([\s]*)history\.go\(-[0-9]*\)([\s]*[;]*[\s]*)$/si', $url)) {
1518  $url = $xoops_url;
1519  }
1520  }
1521  if (!$allowExternalLink && $pos = strpos($url, '://')) {
1522  $xoopsLocation = substr($xoops_url, strpos($xoops_url, '://') + 3);
1523  if (strcasecmp(substr($url, $pos + 3, strlen($xoopsLocation)), $xoopsLocation)) {
1524  $url = $xoops_url;
1525  }
1526  }
1527  if (!defined('XOOPS_CPFUNC_LOADED')) {
1528  $theme = 'default';
1529  } else {
1530  $theme = $this->getConfig('theme_set');
1531  }
1532 
1533  $xoopsThemeFactory = null;
1534  $xoopsThemeFactory = new XoopsThemeFactory();
1535  $xoopsThemeFactory->allowedThemes = $this->getConfig('theme_set_allowed');
1536  $xoopsThemeFactory->defaultTheme = $theme;
1537  $this->setTheme($xoopsThemeFactory->createInstance(array(
1538  "plugins" => array(), "renderBanner" => false
1539  )));
1540  $this->setTpl($this->theme()->template);
1541  $this->tpl()->assign(array(
1542  'xoops_theme' => $theme, 'xoops_imageurl' => \XoopsBaseConfig::get('themes-url') . '/' . $theme . '/',
1543  'xoops_themecss' => $this->getCss($theme),
1544  'xoops_requesturi' => htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES),
1545  'xoops_sitename' => htmlspecialchars($this->getConfig('sitename'), ENT_QUOTES),
1546  'xoops_slogan' => htmlspecialchars($this->getConfig('slogan'), ENT_QUOTES),
1547  'xoops_dirname' => $this->isModule() ? $this->module->getVar('dirname') : 'system',
1548  'xoops_pagetitle' => $this->isModule() ? $this->module->getVar('name') : htmlspecialchars($this->getConfig('slogan'), ENT_QUOTES)
1549  ));
1550 
1551  $this->tpl()->assign('time', intval($time));
1552  if (!empty($_SERVER['REQUEST_URI']) && $addredirect && strstr($url, 'user.php')) {
1553  $joiner = (false===strpos($url, '?')) ? '?' : '&amp;';
1554  $url .= $joiner . 'xoops_redirect=' . urlencode($_SERVER['REQUEST_URI']);
1555  }
1556  $url = preg_replace("/&amp;/i", '&', htmlspecialchars($url, ENT_QUOTES));
1557  $this->tpl()->assign('url', $url);
1558  $message = trim($message) != '' ? $message : XoopsLocale::E_TAKING_YOU_BACK;
1559  $this->tpl()->assign('message', $message);
1560  $this->tpl()->assign('lang_ifnotreload', sprintf(XoopsLocale::F_IF_PAGE_NOT_RELOAD_CLICK_HERE, $url));
1561 
1562  $this->events()->triggerEvent('core.include.functions.redirectheader.end');
1563  $this->tpl()->display('module:system/system_redirect.tpl');
1564  exit();
1565  }
1566 
1574  public function getEnv($key)
1575  {
1576  $ret = '';
1577  if (array_key_exists($key, $_SERVER) && isset($_SERVER[$key])) {
1578  $ret = $_SERVER[$key];
1579  return $ret;
1580  }
1581  if (array_key_exists($key, $_ENV) && isset($_ENV[$key])) {
1582  $ret = $_ENV[$key];
1583  return $ret;
1584  }
1585  return $ret;
1586  }
1587 
1595  public function getCss($theme = '')
1596  {
1597  if ($theme == '') {
1598  $theme = $this->getConfig('theme_set');
1599  }
1600  $uagent = $this->getEnv('HTTP_USER_AGENT');
1601  if (stristr($uagent, 'mac')) {
1602  $str_css = 'styleMAC.css';
1603  } elseif (preg_match("/MSIE ([0-9]\.[0-9]{1,2})/i", $uagent)) {
1604  $str_css = 'style.css';
1605  } else {
1606  $str_css = 'styleNN.css';
1607  }
1608  $xoops_theme_path = \XoopsBaseConfig::get('themes-path');
1609  $xoops_theme_url = \XoopsBaseConfig::get('themes-url');
1610  if (is_dir($xoops_theme_path . '/' . $theme)) {
1611  if (XoopsLoad::fileExists($xoops_theme_path . '/' . $theme . '/' . $str_css)) {
1612  return $xoops_theme_url . '/' . $theme . '/' . $str_css;
1613  } elseif (XoopsLoad::fileExists($xoops_theme_path . '/' . $theme . '/style.css')) {
1614  return $xoops_theme_url . '/' . $theme . '/style.css';
1615  }
1616  }
1617  if (is_dir($xoops_theme_path . '/' . $theme . '/css')) {
1618  if (XoopsLoad::fileExists($xoops_theme_path . '/' . $theme . '/css/' . $str_css)) {
1619  return $xoops_theme_url . '/' . $theme . '/css/' . $str_css;
1620  } elseif (XoopsLoad::fileExists($xoops_theme_path . '/' . $theme . '/css/style.css')) {
1621  return $xoops_theme_url . '/' . $theme . '/css/style.css';
1622  }
1623  }
1624  return '';
1625  }
1626 
1632  public function getMailer()
1633  {
1634  static $mailer;
1635  if (is_object($mailer)) {
1636  return $mailer;
1637  }
1639  if (class_exists('XoopsMailerLocale')) {
1640  $mailer = new XoopsMailerLocale();
1641  } else {
1642  $mailer = new XoopsMailer();
1643  }
1644  return $mailer;
1645  }
1646 
1655  public function getRank($rank_id = 0, $posts = 0)
1656  {
1658  $rank_id = intval($rank_id);
1659  $posts = intval($posts);
1660  $db = $this->db();
1661  $sql = $db->createXoopsQueryBuilder()
1662  ->select('r.rank_title AS title')
1663  ->addSelect('r.rank_image AS image')
1664  ->fromPrefix('ranks', 'r');
1665  $eb = $sql->expr();
1666  if ($rank_id != 0) {
1667  $sql->where($eb->eq('r.rank_id', ':rank'))
1668  ->setParameter(':rank', $rank_id, \PDO::PARAM_INT);
1669  } else {
1670  $sql->where($eb->lte('r.rank_min', ':posts'))
1671  ->andWhere($eb->gte('r.rank_max', ':posts'))
1672  ->andWhere($eb->eq('r.rank_special', 0))
1673  ->setParameter(':posts', $posts, \PDO::PARAM_INT);
1674  }
1675 
1676  $rank = $db->fetchAssoc($sql->getSql(), $sql->getParameters());
1677 
1678  $rank['title'] = $myts->htmlspecialchars($rank['title']);
1679  $rank['id'] = $rank_id;
1680  return $rank;
1681 
1682  }
1683 
1691  public function getOption($key)
1692  {
1693  $ret = '';
1694  if (isset($this->option[$key])) {
1695  $ret = $this->option[$key];
1696  }
1697  return $ret;
1698  }
1699 
1708  public function setOption($key, $value = null)
1709  {
1710  if (!is_null($value)) {
1711  $this->option[$key] = $value;
1712  }
1713  }
1714 
1722  public function getConfig($key)
1723  {
1724  return $this->getModuleConfig($key, 'system');
1725  }
1726 
1732  public function getConfigs()
1733  {
1734  return $this->getModuleConfigs('system');
1735  }
1736 
1745  public function addConfigs($configs, $dirname = 'system')
1746  {
1747  $dirname = trim(strtolower($dirname));
1748  if (empty($dirname)) {
1749  $dirname = $this->isModule() ? $this->module->getVar('dirname') : 'system';
1750  }
1751  if (!empty($dirname)) {
1752  $this->moduleConfigs[$dirname] = array_merge($this->moduleConfigs[$dirname], (array)$configs);
1753  }
1754  }
1755 
1765  public function setConfig($key, $value = null, $dirname = 'system')
1766  {
1767  if (!is_null($value)) {
1768  $dirname = trim(strtolower($dirname));
1769  if (empty($dirname)) {
1770  $dirname = $this->isModule() ? $this->module->getVar('dirname') : 'system';
1771  }
1772  $this->moduleConfigs[$dirname][$key] =& $value;
1773  }
1774  }
1775 
1786  public function appendConfig($key, array $values, $appendWithKey = false, $dirname = 'system')
1787  {
1788  $dirname = trim(strtolower($dirname));
1789  if (empty($dirname)) {
1790  $dirname = $this->isModule() ? $this->module->getVar('dirname') : 'system';
1791  }
1792  if ($appendWithKey) {
1793  foreach ($values as $key2 => $value) {
1794  if (!isset($this->moduleConfigs[$dirname][$key]) || !is_array($this->moduleConfigs[$dirname][$key])) {
1795  $this->moduleConfigs[$dirname][$key] = array();
1796  }
1797  $this->moduleConfigs[$dirname][$key][$key2] =& $value;
1798  }
1799  } else {
1800  $this->moduleConfigs[$dirname][$key][] =& $values;
1801  }
1802  }
1803 
1812  public function getModuleConfig($key, $dirname = '')
1813  {
1814  $dirname = trim(strtolower($dirname));
1815  if (empty($dirname)) {
1816  $dirname = $this->isModule() ? $this->module->getVar('dirname') : 'system';
1817  }
1818 
1819  if (isset($this->moduleConfigs[$dirname][$key])) {
1820  return $this->moduleConfigs[$dirname][$key];
1821  }
1822 
1823  $this->getModuleConfigs($dirname);
1824 
1825  if (!isset($this->moduleConfigs[$dirname][$key])) {
1826  $this->moduleConfigs[$dirname][$key] = '';
1827  }
1828  return $this->moduleConfigs[$dirname][$key];
1829  }
1830 
1838  public function getModuleConfigs($dirname = '')
1839  {
1840  $dirname = trim($dirname);
1841  if (empty($dirname)) {
1842  $dirname = $this->isModule() ? $this->module->getVar('dirname') : 'system';
1843  }
1844  if (isset($this->moduleConfigs[$dirname])) {
1845  return $this->moduleConfigs[$dirname];
1846  }
1847  $this->moduleConfigs[$dirname] = array();
1848  $key = "system/module/configs/{$dirname}";
1849  if (!$configs = $this->cache()->read($key)) {
1850  $module = $this->getModuleByDirname($dirname);
1851  if (is_object($module)) {
1852  $configs = $this->getHandlerConfig()->getConfigsByModule($module->getVar('mid'));
1853  $this->cache()->write($key, $configs);
1854  $this->moduleConfigs[$dirname] =& $configs;
1855  }
1856  } else {
1857  $this->moduleConfigs[$dirname] =& $configs;
1858  }
1859 
1860  if ($this->isModule()) {
1861  //for legacy
1862  $this->moduleConfig =& $this->moduleConfigs[$this->module->getVar('dirname')];
1863  }
1864  if ($dirname == 'system') {
1865  $this->config =& $this->moduleConfigs['system'];
1866  }
1867  return $this->moduleConfigs[$dirname];
1868  }
1869 
1875  public function disableModuleCache()
1876  {
1877  if ($this->isModule()) {
1878  $this->appendConfig('module_cache', array($this->module->getVar('mid') => 0), true);
1879  }
1880  }
1881 
1896  public function getBaseDomain($url, $includeSubdomain = false, $returnObject = false)
1897  {
1898  $pslManager = new \Pdp\PublicSuffixListManager();
1899  $parser = new \Pdp\Parser($pslManager->getList());
1900 
1901  $url=mb_strtolower($url, 'UTF-8');
1902 
1903  try {
1904  // use php-domain-parser to give us just the domain
1905  $pdp = $parser->parseUrl($url);
1906  $host = $pdp->host->host;
1907  } catch (\Exception $e) {
1908  $this->events()->triggerEvent('core.exception', $e);
1909  return null;
1910  }
1911  // check for exceptions, localhost and ip address (v4 & v6)
1912  if (!empty($host)) {
1913  // localhost exception
1914  if ($host=='localhost') {
1915  return $returnObject ? $pdp->host : $host;
1916  }
1917  // Check for IPV6 URL (see http://www.ietf.org/rfc/rfc2732.txt)
1918  // strip brackets before validating
1919  if (substr($host, 0, 1)=='[' && substr($host, -1)==']') {
1920  $host = substr($host, 1, (strlen($host)-2));
1921  }
1922  // ip address exception
1923  if (filter_var($host, FILTER_VALIDATE_IP)) {
1924  return $returnObject ? new \Pdp\Uri\Url\Host(null, null, null, $host) : $host;
1925  }
1926  }
1927 
1928  $host = $pdp->host->registerableDomain;
1929  if (!empty($host) && $includeSubdomain) {
1930  $host = $pdp->host->host;
1931  }
1932  return $returnObject ? $pdp->host : $host;
1933  }
1934 
1942  public function templateTouch($tpl_id)
1943  {
1944  $tplfile = $this->getHandlerTplfile()->get($tpl_id);
1945 
1946  if (is_object($tplfile)) {
1947  $file = $tplfile->getVar('tpl_file', 'n');
1948  $module = $tplfile->getVar('tpl_module', 'n');
1949  $type = $tplfile->getVar('tpl_type', 'n');
1950  $tpl = new XoopsTpl();
1951  return $tpl->touch($type . ':' . $module . '/' . $file);
1952  }
1953  return false;
1954  }
1955 
1964  {
1965  $module = $this->getModuleById($mid);
1966  $xoopsTpl = new XoopsTpl();
1967  $xoopsTpl->clearModuleCompileCache($module->getVar('dirname'));
1968  }
1969 
1977  public function deprecated($message)
1978  {
1979  $message = $this->logger()->sanitizePath($message);
1980  $this->events()->triggerEvent('core.deprecated', array($message));
1981  }
1982 
1988  public function disableErrorReporting()
1989  {
1990  //error_reporting(0);
1991  $this->events()->triggerEvent('core.disableerrorreporting');
1992  }
1993 }
db()
Definition: Xoops.php:175
$mid
Definition: index.php:39
normalizePath($path)
Definition: Xoops.php:406
footer()
Definition: Xoops.php:681
getHandlerConfigitem($optional=false)
Definition: Xoops.php:780
getHandlerBlockmodulelink($optional=false)
Definition: Xoops.php:756
const A_SUBMIT
Definition: en_US.php:128
static getLegacyLanguage()
Definition: Abstract.php:76
$path
Definition: execute.php:31
preload()
Definition: Xoops.php:224
getHandlerGroupperm($optional=false)
Definition: Xoops.php:816
$_SESSION['RF']["verify"]
Definition: dialog.php:4
getMailer()
Definition: Xoops.php:1632
getModuleHandler($name=null, $module_dir=null, $optional=false)
Definition: Xoops.php:980
getHandlerModule($optional=false)
Definition: Xoops.php:852
deprecated($message)
Definition: Xoops.php:1977
$tpl
Definition: Xoops.php:73
$moduleConfigs
Definition: Xoops.php:111
$xoops_url
Definition: backend.php:32
setConfig($key, $value=null, $dirname= 'system')
Definition: Xoops.php:1765
getModuleConfig($key, $dirname= '')
Definition: Xoops.php:1812
$i
Definition: dialog.php:68
getHandlerPrivmessage($optional=false)
Definition: Xoops.php:876
templateClearModuleCache($mid)
Definition: Xoops.php:1963
static getInstance()
Definition: Xoops.php:160
isUser()
Definition: Xoops.php:722
if(!isset($xoops->paths[$path_type])) if($path_type== 'var') $file
Definition: browse.php:55
loadLanguage($name, $domain= '', $language=null)
Definition: Xoops.php:1070
$user
Definition: Xoops.php:58
events()
Definition: Xoops.php:214
$options['editor']
$query
Definition: index.php:37
static loadLocale($domain= 'xoops', $locale=null)
Definition: Xoops.php:1102
const E_TAKING_YOU_BACK
Definition: en_US.php:368
$_SERVER['REQUEST_URI']
$xoopsTpl
Definition: xoops_code.php:45
$activeModules
Definition: Xoops.php:106
$action
Definition: misc.php:32
getHandlerTplfile($optional=false)
Definition: Xoops.php:913
getHandlerMembership($optional=false)
Definition: Xoops.php:840
redirect($url, $time=3, $message= '', $addredirect=true, $allowExternalLink=false)
Definition: Xoops.php:1503
$paths
Definition: Xoops.php:83
setTpl(XoopsTpl $tpl)
Definition: Xoops.php:304
theme($tpl_name=null)
Definition: Xoops.php:314
const VERSION
Definition: Xoops.php:28
$moduleDirname
Definition: Xoops.php:53
setTheme(XoopsTheme $theme)
Definition: Xoops.php:364
buildUrl($url, $params=array())
Definition: Xoops.php:431
$isAdminSide
Definition: Xoops.php:116
gzipCompression()
Definition: Xoops.php:480
getTplInfo($tpl_name)
Definition: Xoops.php:555
$option
Definition: Xoops.php:68
getHandlerGroup($optional=false)
Definition: Xoops.php:804
tpl()
Definition: Xoops.php:292
$userIsAdmin
Definition: Xoops.php:63
confirm($hiddens, $action, $msg, $submit= '', $addtoken=true)
Definition: Xoops.php:1345
getConfig($key)
Definition: Xoops.php:1722
registry()
Definition: Xoops.php:264
getActiveModules()
Definition: Xoops.php:1125
isActiveModule($dirname)
Definition: Xoops.php:1165
exit
Definition: browse.php:104
getUserGroups()
Definition: Xoops.php:1411
getBaseDomain($url, $includeSubdomain=false, $returnObject=false)
Definition: Xoops.php:1896
getHandlerRanks($optional=false)
Definition: Xoops.php:888
setOption($key, $value=null)
Definition: Xoops.php:1708
simpleFooter()
Definition: Xoops.php:1263
$xoops
Definition: admin.php:25
$id
Definition: admin_menu.php:36
$root
appendConfig($key, array $values, $appendWithKey=false, $dirname= 'system')
Definition: Xoops.php:1786
header($tpl_name=null)
Definition: Xoops.php:606
templateTouch($tpl_id)
Definition: Xoops.php:1942
$module
Definition: Xoops.php:38
session()
Definition: Xoops.php:898
disableModuleCache()
Definition: Xoops.php:1875
getModuleHelper($dirname)
Definition: Xoops.php:1053
static fileExists($file)
Definition: xoopsload.php:506
translate($key, $dirname= 'xoops')
Definition: Xoops.php:1115
const E_FILE_NOT_FOUND
Definition: en_US.php:327
getHandlerMember($optional=false)
Definition: Xoops.php:828
makePass()
Definition: Xoops.php:1421
static get($name)
getEnv($key)
Definition: Xoops.php:1574
if(isset($_POST['name'])) $info
Definition: execute.php:57
getCss($theme= '')
Definition: Xoops.php:1595
$xoops isAdminSide
Definition: admin.php:26
$configs
Definition: config.php:27
assets()
Definition: Xoops.php:234
getHandlerConfig($optional=false)
Definition: Xoops.php:768
formatURL($url)
Definition: Xoops.php:1469
logger()
Definition: Xoops.php:203
$sql
Definition: pda.php:32
$type
Definition: misc.php:33
cache($cacheName= 'default')
Definition: Xoops.php:187
static loadMailerLocale()
Definition: Locale.php:108
simpleHeader($closehead=true)
Definition: Xoops.php:1212
themeSelect()
Definition: Xoops.php:534
disableErrorReporting()
Definition: Xoops.php:1988
url($url)
Definition: Xoops.php:418
$groups
static getLangCode()
Definition: Abstract.php:68
userTimeToServerTime($timestamp, $userTZ=null)
Definition: Xoops.php:1399
const WARNING
Definition: install.php:39
getOption($key)
Definition: Xoops.php:1691
static translate($key, $dirname= 'xoops')
Definition: Locale.php:128
$url
Definition: register.php:72
getHandlerUser($optional=false)
Definition: Xoops.php:937
$modules_array
Definition: main.php:54
pathExists($path, $error_type)
Definition: Xoops.php:459
$GLOBALS['xoops']
Definition: common.php:33
addConfigs($configs, $dirname= 'system')
Definition: Xoops.php:1745
isModule()
Definition: Xoops.php:712
if(!is_object($module)||!$module->getVar('isactive')) $msg
Definition: groupperm.php:38
$dirname
Definition: backend.php:38
$var
Definition: userinfo.php:125
$module_handler
Definition: main.php:55
path($url, $virtual =false)
Definition: Xoops.php:377
getModuleForm($obj, $name, $module_dir=null)
Definition: Xoops.php:1021
$sessionManager
Definition: Xoops.php:33
setActiveModules()
Definition: Xoops.php:1146
$language
getModuleConfigs($dirname= '')
Definition: Xoops.php:1838
checkEmail($email, $antispam=false)
Definition: Xoops.php:1450
service($service)
Definition: Xoops.php:250
const F_IF_PAGE_NOT_RELOAD_CLICK_HERE
Definition: en_US.php:414
getHandlerConfigoption($optional=false)
Definition: Xoops.php:792
alert($type, $msg, $title= '/')
Definition: Xoops.php:1278
getRank($rank_id=0, $posts=0)
Definition: Xoops.php:1655
$modules_active
$myts
Definition: edituser.php:38
getModuleById($id)
Definition: Xoops.php:1195
static loadLocale($domain= 'xoops')
Definition: Locale.php:58
isAdmin()
Definition: Xoops.php:732
$tpl_name
Definition: Xoops.php:91
__construct()
Definition: Xoops.php:121
$kernelHandlers
Definition: Xoops.php:96
const INFORMATION
Definition: en_US.php:479
$theme
Definition: Xoops.php:78
security()
Definition: Xoops.php:278
getUserTimestamp($time, $timeoffset= '')
Definition: Xoops.php:1378
getHandler($name, $optional=false)
Definition: Xoops.php:950
getConfigs()
Definition: Xoops.php:1732
$config
Definition: Xoops.php:43
getModuleByDirname($dirname)
Definition: Xoops.php:1178
getHandlerTplset($optional=false)
Definition: Xoops.php:925
pathTranslation()
Definition: Xoops.php:502
getHandlerBlock($optional=false)
Definition: Xoops.php:744
getHandlerOnline($optional=false)
Definition: Xoops.php:864
$email
Definition: lostpass.php:32
$moduleConfig
Definition: Xoops.php:48
$xoops option
Definition: common.php:63
$moduleHandlers
Definition: Xoops.php:101
getBanner()
Definition: Xoops.php:1485