function show() { if (empty($_POST)) { HTTP::redirectTo('index.php'); } $db = Database::get(); $username = HTTP::_GP('username', '', UTF8_SUPPORT); $password = HTTP::_GP('password', '', true); $sql = "SELECT id, password FROM %%USERS%% WHERE universe = :universe AND username = :username;"; $loginData = $db->selectSingle($sql, array(':universe' => Universe::current(), ':username' => $username)); if (isset($loginData)) { $hashedPassword = PlayerUtil::cryptPassword($password); if ($loginData['password'] != $hashedPassword) { // Fallback pre 1.7 if ($loginData['password'] == md5($password)) { $sql = "UPDATE %%USERS%% SET password = :hashedPassword WHERE id = :loginID;"; $db->update($sql, array(':hashedPassword' => $hashedPassword, ':loginID' => $loginData['id'])); } else { HTTP::redirectTo('index.php?code=1'); } } $session = Session::create(); $session->userId = (int) $loginData['id']; $session->adminAccess = 0; $session->save(); HTTP::redirectTo('game.php'); } else { HTTP::redirectTo('index.php?code=1'); } }
function ShowMultiIPPage() { global $LNG; switch ($_GET['action']) { case 'known': $GLOBALS['DATABASE']->query("INSERT INTO " . MULTI . " SET userID = " . (int) $_GET['id'] . ";"); HTTP::redirectTo("admin.php?page=multiips"); break; case 'unknown': $GLOBALS['DATABASE']->query("DELETE FROM " . MULTI . " WHERE userID = " . (int) $_GET['id'] . ";"); HTTP::redirectTo("admin.php?page=multiips"); break; } $Query = $GLOBALS['DATABASE']->query("SELECT id, username, email, register_time, onlinetime, user_lastip, IFNULL(multiID, 0) as isKnown FROM " . USERS . " LEFT JOIN " . MULTI . " ON userID = id WHERE `universe` = '" . Universe::getEmulated() . "' AND user_lastip IN (SELECT user_lastip FROM " . USERS . " WHERE `universe` = '" . Universe::getEmulated() . "' GROUP BY user_lastip HAVING COUNT(*)>1) ORDER BY user_lastip, id ASC;"); $IPs = array(); while ($Data = $GLOBALS['DATABASE']->fetch_array($Query)) { if (!isset($IPs[$Data['user_lastip']])) { $IPs[$Data['user_lastip']] = array(); } $Data['register_time'] = _date($LNG['php_tdformat'], $Data['register_time']); $Data['onlinetime'] = _date($LNG['php_tdformat'], $Data['onlinetime']); $IPs[$Data['user_lastip']][$Data['id']] = $Data; } $template = new template(); $template->assign_vars(array('multiGroups' => $IPs)); $template->show('MultiIPs.tpl'); }
function show() { $method = HTTP::_GP('method', ''); $method = strtolower(str_replace(array('_', '\\', '/', '.', ""), '', $method)); $path = 'includes/classes/extauth/' . $method . '.class.php'; if (!file_exists($path)) { HTTP::redirectTo('index.php'); } $session = Session::create(); require 'includes/classes/extauth/externalAuth.interface.php'; require $path; $methodClass = ucwords($method) . 'Auth'; /** @var $authObj externalAuth */ $authObj = new $methodClass(); if (!$authObj->isActiveMode()) { $session->delete(); $this->redirectTo('index.php?code=5'); } if (!$authObj->isValid()) { $session->delete(); $this->redirectTo('index.php?code=4'); } $loginData = $authObj->getLoginData(); if (empty($loginData)) { $session->delete(); $this->redirectTo('index.php?page=register&externalAuth[account]=' . $authObj->getAccount() . '&externalAuth[method]=facebook'); } $session->userId = (int) $loginData['id']; $session->adminAccess = 0; $session->save(); $this->redirectTo("game.php"); }
function send() { global $USER, $LNG; $ticketID = HTTP::_GP('id', 0); $message = HTTP::_GP('message', '', true); $change = HTTP::_GP('change_status', 0); $ticketDetail = $GLOBALS['DATABASE']->getFirstRow("SELECT ownerID, subject, status FROM " . TICKETS . " WHERE ticketID = " . $ticketID . ";"); $status = $change ? $ticketDetail['status'] <= 1 ? 2 : 1 : 1; if (!$change && empty($message)) { HTTP::redirectTo('admin.php?page=support&mode=view&id=' . $ticketID); } $subject = "RE: " . $ticketDetail['subject']; if ($change && $status == 1) { $this->ticketObj->createAnswer($ticketID, $USER['id'], $USER['username'], $subject, $LNG['ti_admin_open'], $status); } if (!empty($message)) { $this->ticketObj->createAnswer($ticketID, $USER['id'], $USER['username'], $subject, $message, $status); } if ($change && $status == 2) { $this->ticketObj->createAnswer($ticketID, $USER['id'], $USER['username'], $subject, $LNG['ti_admin_close'], $status); } $subject = sprintf($LNG['sp_answer_message_title'], $ticketID); $text = sprintf($LNG['sp_answer_message'], $ticketID); PlayerUtil::sendMessage($ticketDetail['ownerID'], $USER['id'], $USER['username'], 4, $subject, $text, TIMESTAMP, NULL, 1, Universe::getEmulated()); HTTP::redirectTo('admin.php?page=support'); }
function show() { $userData = $this->_activeUser(); $session = Session::create(); $session->userId = (int) $userData['userID']; $session->adminAccess = 0; $session->save(); HTTP::redirectTo('game.php'); }
function register() { $uid = $this->getAccount(); $me = $this->api('/me'); $ValidReg = $GLOBALS['DATABASE']->getFirstCell("SELECT cle FROM " . USERS_VALID . " WHERE universe = " . $UNI . " AND email = '" . $GLOBALS['DATABASE']->sql_escape($me['email']) . "';"); if (!empty($ValidReg)) { HTTP::redirectTo("index.php?uni=" . $UNI . "&page=reg&action=valid&clef=" . $ValidReg); } $GLOBALS['DATABASE']->query("INSERT INTO " . USERS_AUTH . " SET\n\t\tid = (SELECT id FROM " . USERS . " WHERE email = '" . $GLOBALS['DATABASE']->sql_escape($me['email']) . "' OR email_2 = '" . $GLOBALS['DATABASE']->sql_escape($me['email']) . "'),\n\t\taccount = " . $uid . ",\n\t\tmode = 'facebook';"); }
function single() { global $LNG; $LNG->includeData(array('FAQ')); $categoryID = HTTP::_GP('categoryID', 0); $questionID = HTTP::_GP('questionID', 0); if (!isset($LNG['questions'][$categoryID][$questionID])) { HTTP::redirectTo('game.php?page=questions'); } $this->assign(array('questionRow' => $LNG['questions'][$categoryID][$questionID])); $this->display('page.questions.single.tpl'); }
function ShowLoginPage() { global $USER, $LNG; if (isset($_REQUEST['admin_pw'])) { $password = cryptPassword($_REQUEST['admin_pw']); if ($password == $USER['password']) { $_SESSION['admin_login'] = $password; HTTP::redirectTo('admin.php'); } } $template = new template(); $template->assign_vars(array('bodyclass' => 'standalone', 'username' => $USER['username'])); $template->show('LoginPage.tpl'); }
function getUniverse() { $gameConfig = Config::getAll(NULL); if (MODE == 'ADMIN' && isset($_SESSION['adminuni'])) { $UNI = (int) $_SESSION['adminuni']; } elseif (MODE == 'LOGIN') { if (isset($_COOKIE['uni'])) { $UNI = (int) $_COOKIE['uni']; } if (isset($_REQUEST['uni'])) { $UNI = (int) $_REQUEST['uni']; } } if (!isset($UNI)) { if (UNIS_WILDCAST === true) { $UNI = explode('.', $_SERVER['HTTP_HOST']); $UNI = substr($UNI[0], 3); if (!is_numeric($UNI)) { $UNI = ROOT_UNI; } } else { if (count($gameConfig) == 1) { if (HTTP_ROOT != HTTP_BASE) { HTTP::redirectTo(PROTOCOL . HTTP_HOST . HTTP_BASE . HTTP_FILE, true); } $UNI = ROOT_UNI; } else { if (isset($_SERVER['REDIRECT_UNI'])) { // Apache - faster then preg_match $UNI = $_SERVER["REDIRECT_UNI"]; } elseif (isset($_SERVER['REDIRECT_REDIRECT_UNI'])) { // Patch for www.top-hoster.de - Hoster $UNI = $_SERVER["REDIRECT_REDIRECT_UNI"]; } elseif (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache/') === false) { preg_match('!/uni([0-9]+)/!', HTTP_PATH, $match); if (isset($match[1])) { $UNI = $match[1]; } } if (!isset($UNI) || !isset($gameConfig[$UNI])) { HTTP::redirectTo(PROTOCOL . HTTP_HOST . HTTP_BASE . "uni" . ROOT_UNI . "/" . HTTP_FILE, true); } } } } return $UNI; }
public function register() { $uid = $this->getAccount(); $me = $this->fbObj->api('/me'); $sql = 'SELECT validationID, validationKey FROM %%USERS_VALID%% WHERE universe = :universe AND email = :email;'; $registerData = Database::get()->selectSingle($sql, array(':universe' => Universe::current(), ':email' => $me['email'])); if (!empty($registerData)) { $url = sprintf('index.php?uni=%s&page=reg&action=valid&i=%s&validationKey=%s', Universe::current(), $registerData['validationID'], $registerData['validationKey']); HTTP::redirectTo($url); } $sql = 'INSERT INTO %%USERS_AUTH." SET id = (SELECT id FROM %%USERS%% WHERE email = :email OR email_2 = :email), account = :accountId mode = :mode;'; Database::get()->insert($sql, array(':email' => $me['email'], ':accountId' => $uid, ':mode' => 'facebook')); }
function ShowLoginPage() { global $USER; $session = Session::create(); if ($session->adminAccess == 1) { HTTP::redirectTo('admin.php'); } if (isset($_REQUEST['admin_pw'])) { $password = PlayerUtil::cryptPassword($_REQUEST['admin_pw']); if ($password == $USER['password']) { $session->adminAccess = 1; HTTP::redirectTo('admin.php'); } } $template = new template(); $template->assign_vars(array('bodyclass' => 'standalone', 'username' => $USER['username'])); $template->show('LoginPage.tpl'); }
public function register() { $uid = $this->getAccount(); $user = $this->oidObj->getAttributes(); if (empty($user['contact/email'])) { HTTP::redirectTo('index.php?code=4'); } $sql = 'SELECT validationID, validationKey FROM %%USERS_VALID%% WHERE universe = :universe AND email = :email;'; $registerData = Database::get()->selectSingle($sql, array(':universe' => Universe::current(), ':email' => $user['contact/email'])); if (!empty($registerData)) { $url = sprintf('index.php?uni=%s&page=reg&action=valid&i=%s&validationKey=%s', Universe::current(), $registerData['validationID'], $registerData['validationKey']); HTTP::redirectTo($url); } $sql = 'INSERT INTO %%USERS_AUTH%% SET id = (SELECT id FROM %%USERS%% WHERE email = :email OR email_2 = :email), account = :accountId mode = :mode;'; Database::get()->insert($sql, array(':email' => $user['contact/email'], ':accountId' => $uid, ':mode' => $this->oidObj->identity)); }
function show() { $method = HTTP::_GP('method', ''); $method = strtolower(str_replace(array('_', '\\', '/', '.', ""), '', $method)); if (!file_exists('includes/extauth/' . $method . '.class.php')) { HTTP::redirectTo('index.php'); } Session::init(); require 'includes/extauth/' . $method . '.class.php'; $methodClass = ucwords($method) . 'Auth'; $authObj = new $methodClass(); if (!$authObj->isActiveMode()) { $this->redirectTo('index.php?code=5'); } if (!$authObj->isVaild()) { $this->redirectTo('index.php?code=4'); } $loginData = $authObj->getLoginData(); if (empty($loginData)) { $this->redirectTo('index.php?page=register&externalAuth[account]=' . $authObj->getAccount() . '&externalAuth[method]=facebook'); } Session::create($loginData['id'], $loginData['id_planet']); $this->redirectTo("game.php"); }
function getLoginData() { global $UNI; try { $user = $this->getAttributes(); } catch (FacebookApiException $e) { HTTP::redirectTo('index.php?code=4'); } return $GLOBALS['DATABASE']->getFirstRow("SELECT \n\t\tuser.id, user.username, user.dpath, user.authlevel, user.id_planet \n\t\tFROM " . USERS_AUTH . " auth \n\t\tINNER JOIN " . USERS . " user ON auth.id = user.id AND user.universe = " . $UNI . "\n\t\tWHERE auth.account = '" . $user['contact/email'] . "' AND mode = '" . $GLOBALS['DATABASE']->sql_escape($_REQUEST['openid_identifier']) . "';"); }
static function redirectCode($Code) { HTTP::redirectTo('index.php?code=' . $Code); }
/** * 2Moons * Copyright (C) 2012 Jan Kröpke * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package 2Moons * @author Jan Kröpke <*****@*****.**> * @copyright 2012 Jan Kröpke <*****@*****.**> * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License * @version 1.7.3 (2013-05-19) * @info $Id: CombatReport.php 2643 2013-03-26 17:13:31Z slaver7 $ * @link http://2moons.cc/ */ define('MODE', 'INGAME'); define('ROOT_PATH', str_replace('\\', '/', dirname(__FILE__)) . '/'); set_include_path(ROOT_PATH); require 'includes/common.php'; HTTP::redirectTo('game.php?page=raport&raport=' . HTTP::_GP('raport', ''));
<?php define('MODE', 'LOGIN'); define('ROOT_PATH', str_replace('\\', '/', dirname(__FILE__)) . '/'); set_include_path(ROOT_PATH); require 'includes/common.php'; $LNG->includeData(array('L18N', 'INGAME', 'ADMIN')); if (isset($_REQUEST['admin_pw'])) { $login = $GLOBALS['DATABASE']->getFirstRow("SELECT `id`, `username`, `dpath`, `authlevel`, `id_planet` FROM " . USERS . " WHERE `id` = '1' AND `password` = '" . cryptPassword($_REQUEST['admin_pw']) . "';"); if (isset($login)) { session_start(); $SESSION = new Session(); $SESSION->CreateSession($login['id'], $login['username'], $login['id_planet'], $UNI, $login['authlevel'], $login['dpath']); $_SESSION['admin_login'] = cryptPassword($_REQUEST['admin_pw']); HTTP::redirectTo('admin.php'); } } $template = new template(); $tplDir = $template->getTemplateDir(); $template->setTemplateDir($tplDir[0] . 'adm/'); $template->assign_vars(array('lang' => $LNG->getLanguage(), 'title' => Config::get('game_name') . ' - ' . $LNG['adm_cp_title'], 'REV' => substr(Config::get('VERSION'), -4), 'date' => explode("|", date('Y\\|n\\|j\\|G\\|i\\|s\\|Z', TIMESTAMP)), 'Offset' => 0, 'VERSION' => Config::get('VERSION'), 'dpath' => 'gow', 'bodyclass' => 'popup', 'username' => 'root')); $template->show('LoginPage.tpl');
public static function GotoFleetPage($Code = 0) { global $LNG; if (Config::get()->debug == 1) { $temp = debug_backtrace(); echo str_replace($_SERVER["DOCUMENT_ROOT"], '.', $temp[0]['file']) . " on " . $temp[0]['line'] . " | Code: " . $Code . " | Error: " . (isset($LNG['fl_send_error'][$Code]) ? $LNG['fl_send_error'][$Code] : ''); exit; } HTTP::redirectTo('game.php?page=fleetTable&code=' . $Code); }
function changerank() { global $USER, $LNG; if (!$this->rights['RANKS']) { $this->redirectToHome(); } $memberID = HTTP::_GP('memberID', ''); if ($this->allianceData['ally_owner'] == $memberID) { $this->printMessage('<span class="rouge">You can not change your rank or rank of a founder.</span>'); } $rankResult = $GLOBALS['DATABASE']->query("SELECT * FROM " . ALLIANCE_RANK . " WHERE allianceID = " . $this->allianceData['id'] . ";"); $rankList = array(); while ($rankRow = $GLOBALS['DATABASE']->fetch_array($rankResult)) { $rankList[$rankRow['rankID']] = $rankRow; } $GLOBALS['DATABASE']->free_result($rankResult); if (!empty($_POST)) { $memberID = HTTP::_GP('memberID', ''); $rankID = HTTP::_GP('nouveau_rang', ''); $userResult = $GLOBALS['DATABASE']->query("SELECT ally_id FROM " . USERS . " WHERE id = " . $memberID . ";"); $userResult = $GLOBALS['DATABASE']->fetch_array($userResult); $userResult = $userResult['ally_id']; if ($this->allianceData['id'] != $userResult || !isset($userResult)) { $this->printMessage('<span class="rouge">This is not one of your alliance members.</span>'); } else { $GLOBALS['DATABASE']->query("UPDATE " . USERS . " set ally_rank_id = '" . $rankID . "' WHERE id = '" . $memberID . "';"); HTTP::redirectTo("game.php?page=alliance&mode=memberList"); } } $this->tplObj->assign_vars(array('usernames' => $this->getUsername($memberID), 'memberID' => $memberID, 'rankList' => $rankList, 'ownRights' => $this->rights, 'avalibleRanks' => $this->avalibleRanks)); $this->display('page.alliance.changerank.tpl'); }
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); } elseif (MODE === 'ADMIN') { error_reporting(E_ERROR | E_WARNING | E_PARSE); $USER['rights'] = unserialize($USER['rights']); $LNG->includeData(array('ADMIN', 'CUSTOM')); } } elseif (MODE === 'LOGIN') { $LNG = new Language(); $LNG->getUserAgentLanguage(); $LNG->includeData(array('L18N', 'INGAME', 'PUBLIC', 'CUSTOM')); } elseif (MODE === 'CHAT') { $session = Session::load(); if (!$session->isValidSession()) { HTTP::redirectTo('index.php?code=3'); } }
* * @package 2Moons * @author Jan Kröpke <*****@*****.**> * @copyright 2012 Jan Kröpke <*****@*****.**> * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License * @version 1.7.2 (2013-03-18) * @info $Id$ * @link http://2moons.cc/ */ define('MODE', 'ADMIN'); define('DATABASE_VERSION', 'OLD'); define('ROOT_PATH', str_replace('\\', '/', dirname(__FILE__)) . '/'); require 'includes/common.php'; require 'includes/classes/class.Log.php'; if ($USER['authlevel'] == AUTH_USR) { HTTP::redirectTo('game.php'); } $session = Session::create(); if ($session->adminAccess != 1) { include_once 'includes/pages/adm/ShowLoginPage.php'; ShowLoginPage(); exit; } $uni = HTTP::_GP('uni', 0); if ($USER['authlevel'] == AUTH_ADM && !empty($uni)) { Universe::setEmulated($uni); } $page = HTTP::_GP('page', ''); switch ($page) { case 'logout': include_once 'includes/pages/adm/ShowLogoutPage.php';
function show() { if (empty($_POST)) { HTTP::redirectTo('index.php'); } $username = HTTP::_GP('username', '', UTF8_SUPPORT); $password = HTTP::_GP('password', '', true); $loginData = $GLOBALS['DATABASE']->getFirstRow("SELECT id, password, intro, username, user_deleted FROM " . USERS . " WHERE universe = " . $GLOBALS['UNI'] . " AND username = '******'DATABASE']->escape($username) . "';"); if (isset($loginData)) { $hashedPassword = PlayerUtil::cryptPassword($password); if ($loginData['password'] != $hashedPassword) { // Fallback pre 1.7 if ($loginData['password'] == md5($password)) { $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET password = '******' WHERE id = " . $loginData['id'] . ";"); } else { HTTP::redirectTo('index.php?code=1'); } } $ip = ""; if (!empty($_SERVER["HTTP_CLIENT_IP"])) { //check for ip from share internet $ip = $_SERVER["HTTP_CLIENT_IP"]; } elseif (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) { // Check for the Proxy User $ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } else { $ip = $_SERVER["REMOTE_ADDR"]; } $ua = $this->getBrowser(); $os = $this->GetOS(); //$ipCheck = $GLOBALS['DATABASE']->query("SELECT COUNT(logID) as id FROM uni1_iplog WHERE userID = ".$loginData['id']." AND ipaddress = '".$ip."';"); //$ipCheck = $GLOBALS['DATABASE']->fetch_array($ipCheck); //if($ipCheck['id'] == 0){ $GLOBALS['DATABASE']->query("INSERT INTO uni1_iplog VALUES ('" . $GLOBALS['DATABASE']->GetInsertID() . "','" . TIMESTAMP . "','" . $ip . "','" . $ua['name'] . "', '" . $os . "', " . $loginData['id'] . ");"); //} $ipCheck = $GLOBALS['DATABASE']->query("SELECT DISTINCT userID FROM uni1_iplog WHERE userID != " . $loginData['id'] . " AND ipaddress = '" . $ip . "';"); Session::create($loginData['id']); if ($loginData['intro'] == 0) { HTTP::redirectTo('game.php?page=intro'); } else { HTTP::redirectTo('game.php'); } } else { Session::redirectCode(1); } }
} else { $installRevision = (int) $installVersion[2]; } $installVersion = implode('.', $installVersion); try { $db->query(str_replace(array('%PREFIX%', '%VERSION%', '%REVISION%'), array(DB_PREFIX, $installVersion, $installRevision, $installSQL), $installSQL)); $config = Config::get(Universe::current()); $config->timezone = @date_default_timezone_get(); $config->lang = $LNG->getLanguage(); $config->OverviewNewsText = $LNG['sql_welcome'] . $installVersion; $config->uni_name = $LNG['fcm_universe'] . ' ' . Universe::current(); $config->close_reason = $LNG['sql_close_reason']; $config->moduls = implode(';', array_fill(0, MODULE_AMOUNT - 1, 1)); unset($installSQL, $installRevision, $installVersion); $config->save(); HTTP::redirectTo('index.php?mode=install&step=7'); } catch (Exception $e) { require 'includes/config.php'; @unlink('includes/config.php'); $error = $e->getMessage(); $template->assign(array('host' => $database['host'], 'port' => $database['port'], 'user' => $database['user'], 'dbname' => $database['databasename'], 'prefix' => $database['tableprefix'], 'class' => 'fatalerror', 'message' => $LNG['step3_db_error'] . '</p><p>' . $error)); $template->show('ins_step4.tpl'); exit; } break; case 7: $template->show('ins_acc.tpl'); break; case 8: $username = HTTP::_GP('username', '', UTF8_SUPPORT); $password = HTTP::_GP('password', '', true);
/** * 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; }
public static function redirectToUniverse($universe) { HTTP::redirectTo(PROTOCOL . HTTP_HOST . HTTP_BASE . "uni" . $universe . "/" . HTTP_FILE, true); }
function ShowUniversePage() { global $LNG, $USER; $template = new template(); $action = HTTP::_GP('action', ''); $universe = HTTP::_GP('uniID', 0); switch ($action) { case 'open': $config = Config::get($universe); $config->game_disable = 1; $config->save(); break; case 'closed': $config = Config::get($universe); $config->game_disable = 0; $config->save(); break; case 'delete': if (!empty($universe) && $universe != ROOT_UNI && $universe != Universe::current()) { $GLOBALS['DATABASE']->query("DELETE FROM " . ALLIANCE . ", " . ALLIANCE_RANK . ", " . ALLIANCE_REQUEST . " \n\t\t\t\tUSING " . ALLIANCE . " \n\t\t\t\tLEFT JOIN " . ALLIANCE_RANK . " ON " . ALLIANCE . ".id = " . ALLIANCE_RANK . ".allianceID\n\t\t\t\tLEFT JOIN " . ALLIANCE_REQUEST . " ON " . ALLIANCE . ".id = " . ALLIANCE_REQUEST . " .allianceID\n\t\t\t\tWHERE ally_universe = " . $universe . ";"); $GLOBALS['DATABASE']->query("DELETE FROM " . BANNED . " WHERE universe = " . $universe . ";"); $GLOBALS['DATABASE']->query("DELETE FROM " . BUDDY . ", " . BUDDY_REQUEST . "\n\t\t\t\tUSING " . BUDDY . "\n\t\t\t\tLEFT JOIN " . BUDDY_REQUEST . " ON " . BUDDY . ".id = " . BUDDY_REQUEST . ".id\n\t\t\t\tWHERE " . BUDDY . ".universe = " . $universe . ";"); $GLOBALS['DATABASE']->query("DELETE FROM " . CONFIG . " WHERE uni = " . $universe . ";"); $GLOBALS['DATABASE']->query("DELETE FROM " . DIPLO . " WHERE universe = " . $universe . ";"); $GLOBALS['DATABASE']->query("DELETE FROM " . FLEETS . ", " . FLEETS_EVENT . ", " . AKS . ", " . LOG_FLEETS . "\n\t\t\t\tUSING " . FLEETS . "\n\t\t\t\tLEFT JOIN " . FLEETS_EVENT . " ON " . FLEETS . ".fleet_id = " . FLEETS_EVENT . ".fleetID\n\t\t\t\tLEFT JOIN " . AKS . " ON " . FLEETS . ".fleet_group = " . AKS . ".id\n\t\t\t\tLEFT JOIN " . LOG_FLEETS . " ON " . FLEETS . ".fleet_id = " . LOG_FLEETS . ".fleet_id\n\t\t\t\tWHERE " . FLEETS . ".fleet_universe = " . $universe . ";"); $GLOBALS['DATABASE']->query("DELETE FROM " . MESSAGES . " WHERE message_universe = " . $universe . ";"); $GLOBALS['DATABASE']->query("DELETE FROM " . NOTES . " WHERE universe = " . $universe . ";"); $GLOBALS['DATABASE']->query("DELETE FROM " . PLANETS . " WHERE universe = " . $universe . ";"); $GLOBALS['DATABASE']->query("DELETE FROM " . STATPOINTS . " WHERE universe = " . $universe . ";"); $GLOBALS['DATABASE']->query("DELETE FROM " . TICKETS . ", " . TICKETS_ANSWER . "\n\t\t\t\tUSING " . TICKETS . "\n\t\t\t\tLEFT JOIN " . TICKETS_ANSWER . " ON " . TICKETS . ".ticketID = " . TICKETS_ANSWER . ".ticketID\n\t\t\t\tWHERE universe = " . $universe . ";"); $GLOBALS['DATABASE']->query("DELETE FROM " . TOPKB . " WHERE universe = " . $universe . ";"); $GLOBALS['DATABASE']->query("DELETE FROM " . USERS . ", " . USERS_ACS . ", " . USERS_AUTH . ", " . TOPKB_USERS . ", " . SESSION . ", " . SHORTCUTS . ", " . RECORDS . "\n\t\t\t\tUSING " . USERS . "\n\t\t\t\tLEFT JOIN " . USERS_ACS . " ON " . USERS . ".id = " . USERS_ACS . ".userID\n\t\t\t\tLEFT JOIN " . USERS_AUTH . " ON " . USERS . ".id = " . USERS_AUTH . ".id\n\t\t\t\tLEFT JOIN " . TOPKB_USERS . " ON " . USERS . ".id = " . TOPKB_USERS . ".uid\n\t\t\t\tLEFT JOIN " . SESSION . " ON " . USERS . ".id = " . SESSION . ".userID\n\t\t\t\tLEFT JOIN " . SHORTCUTS . " ON " . USERS . ".id = " . SHORTCUTS . ".ownerID\n\t\t\t\tLEFT JOIN " . RECORDS . " ON " . USERS . ".id = " . RECORDS . ".userID\n\t\t\t\tLEFT JOIN " . LOSTPASSWORD . " ON " . USERS . ".id = " . LOSTPASSWORD . ".userID\n\t\t\t\tWHERE " . USERS . ".universe = " . $universe . ";"); $GLOBALS['DATABASE']->query("DELETE FROM " . USERS_VALID . " WHERE universe = " . $universe . ";"); if (Universe::getEmulated() == $universe) { Universe::setEmulated(Universe::current()); } if (count(Universe::availableUniverses()) == 2) { // Hack The Session setcookie(session_name(), session_id(), SESSION_LIFETIME, HTTP_BASE, NULL, HTTPS, true); HTTP::redirectTo("../admin.php?reload=r"); } } break; case 'create': $universeCount = count(Universe::availableUniverses()); // Check Multiuniverse Support $ch = curl_init(); if ($universeCount == 1) { curl_setopt($ch, CURLOPT_URL, PROTOCOL . HTTP_HOST . HTTP_BASE . "uni" . ROOT_UNI . "/"); } else { curl_setopt($ch, CURLOPT_URL, PROTOCOL . HTTP_HOST . HTTP_BASE); } curl_setopt($ch, CURLOPT_HTTPGET, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; 2Moons/" . Config::get()->VERSION . "; +http://2moons.cc)"); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3", "Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4")); curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($httpCode != 302) { $template = new template(); $template->message(str_replace(array('{NGINX-CODE}'), array('rewrite /(.*)/?uni[0-9]+/?(.*) /$1/$2 break;'), $LNG->getTemplate('createUniverseInfo')) . '<a href="javascript:window.history.back();"><button>' . $LNG['uvs_back'] . '</button></a>' . '<a href="javascript:window.location.reload();"><button>' . $LNG['uvs_reload'] . '</button></a>'); exit; } $config = Config::get(); $configSQL = array(); foreach (Config::getGlobalConfigKeys() as $basicConfigKey) { $configSQL[] = '`' . $basicConfigKey . '` = "' . $config->{$basicConfigKey} . '"'; } $configSQL[] = '`uni_name` = "' . $LNG['fcm_universe'] . ' ' . ($universeCount + 1) . '"'; $configSQL[] = '`close_reason` = ""'; $configSQL[] = '`OverviewNewsText` = "' . $GLOBALS['DATABASE']->escape($config->OverviewNewsText) . '"'; $GLOBALS['DATABASE']->query("INSERT INTO " . CONFIG . " SET " . implode(', ', $configSQL) . ";"); $newUniverse = $GLOBALS['DATABASE']->GetInsertID(); Config::reload(); list($userID, $planetID) = PlayerUtil::createPlayer($newUniverse, $USER['username'], '', $USER['email'], $USER['lang'], 1, 1, 1, NULL, AUTH_ADM); $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET password = '******'password'] . "' WHERE id = " . $userID . ";"); if ($universeCount === 1) { // Hack The Session setcookie(session_name(), session_id(), SESSION_LIFETIME, HTTP_ROOT . 'uni' . $USER['universe'] . '/', NULL, HTTPS, true); HTTP::redirectTo("uni" . $USER['universe'] . "/admin.php?reload=r"); } break; } $uniList = array(); $uniResult = $GLOBALS['DATABASE']->query("SELECT uni, users_amount, game_disable, energySpeed, halt_speed, resource_multiplier, fleet_speed, game_speed, uni_name, COUNT(DISTINCT inac.id) as inactive, COUNT(planet.id) as planet\n\tFROM " . CONFIG . " conf\n\tLEFT JOIN " . USERS . " as inac ON uni = inac.universe AND inac.onlinetime < " . (TIMESTAMP - INACTIVE) . "\n\tLEFT JOIN " . PLANETS . " as planet ON uni = planet.universe\n\tGROUP BY conf.uni, inac.universe, planet.universe\n\tORDER BY uni ASC;"); while ($uniRow = $GLOBALS['DATABASE']->fetch_array($uniResult)) { $uniList[$uniRow['uni']] = $uniRow; } $template->assign_vars(array('uniList' => $uniList, 'SID' => session_id())); $template->show('UniversePage.tpl'); }
protected function redirectTo($url) { $this->save(); HTTP::redirectTo($url); exit; }
public static function GotoFleetPage($Code = 0) { global $LNG; $temp = debug_backtrace(); if ($GLOBALS['CONF']['debug'] == 1) { exit(str_replace($_SERVER["DOCUMENT_ROOT"], '.', $temp[0]['file']) . " on " . $temp[0]['line'] . " | Code: " . $Code . " | Error: " . (isset($LNG['fl_send_error'][$Code]) ? $LNG['fl_send_error'][$Code] : '')); } HTTP::redirectTo('game.php?page=fleetTable&code=' . $Code); }
function show() { $userData = $this->_activeUser(); Session::Create($userData['userID'], $userData['planetID']); HTTP::redirectTo('game.php'); }
if (Config::get('game_disable') == 0 && $USER['authlevel'] == AUTH_USR) { ShowErrorPage::printError($LNG['sys_closed_game'] . '<br><br>' . Config::get('close_reason'), false); } $bannedData = $GLOBALS['DATABASE']->getFirstRow("SELECT longer FROM uni1_banned WHERE who = '" . $USER['username'] . "';"); if ($USER['bana'] == 1 && $USER['banaday'] > TIMESTAMP) { 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); } elseif ($USER['bana'] == 1 && $USER['banaday'] < TIMESTAMP) { $GLOBALS['DATABASE']->query("UPDATE uni1_users set bana = '0', banaday = '0' WHERE id = '" . $USER['id'] . "';"); } $bannedMessageData = $GLOBALS['DATABASE']->getFirstRow("SELECT longer FROM uni1_message_banned WHERE who = '" . $USER['username'] . "';"); if ($USER['message_ban'] == 1 && $USER['message_ban_time'] < TIMESTAMP) { $GLOBALS['DATABASE']->query("UPDATE uni1_users set message_ban = '0', message_ban_time = '0' WHERE id = '" . $USER['id'] . "';"); } if (MODE === 'INGAME') { if ($UNI != $USER['universe'] && count($CONFIG) > 1) { HTTP::redirectTo(PROTOCOL . HTTP_HOST . HTTP_BASE . "uni" . $USER['universe'] . "/" . HTTP_FILE, true); } $PLANET = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . PLANETS . " WHERE id = " . $_SESSION['planet'] . ";"); if (empty($PLANET)) { $PLANET = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . PLANETS . " WHERE id = " . $USER['id_planet'] . ";"); if (empty($PLANET)) { throw new Exception("Main Planet does not exist!"); } } $USER['factor'] = getFactors($USER); $USER['PLANETS'] = getPlanets($USER); } elseif (MODE === 'ADMIN') { error_reporting(E_ERROR | E_WARNING | E_PARSE); $USER['rights'] = unserialize($USER['rights']); $LNG->includeData(array('ADMIN', 'CUSTOM')); }