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'; ShowLogoutPage(); break; case 'infos': include_once 'includes/pages/adm/ShowInformationPage.php'; ShowInformationPage(); break; case 'rights': include_once 'includes/pages/adm/ShowRightsPage.php'; ShowRightsPage(); break;
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'); }