| 1: | <?php
|
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: |
|
| 16: | defined('XOOPS_MAINFILE_INCLUDED') || die('Restricted access');
|
| 17: |
|
| 18: | global $xoops, $xoopsPreload, $xoopsLogger, $xoopsErrorHandler, $xoopsSecurity, $sess_handler;
|
| 19: |
|
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: |
|
| 25: | if (!function_exists('get_magic_quotes_gpc')) {
|
| 26: | function get_magic_quotes_gpc() { return false; }
|
| 27: | }
|
| 28: | if (!function_exists('get_magic_quotes_runtime')) {
|
| 29: | function get_magic_quotes_runtime() { return false; }
|
| 30: | }
|
| 31: |
|
| 32: |
|
| 33: | |
| 34: | |
| 35: |
|
| 36: | defined('DS') or define('DS', DIRECTORY_SEPARATOR);
|
| 37: | defined('NWLINE') or define('NWLINE', "\n");
|
| 38: |
|
| 39: | |
| 40: | |
| 41: |
|
| 42: | include_once XOOPS_ROOT_PATH . '/include/defines.php';
|
| 43: | include_once XOOPS_ROOT_PATH . '/include/version.php';
|
| 44: | include_once XOOPS_ROOT_PATH . '/include/license.php';
|
| 45: |
|
| 46: | |
| 47: | |
| 48: |
|
| 49: | require_once XOOPS_ROOT_PATH . '/class/xoopsload.php';
|
| 50: |
|
| 51: | |
| 52: | |
| 53: |
|
| 54: | |
| 55: | |
| 56: |
|
| 57: | XoopsLoad::load('preload');
|
| 58: | $xoopsPreload = XoopsPreload::getInstance();
|
| 59: | $xoopsPreload->triggerEvent('core.include.common.start');
|
| 60: |
|
| 61: | |
| 62: | |
| 63: |
|
| 64: | |
| 65: | |
| 66: | |
| 67: |
|
| 68: | XoopsLoad::load('xoopskernel');
|
| 69: | $xoops = new xos_kernel_Xoops2();
|
| 70: | $xoops->pathTranslation();
|
| 71: | $xoopsRequestUri =& $_SERVER['REQUEST_URI'];
|
| 72: |
|
| 73: | |
| 74: | |
| 75: |
|
| 76: | XoopsLoad::load('xoopssecurity');
|
| 77: | $xoopsSecurity = new XoopsSecurity();
|
| 78: | $xoopsSecurity->checkSuperglobals();
|
| 79: |
|
| 80: | |
| 81: | |
| 82: |
|
| 83: | XoopsLoad::load('xoopslogger');
|
| 84: | $xoopsLogger = XoopsLogger::getInstance();
|
| 85: | $xoopsErrorHandler = XoopsLogger::getInstance();
|
| 86: | $xoopsLogger->startTime();
|
| 87: | $xoopsLogger->startTime('XOOPS Boot');
|
| 88: |
|
| 89: | |
| 90: | |
| 91: |
|
| 92: | include_once $xoops->path('kernel/object.php');
|
| 93: | include_once $xoops->path('class/criteria.php');
|
| 94: | include_once $xoops->path('class/module.textsanitizer.php');
|
| 95: | require_once $xoops->path('include/xoopssetcookie.php');
|
| 96: | include_once $xoops->path('include/functions.php');
|
| 97: |
|
| 98: |
|
| 99: | if (!defined('XOOPS_COOKIE_DOMAIN')) {
|
| 100: | define('XOOPS_COOKIE_DOMAIN', xoops_getBaseDomain(XOOPS_URL));
|
| 101: | }
|
| 102: |
|
| 103: | |
| 104: | |
| 105: | |
| 106: |
|
| 107: | if ($_SERVER['REQUEST_METHOD'] !== 'POST' || !$xoopsSecurity->checkReferer(XOOPS_DB_CHKREF)) {
|
| 108: | define('XOOPS_DB_PROXY', 1);
|
| 109: | }
|
| 110: |
|
| 111: | |
| 112: | |
| 113: | |
| 114: |
|
| 115: | include_once $xoops->path('class/database/databasefactory.php');
|
| 116: |
|
| 117: | $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection();
|
| 118: |
|
| 119: | |
| 120: | |
| 121: | |
| 122: |
|
| 123: |
|
| 124: | $config_handler = xoops_getHandler('config');
|
| 125: | $xoopsConfig = $config_handler->getConfigsByCat(XOOPS_CONF);
|
| 126: |
|
| 127: | |
| 128: | |
| 129: |
|
| 130: | if (file_exists($file = $GLOBALS['xoops']->path('var/configs/xoopsconfig.php'))) {
|
| 131: | $fileConfigs = include $file;
|
| 132: | $xoopsConfig = array_merge($xoopsConfig, (array)$fileConfigs);
|
| 133: | unset($fileConfigs, $file);
|
| 134: | } else {
|
| 135: | trigger_error('File Path Error: ' . 'var/configs/xoopsconfig.php' . ' does not exist.');
|
| 136: | }
|
| 137: |
|
| 138: | |
| 139: | |
| 140: |
|
| 141: | $xFrameOptions = isset($xoopsConfig['xFrameOptions']) ? $xoopsConfig['xFrameOptions'] : 'sameorigin';
|
| 142: | if (!headers_sent() && !empty($xFrameOptions)) {
|
| 143: | header('X-Frame-Options: ' . $xFrameOptions);
|
| 144: | }
|
| 145: |
|
| 146: |
|
| 147: |
|
| 148: |
|
| 149: |
|
| 150: |
|
| 151: |
|
| 152: |
|
| 153: | if (!ini_get('date.timezone')) {
|
| 154: | date_default_timezone_set('UTC');
|
| 155: | }
|
| 156: |
|
| 157: | |
| 158: | |
| 159: | |
| 160: |
|
| 161: | $xoops->gzipCompression();
|
| 162: |
|
| 163: | |
| 164: | |
| 165: |
|
| 166: | if ($xoopsConfig['debug_mode'] == 1 || $xoopsConfig['debug_mode'] == 2) {
|
| 167: | xoops_loadLanguage('logger');
|
| 168: | error_reporting(E_ALL);
|
| 169: | $xoopsLogger->enableRendering();
|
| 170: | $xoopsLogger->usePopup = ($xoopsConfig['debug_mode'] == 2);
|
| 171: | } else {
|
| 172: | error_reporting(0);
|
| 173: | $xoopsLogger->activated = false;
|
| 174: | }
|
| 175: |
|
| 176: | |
| 177: | |
| 178: |
|
| 179: | $xoopsSecurity->checkBadips();
|
| 180: |
|
| 181: | |
| 182: | |
| 183: |
|
| 184: | $xoopsPreload->triggerEvent('core.include.common.language');
|
| 185: | xoops_loadLanguage('global');
|
| 186: | xoops_loadLanguage('errors');
|
| 187: | xoops_loadLanguage('pagetype');
|
| 188: |
|
| 189: | |
| 190: | |
| 191: |
|
| 192: | $xoopsUser = '';
|
| 193: | $xoopsUserIsAdmin = false;
|
| 194: |
|
| 195: | $member_handler = xoops_getHandler('member');
|
| 196: |
|
| 197: | $sess_handler = xoops_getHandler('session');
|
| 198: | if ($xoopsConfig['use_ssl'] && isset($_POST[$xoopsConfig['sslpost_name']]) && $_POST[$xoopsConfig['sslpost_name']] != '') {
|
| 199: | session_id($_POST[$xoopsConfig['sslpost_name']]);
|
| 200: | } elseif ($xoopsConfig['use_mysession'] && $xoopsConfig['session_name'] != '' && $xoopsConfig['session_expire'] > 0) {
|
| 201: | session_name($xoopsConfig['session_name']);
|
| 202: | session_cache_expire($xoopsConfig['session_expire']);
|
| 203: | @ini_set('session.gc_maxlifetime', $xoopsConfig['session_expire'] * 60);
|
| 204: | }
|
| 205: | session_set_save_handler(
|
| 206: | array($sess_handler, 'open'),
|
| 207: | array($sess_handler, 'close'),
|
| 208: | array($sess_handler, 'read'),
|
| 209: | array($sess_handler, 'write'),
|
| 210: | array($sess_handler, 'destroy'),
|
| 211: | array($sess_handler, 'gc')
|
| 212: | );
|
| 213: |
|
| 214: | if (function_exists('session_status')) {
|
| 215: | if (session_status() !== PHP_SESSION_ACTIVE) {
|
| 216: | session_start();
|
| 217: | }
|
| 218: | } else {
|
| 219: |
|
| 220: | @session_start();
|
| 221: | }
|
| 222: | $xoopsPreload->triggerEvent('core.behavior.session.start');
|
| 223: | |
| 224: | |
| 225: |
|
| 226: | if ($xoopsConfig['use_mysession']
|
| 227: | && $xoopsConfig['session_name'] != ''
|
| 228: | && !isset($_COOKIE[$xoopsConfig['session_name']])
|
| 229: | && !empty($_SESSION['xoopsUserId'])
|
| 230: | ) {
|
| 231: | unset($_SESSION['xoopsUserId']);
|
| 232: | }
|
| 233: |
|
| 234: | |
| 235: | |
| 236: |
|
| 237: | $rememberClaims = false;
|
| 238: | if (empty($_SESSION['xoopsUserId'])
|
| 239: | && !empty($GLOBALS['xoopsConfig']['usercookie'])
|
| 240: | ) {
|
| 241: | $rememberClaims = \Xmf\Jwt\TokenReader::fromCookie('rememberme', $GLOBALS['xoopsConfig']['usercookie']);
|
| 242: | if (false !== $rememberClaims && !empty($rememberClaims->uid)) {
|
| 243: | $_SESSION['xoopsUserId'] = $rememberClaims->uid;
|
| 244: | } else {
|
| 245: | xoops_setcookie($GLOBALS['xoopsConfig']['usercookie'], null, time() - 3600, '/', XOOPS_COOKIE_DOMAIN, 0, true);
|
| 246: | xoops_setcookie($GLOBALS['xoopsConfig']['usercookie'], null, time() - 3600);
|
| 247: | }
|
| 248: | }
|
| 249: |
|
| 250: | |
| 251: | |
| 252: |
|
| 253: | if (!empty($_SESSION['xoopsUserId'])) {
|
| 254: | $xoopsUser = $member_handler->getUser($_SESSION['xoopsUserId']);
|
| 255: | if (!is_object($xoopsUser)) {
|
| 256: | $xoopsUser = '';
|
| 257: | $_SESSION = array();
|
| 258: | session_destroy();
|
| 259: | xoops_setcookie($GLOBALS['xoopsConfig']['usercookie'], null, time() - 3600, '/', XOOPS_COOKIE_DOMAIN, 0, true);
|
| 260: | xoops_setcookie($GLOBALS['xoopsConfig']['usercookie'], null, time() - 3600);
|
| 261: | } else {
|
| 262: | if (((int)$xoopsUser->getVar('last_login') + 60 * 5) < time()) {
|
| 263: | $sql = 'UPDATE ' . $xoopsDB->prefix('users') . " SET last_login = '" . time()
|
| 264: | . "' WHERE uid = " . $_SESSION['xoopsUserId'];
|
| 265: | try {
|
| 266: | $xoopsDB->queryF($sql);
|
| 267: | } catch (Exception $e) {
|
| 268: | throw new \RuntimeException(
|
| 269: | \sprintf(_DB_QUERY_ERROR, $sql) . $db->error(), E_USER_ERROR
|
| 270: | );
|
| 271: | }
|
| 272: | }
|
| 273: |
|
| 274: |
|
| 275: | if (isset($_SESSION['xoopsUserGroups'])) {
|
| 276: | $xoopsUser->setGroups($_SESSION['xoopsUserGroups']);
|
| 277: | } else {
|
| 278: | $_SESSION['xoopsUserGroups'] = $xoopsUser->getGroups();
|
| 279: | }
|
| 280: | if (is_object($rememberClaims)) {
|
| 281: | $user_theme = $xoopsUser->getVar('theme');
|
| 282: | if ($user_theme != $xoopsConfig['theme_set'] && in_array($user_theme, $xoopsConfig['theme_set_allowed'])) {
|
| 283: | $_SESSION['xoopsUserTheme'] = $user_theme;
|
| 284: | }
|
| 285: |
|
| 286: | $claims = array(
|
| 287: | 'uid' => $_SESSION['xoopsUserId'],
|
| 288: | );
|
| 289: | $rememberTime = 60*60*24*30;
|
| 290: | $token = \Xmf\Jwt\TokenFactory::build('rememberme', $claims, $rememberTime);
|
| 291: | xoops_setcookie(
|
| 292: | $GLOBALS['xoopsConfig']['usercookie'],
|
| 293: | $token,
|
| 294: | time() + $rememberTime,
|
| 295: | '/',
|
| 296: | XOOPS_COOKIE_DOMAIN,
|
| 297: | (XOOPS_PROT === 'https://'),
|
| 298: | true
|
| 299: | );
|
| 300: | }
|
| 301: | $xoopsUserIsAdmin = $xoopsUser->isAdmin();
|
| 302: | }
|
| 303: | }
|
| 304: | if (PHP_VERSION_ID < 70300) {
|
| 305: | $sess_handler->update_cookie();
|
| 306: | }
|
| 307: |
|
| 308: | $xoopsPreload->triggerEvent('core.include.common.auth.success');
|
| 309: |
|
| 310: | |
| 311: | |
| 312: | |
| 313: | |
| 314: | |
| 315: |
|
| 316: | if ($xoopsLogger->activated) {
|
| 317: | $level = isset($xoopsConfig['debugLevel']) ? (int)$xoopsConfig['debugLevel'] : 2;
|
| 318: | if (($level == 2 && empty($xoopsUserIsAdmin)) || ($level == 1 && !$xoopsUser)) {
|
| 319: | error_reporting(0);
|
| 320: | $xoopsLogger->activated = false;
|
| 321: | }
|
| 322: | unset($level);
|
| 323: | }
|
| 324: |
|
| 325: | |
| 326: | |
| 327: |
|
| 328: | |
| 329: | |
| 330: |
|
| 331: | $xoops->themeSelect();
|
| 332: | xoops_load('XoopsFormRendererInterface');
|
| 333: | xoops_load('XoopsFormRenderer');
|
| 334: |
|
| 335: | |
| 336: | |
| 337: |
|
| 338: | if ($xoopsConfig['closesite'] == 1) {
|
| 339: | include_once $xoops->path('include/site-closed.php');
|
| 340: | }
|
| 341: |
|
| 342: | |
| 343: | |
| 344: |
|
| 345: | if (file_exists('./xoops_version.php')) {
|
| 346: | $url_arr = explode('/', strstr($_SERVER['PHP_SELF'], '/modules/'));
|
| 347: |
|
| 348: | $module_handler = xoops_getHandler('module');
|
| 349: | $xoopsModule = $module_handler->getByDirname($url_arr[2]);
|
| 350: | unset($url_arr);
|
| 351: |
|
| 352: | if (!$xoopsModule || !$xoopsModule->getVar('isactive')) {
|
| 353: | include_once $xoops->path('header.php');
|
| 354: | echo '<h4>' . _MODULENOEXIST . '</h4>';
|
| 355: | include_once $xoops->path('footer.php');
|
| 356: | exit();
|
| 357: | }
|
| 358: |
|
| 359: | $moduleperm_handler = xoops_getHandler('groupperm');
|
| 360: | if ($xoopsUser) {
|
| 361: | if (!$moduleperm_handler->checkRight('module_read', $xoopsModule->getVar('mid'), $xoopsUser->getGroups())) {
|
| 362: | redirect_header(XOOPS_URL, 1, _NOPERM, false);
|
| 363: | }
|
| 364: | $xoopsUserIsAdmin = $xoopsUser->isAdmin($xoopsModule->getVar('mid'));
|
| 365: | } else {
|
| 366: | if (!$moduleperm_handler->checkRight('module_read', $xoopsModule->getVar('mid'), XOOPS_GROUP_ANONYMOUS)) {
|
| 367: | redirect_header(XOOPS_URL . '/user.php?from=' . $xoopsModule->getVar('dirname', 'n'), 1, _NOPERM);
|
| 368: | }
|
| 369: | }
|
| 370: |
|
| 371: | if ($xoopsModule->getVar('dirname', 'n') !== 'system') {
|
| 372: | if (file_exists($file = $xoops->path('modules/' . $xoopsModule->getVar('dirname', 'n') . '/language/' . $xoopsConfig['language'] . '/main.php'))) {
|
| 373: | include_once $file;
|
| 374: | } elseif (file_exists($file = $xoops->path('modules/' . $xoopsModule->getVar('dirname', 'n') . '/language/english/main.php'))) {
|
| 375: | include_once $file;
|
| 376: | }
|
| 377: | unset($file);
|
| 378: | }
|
| 379: |
|
| 380: | if ($xoopsModule->getVar('hasconfig') == 1 || $xoopsModule->getVar('hascomments') == 1 || $xoopsModule->getVar('hasnotification') == 1) {
|
| 381: | $xoopsModuleConfig = $config_handler->getConfigsByCat(0, $xoopsModule->getVar('mid'));
|
| 382: | }
|
| 383: | } elseif ($xoopsUser) {
|
| 384: | $xoopsUserIsAdmin = $xoopsUser->isAdmin(1);
|
| 385: | }
|
| 386: |
|
| 387: | |
| 388: | |
| 389: |
|
| 390: |
|
| 391: | xoops_getActiveModules();
|
| 392: |
|
| 393: | $xoopsLogger->stopTime('XOOPS Boot');
|
| 394: | $xoopsLogger->startTime('Module init');
|
| 395: |
|
| 396: | $xoopsPreload->triggerEvent('core.include.common.end');
|
| 397: | |