if (empty($USER)) { HTTP::redirectTo('index.php?code=3'); } $LNG = new Language($USER['lang']); $LNG->includeData(array('L18N', 'INGAME', 'TECH', 'CUSTOM')); $THEME->setUserTheme($USER['dpath']); if ($config->game_disable == 0 && $USER['authlevel'] == AUTH_USR) { ShowErrorPage::printError($LNG['sys_closed_game'] . '<br><br>' . $config->close_reason, false); } if ($USER['bana'] == 1) { ShowErrorPage::printError("<font size=\"6px\">" . $LNG['css_account_banned_message'] . "</font><br><br>" . sprintf($LNG['css_account_banned_expire'], _date($LNG['php_tdformat'], $USER['banaday'], $USER['timezone'])) . "<br><br>" . $LNG['css_goto_homeside'], false); } if (MODE === 'INGAME') { $universeAmount = count(Universe::availableUniverses()); if (Universe::current() != $USER['universe'] && $universeAmount > 1) { HTTP::redirectToUniverse($USER['universe']); } $session->selectActivePlanet(); $sql = "SELECT * FROM %%PLANETS%% WHERE id = :planetId;"; $PLANET = $db->selectSingle($sql, array(':planetId' => $session->planetId)); if (empty($PLANET)) { $sql = "SELECT * FROM %%PLANETS%% WHERE id = :planetId;"; $PLANET = $db->selectSingle($sql, array(':planetId' => $USER['id_planet'])); if (empty($PLANET)) { throw new Exception("Main Planet does not exist!"); } else { $session->planetId = $USER['id_planet']; } } $USER['factor'] = getFactors($USER); $USER['PLANETS'] = getPlanets($USER);
/** * Find current universe id using cookies, get parameter or session keys. * * @return int */ private static function defineCurrentUniverse() { $universe = NULL; if (MODE === 'INSTALL') { // Installer are always in the first universe. return ROOT_UNI; } if (count(self::availableUniverses()) != 1) { if (MODE == 'LOGIN') { if (isset($_COOKIE['uni'])) { $universe = (int) $_COOKIE['uni']; } if (isset($_REQUEST['uni'])) { $universe = (int) $_REQUEST['uni']; } } elseif (MODE == 'ADMIN' && isset($_SESSION['admin_uni'])) { $universe = (int) $_SESSION['admin_uni']; } if (is_null($universe)) { if (UNIS_WILDCAST === true) { $temp = explode('.', $_SERVER['HTTP_HOST']); $temp = substr($temp[0], 3); if (is_numeric($temp)) { $universe = $temp; } else { $universe = ROOT_UNI; } } else { if (isset($_SERVER['REDIRECT_UNI'])) { // Apache - faster then preg_match $universe = $_SERVER["REDIRECT_UNI"]; } elseif (isset($_SERVER['REDIRECT_REDIRECT_UNI'])) { // Patch for www.top-hoster.de - Hoster $universe = $_SERVER["REDIRECT_REDIRECT_UNI"]; } elseif (preg_match('!/uni([0-9]+)/!', HTTP_PATH, $match)) { if (isset($match[1])) { $universe = $match[1]; } } else { $universe = ROOT_UNI; } if (!isset($universe) || !self::exists($universe)) { HTTP::redirectToUniverse(ROOT_UNI); } } } } else { if (HTTP_ROOT != HTTP_BASE) { HTTP::redirectTo(PROTOCOL . HTTP_HOST . HTTP_BASE . HTTP_FILE, true); } $universe = ROOT_UNI; } return $universe; }