/** * 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: CreateOnePlanetRecord.php 2640 2013-03-23 19:23:26Z slaver7 $ * @link http://2moons.cc/ */ function CreateOnePlanetRecord($Galaxy, $System, $Position, $Universe, $PlanetOwnerID, $PlanetName, $HomeWorld = false, $AuthLevel = 0, $Iron, $Gold, $Crystal, $Elyrium, $iPlanetCount) { global $LNG; $CONF = Config::getAll(NULL, $Universe); if (Config::get('max_galaxy') < $Galaxy || 1 > $Galaxy) { throw new Exception("Access denied for CreateOnePlanetRecord.php.<br>Try to create a planet at position:" . $Galaxy . ":" . $System . ":" . $Position); } if (Config::get('max_system') < $System || 1 > $System) { throw new Exception("Access denied for CreateOnePlanetRecord.php.<br>Try to create a planet at position:" . $Galaxy . ":" . $System . ":" . $Position); } if (Config::get('max_planets') < $Position || 1 > $Position) { throw new Exception("Access denied for CreateOnePlanetRecord.php.<br>Try to create a planet at position:" . $Galaxy . ":" . $System . ":" . $Position); } if (CheckPlanetIfExist($Galaxy, $System, $Position, $Universe)) { return false; } $tp = 0; if ($iPlanetCount >= 3) { $tp = 1; } $FieldFactor = Config::get('planet_factor'); require 'includes/PlanetData.php'; $Pos = ceil($Position / (Config::get('max_planets') / count($PlanetData))); $TMax = $PlanetData[$Pos]['temp']; $TMin = $TMax - 40; $Fields = $PlanetData[$Pos]['fields'] * Config::get('planet_factor'); $Types = $PlanetData[$Pos]['image']; $Name = !empty($PlanetName) ? $GLOBALS['DATABASE']->sql_escape($PlanetName) : $LNG['type_planet'][1]; $GLOBALS['DATABASE']->query("INSERT INTO " . PLANETS . " SET\n\t\t\t\tname = '" . $Name . "',\n\t\t\t\tuniverse = " . $Universe . ",\n\t\t\t\tid_owner = " . $PlanetOwnerID . ",\n\t\t\t\tgalaxy = " . $Galaxy . ",\n\t\t\t\tsystem = " . $System . ",\n\t\t\t\tplanet = " . $Position . ",\n\t\t\t\tlast_update = " . TIMESTAMP . ",\n\t\t\t\tplanet_type = '1',\n\t\t\t\tcolo_metal = " . $Iron . ",\n\t\t\t\tcolo_crystal = " . $Gold . ",\n\t\t\t\tcolo_deut = " . $Crystal . ",\n\t\t\t\tcolo_elyrium = " . $Elyrium . ",\n\t\t\t\tteleport_portal = " . $tp . ",\n\t\t\t\timage = '" . $Types . "',\n\t\t\t\tdiameter = " . floor(1000 * sqrt($Fields)) . ",\n\t\t\t\tfield_max = " . ($HomeWorld ? Config::get('initial_fields') : floor($Fields)) . ",\n\t\t\t\ttemp_min = " . $TMin . ",\n\t\t\t\ttemp_max = " . $TMax . ",\n\t\t\t\tmetal = " . Config::get('metal_start') . ",\n\t\t\t\tmetal_perhour = " . Config::get('metal_basic_income') . ",\n\t\t\t\tcrystal = " . Config::get('crystal_start') . ",\n\t\t\t\tcrystal_perhour = " . Config::get('crystal_basic_income') . ",\n\t\t\t\tdeuterium = " . Config::get('deuterium_start') . ",\n\t\t\t\tdeuterium_perhour = " . Config::get('deuterium_basic_income') . ",\n\t\t\t\telyrium = " . Config::get('deuterium_start') . ",\n\t\t\t\telyrium_perhour = " . Config::get('deuterium_basic_income') . ";"); return $GLOBALS['DATABASE']->GetInsertID(); }
/** * 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: CreateOnePlanetRecord.php 2640 2013-03-23 19:23:26Z slaver7 $ * @link http://2moons.cc/ */ function CreateOnePlanetRecord($Galaxy, $System, $Position, $Universe, $PlanetOwnerID, $PlanetName = '', $HomeWorld = false, $AuthLevel = 0) { global $LNG; $CONF = Config::getAll(NULL, $Universe); if (Config::get('max_galaxy') < $Galaxy || 1 > $Galaxy) { throw new Exception("Access denied for CreateOnePlanetRecord.php.<br>Try to create a planet at position:" . $Galaxy . ":" . $System . ":" . $Position); } if (Config::get('max_system') < $System || 1 > $System) { throw new Exception("Access denied for CreateOnePlanetRecord.php.<br>Try to create a planet at position:" . $Galaxy . ":" . $System . ":" . $Position); } if (Config::get('max_planets') < $Position || 1 > $Position) { throw new Exception("Access denied for CreateOnePlanetRecord.php.<br>Try to create a planet at position:" . $Galaxy . ":" . $System . ":" . $Position); } if (CheckPlanetIfExist($Galaxy, $System, $Position, $Universe)) { return false; } $FieldFactor = Config::get('planet_factor'); require_once 'includes/PlanetDataBis.php'; // teste $PlanetData = array(1 => array('temp' => mt_rand(220, 260), 'fields' => mt_rand(385, 498), 'image' => array('trocken' => mt_rand(1, 10), 'wuesten' => mt_rand(1, 4))), 2 => array('temp' => mt_rand(170, 210), 'fields' => mt_rand(387, 500), 'image' => array('trocken' => mt_rand(1, 10), 'wuesten' => mt_rand(1, 4))), 3 => array('temp' => mt_rand(120, 160), 'fields' => mt_rand(488, 527), 'image' => array('trocken' => mt_rand(1, 10), 'wuesten' => mt_rand(1, 4))), 4 => array('temp' => mt_rand(70, 110), 'fields' => mt_rand(513, 593), 'image' => array('dschjungel' => mt_rand(1, 10))), 5 => array('temp' => mt_rand(60, 100), 'fields' => mt_rand(538, 600), 'image' => array('dschjungel' => mt_rand(1, 10))), 6 => array('temp' => mt_rand(50, 90), 'fields' => mt_rand(538, 616), 'image' => array('dschjungel' => mt_rand(1, 10))), 7 => array('temp' => mt_rand(40, 80), 'fields' => mt_rand(531, 663), 'image' => array('normaltemp' => mt_rand(1, 7))), 8 => array('temp' => mt_rand(30, 70), 'fields' => mt_rand(559, 636), 'image' => array('normaltemp' => mt_rand(1, 7))), 9 => array('temp' => mt_rand(20, 60), 'fields' => mt_rand(551, 628), 'image' => array('normaltemp' => mt_rand(1, 7), 'wasser' => mt_rand(1, 9))), 10 => array('temp' => mt_rand(10, 50), 'fields' => mt_rand(544, 614), 'image' => array('normaltemp' => mt_rand(1, 7), 'wasser' => mt_rand(1, 9))), 11 => array('temp' => mt_rand(0, 40), 'fields' => mt_rand(538, 594), 'image' => array('normaltemp' => mt_rand(1, 7), 'wasser' => mt_rand(1, 9))), 12 => array('temp' => mt_rand(-10, 30), 'fields' => mt_rand(526, 561), 'image' => array('normaltemp' => mt_rand(1, 7), 'wasser' => mt_rand(1, 9))), 13 => array('temp' => mt_rand(-50, -10), 'fields' => mt_rand(499, 511), 'image' => array('eis' => mt_rand(1, 10))), 14 => array('temp' => mt_rand(-90, -50), 'fields' => mt_rand(471, 483), 'image' => array('eis' => mt_rand(1, 10))), 15 => array('temp' => mt_rand(-130, -90), 'fields' => mt_rand(445, 464), 'image' => array('eis' => mt_rand(1, 10)))); // fim teste $Pos = ceil($Position / (Config::get('max_planets') / count($PlanetData))); $TMax = $PlanetData[$Pos]['temp']; $TMin = $TMax - 40; $Fields = $PlanetData[$Pos]['fields'] * Config::get('planet_factor'); $Types = array_keys($PlanetData[$Pos]['image']); $Type = $Types[array_rand($Types)]; $Class = $Type . 'planet' . ($PlanetData[$Pos]['image'][$Type] < 10 ? '0' : '') . $PlanetData[$Pos]['image'][$Type]; $Name = !empty($PlanetName) ? $GLOBALS['DATABASE']->sql_escape($PlanetName) : $LNG['type_planet'][1]; $GLOBALS['DATABASE']->query("INSERT INTO " . PLANETS . " SET\n\t\t\t\tname = '" . $Name . "',\n\t\t\t\tuniverse = " . $Universe . ",\n\t\t\t\tid_owner = " . $PlanetOwnerID . ",\n\t\t\t\tgalaxy = " . $Galaxy . ",\n\t\t\t\tsystem = " . $System . ",\n\t\t\t\tplanet = " . $Position . ",\n\t\t\t\tlast_update = " . TIMESTAMP . ",\n\t\t\t\tplanet_type = '1',\n\t\t\t\timage = '" . $Class . "',\n\t\t\t\tdiameter = " . floor(1000 * sqrt($Fields)) . ",\n\t\t\t\tfield_max = " . ($HomeWorld ? Config::get('initial_fields') : floor($Fields)) . ",\n\t\t\t\ttemp_min = " . $TMin . ",\n\t\t\t\ttemp_max = " . $TMax . ",\n\t\t\t\tplanet_protection = '0',\n\t\t\t\tmetal = " . Config::get('metal_start') . ",\n\t\t\t\tmetal_perhour = " . Config::get('metal_basic_income') . ",\n\t\t\t\tcrystal = " . Config::get('crystal_start') . ",\n\t\t\t\tcrystal_perhour = " . Config::get('crystal_basic_income') . ",\n\t\t\t\tdeuterium = " . Config::get('deuterium_start') . ",\n\t\t\t\tdeuterium_perhour = " . Config::get('deuterium_basic_income') . ";"); return $GLOBALS['DATABASE']->GetInsertID(); }
function getCoords() { global $resource, $pricelist, $CONF; $PlanetCount = $this->PlanetCount(); $GalaxyAmplitude = ceil($PlanetCount / 2); $GalaxyMin = max($this->PLANET['galaxy'] - $Amplitude, 1); $GalaxyMax = min($this->PLANET['galaxy'] + $Amplitude, $CONF['max_galaxy']); $SystemAmplitude = ceil($PlanetCount / 1); $SystemMin = max($this->PLANET['system'] - $Amplitude, 1); $SystemMax = min($this->PLANET['system'] + $Amplitude, $CONF['max_galaxy']); $PlanetMin = 1; $PlanetMax = $CONF['max_planets']; $i = 0; do { $Galaxy = $this->randomNum($GalaxyMin, $GalaxyMax); $System = $this->randomNum($SystemMin, $SystemMax); $Planet = $this->randomNum($PlanetMin, $PlanetMax); if ($i >= self::BOTS_MAX_TRY_COLONIZE) { return false; } $i++; } while (CheckPlanetIfExist($Galaxy, $System, $Planet, $this->USER['universe'])); return array('galaxy' => $Galaxy, 'system' => $System, 'planet' => $Planet); }
/** * 2Moons * Copyright (C) 2011 Slaver * * 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 Slaver <*****@*****.**> * @copyright 2009 Lucky <*****@*****.**> (XGProyecto) * @copyright 2011 Slaver <*****@*****.**> (Fork/2Moons) * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License * @version 1.3 (2011-01-21) * @link http://code.google.com/p/2moons/ */ function CreateOnePlanetRecord($Galaxy, $System, $Position, $Universe, $PlanetOwnerID, $PlanetName = '', $HomeWorld = false, $AuthLevel = 0) { global $LNG, $db, $CONF; if (MAX_GALAXY_IN_WORLD < $Galaxy || 1 > $Galaxy) { throw new Exception("Access denied for CreateOnePlanetRecord.php.<br>Try to create a planet at position:" . $Galaxy . ":" . $System . ":" . $Position); } if (MAX_SYSTEM_IN_GALAXY < $System || 1 > $System) { throw new Exception("Access denied for CreateOnePlanetRecord.php.<br>Try to create a planet at position:" . $Galaxy . ":" . $System . ":" . $Position); } if (MAX_PLANET_IN_SYSTEM < $Position || 1 > $Position) { throw new Exception("Access denied for CreateOnePlanetRecord.php.<br>Try to create a planet at position:" . $Galaxy . ":" . $System . ":" . $Position); } if (CheckPlanetIfExist($Galaxy, $System, $Position, $Universe)) { return false; } $FieldFactor = $CONF['initial_fields'] / 163 * PLANET_SIZE_FACTOR; $Position = $Position > 15 ? mt_rand(1, 15) : $Position; switch ($Position) { case 1: $PlanetType = array('trocken', 'wuesten'); $PlanetClass = array('planet'); $PlanetDesign = array('trocken' => rand(1, 10), 'wuesten' => rand(1, 4)); $TMax = rand(220, 260); $TMin = $TMax - 40; $Fields = rand(95, 108) * $FieldFactor; break; case 2: $PlanetType = array('trocken', 'wuesten'); $PlanetClass = array('planet'); $PlanetDesign = array('trocken' => rand(1, 10), 'wuesten' => rand(1, 4)); $TMax = rand(170, 210); $TMin = $TMax - 40; $Fields = rand(97, 110) * $FieldFactor; break; case 3: $PlanetType = array('trocken', 'wuesten'); $PlanetClass = array('planet'); $PlanetDesign = array('trocken' => rand(1, 10), 'wuesten' => rand(1, 4)); $TMax = rand(120, 160); $TMin = $TMax - 40; $Fields = rand(98, 137) * $FieldFactor; break; case 4: $PlanetType = array('dschjungel'); $PlanetClass = array('planet'); $PlanetDesign = array('dschjungel' => rand(1, 10)); $TMax = rand(70, 110); $TMin = $TMax - 40; $Fields = rand(123, 203) * $FieldFactor; break; case 5: $PlanetType = array('dschjungel'); $PlanetClass = array('planet'); $PlanetDesign = array('dschjungel' => rand(1, 10)); $TMax = rand(60, 100); $TMin = $TMax - 40; $Fields = rand(148, 210) * $FieldFactor; break; case 6: $PlanetType = array('dschjungel'); $PlanetClass = array('planet'); $PlanetDesign = array('dschjungel' => rand(1, 10)); $TMax = rand(50, 90); $TMin = $TMax - 40; $Fields = rand(148, 226) * $FieldFactor; break; case 7: $PlanetType = array('normaltemp'); $PlanetClass = array('planet'); $PlanetDesign = array('normaltemp' => rand(1, 7)); $TMax = rand(40, 80); $TMin = $TMax - 40; $Fields = rand(141, 273) * $FieldFactor; break; case 8: $PlanetType = array('normaltemp'); $PlanetClass = array('planet'); $PlanetDesign = array('normaltemp' => rand(1, 7)); $TMax = rand(30, 70); $TMin = $TMax - 40; $Fields = rand(169, 246) * $FieldFactor; break; case 9: $PlanetType = array('normaltemp', 'wasser'); $PlanetClass = array('planet'); $PlanetDesign = array('normaltemp' => rand(1, 7), 'wasser' => rand(1, 9)); $TMax = rand(20, 60); $TMin = $TMax - 40; $Fields = rand(161, 238) * $FieldFactor; break; case 10: $PlanetType = array('wasser'); $PlanetClass = array('planet'); $PlanetDesign = array('wasser' => rand(1, 9)); $TMax = rand(10, 50); $TMin = $TMax - 40; $Fields = rand(154, 224) * $FieldFactor; break; case 11: $PlanetType = array('wasser'); $PlanetClass = array('planet'); $PlanetDesign = array('wasser' => rand(1, 9)); $TMax = rand(0, 40); $TMin = $TMax - 40; $Fields = rand(148, 204) * $FieldFactor; break; case 12: $PlanetType = array('wasser'); $PlanetClass = array('planet'); $PlanetDesign = array('wasser' => rand(1, 9)); $TMax = rand(-10, 30); $TMin = $TMax - 40; $Fields = rand(136, 171) * $FieldFactor; break; case 13: $PlanetType = array('eis'); $PlanetClass = array('planet'); $PlanetDesign = array('eis' => rand(1, 10)); $TMax = rand(-50, -10); $TMin = $TMax - 40; $Fields = rand(109, 121) * $FieldFactor; break; case 14: $PlanetType = array('eis', 'gas'); $PlanetClass = array('planet'); $PlanetDesign = array('eis' => rand(1, 10), 'gas' => rand(1, 8)); $TMax = rand(-90, -50); $TMin = $TMax - 40; $Fields = rand(81, 93) * $FieldFactor; break; case 15: $PlanetType = array('eis', 'gas'); $PlanetClass = array('planet'); $PlanetDesign = array('eis' => rand(1, 10), 'gas' => rand(1, 8)); $TMax = rand(-130, -90); $TMin = $TMax - 40; $Fields = rand(65, 74) * $FieldFactor; break; } $Type = $PlanetType[array_rand($PlanetType)]; $Class = $PlanetClass[array_rand($PlanetClass)]; $SQL = "INSERT INTO " . PLANETS . " SET "; if (!empty($PlanetName)) { $SQL .= "`name` = '" . $PlanetName . "', "; } if ($CONF['adm_attack'] == 0) { $AuthLevel = 0; } $SQL .= "`universe` = '" . $Universe . "', "; $SQL .= "`id_owner` = '" . $PlanetOwnerID . "', "; $SQL .= "`id_level` = '" . $AuthLevel . "', "; $SQL .= "`galaxy` = '" . $Galaxy . "', "; $SQL .= "`system` = '" . $System . "', "; $SQL .= "`planet` = '" . $Position . "', "; $SQL .= "`last_update` = '" . TIMESTAMP . "', "; $SQL .= "`planet_type` = '1', "; $SQL .= "`image` = '" . ($Type . $Class . ($PlanetDesign[$Type] <= 9 ? '0' : '') . $PlanetDesign[$Type]) . "', "; $SQL .= "`diameter` = '" . floor(1000 * sqrt($Fields)) . "', "; $SQL .= "`field_max` = '" . ($HomeWorld ? $CONF['initial_fields'] : floor($Fields)) . "', "; $SQL .= "`temp_min` = '" . $TMin . "', "; $SQL .= "`temp_max` = '" . $TMax . "', "; $SQL .= "`metal` = '" . BUILD_METAL . "', "; $SQL .= "`metal_perhour` = '" . $CONF['metal_basic_income'] . "', "; $SQL .= "`crystal` = '" . BUILD_CRISTAL . "', "; $SQL .= "`crystal_perhour` = '" . $CONF['crystal_basic_income'] . "', "; $SQL .= "`deuterium` = '" . BUILD_DEUTERIUM . "', "; $SQL .= "`deuterium_perhour` = '" . $CONF['deuterium_basic_income'] . "';"; $db->query($SQL); return $db->GetInsertID(); }
function ShowAccountEditorPage() { global $USER, $db, $LNG, $reslist, $resource, $UNI; $template = new template(); switch ($_GET['edit']) { case 'resources': $id = request_var('id', 0); $id_dark = request_var('id_dark', 0); $metal = floattostring(round(abs(request_var('metal', 0.0)), 0)); $cristal = floattostring(round(abs(request_var('cristal', 0.0)), 0)); $deut = floattostring(round(abs(request_var('deut', 0.0)), 0)); $norio = floattostring(round(abs(request_var('norio', 0.0)), 0)); $dark = request_var('dark', 0); if ($_POST) { if ($_POST['add']) { $SQL = "UPDATE " . PLANETS . " SET "; $SQL .= "`metal` = `metal` + '" . $metal . "', "; $SQL .= "`crystal` = `crystal` + '" . $cristal . "', "; $SQL .= "`deuterium` = `deuterium` + '" . $deut . "', "; $SQL .= "`norio` = `norio` + '" . $norio . "' "; $SQL .= "WHERE "; $SQL .= "`id` = '" . $id . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"; $db->query($SQL); if (!empty($id_dark)) { $SQL = "UPDATE " . USERS . " SET "; $SQL .= "`darkmatter` = `darkmatter` + '" . $dark . "' "; $SQL .= "WHERE "; $SQL .= "`id` = '" . $id_dark . "' AND `universe` = '" . $_SESSION['adminuni'] . "' "; $db->query($SQL); } $template->message($LNG['ad_add_sucess'], '?page=accounteditor&edit=resources'); } elseif ($_POST['delete']) { $SQL = "UPDATE " . PLANETS . " SET "; $SQL .= "`metal` = `metal` - '" . $metal . "', "; $SQL .= "`crystal` = `crystal` - '" . $cristal . "', "; $SQL .= "`deuterium` = `deuterium` - '" . $deut . "', "; $SQL .= "`norio` = `norio` - '" . $norio . "' "; $SQL .= "WHERE "; $SQL .= "`id` = '" . $id . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"; $db->query($SQL); if (!empty($id_dark)) { $SQL = "UPDATE " . USERS . " SET "; $SQL .= "`darkmatter` = `darkmatter` - '" . $dark . "' "; $SQL .= "WHERE "; $SQL .= "`id` = '" . $id_dark . "';"; $db->query($SQL); } $template->message($LNG['ad_delete_sucess'], '?page=accounteditor&edit=resources'); } exit; } $template->assign_vars(array('button_reset' => $LNG['button_reset'], 'button_delete' => $LNG['button_delete'], 'button_add' => $LNG['button_add'], 'Metal' => $LNG['Metal'], 'Crystal' => $LNG['Crystal'], 'Deuterium' => $LNG['Deuterium'], 'Norio' => $LNG['Norio'], 'Darkmatter' => $LNG['Darkmatter'], 'ad_back_to_menu' => $LNG['ad_back_to_menu'], 'input_id_user' => $LNG['input_id_user'], 'resources_title' => $LNG['resources_title'], 'input_id_p_m' => $LNG['input_id_p_m'])); $template->show('adm/AccountEditorPageResources.tpl'); break; case 'ships': if ($_POST) { if ($_POST['add']) { $SQL = "UPDATE " . PLANETS . " SET "; foreach ($reslist['fleet'] as $ID) { $QryUpdate[] = "`" . $resource[$ID] . "` = `" . $resource[$ID] . "` + '" . floattostring(round(abs(request_var($resource[$ID], 0.0)), 0)) . "'"; } $SQL .= implode(", ", $QryUpdate); $SQL .= "WHERE "; $SQL .= "`id` = '" . request_var('id', 0) . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"; $db->query($SQL); $template->message($LNG['ad_add_sucess_ships'], '?page=accounteditor&edit=ships'); } elseif ($_POST['delete']) { $SQL = "UPDATE " . PLANETS . " SET "; foreach ($reslist['fleet'] as $ID) { $QryUpdate[] = "`" . $resource[$ID] . "` = `" . $resource[$ID] . "` - '" . floattostring(round(abs(request_var($resource[$ID], 0.0)), 0)) . "'"; } $SQL .= implode(", ", $QryUpdate); $SQL .= "WHERE "; $SQL .= "`id` = '" . request_var('id', 0) . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"; $db->query($SQL); $template->message($LNG['ad_delete_sucess_ships'], '?page=accounteditor&edit=ships'); } exit; } $parse['ships'] = ""; foreach ($reslist['fleet'] as $ID) { $INPUT[$ID] = array('name' => $LNG['tech'][$ID], 'type' => $resource[$ID]); } $template->assign_vars(array('inputlist' => $INPUT, 'button_reset' => $LNG['button_reset'], 'button_delete' => $LNG['button_delete'], 'button_add' => $LNG['button_add'], 'ad_back_to_menu' => $LNG['ad_back_to_menu'], 'input_id_p_m' => $LNG['input_id_p_m'], 'ships_title' => $LNG['ad_ships_title'], 'ad_number' => $LNG['ad_number'], 'ships_count' => $LNG['ad_count'])); $template->show('adm/AccountEditorPageShips.tpl'); break; case 'defenses': if ($_POST) { if ($_POST['add']) { $SQL = "UPDATE " . PLANETS . " SET "; foreach ($reslist['defense'] as $ID) { $QryUpdate[] = "`" . $resource[$ID] . "` = `" . $resource[$ID] . "` + '" . floattostring(round(abs(request_var($resource[$ID], 0.0)), 0)) . "'"; } $SQL .= implode(", ", $QryUpdate); $SQL .= "WHERE "; $SQL .= "`id` = '" . request_var('id', 0) . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"; $db->query($SQL); $template->message($LNG['ad_add_defenses_succes'], '?page=accounteditor&edit=defenses'); } elseif ($_POST['delete']) { $SQL = "UPDATE " . PLANETS . " SET "; foreach ($reslist['defense'] as $ID) { $QryUpdate[] = "`" . $resource[$ID] . "` = `" . $resource[$ID] . "` - '" . floattostring(round(abs(request_var($resource[$ID], 0.0)), 0)) . "'"; } $SQL .= implode(", ", $QryUpdate); $SQL .= "WHERE "; $SQL .= "`id` = '" . request_var('id', 0) . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"; $db->query($SQL); $Name = $LNG['log_nomoree']; $template->message($LNG['ad_delete_defenses_succes'], '?page=accounteditor&edit=defenses'); } exit; } foreach ($reslist['defense'] as $ID) { $INPUT[$ID] = array('name' => $LNG['tech'][$ID], 'type' => $resource[$ID]); } $template->assign_vars(array('inputlist' => $INPUT, 'button_reset' => $LNG['button_reset'], 'button_delete' => $LNG['button_delete'], 'button_add' => $LNG['button_add'], 'ad_back_to_menu' => $LNG['ad_back_to_menu'], 'input_id_p_m' => $LNG['input_id_p_m'], 'defenses_title' => $LNG['ad_defenses_title'], 'ad_number' => $LNG['ad_number'], 'defenses_count' => $LNG['ad_count'])); $template->show('adm/AccountEditorPageDefenses.tpl'); break; break; case 'buildings': if ($_POST) { $PlanetData = $db->uniquequery("SELECT `planet_type` FROM " . PLANETS . " WHERE `id` = '" . request_var('id', 0) . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"); if (!isset($PlanetData)) { $template->message($LNG['ad_add_not_exist'], '?page=accounteditor&edit=buildings'); } if ($_POST['add']) { $SQL = "UPDATE " . PLANETS . " SET "; foreach ($reslist['allow'][$PlanetData['planet_type']] as $ID) { $QryUpdate[] = "`" . $resource[$ID] . "` = `" . $resource[$ID] . "` + '" . floattostring(round(abs(request_var($resource[$ID], 0.0)), 0)) . "'"; } $SQL .= implode(", ", $QryUpdate); $SQL .= "WHERE "; $SQL .= "`id` = '" . request_var('id', 0) . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"; $db->query($SQL); $template->message($LNG['ad_add_succes'], '?page=accounteditor&edit=buildings'); } elseif ($_POST['delete']) { $SQL = "UPDATE " . PLANETS . " SET "; foreach ($reslist['allow'][$PlanetData['planet_type']] as $ID) { $QryUpdate[] = "`" . $resource[$ID] . "` = `" . $resource[$ID] . "` - '" . floattostring(round(abs(request_var($resource[$ID], 0.0)), 0)) . "'"; } $SQL .= implode(", ", $QryUpdate); $SQL .= "WHERE "; $SQL .= "`id` = '" . request_var('id', 0) . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"; $db->query($SQL); $template->message($LNG['ad_delete_succes'], '?page=accounteditor&edit=buildings'); } exit; } foreach ($reslist['build'] as $ID) { $INPUT[$ID] = array('name' => $LNG['tech'][$ID], 'type' => $resource[$ID]); } $template->assign_vars(array('inputlist' => $INPUT, 'button_reset' => $LNG['button_reset'], 'button_delete' => $LNG['button_delete'], 'button_add' => $LNG['button_add'], 'ad_back_to_menu' => $LNG['ad_back_to_menu'], 'input_id_p_m' => $LNG['input_id_p_m'], 'buildings_title' => $LNG['ad_buildings_title'], 'ad_number' => $LNG['ad_number'], 'ad_levels' => $LNG['ad_levels'])); $template->show('adm/AccountEditorPageBuilds.tpl'); break; case 'researchs': if ($_POST) { if ($_POST['add']) { $SQL = "UPDATE " . USERS . " SET "; foreach ($reslist['tech'] as $ID) { $QryUpdate[] = "`" . $resource[$ID] . "` = `" . $resource[$ID] . "` + '" . floattostring(round(abs(request_var($resource[$ID], 0.0)), 0)) . "'"; } $SQL .= implode(", ", $QryUpdate); $SQL .= "WHERE "; $SQL .= "`id` = '" . request_var('id', 0) . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"; $db->query($SQL); $template->message($LNG['ad_add_succes'], '?page=accounteditor&edit=researchs'); } elseif ($_POST['delete']) { $SQL = "UPDATE " . USERS . " SET "; foreach ($reslist['tech'] as $ID) { $QryUpdate[] = "`" . $resource[$ID] . "` = `" . $resource[$ID] . "` - '" . floattostring(round(abs(request_var($resource[$ID], 0.0)), 0)) . "'"; } $SQL .= implode(", ", $QryUpdate); $SQL .= "WHERE "; $SQL .= "`id` = '" . request_var('id', 0) . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"; $db->query($SQL); $template->message($LNG['ad_delete_succes'], '?page=accounteditor&edit=researchs'); } exit; } foreach ($reslist['tech'] as $ID) { $INPUT[$ID] = array('name' => $LNG['tech'][$ID], 'type' => $resource[$ID]); } $template->assign_vars(array('inputlist' => $INPUT, 'button_reset' => $LNG['button_reset'], 'button_delete' => $LNG['button_delete'], 'button_add' => $LNG['button_add'], 'ad_back_to_menu' => $LNG['ad_back_to_menu'], 'input_id_user' => $LNG['input_id_user'], 'research_title' => $LNG['ad_research_title'], 'ad_number' => $LNG['ad_number'], 'research_count' => $LNG['ad_count'])); $template->show('adm/AccountEditorPageResearch.tpl'); break; case 'personal': if ($_POST) { $id = request_var('id', 0); $username = request_var('username', '', UTF8_SUPPORT); $password = request_var('password', '', true); $email = request_var('email', ''); $email_2 = request_var('email_2', ''); $vacation = request_var('vacation', ''); $PersonalQuery = "UPDATE " . USERS . " SET "; if (!empty($username) && $id != 1) { $PersonalQuery .= "`username` = '" . $db->sql_escape($username) . "', "; } if (!empty($email) && $id != 1) { $PersonalQuery .= "`email` = '" . $db->sql_escape($email) . "', "; } if (!empty($email_2) && $id != 1) { $PersonalQuery .= "`email_2` = '" . $db->sql_escape($email_2) . "', "; } if (!empty($password) && $id != 1) { $PersonalQuery .= "`password` = '" . $db->sql_escape(md5($password)) . "', "; } $Answer = 0; $TimeAns = 0; if ($vacation == 'yes') { $Answer = 1; $TimeAns = TIMESTAMP + $_POST['d'] * 86400 + $_POST['h'] * 3600 + $_POST['m'] * 60 + $_POST['s']; } $PersonalQuery .= "`urlaubs_modus` = '" . $Answer . "', `urlaubs_until` = '" . $TimeAns . "' "; $PersonalQuery .= "WHERE `id` = '" . $id . "' AND `universe` = '" . $_SESSION['adminuni'] . "'"; $db->query($PersonalQuery); $template->message($LNG['ad_personal_succes'], '?page=accounteditor&edit=personal'); exit; } $template->assign_vars(array('button_submit' => $LNG['button_submit'], 'ad_back_to_menu' => $LNG['ad_back_to_menu'], 'input_id' => $LNG['input_id'], 'ad_personal_vacat' => $LNG['ad_personal_vacat'], 'ad_personal_email2' => $LNG['ad_personal_email2'], 'ad_personal_email' => $LNG['ad_personal_email'], 'ad_personal_pass' => $LNG['ad_personal_pass'], 'ad_personal_name' => $LNG['ad_personal_name'], 'ad_personal_title' => $LNG['ad_personal_title'], 'time_seconds' => $LNG['time_seconds'], 'time_minutes' => $LNG['time_minutes'], 'time_hours' => $LNG['time_hours'], 'time_days' => $LNG['time_days'], 'Selector' => array('' => $LNG['select_option'], 'yes' => $LNG['one_is_yes'][1], 'no' => $LNG['one_is_yes'][0]))); $template->show('adm/AccountEditorPagePersonal.tpl'); break; case 'officiers': if ($_POST) { if ($_POST['add']) { $SQL = "UPDATE " . USERS . " SET "; foreach ($reslist['dmfunc'] as $ID) { $QryUpdate[] = "`" . $resource[$ID] . "` = `" . $resource[$ID] . "` + '" . floattostring(round(abs(request_var($resource[$ID], 0.0)), 0)) . "'"; } $SQL .= implode(", ", $QryUpdate); $SQL .= "WHERE "; $SQL .= "`id` = '" . request_var('id', 0) . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"; $db->query($SQL); $template->message($LNG['ad_offi_succes_add'], '?page=accounteditor&edit=officiers'); } elseif ($_POST['delete']) { $SQL = "UPDATE " . USERS . " SET "; foreach ($reslist['dmfunc'] as $ID) { $QryUpdate[] = "`" . $resource[$ID] . "` = `" . $resource[$ID] . "` - '" . floattostring(round(abs(request_var($resource[$ID], 0.0)), 0)) . "'"; } $SQL .= implode(", ", $QryUpdate); $SQL .= "WHERE "; $SQL .= "`id` = '" . request_var('id', 0) . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"; $db->query($SQL); $template->message($LNG['ad_offi_succes_delete'], '?page=accounteditor&edit=officiers'); } exit; } foreach ($reslist['dmfunc'] as $ID) { $INPUT[$ID] = array('name' => $LNG['tech'][$ID], 'type' => $resource[$ID]); } $template->assign_vars(array('inputlist' => $INPUT, 'button_reset' => $LNG['button_reset'], 'button_delete' => $LNG['button_delete'], 'button_add' => $LNG['button_add'], 'ad_back_to_menu' => $LNG['ad_back_to_menu'], 'input_id_user' => $LNG['input_id_user'], 'officiers_title' => $LNG['ad_offi_title'], 'ad_number' => $LNG['ad_number'], 'officiers_count' => $LNG['ad_count'])); $template->show('adm/AccountEditorPageOfficiers.tpl'); break; case 'planets': if ($_POST) { $id = request_var('id', 0); $name = request_var('name', '', UTF8_SUPPORT); $diameter = request_var('diameter', 0); $fields = request_var('fields', 0); $buildings = request_var('0_buildings', ''); $ships = request_var('0_ships', ''); $defenses = request_var('0_defenses', ''); $c_hangar = request_var('0_c_hangar', ''); $c_buildings = request_var('0_c_buildings', ''); $change_pos = request_var('change_position', ''); $galaxy = request_var('g', 0); $system = request_var('s', 0); $planet = request_var('p', 0); if (!empty($name)) { $db->query("UPDATE " . PLANETS . " SET `name` = '" . $db->sql_escape($name) . "' WHERE `id` = '" . $id . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"); } if ($buildings == 'on') { foreach ($reslist['build'] as $ID) { $BUILD[] = "`" . $resource[$ID] . "` = '0'"; } $db->query("UPDATE " . PLANETS . " SET " . implode(', ', $BUILD) . " WHERE `id` = '" . $id . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"); } if ($ships == 'on') { foreach ($reslist['fleet'] as $ID) { $SHIPS[] = "`" . $resource[$ID] . "` = '0'"; } $db->query("UPDATE " . PLANETS . " SET " . implode(', ', $SHIPS) . " WHERE `id` = '" . $id . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"); } if ($defenses == 'on') { foreach ($reslist['defense'] as $ID) { $DEFS[] = "`" . $resource[$ID] . "` = '0'"; } $db->query("UPDATE " . PLANETS . " SET " . implode(', ', $DEFS) . " WHERE `id` = '" . $id . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"); } if ($c_hangar == 'on') { $db->query("UPDATE " . PLANETS . " SET `b_hangar` = '0', `b_hangar_plus` = '0', `b_hangar_id` = '' WHERE `id` = '" . $id . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"); } if ($c_buildings == 'on') { $db->query("UPDATE " . PLANETS . " SET `b_building` = '0', `b_building_id` = '' WHERE `id` = '" . $id . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"); } if (!empty($diameter)) { $db->query("UPDATE " . PLANETS . " SET `diameter` = '" . $diameter . "' WHERE `id` = '" . $id . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"); } if (!empty($fields)) { $db->query("UPDATE " . PLANETS . " SET `field_max` = '" . $fields . "' WHERE `id` = '" . $id . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"); } if ($change_pos == 'on' && $galaxy > 0 && $system > 0 && $planet > 0 && $galaxy <= MAX_GALAXY_IN_WORLD && $system <= MAX_SYSTEM_IN_GALAXY && $planet <= MAX_PLANET_IN_SYSTEM) { $P = $db->uniquequery("SELECT galaxy,system,planet,planet_type FROM " . PLANETS . " WHERE `id` = '" . $id . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"); if ($P['planet_type'] == '1') { if (CheckPlanetIfExist($galaxy, $system, $planet, $UNI, $P['planet_type'])) { $template->message($LNG['ad_pla_error_planets3'], '?page=accounteditor&edit=planets'); exit; } $db->query("UPDATE " . PLANETS . " SET `galaxy` = '" . $galaxy . "', `system` = '" . $system . "', `planet` = '" . $planet . "' WHERE `id` = '" . $id . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"); } else { if (CheckPlanetIfExist($galaxy, $system, $planet, $UNI, $P['planet_type'])) { $template->message($LNG['ad_pla_error_planets5'], '?page=accounteditor&edit=planets'); exit; } $Target = $db->uniquequery("SELECT id_luna FROM " . PLANETS . " WHERE `galaxy` = '" . $galaxy . "' AND `system` = '" . $system . "' AND `planet` = '" . $planet . "' AND `planet_type` = '1';"); if ($Target['id_luna'] != '0') { $template->message($LNG['ad_pla_error_planets4'], '?page=accounteditor&edit=planets'); exit; } $db->multi_query("UPDATE " . PLANETS . " SET `id_luna` = '0' WHERE `galaxy` = '" . $P['galaxy'] . "' AND `system` = '" . $P['system'] . "' AND `planet` = '" . $P['planet'] . "' AND `planet_type` = '1';UPDATE " . PLANETS . " SET `id_luna` = '" . $id . "' WHERE `galaxy` = '" . $galaxy . "' AND `system` = '" . $system . "' AND `planet` = '" . $planet . "' AND planet_type = '1';UPDATE " . PLANETS . " SET `galaxy` = '" . $galaxy . "', `system` = '" . $system . "', `planet` = '" . $planet . "' WHERE `id` = '" . $id . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"); $QMOON2 = $db->uniquequery("SELECT id_level, id_owner FROM " . PLANETS . " WHERE `galaxy` = '" . $galaxy . "' AND `system` = '" . $system . "' AND `planet` = '" . $planet . "';"); $db->query("UPDATE " . PLANETS . " SET `galaxy` = '" . $galaxy . "', `system` = '" . $system . "', `planet` = '" . $planet . "', `id_owner` = '" . $QMOON2['id_owner'] . "', `id_level` = '" . $QMOON2['id_level'] . "' WHERE `id` = '" . $id . "' AND `universe` = '" . $_SESSION['adminuni'] . "' AND `planet_type` = '3';"); } } $template->message($LNG['ad_pla_succes'], '?page=accounteditor&edit=planets'); exit; } $template->assign_vars(array('button_submit' => $LNG['button_submit'], 'button_reset' => $LNG['button_reset'], 'ad_back_to_menu' => $LNG['ad_back_to_menu'], 'ad_pla_title' => $LNG['ad_pla_title'], 'input_id_p_m' => $LNG['input_id_p_m'], 'ad_pla_edit_name' => $LNG['ad_pla_edit_name'], 'ad_pla_edit_diameter' => $LNG['ad_pla_edit_diameter'], 'ad_pla_edit_fields' => $LNG['ad_pla_edit_fields'], 'ad_pla_delete_b' => $LNG['ad_pla_delete_b'], 'ad_pla_delete_s' => $LNG['ad_pla_delete_s'], 'ad_pla_delete_d' => $LNG['ad_pla_delete_d'], 'ad_pla_delete_hd' => $LNG['ad_pla_delete_hd'], 'ad_pla_delete_cb' => $LNG['ad_pla_delete_cb'], 'ad_pla_title_l' => $LNG['ad_pla_title_l'], 'ad_pla_change_p' => $LNG['ad_pla_change_p'], 'ad_pla_change_pp' => $LNG['ad_pla_change_pp'])); $template->show('adm/AccountEditorPagePlanets.tpl'); break; case 'alliances': if ($_POST) { $id = request_var('id', 0); $name = request_var('name', '', UTF8_SUPPORT); $changeleader = request_var('changeleader', 0); $tag = request_var('tag', '', UTF8_SUPPORT); $externo = request_var('externo', '', true); $interno = request_var('interno', '', true); $solicitud = request_var('solicitud', '', true); $delete = request_var('delete', ''); $delete_u = request_var('delete_u', ''); #$QueryF = $db->uniquequery("SELECT * FROM ".ALLIANCE." WHERE `id` = '".$id."' AND `universe` = '".$_SESSION['adminuni']."';"); $QueryF = $db->uniquequery("SELECT * FROM " . ALLIANCE . " WHERE `id` = '" . $id . "' AND `ally_universe` = '" . $_SESSION['adminuni'] . "';"); if (!empty($name)) { #$db->multi_query("UPDATE ".ALLIANCE." SET `ally_name` = '".$name."' WHERE `id` = '".$id."' AND `universe` = '".$_SESSION['adminuni']."';UPDATE ".USERS." SET `ally_name` = '".$name."' WHERE `ally_id` = '".$id."';"); $db->multi_query("UPDATE " . ALLIANCE . " SET `ally_name` = '" . $name . "' WHERE `id` = '" . $id . "' AND `ally_universe` = '" . $_SESSION['adminuni'] . "';UPDATE " . USERS . " SET `ally_name` = '" . $name . "' WHERE `ally_id` = '" . $id . "';"); } if (!empty($tag)) { #$db->query("UPDATE ".ALLIANCE." SET `ally_tag` = '".$tag."' WHERE `id` = '".$id."' AND `universe` = '".$_SESSION['adminuni']."';"); $db->query("UPDATE " . ALLIANCE . " SET `ally_tag` = '" . $tag . "' WHERE `id` = '" . $id . "' AND `ally_universe` = '" . $_SESSION['adminuni'] . "';"); } $QueryF2 = $db->uniquequery("SELECT ally_id FROM " . USERS . " WHERE `id` = '" . $changeleader . "';"); #$db->multi_query("UPDATE ".ALLIANCE." SET `ally_owner` = '".$changeleader."' WHERE `id` = '".$id."' AND `universe` = '".$_SESSION['adminuni']."';UPDATE ".USERS." SET `ally_rank_id` = '0' WHERE `id` = '".$changeleader."';"); $db->multi_query("UPDATE " . ALLIANCE . " SET `ally_owner` = '" . $changeleader . "' WHERE `id` = '" . $id . "' AND `ally_universe` = '" . $_SESSION['adminuni'] . "';UPDATE " . USERS . " SET `ally_rank_id` = '0' WHERE `id` = '" . $changeleader . "';"); if (!empty($externo)) { #$db->query("UPDATE ".ALLIANCE." SET `ally_description` = '".$externo."' WHERE `id` = '".$id."' AND `universe` = '".$_SESSION['adminuni']."';"); $db->query("UPDATE " . ALLIANCE . " SET `ally_description` = '" . $externo . "' WHERE `id` = '" . $id . "' AND `ally_universe` = '" . $_SESSION['adminuni'] . "';"); } if (!empty($interno)) { #$db->query("UPDATE ".ALLIANCE." SET `ally_text` = '".$interno."' WHERE `id` = '".$id."' AND `universe` = '".$_SESSION['adminuni']."';"); $db->query("UPDATE " . ALLIANCE . " SET `ally_text` = '" . $interno . "' WHERE `id` = '" . $id . "' AND `ally_universe` = '" . $_SESSION['adminuni'] . "';"); } if (!empty($solicitud)) { $db->query("UPDATE " . ALLIANCE . " SET `ally_request` = '" . $solicitud . "' WHERE `id` = '" . $id . "' AND `universe` = '" . $_SESSION['adminuni'] . "';"); } #$db->query("UPDATE ".ALLIANCE." SET `ally_request` = '".$solicitud."' WHERE `id` = '".$id."' AND `ally_universe` = '".$_SESSION['adminuni']."';"); if ($delete == 'on') { #$db->multi_query("DELETE FROM ".ALLIANCE." WHERE `id` = '".$id."' AND `universe` = '".$_SESSION['adminuni']."';UPDATE ".USERS." SET `ally_id` = '0', `ally_name` = '', `ally_request` = '0', `ally_rank_id` = '0', `ally_register_time` = '0', `ally_request` = '0' WHERE `ally_id` = '".$id."';"); $db->multi_query("DELETE FROM " . ALLIANCE . " WHERE `id` = '" . $id . "' AND `ally_universe` = '" . $_SESSION['adminuni'] . "';UPDATE " . USERS . " SET `ally_id` = '0', `ally_name` = '', `ally_request` = '0', `ally_rank_id` = '0', `ally_register_time` = '0', `ally_request` = '0' WHERE `ally_id` = '" . $id . "';"); } if (!empty($delete_u)) { #$db->multi_query("UPDATE ".ALLIANCE." SET `ally_members` = ally_members - 1 WHERE `id` = '".$id."' AND `universe` = '".$_SESSION['adminuni']."';UPDATE ".USERS." SET `ally_id` = '0', `ally_name` = '', `ally_request` = '0', `ally_rank_id` = '0', `ally_register_time` = '0', `ally_request` = '0' WHERE `id` = '".$delete_u."' AND `ally_id` = '".$id."';"); $db->multi_query("UPDATE " . ALLIANCE . " SET `ally_members` = ally_members - 1 WHERE `id` = '" . $id . "' AND `ally_universe` = '" . $_SESSION['adminuni'] . "';UPDATE " . USERS . " SET `ally_id` = '0', `ally_name` = '', `ally_request` = '0', `ally_rank_id` = '0', `ally_register_time` = '0', `ally_request` = '0' WHERE `id` = '" . $delete_u . "' AND `ally_id` = '" . $id . "';"); } $template->message($LNG['ad_ally_succes'], '?page=accounteditor&edit=alliances'); exit; } $template->assign_vars(array('button_submit' => $LNG['button_submit'], 'ad_back_to_menu' => $LNG['ad_back_to_menu'], 'ad_pla_title' => $LNG['ad_pla_title'], 'ad_ally_title' => $LNG['ad_ally_title'], 'input_id_ally' => $LNG['input_id_ally'], 'ad_ally_change_id' => $LNG['ad_ally_change_id'], 'ad_ally_name' => $LNG['ad_ally_name'], 'ad_ally_tag' => $LNG['ad_ally_tag'], 'ad_ally_delete_u' => $LNG['ad_ally_delete_u'], 'ad_ally_user_id' => $LNG['ad_ally_user_id'], 'ad_ally_delete' => $LNG['ad_ally_delete'], 'ad_ally_text1' => $LNG['ad_ally_text1'], 'ad_ally_text2' => $LNG['ad_ally_text2'], 'ad_ally_text3' => $LNG['ad_ally_text3'])); $template->show('adm/AccountEditorPageAlliance.tpl'); break; default: $template->assign_vars(array('ad_editor_personal' => $LNG['ad_editor_personal'], 'ad_editor_alliances' => $LNG['ad_editor_alliances'], 'ad_editor_planets' => $LNG['ad_editor_planets'], 'ad_editor_resources' => $LNG['ad_editor_resources'], 'ad_editor_officiers' => $LNG['ad_editor_officiers'], 'ad_editor_researchs' => $LNG['ad_editor_researchs'], 'ad_editor_defenses' => $LNG['ad_editor_defenses'], 'ad_editor_ships' => $LNG['ad_editor_ships'], 'ad_editor_buildings' => $LNG['ad_editor_buildings'], 'ad_editor_title' => $LNG['ad_editor_title'])); $template->show('adm/AccountEditorPageMenu.tpl'); break; } }
function ShowAccountEditorPage() { global $USER, $LNG, $reslist, $resource, $UNI; $template = new template(); switch ($_GET['edit']) { case 'resources': $id = HTTP::_GP('id', 0); $id_dark = HTTP::_GP('id_dark', 0); $metal = max(0, round(HTTP::_GP('metal', 0.0))); $cristal = max(0, round(HTTP::_GP('cristal', 0.0))); $deut = max(0, round(HTTP::_GP('deut', 0.0))); $dark = HTTP::_GP('dark', 0); if ($_POST) { if (!empty($id)) { $before = $GLOBALS['DATABASE']->getFirstRow("SELECT `metal`,`crystal`,`deuterium`,`universe` FROM " . PLANETS . " WHERE `id` = '" . $id . "';"); } if (!empty($id_dark)) { $before_dm = $GLOBALS['DATABASE']->getFirstRow("SELECT `antimatter` FROM " . USERS . " WHERE `id` = '" . $id_dark . "';"); } if ($_POST['add']) { if (!empty($id)) { $SQL = "UPDATE " . PLANETS . " SET "; $SQL .= "`metal` = `metal` + '" . $metal . "', "; $SQL .= "`crystal` = `crystal` + '" . $cristal . "', "; $SQL .= "`deuterium` = `deuterium` + '" . $deut . "' "; $SQL .= "WHERE "; $SQL .= "`id` = '" . $id . "' AND `universe` = '1';"; $GLOBALS['DATABASE']->query($SQL); $after = array('metal' => $before['metal'] + $metal, 'crystal' => $before['crystal'] + $cristal, 'deuterium' => $before['deuterium'] + $deut); } if (!empty($id_dark)) { $SQL = "UPDATE " . USERS . " SET "; $SQL .= "`antimatter` = `antimatter` + '" . $dark . "' "; $SQL .= "WHERE "; $SQL .= "`id` = '" . $id_dark . "' AND `universe` = '1' "; $GLOBALS['DATABASE']->query($SQL); $after_dm = array('antimatter' => $before_dm['antimatter'] + $dark); } } elseif ($_POST['delete']) { if (!empty($id)) { $SQL = "UPDATE " . PLANETS . " SET "; $SQL .= "`metal` = `metal` - '" . $metal . "', "; $SQL .= "`crystal` = `crystal` - '" . $cristal . "', "; $SQL .= "`deuterium` = `deuterium` - '" . $deut . "' "; $SQL .= "WHERE "; $SQL .= "`id` = '" . $id . "' AND `universe` = '1';"; $GLOBALS['DATABASE']->query($SQL); $after = array('metal' => $before['metal'] - $metal, 'crystal' => $before['crystal'] - $cristal, 'deuterium' => $before['deuterium'] - $deut); } if (!empty($id_dark)) { $SQL = "UPDATE " . USERS . " SET "; $SQL .= "`antimatter` = `antimatter` - '" . $dark . "' "; $SQL .= "WHERE "; $SQL .= "`id` = '" . $id_dark . "';"; $GLOBALS['DATABASE']->query($SQL); $after_dm = array('antimatter' => $before_dm['antimatter'] - $dark); } } if (!empty($id)) { $LOG = new Log(2); $LOG->target = $id; $LOG->universe = $before_dm['universe']; $LOG->old = $before; $LOG->new = $after; $LOG->save(); } if (!empty($id_dark)) { $LOG = new Log(1); $LOG->target = $id_dark; $LOG->universe = $before_dm['universe']; $LOG->old = $before_dm; $LOG->new = $after_dm; $LOG->save(); } if ($_POST['add']) { $template->message($LNG['ad_add_res_sucess'], '?page=accounteditor&edit=resources'); } else { if ($_POST['delete']) { $template->message($LNG['ad_delete_res_sucess'], '?page=accounteditor&edit=resources'); } } exit; } $template->show('AccountEditorPageResources.tpl'); break; case 'ships': if ($_POST) { $before1 = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . PLANETS . " WHERE `id` = '" . HTTP::_GP('id', 0) . "';"); $before = array(); $after = array(); foreach ($reslist['fleet'] as $ID) { $before[$ID] = $before1[$resource[$ID]]; } if ($_POST['add']) { $SQL = "UPDATE " . PLANETS . " SET "; $SQL .= "`eco_hash` = '', "; foreach ($reslist['fleet'] as $ID) { $QryUpdate[] = "`" . $resource[$ID] . "` = `" . $resource[$ID] . "` + '" . max(0, round(HTTP::_GP($resource[$ID], 0.0))) . "'"; $after[$ID] = $before[$ID] + max(0, round(HTTP::_GP($resource[$ID], 0.0))); } $SQL .= implode(", ", $QryUpdate); $SQL .= "WHERE "; $SQL .= "`id` = '" . HTTP::_GP('id', 0) . "' AND `universe` = '1';"; $GLOBALS['DATABASE']->query($SQL); } elseif ($_POST['delete']) { $SQL = "UPDATE " . PLANETS . " SET "; $SQL .= "`eco_hash` = '', "; foreach ($reslist['fleet'] as $ID) { $QryUpdate[] = "`" . $resource[$ID] . "` = `" . $resource[$ID] . "` - '" . max(0, round(HTTP::_GP($resource[$ID], 0.0))) . "'"; $after[$ID] = max($before[$ID] - max(0, round(HTTP::_GP($resource[$ID], 0.0))), 0); } $SQL .= implode(", ", $QryUpdate); $SQL .= "WHERE "; $SQL .= "`id` = '" . HTTP::_GP('id', 0) . "' AND `universe` = '1';"; $GLOBALS['DATABASE']->query($SQL); } $LOG = new Log(2); $LOG->target = HTTP::_GP('id', 0); $LOG->universe = $before1['universe']; $LOG->old = $before; $LOG->new = $after; $LOG->save(); if ($_POST['add']) { $template->message($LNG['ad_add_ships_sucess'], '?page=accounteditor&edit=ships'); } else { if ($_POST['delete']) { $template->message($LNG['ad_delete_ships_sucess'], '?page=accounteditor&edit=ships'); } } exit; } $parse['ships'] = ""; foreach ($reslist['fleet'] as $ID) { $INPUT[$ID] = array('type' => $resource[$ID]); } $template->assign_vars(array('inputlist' => $INPUT)); $template->show('AccountEditorPageShips.tpl'); break; case 'defenses': if ($_POST) { $before1 = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . PLANETS . " WHERE `id` = '" . HTTP::_GP('id', 0) . "';"); $before = array(); $after = array(); foreach ($reslist['defense'] as $ID) { $before[$ID] = $before1[$resource[$ID]]; } if ($_POST['add']) { $SQL = "UPDATE " . PLANETS . " SET "; foreach ($reslist['defense'] as $ID) { $QryUpdate[] = "`" . $resource[$ID] . "` = `" . $resource[$ID] . "` + '" . max(0, round(HTTP::_GP($resource[$ID], 0.0))) . "'"; $after[$ID] = $before[$ID] + max(0, round(HTTP::_GP($resource[$ID], 0.0))); } $SQL .= implode(", ", $QryUpdate); $SQL .= "WHERE "; $SQL .= "`id` = '" . HTTP::_GP('id', 0) . "' AND `universe` = '1';"; $GLOBALS['DATABASE']->query($SQL); } elseif ($_POST['delete']) { $SQL = "UPDATE " . PLANETS . " SET "; foreach ($reslist['defense'] as $ID) { $QryUpdate[] = "`" . $resource[$ID] . "` = `" . $resource[$ID] . "` - '" . max(0, round(HTTP::_GP($resource[$ID], 0.0))) . "'"; $after[$ID] = max($before[$ID] - max(0, round(HTTP::_GP($resource[$ID], 0.0))), 0); } $SQL .= implode(", ", $QryUpdate); $SQL .= "WHERE "; $SQL .= "`id` = '" . HTTP::_GP('id', 0) . "' AND `universe` = '1';"; $GLOBALS['DATABASE']->query($SQL); $Name = $LNG['log_nomoree']; } $LOG = new Log(2); $LOG->target = HTTP::_GP('id', 0); $LOG->universe = $before1['universe']; $LOG->old = $before; $LOG->new = $after; $LOG->save(); if ($_POST['add']) { $template->message($LNG['ad_add_defenses_success'], '?page=accounteditor&edit=defenses'); } else { if ($_POST['delete']) { $template->message($LNG['ad_delete_defenses_success'], '?page=accounteditor&edit=defenses'); } } exit; } foreach ($reslist['defense'] as $ID) { $INPUT[$ID] = array('type' => $resource[$ID]); } $template->assign_vars(array('inputlist' => $INPUT)); $template->show('AccountEditorPageDefenses.tpl'); break; break; case 'buildings': if ($_POST) { $PlanetData = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . PLANETS . " WHERE `id` = '" . HTTP::_GP('id', 0) . "';"); if (!isset($PlanetData)) { $template->message($LNG['ad_add_not_exist'], '?page=accounteditor&edit=buildings'); } $before = array(); $after = array(); foreach ($reslist['allow'][$PlanetData['planet_type']] as $ID) { $before[$ID] = $PlanetData[$resource[$ID]]; } if ($_POST['add']) { $Fields = 0; $SQL = "UPDATE " . PLANETS . " SET "; $SQL .= "`eco_hash` = '', "; foreach ($reslist['allow'][$PlanetData['planet_type']] as $ID) { $Count = max(0, round(HTTP::_GP($resource[$ID], 0.0))); $QryUpdate[] = "`" . $resource[$ID] . "` = `" . $resource[$ID] . "` + '" . $Count . "'"; $after[$ID] = $before[$ID] + $Count; $Fields += $Count; } $SQL .= implode(", ", $QryUpdate); $SQL .= ", `field_current` = `field_current` + '" . $Fields . "'"; $SQL .= "WHERE "; $SQL .= "`id` = '" . HTTP::_GP('id', 0) . "' AND `universe` = '1';"; $GLOBALS['DATABASE']->query($SQL); } elseif ($_POST['delete']) { $Fields = 0; $SQL = "UPDATE " . PLANETS . " SET "; $SQL .= "`eco_hash` = '', "; foreach ($reslist['allow'][$PlanetData['planet_type']] as $ID) { $Count = max(0, round(HTTP::_GP($resource[$ID], 0.0))); $QryUpdate[] = "`" . $resource[$ID] . "` = `" . $resource[$ID] . "` - '" . $Count . "'"; $after[$ID] = max($before[$ID] - $Count, 0); $Fields += $Count; } $SQL .= implode(", ", $QryUpdate); $SQL .= ", `field_current` = `field_current` - '" . $Fields . "'"; $SQL .= "WHERE "; $SQL .= "`id` = '" . HTTP::_GP('id', 0) . "' AND `universe` = '1';"; $GLOBALS['DATABASE']->query($SQL); } $LOG = new Log(2); $LOG->target = HTTP::_GP('id', 0); $LOG->universe = $before1['universe']; $LOG->old = $before; $LOG->new = $after; $LOG->save(); if ($_POST['add']) { $template->message($LNG['ad_add_build_success'], '?page=accounteditor&edit=buildings'); } else { if ($_POST['delete']) { $template->message($LNG['ad_delete_build_success'], '?page=accounteditor&edit=buildings'); } } exit; } foreach ($reslist['build'] as $ID) { $INPUT[$ID] = array('type' => $resource[$ID]); } $template->assign_vars(array('inputlist' => $INPUT)); $template->show('AccountEditorPageBuilds.tpl'); break; case 'researchs': if ($_POST) { $before1 = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE `id` = '" . HTTP::_GP('id', 0) . "';"); $before = array(); $after = array(); foreach ($reslist['tech'] as $ID) { $before[$ID] = $before1[$resource[$ID]]; } if ($_POST['add']) { $SQL = "UPDATE " . USERS . " SET "; foreach ($reslist['tech'] as $ID) { $QryUpdate[] = "`" . $resource[$ID] . "` = `" . $resource[$ID] . "` + '" . max(0, round(HTTP::_GP($resource[$ID], 0.0))) . "'"; $after[$ID] = $before[$ID] + max(0, round(HTTP::_GP($resource[$ID], 0.0))); } $SQL .= implode(", ", $QryUpdate); $SQL .= "WHERE "; $SQL .= "`id` = '" . HTTP::_GP('id', 0) . "' AND `universe` = '1';"; $GLOBALS['DATABASE']->query($SQL); } elseif ($_POST['delete']) { $SQL = "UPDATE " . USERS . " SET "; foreach ($reslist['tech'] as $ID) { $QryUpdate[] = "`" . $resource[$ID] . "` = `" . $resource[$ID] . "` - '" . max(0, round(HTTP::_GP($resource[$ID], 0.0))) . "'"; $after[$ID] = max($before[$ID] - max(0, round(HTTP::_GP($resource[$ID], 0.0))), 0); } $SQL .= implode(", ", $QryUpdate); $SQL .= "WHERE "; $SQL .= "`id` = '" . HTTP::_GP('id', 0) . "' AND `universe` = '1';"; $GLOBALS['DATABASE']->query($SQL); } $LOG = new Log(1); $LOG->target = HTTP::_GP('id', 0); $LOG->universe = $before1['universe']; $LOG->old = $before; $LOG->new = $after; $LOG->save(); if ($_POST['add']) { $template->message($LNG['ad_add_tech_success'], '?page=accounteditor&edit=researchs'); } else { if ($_POST['delete']) { $template->message($LNG['ad_delete_tech_success'], '?page=accounteditor&edit=researchs'); } } exit; } foreach ($reslist['tech'] as $ID) { $INPUT[$ID] = array('type' => $resource[$ID]); } $template->assign_vars(array('inputlist' => $INPUT)); $template->show('AccountEditorPageResearch.tpl'); break; case 'personal': if ($_POST) { $id = HTTP::_GP('id', 0); $username = HTTP::_GP('username', '', UTF8_SUPPORT); $password = HTTP::_GP('password', '', true); $email = HTTP::_GP('email', ''); $email_2 = HTTP::_GP('email_2', ''); $vacation = HTTP::_GP('vacation', ''); $before = $GLOBALS['DATABASE']->getFirstRow("SELECT `username`,`email`,`email_2`,`password`,`urlaubs_modus`,`urlaubs_until` FROM " . USERS . " WHERE `id` = '" . HTTP::_GP('id', 0) . "';"); $after = array(); $PersonalQuery = "UPDATE " . USERS . " SET "; if (!empty($username) && $id != ROOT_USER) { $PersonalQuery .= "`username` = '" . $GLOBALS['DATABASE']->sql_escape($username) . "', "; $after['username'] = $username; } if (!empty($email) && $id != ROOT_USER) { $PersonalQuery .= "`email` = '" . $GLOBALS['DATABASE']->sql_escape($email) . "', "; $after['email'] = $email; } if (!empty($email_2) && $id != ROOT_USER) { $PersonalQuery .= "`email_2` = '" . $GLOBALS['DATABASE']->sql_escape($email_2) . "', "; $after['email_2'] = $email_2; } if (!empty($password) && $id != ROOT_USER) { $PersonalQuery .= "`password` = '" . $GLOBALS['DATABASE']->sql_escape(cryptPassword($password)) . "', "; $after['password'] = cryptPassword($password) != $before['password'] ? 'CHANGED' : ''; } $before['password'] = ''; $Answer = 0; $TimeAns = 0; if ($vacation == 'yes') { $Answer = 1; $after['urlaubs_modus'] = 1; $TimeAns = TIMESTAMP + $_POST['d'] * 86400 + $_POST['h'] * 3600 + $_POST['m'] * 60 + $_POST['s']; $after['urlaubs_until'] = $TimeAns; } $PersonalQuery .= "`urlaubs_modus` = '" . $Answer . "', `urlaubs_until` = '" . $TimeAns . "' "; $PersonalQuery .= "WHERE `id` = '" . $id . "' AND `universe` = '1'"; $GLOBALS['DATABASE']->query($PersonalQuery); $LOG = new Log(1); $LOG->target = $id; $LOG->universe = $before['universe']; $LOG->old = $before; $LOG->new = $after; $LOG->save(); $template->message($LNG['ad_personal_succes'], '?page=accounteditor&edit=personal'); exit; } $template->assign_vars(array('Selector' => array('' => $LNG['select_option'], 'yes' => $LNG['one_is_yes'][1], 'no' => $LNG['one_is_yes'][0]))); $template->show('AccountEditorPagePersonal.tpl'); break; case 'officiers': if ($_POST) { $before1 = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE `id` = '" . HTTP::_GP('id', 0) . "';"); $before = array(); $after = array(); foreach ($reslist['officier'] as $ID) { $before[$ID] = $before1[$resource[$ID]]; } if ($_POST['add']) { $SQL = "UPDATE " . USERS . " SET "; foreach ($reslist['officier'] as $ID) { $QryUpdate[] = "`" . $resource[$ID] . "` = `" . $resource[$ID] . "` + '" . max(0, round(HTTP::_GP($resource[$ID], 0.0))) . "'"; $after[$ID] = $before[$ID] + max(0, round(HTTP::_GP($resource[$ID], 0.0))); } $SQL .= implode(", ", $QryUpdate); $SQL .= "WHERE "; $SQL .= "`id` = '" . HTTP::_GP('id', 0) . "' AND `universe` = '1';"; $GLOBALS['DATABASE']->query($SQL); } elseif ($_POST['delete']) { $SQL = "UPDATE " . USERS . " SET "; foreach ($reslist['officier'] as $ID) { $QryUpdate[] = "`" . $resource[$ID] . "` = `" . $resource[$ID] . "` - '" . max(0, round(HTTP::_GP($resource[$ID], 0.0))) . "'"; $after[$ID] = max($before[$ID] - max(0, round(HTTP::_GP($resource[$ID], 0.0))), 0); } $SQL .= implode(", ", $QryUpdate); $SQL .= "WHERE "; $SQL .= "`id` = '" . HTTP::_GP('id', 0) . "' AND `universe` = '1';"; $GLOBALS['DATABASE']->query($SQL); } $LOG = new Log(1); $LOG->target = HTTP::_GP('id', 0); $LOG->universe = $before1['universe']; $LOG->old = $before; $LOG->new = $after; $LOG->save(); if ($_POST['add']) { $template->message($LNG['ad_add_offi_success'], '?page=accounteditor&edit=officiers'); } else { if ($_POST['delete']) { $template->message($LNG['ad_delete_offi_success'], '?page=accounteditor&edit=officiers'); } } exit; } foreach ($reslist['officier'] as $ID) { $INPUT[$ID] = array('type' => $resource[$ID]); } $template->assign_vars(array('inputlist' => $INPUT)); $template->show('AccountEditorPageOfficiers.tpl'); break; case 'planets': if ($_POST) { $id = HTTP::_GP('id', 0); $name = HTTP::_GP('name', '', UTF8_SUPPORT); $diameter = HTTP::_GP('diameter', 0); $fields = HTTP::_GP('fields', 0); $buildings = HTTP::_GP('0_buildings', ''); $ships = HTTP::_GP('0_ships', ''); $defenses = HTTP::_GP('0_defenses', ''); $c_hangar = HTTP::_GP('0_c_hangar', ''); $c_buildings = HTTP::_GP('0_c_buildings', ''); $change_pos = HTTP::_GP('change_position', ''); $galaxy = HTTP::_GP('g', 0); $system = HTTP::_GP('s', 0); $planet = HTTP::_GP('p', 0); if (!empty($name)) { $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " SET `name` = '" . $GLOBALS['DATABASE']->sql_escape($name) . "' WHERE `id` = '" . $id . "' AND `universe` = '1';"); } if ($buildings == 'on') { foreach ($reslist['build'] as $ID) { $BUILD[] = "`" . $resource[$ID] . "` = '0'"; } $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " SET " . implode(', ', $BUILD) . " WHERE `id` = '" . $id . "' AND `universe` = '1';"); } if ($ships == 'on') { foreach ($reslist['fleet'] as $ID) { $SHIPS[] = "`" . $resource[$ID] . "` = '0'"; } $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " SET " . implode(', ', $SHIPS) . " WHERE `id` = '" . $id . "' AND `universe` = '1';"); } if ($defenses == 'on') { foreach ($reslist['defense'] as $ID) { $DEFS[] = "`" . $resource[$ID] . "` = '0'"; } $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " SET " . implode(', ', $DEFS) . " WHERE `id` = '" . $id . "' AND `universe` = '1';"); } if ($c_hangar == 'on') { $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " SET `b_hangar` = '0', `b_hangar_plus` = '0', `b_hangar_id` = '' WHERE `id` = '" . $id . "' AND `universe` = '1';"); } if ($c_buildings == 'on') { $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " SET `b_building` = '0', `b_building_id` = '' WHERE `id` = '" . $id . "' AND `universe` = '1';"); } if (!empty($diameter)) { $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " SET `diameter` = '" . $diameter . "' WHERE `id` = '" . $id . "' AND `universe` = '1';"); } if (!empty($fields)) { $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " SET `field_max` = '" . $fields . "' WHERE `id` = '" . $id . "' AND `universe` = '1';"); } if ($change_pos == 'on' && $galaxy > 0 && $system > 0 && $planet > 0 && $galaxy <= $GLOBALS['CONFIG'][$_SESSION['adminuni']]['max_galaxy'] && $system <= $GLOBALS['CONFIG'][$_SESSION['adminuni']]['max_system'] && $planet <= $GLOBALS['CONFIG'][$_SESSION['adminuni']]['max_planets']) { $P = $GLOBALS['DATABASE']->getFirstRow("SELECT galaxy,system,planet,planet_type FROM " . PLANETS . " WHERE `id` = '" . $id . "' AND `universe` = '1';"); if ($P['planet_type'] == '1') { if (CheckPlanetIfExist($galaxy, $system, $planet, $UNI, $P['planet_type'])) { $template->message($LNG['ad_pla_error_planets3'], '?page=accounteditor&edit=planets'); exit; } $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " SET `galaxy` = '" . $galaxy . "', `system` = '" . $system . "', `planet` = '" . $planet . "' WHERE `id` = '" . $id . "' AND `universe` = '1';"); } else { if (CheckPlanetIfExist($galaxy, $system, $planet, $UNI, $P['planet_type'])) { $template->message($LNG['ad_pla_error_planets5'], '?page=accounteditor&edit=planets'); exit; } $Target = $GLOBALS['DATABASE']->getFirstRow("SELECT id_luna FROM " . PLANETS . " WHERE `galaxy` = '" . $galaxy . "' AND `system` = '" . $system . "' AND `planet` = '" . $planet . "' AND `planet_type` = '1';"); if ($Target['id_luna'] != '0') { $template->message($LNG['ad_pla_error_planets4'], '?page=accounteditor&edit=planets'); exit; } $GLOBALS['DATABASE']->multi_query("UPDATE " . PLANETS . " SET `id_luna` = '0' WHERE `galaxy` = '" . $P['galaxy'] . "' AND `system` = '" . $P['system'] . "' AND `planet` = '" . $P['planet'] . "' AND `planet_type` = '1';UPDATE " . PLANETS . " SET `id_luna` = '" . $id . "' WHERE `galaxy` = '" . $galaxy . "' AND `system` = '" . $system . "' AND `planet` = '" . $planet . "' AND planet_type = '1';UPDATE " . PLANETS . " SET `galaxy` = '" . $galaxy . "', `system` = '" . $system . "', `planet` = '" . $planet . "' WHERE `id` = '" . $id . "' AND `universe` = '1';"); $QMOON2 = $GLOBALS['DATABASE']->getFirstRow("SELECT id_owner FROM " . PLANETS . " WHERE `galaxy` = '" . $galaxy . "' AND `system` = '" . $system . "' AND `planet` = '" . $planet . "';"); $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " SET `galaxy` = '" . $galaxy . "', `system` = '" . $system . "', `planet` = '" . $planet . "', `id_owner` = '" . $QMOON2['id_owner'] . "' WHERE `id` = '" . $id . "' AND `universe` = '1' AND `planet_type` = '3';"); } } $template->message($LNG['ad_pla_succes'], '?page=accounteditor&edit=planets'); exit; } $template->show('AccountEditorPagePlanets.tpl'); break; case 'alliances': if ($_POST) { $id = HTTP::_GP('id', 0); $name = HTTP::_GP('name', '', UTF8_SUPPORT); $changeleader = HTTP::_GP('changeleader', 0); $tag = HTTP::_GP('tag', '', UTF8_SUPPORT); $externo = HTTP::_GP('externo', '', true); $interno = HTTP::_GP('interno', '', true); $solicitud = HTTP::_GP('solicitud', '', true); $delete = HTTP::_GP('delete', ''); $delete_u = HTTP::_GP('delete_u', ''); $QueryF = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . ALLIANCE . " WHERE `id` = '" . $id . "' AND `ally_universe` = '1';"); if (!empty($name)) { $GLOBALS['DATABASE']->query("UPDATE " . ALLIANCE . " SET `ally_name` = '" . $name . "' WHERE `id` = '" . $id . "' AND `ally_universe` = '1';"); } if (!empty($tag)) { $GLOBALS['DATABASE']->query("UPDATE " . ALLIANCE . " SET `ally_tag` = '" . $tag . "' WHERE `id` = '" . $id . "' AND `ally_universe` = '1';"); } $QueryF2 = $GLOBALS['DATABASE']->getFirstRow("SELECT ally_id FROM " . USERS . " WHERE `id` = '" . $changeleader . "';"); $GLOBALS['DATABASE']->multi_query("UPDATE " . ALLIANCE . " SET `ally_owner` = '" . $changeleader . "' WHERE `id` = '" . $id . "' AND `ally_universe` = '1';UPDATE " . USERS . " SET `ally_rank_id` = '0' WHERE `id` = '" . $changeleader . "';"); if (!empty($externo)) { $GLOBALS['DATABASE']->query("UPDATE " . ALLIANCE . " SET `ally_description` = '" . $externo . "' WHERE `id` = '" . $id . "' AND `ally_universe` = '1';"); } if (!empty($interno)) { $GLOBALS['DATABASE']->query("UPDATE " . ALLIANCE . " SET `ally_text` = '" . $interno . "' WHERE `id` = '" . $id . "' AND `ally_universe` = '1';"); } if (!empty($solicitud)) { $GLOBALS['DATABASE']->query("UPDATE " . ALLIANCE . " SET `ally_request` = '" . $solicitud . "' WHERE `id` = '" . $id . "' AND `ally_universe` = '1';"); } if ($delete == 'on') { $GLOBALS['DATABASE']->multi_query("DELETE FROM " . ALLIANCE . " WHERE `id` = '" . $id . "' AND `ally_universe` = '1';UPDATE " . USERS . " SET `ally_id` = '0', `ally_rank_id` = '0', `ally_register_time` = '0' WHERE `ally_id` = '" . $id . "';"); } if (!empty($delete_u)) { $GLOBALS['DATABASE']->multi_query("UPDATE " . ALLIANCE . " SET `ally_members` = ally_members - 1 WHERE `id` = '" . $id . "' AND `ally_universe` = '1';UPDATE " . USERS . " SET `ally_id` = '0', `ally_rank_id` = '0', `ally_register_time` = '0' WHERE `id` = '" . $delete_u . "' AND `ally_id` = '" . $id . "';"); } $template->message($LNG['ad_ally_succes'], '?page=accounteditor&edit=alliances'); exit; } $template->show('AccountEditorPageAlliance.tpl'); break; default: $template->show('AccountEditorPageMenu.tpl'); break; } }
function ShowCreatorPage() { global $LNG, $USER, $UNI, $CONF; $template = new template(); switch ($_GET['mode']) { case 'user': $LNG->includeData(array('PUBLIC')); if ($_POST) { $UserName = HTTP::_GP('name', '', UTF8_SUPPORT); $UserPass = HTTP::_GP('password', ''); $UserPass2 = HTTP::_GP('password2', ''); $UserMail = HTTP::_GP('email', ''); $UserMail2 = HTTP::_GP('email2', ''); $UserLang = HTTP::_GP('lang', ''); $UserAuth = HTTP::_GP('authlevel', 0); $Galaxy = HTTP::_GP('galaxy', 0); $System = HTTP::_GP('system', 0); $Planet = HTTP::_GP('planet', 0); $ExistsUser = $GLOBALS['DATABASE']->getFirstCell("SELECT (SELECT COUNT(*) FROM " . USERS . " WHERE universe = " . $_SESSION['adminuni'] . " AND username = '******'DATABASE']->sql_escape($UserName) . "') + (SELECT COUNT(*) FROM " . USERS_VALID . " WHERE universe = " . $_SESSION['adminuni'] . " AND username = '******'DATABASE']->sql_escape($UserName) . "')"); $ExistsMails = $GLOBALS['DATABASE']->getFirstCell("SELECT (SELECT COUNT(*) FROM " . USERS . " WHERE universe = " . $_SESSION['adminuni'] . " AND (email = '" . $GLOBALS['DATABASE']->sql_escape($UserMail) . "' OR email_2 = '" . $GLOBALS['DATABASE']->sql_escape($UserMail) . "')) + (SELECT COUNT(*) FROM " . USERS_VALID . " WHERE universe = " . $_SESSION['adminuni'] . " AND email = '" . $GLOBALS['DATABASE']->sql_escape($UserMail) . "')"); if (!ValidateAddress($UserMail)) { $errors .= $LNG['invalid_mail_adress']; } if (empty($UserName)) { $errors .= $LNG['empty_user_field']; } if (strlen($UserPass) < 6) { $errors .= $LNG['password_lenght_error']; } if ($UserPass != $UserPass2) { $errors .= $LNG['different_passwords']; } if ($UserMail != $UserMail2) { $errors .= $LNG['different_mails']; } if (!CheckName($UserName)) { $errors .= $LNG['user_field_specialchar']; } if ($ExistsUser != 0) { $errors .= $LNG['user_already_exists']; } if ($ExistsMails != 0) { $errors .= $LNG['mail_already_exists']; } if (CheckPlanetIfExist($Galaxy, $System, $Planet, $_SESSION['adminuni'])) { $errors .= $LNG['planet_already_exists']; } if ($Galaxy > Config::get('max_galaxy') || $System > Config::get('max_system') || $Planet > Config::get('max_planets')) { $errors .= $LNG['po_complete_all2']; } if (!empty($errors)) { $template->message($errors, '?page=create&mode=user', 10, true); exit; } $SQL = "INSERT INTO " . USERS . " SET\n\t\t\t\tusername\t\t= '" . $GLOBALS['DATABASE']->sql_escape($UserName) . "',\n\t\t\t\tpassword\t\t= '" . cryptPassword($UserPass) . "',\n\t\t\t\temail\t\t\t= '" . $GLOBALS['DATABASE']->sql_escape($UserMail) . "',\n\t\t\t\temail_2\t\t\t= '" . $GLOBALS['DATABASE']->sql_escape($UserMail) . "',\n\t\t\t\tlang\t\t\t= '" . $GLOBALS['DATABASE']->sql_escape($UserLang) . "',\n\t\t\t\tauthlevel\t\t= " . $UserAuth . ",\n\t\t\t\tip_at_reg\t\t= '" . $_SERVER['REMOTE_ADDR'] . "',\n\t\t\t\tid_planet\t\t= 0,\n\t\t\t\tuniverse\t\t= " . $_SESSION['adminuni'] . ",\n\t\t\t\tonlinetime\t\t= " . TIMESTAMP . ",\n\t\t\t\tregister_time\t= " . TIMESTAMP . ",\n\t\t\t\tdpath\t\t\t= '" . DEFAULT_THEME . "',\n\t\t\t\ttimezone\t\t= '" . Config::get('timezone') . "',\n\t\t\t\tuctime\t\t\t= 0;"; $GLOBALS['DATABASE']->query($SQL); $UserID = $GLOBALS['DATABASE']->GetInsertID(); require_once 'includes/functions/CreateOnePlanetRecord.php'; $PlanerID = CreateOnePlanetRecord($Galaxy, $System, $Planet, $_SESSION['adminuni'], $UserID, $LNG['fcm_planet'], true, $UserAuth); $SQL = "UPDATE " . USERS . " SET \n\t\t\t\tid_planet\t= " . $PlanerID . ",\n\t\t\t\tgalaxy\t\t= " . $Galaxy . ",\n\t\t\t\tsystem\t\t= " . $System . ",\n\t\t\t\tplanet\t\t= " . $Planet . "\n\t\t\t\tWHERE\n\t\t\t\tid\t\t\t= " . $UserID . ";\n\t\t\t\tINSERT INTO " . STATPOINTS . " SET \n\t\t\t\tid_owner\t= " . $UserID . ",\n\t\t\t\tuniverse\t= " . $_SESSION['adminuni'] . ",\n\t\t\t\tstat_type\t= 1,\n\t\t\t\ttech_rank\t= " . (Config::get('users_amount') + 1) . ",\n\t\t\t\tbuild_rank\t= " . (Config::get('users_amount') + 1) . ",\n\t\t\t\tdefs_rank\t= " . (Config::get('users_amount') + 1) . ",\n\t\t\t\tfleet_rank\t= " . (Config::get('users_amount') + 1) . ",\n\t\t\t\ttotal_rank\t= " . (Config::get('users_amount') + 1) . ";"; $GLOBALS['DATABASE']->multi_query($SQL); Config::update(array('users_amount' => Config::get('users_amount') + 1)); $template->message($LNG['new_user_success'], '?page=create&mode=user', 5, true); exit; } $AUTH = array(); $AUTH[AUTH_USR] = $LNG['user_level'][AUTH_USR]; if ($USER['authlevel'] >= AUTH_OPS) { $AUTH[AUTH_OPS] = $LNG['user_level'][AUTH_OPS]; } if ($USER['authlevel'] >= AUTH_MOD) { $AUTH[AUTH_MOD] = $LNG['user_level'][AUTH_MOD]; } if ($USER['authlevel'] >= AUTH_ADM) { $AUTH[AUTH_ADM] = $LNG['user_level'][AUTH_ADM]; } $template->assign_vars(array('admin_auth' => $USER['authlevel'], 'new_add_user' => $LNG['new_add_user'], 'new_creator_refresh' => $LNG['new_creator_refresh'], 'new_creator_go_back' => $LNG['new_creator_go_back'], 'universe' => $LNG['mu_universe'], 'user_reg' => $LNG['user_reg'], 'pass_reg' => $LNG['pass_reg'], 'pass2_reg' => $LNG['pass2_reg'], 'email_reg' => $LNG['email_reg'], 'email2_reg' => $LNG['email2_reg'], 'new_coord' => $LNG['new_coord'], 'new_range' => $LNG['new_range'], 'lang_reg' => $LNG['lang_reg'], 'new_title' => $LNG['new_title'], 'Selector' => array('auth' => $AUTH, 'lang' => $LNG->getAllowedLangs(false)))); $template->show('CreatePageUser.tpl'); break; case 'moon': if ($_POST) { $PlanetID = HTTP::_GP('add_moon', 0); $MoonName = HTTP::_GP('name', '', UTF8_SUPPORT); $Diameter = HTTP::_GP('diameter', 0); $FieldMax = HTTP::_GP('field_max', 0); $MoonPlanet = $GLOBALS['DATABASE']->getFirstRow("SELECT temp_max, temp_min, id_luna, galaxy, system, planet, planet_type, destruyed, id_owner FROM " . PLANETS . " WHERE id = '" . $PlanetID . "' AND universe = '" . $_SESSION['adminuni'] . "' AND planet_type = '1' AND destruyed = '0';"); if (!isset($MoonPlanet)) { $template->message($LNG['mo_planet_doesnt_exist'], '?page=create&mode=moon', 3, true); exit; } require_once 'includes/functions/CreateOneMoonRecord.php'; if (empty($MoonName)) { $MoonName = $LNG['type_planet'][3]; } if (CreateOneMoonRecord($MoonPlanet['galaxy'], $MoonPlanet['system'], $MoonPlanet['planet'], $_SESSION['adminuni'], $MoonPlanet['id_owner'], $MoonName, 20, TIMESTAMP, $_POST['diameter_check'] == 'on' ? 0 : $Diameter) !== false) { $template->message($LNG['mo_moon_added'], '?page=create&mode=moon', 3, true); } else { $template->message($LNG['mo_moon_unavaible'], '?page=create&mode=moon', 3, true); } exit; } $template->assign_vars(array('admin_auth' => $USER['authlevel'], 'universum' => $LNG['mu_universe'], 'po_add_moon' => $LNG['po_add_moon'], 'input_id_planet' => $LNG['input_id_planet'], 'mo_moon_name' => $LNG['mo_moon_name'], 'mo_diameter' => $LNG['mo_diameter'], 'mo_temperature' => $LNG['mo_temperature'], 'mo_fields_avaibles' => $LNG['mo_fields_avaibles'], 'button_add' => $LNG['button_add'], 'new_creator_refresh' => $LNG['new_creator_refresh'], 'mo_moon' => $LNG['fcm_moon'], 'new_creator_go_back' => $LNG['new_creator_go_back'])); $template->show('CreatePageMoon.tpl'); break; case 'planet': if ($_POST) { $id = HTTP::_GP('id', 0); $Galaxy = HTTP::_GP('galaxy', 0); $System = HTTP::_GP('system', 0); $Planet = HTTP::_GP('planet', 0); $name = HTTP::_GP('name', '', UTF8_SUPPORT); $field_max = HTTP::_GP('field_max', 0); if ($Galaxy > Config::get('max_galaxy') || $System > Config::get('max_system') || $Planet > Config::get('max_planets')) { $template->message($LNG['po_complete_all2'], '?page=create&mode=planet', 3, true); exit; } $ISUser = $GLOBALS['DATABASE']->getFirstRow("SELECT id, authlevel FROM " . USERS . " WHERE id = '" . $id . "' AND universe = '" . $_SESSION['adminuni'] . "';"); if (CheckPlanetIfExist($Galaxy, $System, $Planet, $_SESSION['adminuni']) || !isset($ISUser)) { $template->message($LNG['po_complete_all'], '?page=create&mode=planet', 3, true); exit; } require_once 'includes/functions/CreateOnePlanetRecord.php'; CreateOnePlanetRecord($Galaxy, $System, $Planet, $_SESSION['adminuni'], $id, '', '', false); $SQL = "UPDATE " . PLANETS . " SET "; if ($_POST['diameter_check'] != 'on' || $field_max > 0) { $SQL .= "field_max = '" . $field_max . "' "; } if (!empty($name)) { $SQL .= ", name = '" . $GLOBALS['DATABASE']->sql_escape($name) . "' "; } $SQL .= "WHERE "; $SQL .= "universe = '" . $_SESSION['adminuni'] . "' AND "; $SQL .= "galaxy = '" . $Galaxy . "' AND "; $SQL .= "system = '" . $System . "' AND "; $SQL .= "planet = '" . $Planet . "' AND "; $SQL .= "planet_type = '1'"; $GLOBALS['DATABASE']->query($SQL); $template->message($LNG['po_complete_succes'], '?page=create&mode=planet', 3, true); exit; } $Query = $GLOBALS['DATABASE']->query("SELECT uni, game_name FROM " . CONFIG . " ORDER BY uni ASC;"); while ($Unis = $GLOBALS['DATABASE']->fetch_array($Query)) { $AvailableUnis[$Unis['uni']] = $Unis; } $template->assign_vars(array('AvailableUnis' => $AvailableUnis, 'admin_auth' => $USER['authlevel'], 'universum' => $LNG['mu_universe'], 'po_add_planet' => $LNG['po_add_planet'], 'po_galaxy' => $LNG['po_galaxy'], 'po_system' => $LNG['po_system'], 'po_planet' => $LNG['po_planet'], 'input_id_user' => $LNG['input_id_user'], 'new_creator_coor' => $LNG['new_creator_coor'], 'po_name_planet' => $LNG['po_name_planet'], 'po_fields_max' => $LNG['po_fields_max'], 'button_add' => $LNG['button_add'], 'po_colony' => $LNG['fcp_colony'], 'new_creator_refresh' => $LNG['new_creator_refresh'], 'new_creator_go_back' => $LNG['new_creator_go_back'])); $template->show('CreatePagePlanet.tpl'); break; default: $template->assign_vars(array('new_creator_title_u' => $LNG['new_creator_title_u'], 'new_creator_title_p' => $LNG['new_creator_title_p'], 'new_creator_title_l' => $LNG['new_creator_title_l'], 'new_creator_title' => $LNG['new_creator_title'])); $template->show('CreatePage.tpl'); break; } }
$LastSettedSystemPos = 1; $LastSettedPlanetPos = 1; break; } else { $LastSettedPlanetPos = 1; } $LastSettedSystemPos += 1; break; } break; } break; } break; } if (!CheckPlanetIfExist($Galaxy, $System, $Planet)) { require_once ROOT_PATH . 'includes/functions/CreateOnePlanetRecord.' . PHP_EXT; CreateOnePlanetRecord($Galaxy, $System, $Planet, $NewUser['id'], $UserPlanet, true); $QryInsertConfig = "UPDATE " . CONFIG . " SET `config_value` = '" . $LastSettedGalaxyPos . "' WHERE `config_name` = 'LastSettedGalaxyPos';"; $QryInsertConfig .= "UPDATE " . CONFIG . " SET `config_value` = '" . $LastSettedSystemPos . "' WHERE `config_name` = 'LastSettedSystemPos';"; $QryInsertConfig .= "UPDATE " . CONFIG . " SET `config_value` = '" . $LastSettedPlanetPos . "' WHERE `config_name` = 'LastSettedPlanetPos';"; $db->multi_query($QryInsertConfig); $newpos_checked = true; } } $PlanetID = $db->uniquequery("SELECT `id` FROM " . PLANETS . " WHERE `id_owner` = '" . $NewUser['id'] . "';"); $SQL = "UPDATE " . USERS . " SET "; $SQL .= "`id_planet` = '" . $PlanetID['id'] . "', "; $SQL .= "`galaxy` = '" . $Galaxy . "', "; $SQL .= "`system` = '" . $System . "', "; $SQL .= "`planet` = '" . $Planet . "' ";
function ShowCreatorPage() { global $LNG, $db, $USER; $template = new template(); $template->page_header(); switch ($_GET['mode']) { case 'user': includeLang('PUBLIC'); if ($_POST) { $UserName = request_var('name', '', UTF8_SUPPORT); $UserPass = request_var('password', ''); $UserPass2 = request_var('password2', ''); $UserMail = request_var('email', ''); $UserMail2 = request_var('email2', ''); $UserLang = request_var('lang', ''); $UserAuth = request_var('authlevel', 0); $Galaxy = request_var('galaxy', 0); $System = request_var('system', 0); $Planet = request_var('planet', 0); if ($CONF['capaktiv'] === '1') { require_once 'includes/libs/reCAPTCHA/recaptchalib.php'; $resp = recaptcha_check_answer($CONF['capprivate'], $_SERVER['REMOTE_ADDR'], request_var('recaptcha_challenge_field', ''), request_var('recaptcha_response_field', '')); if (!$resp->is_valid) { $errorlist .= $LNG['wrong_captcha']; } } $Exist['userv'] = $db->uniquequery("SELECT username, email FROM " . USERS . " WHERE username = '******' OR email = '" . $db->sql_escape($UserEmail) . "';"); $Exist['vaild'] = $db->uniquequery("SELECT username, email FROM " . USERS_VALID . " WHERE username = '******' OR email = '" . $db->sql_escape($UserEmail) . "';"); if (!ValidateAddress($UserMail)) { $errors .= $LNG['invalid_mail_adress']; } if (empty($UserName)) { $errors .= $LNG['empty_user_field']; } if (strlen($UserPass) < 6) { $errors .= $LNG['password_lenght_error']; } if ($UserPass != $UserPass2) { $errors .= $LNG['different_passwords']; } if ($UserMail != $UserMail2) { $errors .= $LNG['different_mails']; } if (!CheckName($UserName)) { $errors .= UTF8_SUPPORT ? $LNG['user_field_no_space'] : $LNG['user_field_no_alphanumeric']; } if (isset($Exist['userv']['username']) || isset($Exist['vaild']['username']) && ($UserName == $Exist['userv']['username'] || $UserName == $Exist['vaild']['username'])) { $errors .= $LNG['user_already_exists']; } if ((isset($Exist['userv']['email']) || isset($Exist['vaild']['email'])) && ($UserEmail == $Exist['userv']['email'] || $UserEmail == $Exist['vaild']['email'])) { $errors .= $LNG['mail_already_exists']; } if (CheckPlanetIfExist($Galaxy, $System, $Position)) { $errors .= $LNG['planet_already_exists']; } if (!empty($errors)) { $template->message($errors, '?page=create&mode=user', 3, true); exit; } $SQL = "INSERT INTO " . USERS . " SET "; $SQL .= "`username` = '" . $db->sql_escape($UserName) . "', "; $SQL .= "`email` = '" . $db->sql_escape($UserMail) . "', "; $SQL .= "`email_2` = '" . $db->sql_escape($UserMail) . "', "; $SQL .= "`lang` = '" . $db->sql_escape($UserLang) . "', "; $SQL .= "`authlevel` = '" . $UserAuth . "', "; $SQL .= "`ip_at_reg` = '" . $_SERVER['REMOTE_ADDR'] . "', "; $SQL .= "`id_planet` = '0', "; $SQL .= "`onlinetime` = '" . TIMESTAMP . "', "; $SQL .= "`register_time` = '" . TIMESTAMP . "', "; $SQL .= "`password` = '" . md5($UserPass) . "', "; $SQL .= "`dpath` = '" . DEFAULT_SKINPATH . "', "; $SQL .= "`uctime`= '0';"; $db->query($SQL); $db->query("UPDATE " . CONFIG . " SET `config_value` = config_value + '1' WHERE `config_name` = 'users_amount';"); $ID_USER = $db->uniquequery("SELECT `id` FROM " . USERS . " WHERE `username` = '" . $db->sql_escape($UserName) . "';"); require_once ROOT_PATH . 'includes/functions/CreateOnePlanetRecord.' . PHP_EXT; CreateOnePlanetRecord($Galaxy, $System, $Planet, $ID_USER['id'], $UserPlanet, true, $UserAuth); $ID_PLANET = $db->uniquequery("SELECT `id` FROM " . PLANETS . " WHERE `id_owner` = '" . $ID_USER['id'] . "';"); $SQL = "UPDATE " . USERS . " SET "; $SQL .= "`id_planet` = '" . $ID_PLANET['id'] . "', "; $SQL .= "`galaxy` = '" . $Galaxy . "', "; $SQL .= "`system` = '" . $System . "', "; $SQL .= "`planet` = '" . $Planet . "' "; $SQL .= "WHERE "; $SQL .= "`id` = '" . $ID_USER['id'] . "' "; $SQL .= "LIMIT 1;"; $db->query($SQL); $template->message($LNG['new_user_success'], '?page=create&mode=user', 3, true); exit; } $AUTH[0] = $LNG['user_level'][0]; if ($USER['authlevel'] >= AUTH_OPS) { $AUTH[AUTH_OPS] = $LNG['user_level'][AUTH_OPS]; } if ($USER['authlevel'] >= AUTH_MOD) { $AUTH[AUTH_MOD] = $LNG['user_level'][AUTH_MOD]; } if ($USER['authlevel'] >= AUTH_ADM) { $AUTH[AUTH_ADM] = $LNG['user_level'][AUTH_ADM]; } $template->assign_vars(array('new_add_user' => $LNG['new_add_user'], 'new_creator_refresh' => $LNG['new_creator_refresh'], 'new_creator_go_back' => $LNG['new_creator_go_back'], 'user_reg' => $LNG['user_reg'], 'pass_reg' => $LNG['pass_reg'], 'pass2_reg' => $LNG['pass2_reg'], 'email_reg' => $LNG['email_reg'], 'email2_reg' => $LNG['email2_reg'], 'new_coord' => $LNG['new_coord'], 'new_range' => $LNG['new_range'], 'new_title' => $LNG['new_title'], 'Selector' => $AUTH)); $template->show('adm/CreatePageUser.tpl'); break; case 'moon': if ($_POST) { $PlanetID = request_var('add_moon', 0); $MoonName = request_var('name', '', UTF8_SUPPORT); $Diameter = request_var('diameter', 0); $FieldMax = request_var('field_max', 0); $MoonPlanet = $db->uniquequery("SELECT `temp_max`, `temp_min`, `id_luna`, `galaxy`, `system`, `planet`, `planet_type`, `destruyed`, `id_level`, `id_owner` FROM " . PLANETS . " WHERE `id` = '" . $PlanetID . "' AND `planet_type` = '1' AND `destruyed` = '0';"); if (!isset($MoonPlanet)) { $template->message($LNG['mo_planet_doesnt_exist'], '?page=create&mode=moon', 3, true); exit; } require_once ROOT_PATH . 'includes/functions/CreateOneMoonRecord.' . PHP_EXT; if (CreateOneMoonRecord($MoonPlanet['galaxy'], $MoonPlanet['system'], $MoonPlanet['planet'], $MoonPlanet['id_owner'], 0, $MoonName, 20, $_POST['diameter_check'] == 'on' ? 0 : $Diameter) !== false) { $template->message($LNG['mo_moon_added'], '?page=create&mode=moon', 3, true); } else { $template->message($LNG['mo_moon_unavaible'], '?page=create&mode=moon', 3, true); } exit; } $template->assign_vars(array('po_add_moon' => $LNG['po_add_moon'], 'input_id_planet' => $LNG['input_id_planet'], 'mo_moon_name' => $LNG['mo_moon_name'], 'mo_diameter' => $LNG['mo_diameter'], 'mo_temperature' => $LNG['mo_temperature'], 'mo_fields_avaibles' => $LNG['mo_fields_avaibles'], 'button_add' => $LNG['button_add'], 'new_creator_refresh' => $LNG['new_creator_refresh'], 'mo_moon' => $LNG['fcm_moon'], 'new_creator_go_back' => $LNG['new_creator_go_back'])); $template->show('adm/CreatePageMoon.tpl'); break; case 'planet': if ($_POST) { $id = request_var('id', 0); $Galaxy = request_var('galaxy', 0); $System = request_var('system', 0); $Planet = request_var('planet', 0); $name = request_var('name', '', UTF8_SUPPORT); $field_max = request_var('field_max', 0); $ISUser = $db->uniquequery("SELECT id, authlevel FROM " . USERS . " WHERE `id` = '" . $id . "';"); if (CheckPlanetIfExist($Galaxy, $System, $Planet) || !isset($ISUser)) { $template->message($LNG['po_complete_all'], '?page=create&mode=planet', 3, true); exit; } require_once ROOT_PATH . 'includes/functions/CreateOnePlanetRecord.' . PHP_EXT; CreateOnePlanetRecord($Galaxy, $System, $Planet, $id, '', '', false); $SQL = "UPDATE " . PLANETS . " SET "; if ($_POST['diameter_check'] != 'on' || $field_max > 0) { $SQL .= "`field_max` = '" . $field_max . "', "; } if (!empty($name)) { $SQL .= "`name` = '" . $db->sql_escape($name) . "', "; } $SQL .= "`id_level` = '" . $ISUser['authlevel'] . "' "; $SQL .= "WHERE "; $SQL .= "`galaxy` = '" . $Galaxy . "' AND "; $SQL .= "`system` = '" . $System . "' AND "; $SQL .= "`planet` = '" . $Planet . "' AND "; $SQL .= "`planet_type` = '1'"; $db->query($SQL); $template->message($LNG['po_complete_succes'], '?page=create&mode=planet', 3, true); exit; } $template->assign_vars(array('po_add_planet' => $LNG['po_add_planet'], 'po_galaxy' => $LNG['po_galaxy'], 'po_system' => $LNG['po_system'], 'po_planet' => $LNG['po_planet'], 'input_id_user' => $LNG['input_id_user'], 'new_creator_coor' => $LNG['new_creator_coor'], 'po_name_planet' => $LNG['po_name_planet'], 'po_fields_max' => $LNG['po_fields_max'], 'button_add' => $LNG['button_add'], 'po_colony' => $LNG['fcp_colony'], 'new_creator_refresh' => $LNG['new_creator_refresh'], 'new_creator_go_back' => $LNG['new_creator_go_back'])); $template->show('adm/CreatePagePlanet.tpl'); break; default: $template->assign_vars(array('new_creator_title_u' => $LNG['new_creator_title_u'], 'new_creator_title_p' => $LNG['new_creator_title_p'], 'new_creator_title_l' => $LNG['new_creator_title_l'], 'new_creator_title' => $LNG['new_creator_title'])); $template->show('adm/CreatePage.tpl'); break; } }