public function __construct() { global $CONF, $dpath, $LNG, $db, $USER, $PLANET; $mode = request_var('mode', ''); $msg = request_var('msg', '', true); $ctype = request_var('chat_type', ''); $MessageID = request_var('id', 0); switch ($mode) { case "delete": $this->DelMeassageFromChat($MessageID); break; case "send": $this->SetMeassageInChat($ctype, $msg); break; case "call": $this->GetMessages($ctype); break; default: $template = new template(); $template->execscript("showMessage();setInterval(showMessage, 10000);"); $template->loadscript("chat.js"); if (empty($ctype)) { $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $PlanetRess->SavePlanetToDB(); } else { $template->isPopup(true); } $template->assign_vars(array('ctype' => $ctype, 'chat_send' => $LNG['chat_send'], 'chat_disc' => $LNG['chat_disc'], 'chat_message' => $LNG['chat_message'], 'chat_bbcode' => $LNG['chat_bbcode'], 'chat_fontcolor' => $LNG['chat_fontcolor'], 'chat_color_white' => $LNG['chat_color_white'], 'chat_color_blue' => $LNG['chat_color_blue'], 'chat_color_yellow' => $LNG['chat_color_yellow'], 'chat_color_green' => $LNG['chat_color_green'], 'chat_color_pink' => $LNG['chat_color_pink'], 'chat_color_red' => $LNG['chat_color_red'], 'chat_color_orange' => $LNG['chat_color_orange'], 'chat_notext' => $LNG['chat_notext'], 'chat_request_url' => $LNG['chat_request_url'], 'chat_request_url_desc' => $LNG['chat_request_url_desc'])); $template->show("chat_overview.tpl"); break; } }
/** _ \_/ |\ | /¯¯\ \ / /\ |¯¯) |_¯ \ / /¯¯\ | | |´¯|¯` | /¯¯\ |\ |5 ¯ /¯\ | \| \__/ \/ /--\ |¯¯\ |__ \/ \__/ |__ \_/ | | \__/ | \|Core. * @author: Copyright (C) 2011 by Brayan Narvaez (Prinick) developer of xNova Revolution * @link: http://www.xnovarevolution.con.ar * @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/ * Please do not remove the credits */ function ShowFleetTraderPage() { global $USER, $PLANET, $LNG, $CONF, $pricelist, $resource; $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $CONF['trade_allowed_ships'] = explode(',', $CONF['trade_allowed_ships']); $ID = request_var('id', 0); if (!empty($ID) && in_array($ID, $CONF['trade_allowed_ships'])) { $Count = max(min(request_var('count', '0'), $PLANET[$resource[$ID]]), 0); $PLANET['metal'] = bcadd($PLANET['metal'], bcmul($Count, bcmul($pricelist[$ID]['metal'], (double) (1 - $CONF['trade_charge'])))); $PLANET['crystal'] = bcadd($PLANET['crystal'], bcmul($Count, bcmul($pricelist[$ID]['crystal'], (double) (1 - $CONF['trade_charge'])))); $PLANET['deuterium'] = bcadd($PLANET['deuterium'], bcmul($Count, bcmul($pricelist[$ID]['deuterium'], (double) (1 - $CONF['trade_charge'])))); $PLANET['norio'] = bcadd($PLANET['norio'], bcmul($Count, bcmul($pricelist[$ID]['norio'], (double) (1 - $CONF['trade_charge'])))); $USER['darkmatter'] = bcadd($USER['darkmatter'], bcmul($Count, bcmul($pricelist[$ID]['darkmatter'], (double) (1 - $CONF['trade_charge'])))); $PlanetRess->Builded[$ID] = bcadd(bcmul('-1', $Count), $PlanetRess->Builded[$ID]); } $PlanetRess->SavePlanetToDB(); $template = new template(); $template->loadscript('fleettrader.js'); $template->execscript('updateVars();'); $Cost = array(); foreach ($CONF['trade_allowed_ships'] as $ID) { $Cost[$ID] = array($PLANET[$resource[$ID]], $pricelist[$ID]['metal'], $pricelist[$ID]['crystal'], $pricelist[$ID]['deuterium'], $pricelist[$ID]['darkmatter'], $pricelist[$ID]['norio']); } $template->assign_vars(array('tech' => $LNG['tech'], 'ft_head' => $LNG['ft_head'], 'ft_count' => $LNG['ft_count'], 'ft_max' => $LNG['ft_max'], 'ft_total' => $LNG['ft_total'], 'ft_charge' => $LNG['ft_charge'], 'ft_absenden' => $LNG['ft_absenden'], 'trade_allowed_ships' => $CONF['trade_allowed_ships'], 'CostInfos' => json_encode($Cost), 'Charge' => $CONF['trade_charge'])); $template->show("fleettrader_overview.tpl"); }
/** _ \_/ |\ | /¯¯\ \ / /\ |¯¯) |_¯ \ / /¯¯\ | | |´¯|¯` | /¯¯\ |\ |5 ¯ /¯\ | \| \__/ \/ /--\ |¯¯\ |__ \/ \__/ |__ \_/ | | \__/ | \|Core. * @author: Copyright (C) 2011 by Brayan Narvaez (Prinick) developer of xNova Revolution * @link: http://www.xnovarevolution.con.ar * @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/ * Please do not remove the credits */ function ShowTopKB() { global $USER, $PLANET, $LNG, $UNI, $db, $LANG; $mode = request_var('mode', ''); $template = new template(); switch ($mode) { case "showkb": $template->isPopup(true); $LANG->includeLang(array('FLEET')); $ReportID = request_var('rid', ''); if (file_exists(ROOT_PATH . 'raports/topkb_' . $ReportID . '.php')) { require_once ROOT_PATH . 'raports/topkb_' . $ReportID . '.php'; $RaportRAW = $db->uniquequery("SELECT `angreifer`, `defender` FROM " . TOPKB . " WHERE `rid` = '" . $db->sql_escape($ReportID) . "';"); } foreach ($LNG['tech_rc'] as $id => $s_name) { $ship[] = "[ship[" . $id . "]]"; $shipname[] = $s_name; } $template->assign_vars(array('attacker' => $RaportRAW['angreifer'], 'defender' => $RaportRAW['defender'], 'report' => $raport)); $template->show("topkb_report.tpl"); break; default: $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $PlanetRess->SavePlanetToDB(); $top = $db->query("SELECT * FROM " . TOPKB . " WHERE `universe` = '" . $UNI . "' ORDER BY gesamtunits DESC LIMIT 100;"); while ($data = $db->fetch_array($top)) { $TopKBList[] = array('result' => $data['fleetresult'], 'time' => date(TDFORMAT, $data['time']), 'units' => pretty_number($data['gesamtunits']), 'rid' => $data['rid'], 'attacker' => $data['angreifer'], 'defender' => $data['defender'], 'result' => $data['fleetresult']); } $db->free_result($top); $template->assign_vars(array('tkb_units' => $LNG['tkb_units'], 'tkb_datum' => $LNG['tkb_datum'], 'tkb_owners' => $LNG['tkb_owners'], 'tkb_platz' => $LNG['tkb_platz'], 'tkb_top' => $LNG['tkb_top'], 'tkb_gratz' => $LNG['tkb_gratz'], 'tkb_legende' => $LNG['tkb_legende'], 'tkb_gewinner' => $LNG['tkb_gewinner'], 'tkb_verlierer' => $LNG['tkb_verlierer'], 'TopKBList' => $TopKBList)); $template->show("topkb_overview.tpl"); break; } }
/** _ \_/ |\ | /¯¯\ \ / /\ |¯¯) |_¯ \ / /¯¯\ | | |´¯|¯` | /¯¯\ |\ |5 ¯ /¯\ | \| \__/ \/ /--\ |¯¯\ |__ \/ \__/ |__ \_/ | | \__/ | \|Core. * @author: Copyright (C) 2011 by Brayan Narvaez (Prinick) developer of xNova Revolution * @link: http://www.xnovarevolution.con.ar * @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/ * Please do not remove the credits */ function ShowTechTreePage() { global $resource, $requeriments, $LNG, $reslist, $USER, $PLANET; $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $PlanetRess->SavePlanetToDB(); $template = new template(); $RequeriList = array(); foreach ($LNG['tech'] as $Element => $ElementName) { if (in_array($Element, $reslist['dmfunc'])) { continue; } if (!isset($resource[$Element])) { $TechTreeList[] = $ElementName; } else { $RequeriList = array(); if (isset($requeriments[$Element])) { foreach ($requeriments[$Element] as $RegID => $RedCount) { $RequeriList[$Element][] = array('id' => $RegID, 'count' => $RedCount, 'own' => isset($PLANET[$resource[$RegID]]) ? $PLANET[$resource[$RegID]] : $USER[$resource[$RegID]]); } } $TechTreeList[] = array('id' => $Element, 'name' => $ElementName, 'need' => $RequeriList); } } $template->assign_vars(array('TechTreeList' => $TechTreeList, 'tt_requirements' => $LNG['tt_requirements'], 'LNG' => $LNG['tech'], 'tt_lvl' => $LNG['tt_lvl'])); $template->show("techtree_overview.tpl"); }
function ShowRecordsPage() { global $USER, $PLANET, $LNG, $resource, $db, $CONF, $UNI; $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $PlanetRess->SavePlanetToDB(); $template = new template(); $Records = new records(); $RecordsArray = $Records->GetRecords($UNI); foreach ($RecordsArray as $ElementID => $ElementIDArray) { if ($ElementID >= 1 && $ElementID <= 39 || $ElementID == 44) { $Builds[$LNG['tech'][$ElementID]] = array('winner' => $ElementIDArray['maxlvl'] != 0 ? $ElementIDArray['username'] : $LNG['rec_rien'], 'count' => $ElementIDArray['maxlvl'] != 0 ? pretty_number($ElementIDArray['maxlvl']) : $LNG['rec_rien']); } elseif ($ElementID >= 41 && $ElementID <= 99 && $ElementID != 44) { $MoonsBuilds[$LNG['tech'][$ElementID]] = array('winner' => $ElementIDArray['maxlvl'] != 0 ? $ElementIDArray['username'] : $LNG['rec_rien'], 'count' => $ElementIDArray['maxlvl'] != 0 ? pretty_number($ElementIDArray['maxlvl']) : $LNG['rec_rien']); } elseif ($ElementID >= 101 && $ElementID <= 199) { $Techno[$LNG['tech'][$ElementID]] = array('winner' => $ElementIDArray['maxlvl'] != 0 ? $ElementIDArray['username'] : $LNG['rec_rien'], 'count' => $ElementIDArray['maxlvl'] != 0 ? pretty_number($ElementIDArray['maxlvl']) : $LNG['rec_rien']); } elseif ($ElementID >= 201 && $ElementID <= 399) { $Fleet[$LNG['tech'][$ElementID]] = array('winner' => $ElementIDArray['maxlvl'] != 0 ? $ElementIDArray['username'] : $LNG['rec_rien'], 'count' => $ElementIDArray['maxlvl'] != 0 ? pretty_number($ElementIDArray['maxlvl']) : $LNG['rec_rien']); } elseif ($ElementID >= 401 && $ElementID <= 599) { $Defense[$LNG['tech'][$ElementID]] = array('winner' => $ElementIDArray['maxlvl'] != 0 ? $ElementIDArray['username'] : $LNG['rec_rien'], 'count' => $ElementIDArray['maxlvl'] != 0 ? pretty_number($ElementIDArray['maxlvl']) : $LNG['rec_rien']); } } $Records = array($LNG['rec_build'] => $Builds, $LNG['rec_specb'] => $MoonsBuilds, $LNG['rec_techn'] => $Techno, $LNG['rec_fleet'] => $Fleet, $LNG['rec_defes'] => $Defense); $template->assign_vars(array('Records' => $Records, 'update' => sprintf($LNG['rec_last_update_on'], date(TDFORMAT, $CONF['stat_last_update'])), 'level' => $LNG['rec_level'], 'player' => $LNG['rec_playe'])); $template->show("records_overview.tpl"); }
function show() { global $LNG, $USER, $PLANET, $resource, $reslist; if ($USER['planet_sort'] == 0) { $Order = "id "; } elseif ($USER['planet_sort'] == 1) { $Order = "galaxy, system, planet, planet_type "; } elseif ($USER['planet_sort'] == 2) { $Order = "name "; } $Order .= $USER['planet_sort_order'] == 1 ? "DESC" : "ASC"; $PlanetsRAW = $GLOBALS['DATABASE']->query("SELECT * FROM " . PLANETS . " WHERE id_owner = '" . $USER['id'] . "' AND destruyed = '0' AND planet_type != '4' ORDER BY " . $Order . ";"); $elementALL = array(212, 202, 203, 204, 205, 229, 209, 206, 207, 217, 215, 213, 211, 219, 225, 226, 214, 216, 230, 227, 228, 222, 218, 221, 208, 210, 220, 223); $elementALLBis = array(401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 416, 417, 418, 419, 420, 421, 422, 502, 503); $elementAllTris = array(1, 2, 3, 4, 5, 6, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 41, 42, 43, 44, 48); foreach ($elementAllTris as $Element) { $elementListallTris[$Element] = array('id' => $Element); } foreach ($elementALL as $Element) { $elementListall[$Element] = array('id' => $Element); } foreach ($elementALLBis as $Element) { $elementListallBis[$Element] = array('id' => $Element); } $planetList = array(); $PlanetRess = new ResourceUpdate(); while ($PLANETA = $GLOBALS['DATABASE']->fetch_array($PlanetsRAW)) { list($USER, $PLANETA) = $PlanetRess->CalcResource($USER, $PLANETA, true); $planetList[] = array('id' => $PLANETA['id'], 'name' => $PLANETA['name'], 'image' => $PLANETA['image'], 'galaxy' => $PLANETA['galaxy'], 'system' => $PLANETA['system'], 'planet' => $PLANETA['planet'], 'type' => $PLANETA['planet_type'], 'metal_percent' => round($PLANETA['metal'] * 100 / $PLANETA['metal_max']), 'cystal_percent' => round($PLANETA['crystal'] * 100 / $PLANETA['crystal_max']), 'deut_percent' => round($PLANETA['deuterium'] * 100 / $PLANETA['deuterium_max']), 'metal_mine' => $PLANETA['metal_mine'], 'crystal_mine' => $PLANETA['crystal_mine'], 'deuterium_sintetizer' => $PLANETA['deuterium_sintetizer'], 'solar_plant' => $PLANETA['solar_plant'], 'searcher' => $PLANETA['searcher'], 'fusion_plant' => $PLANETA['fusion_plant'], 'robot_factory' => $PLANETA['robot_factory'], 'nano_factory' => $PLANETA['nano_factory'], 'hangar' => $PLANETA['hangar'], 'metal_store' => $PLANETA['metal_store'], 'crystal_store' => $PLANETA['crystal_store'], 'deuterium_store' => $PLANETA['deuterium_store'], 'laboratory' => $PLANETA['laboratory'], 'terraformer' => $PLANETA['terraformer'], 'university' => $PLANETA['university'], 'ally_deposit' => $PLANETA['ally_deposit'], 'silo' => $PLANETA['silo'], 'mondbasis' => $PLANETA['mondbasis'], 'phalanx' => $PLANETA['phalanx'], 'sprungtor' => $PLANETA['sprungtor'], 'collider' => $PLANETA['collider'], 'solar_satelit' => pretty_number($PLANETA['solar_satelit']), 'small_ship_cargo' => pretty_number($PLANETA['small_ship_cargo']), 'big_ship_cargo' => pretty_number($PLANETA['big_ship_cargo']), 'light_hunter' => pretty_number($PLANETA['light_hunter']), 'heavy_hunter' => pretty_number($PLANETA['heavy_hunter']), 'M7' => pretty_number($PLANETA['M7']), 'recycler' => pretty_number($PLANETA['recycler']), 'crusher' => pretty_number($PLANETA['crusher']), 'battle_ship' => pretty_number($PLANETA['battle_ship']), 'ev_transporter' => pretty_number($PLANETA['ev_transporter']), 'battleship' => pretty_number($PLANETA['battleship']), 'destructor' => pretty_number($PLANETA['destructor']), 'bomber_ship' => pretty_number($PLANETA['bomber_ship']), 'М19' => pretty_number($PLANETA['М19']), 'giga_recykler' => pretty_number($PLANETA['giga_recykler']), 'galleon' => pretty_number($PLANETA['galleon']), 'destroyer' => pretty_number($PLANETA['destroyer']), 'dearth_star' => pretty_number($PLANETA['dearth_star']), 'lune_noir' => pretty_number($PLANETA['lune_noir']), 'M32' => pretty_number($PLANETA['M32']), 'frigate' => pretty_number($PLANETA['frigate']), 'black_wanderer' => pretty_number($PLANETA['black_wanderer']), 'flying_death' => pretty_number($PLANETA['flying_death']), 'star_crasher' => pretty_number($PLANETA['star_crasher']), 'bs_class_oneil' => pretty_number($PLANETA['bs_class_oneil']), 'colonizer' => pretty_number($PLANETA['colonizer']), 'spy_sonde' => pretty_number($PLANETA['spy_sonde']), 'dm_ship' => pretty_number($PLANETA['dm_ship']), 'Scrappy' => pretty_number($PLANETA['Scrappy']), 'misil_launcher' => pretty_number($PLANETA['misil_launcher']), 'small_laser' => pretty_number($PLANETA['small_laser']), 'big_laser' => pretty_number($PLANETA['big_laser']), 'gauss_canyon' => pretty_number($PLANETA['gauss_canyon']), 'ionic_canyon' => pretty_number($PLANETA['ionic_canyon']), 'buster_canyon' => pretty_number($PLANETA['buster_canyon']), 'small_protection_shield' => pretty_number($PLANETA['small_protection_shield']), 'big_protection_shield' => pretty_number($PLANETA['big_protection_shield']), 'planet_protector' => pretty_number($PLANETA['planet_protector']), 'graviton_canyon' => pretty_number($PLANETA['graviton_canyon']), 'orbital_station' => pretty_number($PLANETA['orbital_station']), 'lepton_gun' => pretty_number($PLANETA['lepton_gun']), 'proton_gun' => pretty_number($PLANETA['proton_gun']), 'canyon' => pretty_number($PLANETA['canyon']), 'hydrogen_gun' => pretty_number($PLANETA['hydrogen_gun']), 'dora_gun' => pretty_number($PLANETA['dora_gun']), 'photon_cannon' => pretty_number($PLANETA['photon_cannon']), 'particle_emitter' => pretty_number($PLANETA['particle_emitter']), 'slim_mehador' => pretty_number($PLANETA['slim_mehador']), 'iron_mehador' => pretty_number($PLANETA['iron_mehador']), 'grand_mehador' => pretty_number($PLANETA['grand_mehador']), 'interceptor_misil' => pretty_number($PLANETA['interceptor_misil']), 'interplanetary_misil' => pretty_number($PLANETA['interplanetary_misil']), 'current' => $PLANETA['field_current'], 'max' => CalculateMaxPlanetFields($PLANETA), 'energy_used' => $PLANETA['energy'] + $PLANETA['energy_used'], 'resource901' => pretty_number($PLANETA['metal']), 'resource902' => pretty_number($PLANETA['crystal']), 'resource903' => pretty_number($PLANETA['deuterium']), 'resource911' => pretty_number($PLANETA['energy'])); } $this->tplObj->loadscript("empire.js"); $this->tplObj->assign_vars(array('planetList' => $planetList, 'elementListall' => $elementListall, 'elementListallBis' => $elementListallBis, 'elementListallTris' => $elementListallTris)); $this->display('page.empire.default.tpl'); }
function show() { global $USER, $PLANET, $LNG, $LANG, $CONF, $UNI; $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $PlanetRess->SavePlanetToDb(); $this->tplObj->assign_vars(array()); $this->display('page.planetjump.default.tpl'); }
/** _ \_/ |\ | /¯¯\ \ / /\ |¯¯) |_¯ \ / /¯¯\ | | |´¯|¯` | /¯¯\ |\ |5 ¯ /¯\ | \| \__/ \/ /--\ |¯¯\ |__ \/ \__/ |__ \_/ | | \__/ | \|Core. * @author: Copyright (C) 2011 by Brayan Narvaez (Prinick) developer of xNova Revolution * @link: http://www.xnovarevolution.con.ar * * Please do not remove the credits */ function ShowCreditsPage() { global $USER, $PLANET, $LNG, $LANG; $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $PlanetRess->SavePlanetToDB(); $template = new template(); $template->show("creditos_overview.tpl"); }
function show() { global $USER, $PLANET, $resource, $reslist; $db = Database::get(); switch ($USER['planet_sort']) { case 2: $orderBy = 'name'; break; case 1: $orderBy = 'galaxy, system, planet, planet_type'; break; default: $orderBy = 'id'; break; } $orderBy .= ' ' . ($USER['planet_sort_order'] == 1) ? 'DESC' : 'ASC'; $sql = "SELECT * FROM %%PLANETS%% WHERE id != :planetID AND id_owner = :userID AND destruyed = '0' ORDER BY :order;"; $PlanetsRAW = $db->select($sql, array(':planetID' => $PLANET['id'], ':userID' => $USER['id'], ':order' => $orderBy)); $PLANETS = array($PLANET); $PlanetRess = new ResourceUpdate(); foreach ($PlanetsRAW as $CPLANET) { list($USER, $CPLANET) = $PlanetRess->CalcResource($USER, $CPLANET, true); $PLANETS[] = $CPLANET; unset($CPLANET); } $planetList = array(); foreach ($PLANETS as $Planet) { $planetList['name'][$Planet['id']] = $Planet['name']; $planetList['image'][$Planet['id']] = $Planet['image']; $planetList['coords'][$Planet['id']]['galaxy'] = $Planet['galaxy']; $planetList['coords'][$Planet['id']]['system'] = $Planet['system']; $planetList['coords'][$Planet['id']]['planet'] = $Planet['planet']; $planetList['field'][$Planet['id']]['current'] = $Planet['field_current']; $planetList['field'][$Planet['id']]['max'] = CalculateMaxPlanetFields($Planet); $planetList['energy_used'][$Planet['id']] = $Planet['energy'] + $Planet['energy_used']; $planetList['resource'][901][$Planet['id']] = $Planet['metal']; $planetList['resource'][902][$Planet['id']] = $Planet['crystal']; $planetList['resource'][903][$Planet['id']] = $Planet['deuterium']; $planetList['resource'][911][$Planet['id']] = $Planet['energy']; foreach ($reslist['build'] as $elementID) { $planetList['build'][$elementID][$Planet['id']] = $Planet[$resource[$elementID]]; } foreach ($reslist['fleet'] as $elementID) { $planetList['fleet'][$elementID][$Planet['id']] = $Planet[$resource[$elementID]]; } foreach ($reslist['defense'] as $elementID) { $planetList['defense'][$elementID][$Planet['id']] = $Planet[$resource[$elementID]]; } } foreach ($reslist['tech'] as $elementID) { $planetList['tech'][$elementID] = $USER[$resource[$elementID]]; } $this->assign(array('colspan' => count($PLANETS) + 2, 'planetList' => $planetList)); $this->display('page.empire.default.tpl'); }
/** * 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 ShowFAQPage() { global $USER, $PLANET, $LNG, $LANG; $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $PlanetRess->SavePlanetToDB(); $template = new template(); $LANG->includeLang(array('FAQ')); $template->assign_vars(array('FAQList' => $LNG['faq'], 'faq_overview' => $LNG['faq_overview'])); $template->show("faq_overview.tpl"); }
/** _ \_/ |\ | /¯¯\ \ / /\ |¯¯) |_¯ \ / /¯¯\ | | |´¯|¯` | /¯¯\ |\ |5 ¯ /¯\ | \| \__/ \/ /--\ |¯¯\ |__ \/ \__/ |__ \_/ | | \__/ | \|Core. * @author: Copyright (C) 2011 by Brayan Narvaez (Prinick) developer of xNova Revolution * @link: http://www.xnovarevolution.con.ar * @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/ * Please do not remove the credits */ function ShowChangelogPage() { global $USER, $PLANET, $LNG, $LANG; $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $PlanetRess->SavePlanetToDB(); $template = new template(); $LANG->includeLang(array('CHANGELOG')); $template->assign_vars(array('ChangelogList' => array_map('makebr', $LNG['changelog']), 'Version' => $LNG['Version'], 'Description' => $LNG['Description'])); $template->show("changelog_overview.tpl"); }
function ShowSearchPage() { global $USER, $PLANET, $dpath, $LNG, $db; $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $PlanetRess->SavePlanetToDB(); $template = new template(); $template->page_header(); $template->page_topnav(); $template->page_leftmenu(); $template->page_planetmenu(); $template->page_footer(); $type = request_var('type', ''); $searchtext = request_var('searchtext', ''); switch ($type) { case 'playername': $search = $db->query("SELECT a.id, a.username, a.ally_id, a.ally_name, a.galaxy, a.system, a.planet, b.name, c.total_rank FROM " . USERS . " as a LEFT JOIN " . PLANETS . " as b ON b.id = a.id_planet LEFT JOIN " . STATPOINTS . " as c ON c.stat_type = 1 AND c.id_owner = a.id WHERE a.username LIKE '%" . $db->sql_escape($searchtext, true) . "%' LIMIT 25;"); while ($s = $db->fetch_array($search)) { $SearchResult[] = array('planetname' => $s['name'], 'username' => $s['username'], 'userid' => $s['id'], 'allyname' => $s['ally_name'], 'allyid' => $s['ally_id'], 'galaxy' => $s['galaxy'], 'system' => $s['system'], 'planet' => $s['planet'], 'rank' => $s['total_rank']); } $db->free_result($search); break; case 'planetname': $search = $db->query("SELECT a.name, a.galaxy, a.planet, a.system, b.ally_name, b.id, b.ally_id, b.username, c.total_rank FROM " . PLANETS . " as a LEFT JOIN " . USERS . " as b ON b.id = a.id_owner LEFT JOIN " . STATPOINTS . " as c ON c.stat_type = 1 AND c.id_owner = b.id WHERE a.name LIKE '%" . $db->sql_escape($searchtext, true) . "%' LIMIT 25;"); while ($s = $db->fetch_array($search)) { $SearchResult[] = array('planetname' => $s['name'], 'username' => $s['username'], 'userid' => $s['id'], 'allyname' => $s['ally_name'], 'allyid' => $s['ally_id'], 'galaxy' => $s['galaxy'], 'system' => $s['system'], 'planet' => $s['planet'], 'rank' => $s['total_rank']); } $db->free_result($search); break; case "allytag": $search = $db->query("SELECT a.ally_name, a.ally_tag, a.ally_members, b.total_points FROM " . ALLIANCE . " as a, " . STATPOINTS . " as b WHERE b.stat_type = 1 AND b.id_owner = a.id AND a.ally_tag LIKE '%" . $db->sql_escape($searchtext, true) . "%' LIMIT 25;"); while ($s = $db->fetch_array($search)) { $SearchResult[] = array('allypoints' => pretty_number($s['total_points']), 'allytag' => $s['ally_tag'], 'allymembers' => $s['ally_members'], 'allyname' => $s['ally_name']); } $db->free_result($search); break; case "allyname": $search = $db->query("SELECT a.ally_name, a.ally_tag, a.ally_members, b.total_points FROM " . ALLIANCE . " as a, " . STATPOINTS . " as b WHERE b.stat_type = 1 AND b.id_owner = a.id AND a.ally_name LIKE '%" . $db->sql_escape($searchtext, true) . "%' LIMIT 25;"); while ($s = $db->fetch_array($search)) { $SearchResult[] = array('allypoints' => pretty_number($s['total_points']), 'allytag' => $s['ally_tag'], 'allymembers' => $s['ally_members'], 'allyname' => $s['ally_name']); } $db->free_result($search); break; } $SeachTypes = array("playername" => $LNG['sh_player_name'], "planetname" => $LNG['sh_planet_name'], "allytag" => $LNG['sh_alliance_tag'], "allyname" => $LNG['sh_alliance_name']); $template->assign_vars(array('SearchResult' => $SearchResult, 'SeachTypes' => $SeachTypes, 'SeachInput' => $searchtext, 'SeachType' => $type, 'sh_search' => $LNG['sh_search'], 'sh_search_in_the_universe' => $LNG['sh_search_in_the_universe'], 'sh_buddy_request' => $LNG['sh_buddy_request'], 'sh_write_message' => $LNG['sh_write_message'], 'sh_name' => $LNG['sh_name'], 'sh_alliance' => $LNG['sh_alliance'], 'sh_planet' => $LNG['sh_planet'], 'sh_coords' => $LNG['sh_coords'], 'sh_position' => $LNG['sh_position'], 'sh_tag' => $LNG['sh_tag'], 'sh_members' => $LNG['sh_members'], 'sh_points' => $LNG['sh_points'])); $template->show("search_body.tpl"); }
/** _ \_/ |\ | /¯¯\ \ / /\ |¯¯) |_¯ \ / /¯¯\ | | |´¯|¯` | /¯¯\ |\ |5 ¯ /¯\ | \| \__/ \/ /--\ |¯¯\ |__ \/ \__/ |__ \_/ | | \__/ | \|Core. * @author: Copyright (C) 2011 by Brayan Narvaez (Prinick) developer of xNova Revolution * @link: http://www.xnovarevolution.con.ar * @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/ * Please do not remove the credits */ function ShowBannedPage() { global $USER, $PLANET, $LNG, $db; $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $PlanetRess->SavePlanetToDB(); $template = new template(); $query = $db->query("SELECT * FROM " . BANNED . " ORDER BY `id`;"); $PrangerList = array(); while ($u = $db->fetch_array($query)) { $PrangerList[] = array('player' => $u['who'], 'theme' => $u['theme'], 'from' => date(TDFORMAT, $u['time']), 'to' => date(TDFORMAT, $u['longer']), 'admin' => $u['author'], 'mail' => $u['email'], 'info' => sprintf($LNG['bn_writemail'], $u['author'])); } $db->free_result($query); $template->assign_vars(array('PrangerList' => $PrangerList, 'bn_no_players_banned' => $LNG['bn_no_players_banned'], 'bn_exists' => $LNG['bn_exists'], 'bn_players_banned' => $LNG['bn_players_banned'], 'bn_players_banned_list' => $LNG['bn_players_banned_list'], 'bn_player' => $LNG['bn_player'], 'bn_reason' => $LNG['bn_reason'], 'bn_from' => $LNG['bn_from'], 'bn_until' => $LNG['bn_until'], 'bn_by' => $LNG['bn_by'])); $template->show("banned_overview.tpl"); }
function ShowFAQPage() { global $USER, $PLANET, $LNG; $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $PlanetRess->SavePlanetToDB(); $template = new template(); $template->page_header(); $template->page_topnav(); $template->page_leftmenu(); $template->page_planetmenu(); $template->page_footer(); includeLang('FAQ'); $template->assign_vars(array('FAQList' => $LNG['faq'], 'faq_overview' => $LNG['faq_overview'])); $template->show("faq_overview.tpl"); }
function ShowImperiumPage() { global $LNG, $USER, $PLANET, $resource, $reslist, $db; $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $PlanetRess->SavePlanetToDB(); $template = new template(); $template->loadscript("trader.js"); $template->page_topnav(); $template->page_header(); $template->page_leftmenu(); $template->page_planetmenu(); $template->page_footer(); $SQLArray = array_merge($reslist['build'], $reslist['fleet'], $reslist['defense']); $Query = ""; foreach ($SQLArray as $id => $gid) { $Query .= ",`" . $resource[$gid] . "`"; } if ($USER['planet_sort'] == 0) { $Order = "`id` "; } elseif ($USER['planet_sort'] == 1) { $Order = "`galaxy`, `system`, `planet`, `planet_type` "; } elseif ($USER['planet_sort'] == 2) { $Order = "`name` "; } $Order .= $USER['planet_sort_order'] == 1 ? "DESC" : "ASC"; $PlanetsRAW = $db->query("\r\n\tSELECT `id`,`name`,`galaxy`,`system`,`planet`,`planet_type`,\r\n\t`image`,`field_current`,`field_max`,`metal`,`crystal`,`deuterium`,\r\n\t`energy_used`,`energy_max` " . $Query . " FROM " . PLANETS . " WHERE `id_owner` = '" . $USER['id'] . "' AND `destruyed` = '0' ORDER BY " . $Order . ";"); while ($Planet = $db->fetch_array($PlanetsRAW)) { $InfoList = array('id' => $Planet['id'], 'name' => $Planet['name'], 'image' => $Planet['image'], 'galaxy' => $Planet['galaxy'], 'system' => $Planet['system'], 'planet' => $Planet['planet'], 'field_current' => $Planet['field_current'], 'field_max' => CalculateMaxPlanetFields($Planet), 'metal' => pretty_number($Planet['metal']), 'crystal' => pretty_number($Planet['crystal']), 'deuterium' => pretty_number($Planet['deuterium']), 'energy_used' => pretty_number($Planet['energy_max'] + $Planet['energy_used']), 'energy_max' => pretty_number($Planet['energy_max'])); foreach ($reslist['build'] as $gid) { $BuildsList[$gid] = pretty_number($Planet[$resource[$gid]]); } foreach ($reslist['fleet'] as $gid) { $FleetsList[$gid] = pretty_number($Planet[$resource[$gid]]); } foreach ($reslist['defense'] as $gid) { $DefensesList[$gid] = pretty_number($Planet[$resource[$gid]]); } $PlanetsList[] = array('InfoList' => $InfoList, 'BuildsList' => $BuildsList, 'FleetsList' => $FleetsList, 'DefensesList' => $DefensesList); } foreach ($reslist['tech'] as $gid) { $ResearchList[$gid] = pretty_number($USER[$resource[$gid]]); } $template->assign_vars(array('colspan' => count($PlanetsList) + 1, 'PlanetsList' => $PlanetsList, 'ResearchList' => $ResearchList, 'iv_imperium_title' => $LNG['iv_imperium_title'], 'iv_planet' => $LNG['iv_planet'], 'iv_name' => $LNG['iv_name'], 'iv_coords' => $LNG['iv_coords'], 'iv_fields' => $LNG['iv_fields'], 'iv_resources' => $LNG['iv_resources'], 'Metal' => $LNG['Metal'], 'Crystal' => $LNG['Crystal'], 'Deuterium' => $LNG['Deuterium'], 'Energy' => $LNG['Energy'], 'iv_buildings' => $LNG['iv_buildings'], 'iv_technology' => $LNG['iv_technology'], 'iv_ships' => $LNG['iv_ships'], 'iv_defenses' => $LNG['iv_defenses'], 'tech' => $LNG['tech'], 'build' => $reslist['build'], 'fleet' => $reslist['fleet'], 'defense' => $reslist['defense'], 'research' => $reslist['tech'])); $template->show("empire_overview.tpl"); }
function ShowOverviewPage() { global $CONF, $LNG, $PLANET, $USER, $db, $resource, $UNI; $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $PlanetRess->SavePlanetToDB(); $template = new template(); $template->getplanets(); $AdminsOnline = $AllPlanets = $Moon = array(); foreach ($template->UserPlanets as $ID => $CPLANET) { if ($ID == $_SESSION['planet'] || $CPLANET['planet_type'] == 3) { continue; } if (!empty($CPLANET['b_building']) && $CPLANET['b_building'] > TIMESTAMP) { $Queue = explode(';', $CPLANET['b_building_id']); $CurrBuild = explode(',', $Queue[0]); $BuildPlanet = $LNG['tech'][$CurrBuild[0]] . " (" . $CurrBuild[1] . ")<br><span style=\"color:#7F7F7F;\">(" . pretty_time($CurrBuild[3] - TIMESTAMP) . ")</span>"; } else { $BuildPlanet = $LNG['ov_free']; } $AllPlanets[] = array('id' => $CPLANET['id'], 'name' => $CPLANET['name'], 'image' => $CPLANET['image'], 'build' => $BuildPlanet); } if ($PLANET['id_luna'] != 0) { $Moon = $db->uniquequery("SELECT `id`, `name` FROM " . PLANETS . " WHERE `id` = '" . $PLANET['id_luna'] . "';"); } if (!empty($PLANET['b_building'])) { $Queue = explode(';', $PLANET['b_building_id']); $CurrBuild = explode(',', $Queue[0]); $Build = $LNG['tech'][$CurrBuild[0]] . ' (' . $CurrBuild[1] . ')<br><div id="blc">"' . pretty_time($PLANET['b_building'] - TIMESTAMP) . '</div>'; $template->execscript('BuildTime();'); } else { $Build = $LNG['ov_free']; } $OnlineAdmins = $db->query("SELECT `id`,`username` FROM " . USERS . " WHERE `universe` = '" . $UNI . "' AND `onlinetime` >= '" . (TIMESTAMP - 10 * 60) . "' AND `authlevel` > '0';"); while ($AdminRow = $db->fetch_array($OnlineAdmins)) { $AdminsOnline[$AdminRow['id']] = $AdminRow['username']; } $db->free_result($OnlineAdmins); $template->loadscript('mbContainer.js'); $template->loadscript('overview.js'); $template->execscript('GetFleets(true);'); $template->assign_vars(array('user_rank' => sprintf($LNG['ov_userrank_info'], pretty_number($USER['total_points']), $LNG['ov_place'], $USER['total_rank'], $USER['total_rank'], $LNG['ov_of'], $CONF['users_amount']), 'is_news' => $CONF['OverviewNewsFrame'], 'news' => makebr($CONF['OverviewNewsText']), 'planetname' => $PLANET['name'], 'planetimage' => $PLANET['image'], 'galaxy' => $PLANET['galaxy'], 'system' => $PLANET['system'], 'planet' => $PLANET['planet'], 'buildtime' => $PLANET['b_building'], 'userid' => $USER['id'], 'username' => $USER['username'], 'build' => $Build, 'Moon' => $Moon, 'AllPlanets' => $AllPlanets, 'AdminsOnline' => $AdminsOnline, 'Teamspeak' => GetTeamspeakData(), 'messages' => $USER['new_message'] > 0 ? $USER['new_message'] == 1 ? $LNG['ov_have_new_message'] : sprintf($LNG['ov_have_new_messages'], pretty_number($USER['new_message'])) : false, 'planet_diameter' => pretty_number($PLANET['diameter']), 'planet_field_current' => $PLANET['field_current'], 'planet_field_max' => CalculateMaxPlanetFields($PLANET), 'planet_temp_min' => $PLANET['temp_min'], 'planet_temp_max' => $PLANET['temp_max'], 'ov_news' => $LNG['ov_news'], 'fcm_moon' => $LNG['fcm_moon'], 'ov_server_time' => $LNG['ov_server_time'], 'ov_planet' => $LNG['ov_planet'], 'ov_planetmenu' => $LNG['ov_planetmenu'], 'ov_diameter' => $LNG['ov_diameter'], 'ov_distance_unit' => $LNG['ov_distance_unit'], 'ov_developed_fields' => $LNG['ov_developed_fields'], 'ov_max_developed_fields' => $LNG['ov_max_developed_fields'], 'ov_fields' => $LNG['ov_fields'], 'ov_temperature' => $LNG['ov_temperature'], 'ov_aprox' => $LNG['ov_aprox'], 'ov_temp_unit' => $LNG['ov_temp_unit'], 'ov_to' => $LNG['ov_to'], 'ov_position' => $LNG['ov_position'], 'ov_points' => $LNG['ov_points'], 'ov_events' => $LNG['ov_events'], 'ov_admins_online' => $LNG['ov_admins_online'], 'ov_no_admins_online' => $LNG['ov_no_admins_online'], 'ov_userbanner' => $LNG['ov_userbanner'], 'ov_teamspeak' => $LNG['ov_teamspeak'], 'ov_your_planet' => $LNG['ov_your_planet'], 'ov_coords' => $LNG['ov_coords'], 'ov_planet_name' => $LNG['ov_planet_name'], 'ov_actions' => $LNG['ov_actions'], 'ov_abandon_planet' => $LNG['ov_abandon_planet'], 'ov_planet_rename' => $LNG['ov_planet_rename'], 'ov_planet_rename_action' => $LNG['ov_planet_rename_action'], 'ov_password' => $LNG['ov_password'], 'ov_with_pass' => $LNG['ov_with_pass'], 'ov_security_confirm' => $LNG['ov_security_confirm'], 'ov_security_request' => $LNG['ov_security_request'], 'ov_delete_planet' => $LNG['ov_delete_planet'], 'ov_planet_abandoned' => $LNG['ov_planet_abandoned'], 'path' => PROTOCOL . $_SERVER['HTTP_HOST'] . HTTP_ROOT)); $template->show("overview_body.tpl"); }
public function ShowSupportPage() { $action = request_var('action', ""); $id = request_var('id', 0); $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $PlanetRess->SavePlanetToDB(); switch ($action) { case 'newticket': $this->CreaeTicket(); break; case 'send': $this->UpdateTicket($id); break; default: $this->ShowSupportTickets(); break; } }
public function __construct() { global $USER, $PLANET, $resource, $reslist, $LNG, $db, $ExtraDM; $action = request_var('action', ''); $Offi = request_var('offi', 0); $Extra = request_var('extra', 0); $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); if ($action == "send" && $USER['urlaubs_modus'] == 0) { if (!empty($Offi) && !CheckModule(8)) { $this->UpdateOfficier($Offi); } elseif (!empty($Extra) && !CheckModule(18)) { $this->UpdateExtra($Extra); } } $PlanetRess->SavePlanetToDB(); $template = new template(); $template->loadscript('officier.js'); $template->page_header(); $template->page_topnav(); $template->page_leftmenu(); $template->page_planetmenu(); $template->page_footer(); if (!CheckModule(8)) { foreach ($reslist['dmfunc'] as $Element) { if ($USER[$resource[$Element]] > TIMESTAMP) { $template->execscript("GetOfficerTime(" . $Element . ", " . ($USER[$resource[$Element]] - TIMESTAMP) . ");"); } $ExtraDMList[] = array('id' => $Element, 'active' => $USER[$resource[$Element]] - TIMESTAMP, 'price' => pretty_number($ExtraDM[$Element]['darkmatter']), 'isok' => $USER['darkmatter'] - $ExtraDM[$Element]['darkmatter'] >= 0 ? true : false, 'time' => pretty_time($ExtraDM[$Element]['time'] * 3600), 'name' => $LNG['tech'][$Element], 'desc' => sprintf($LNG['res']['descriptions'][$Element], $ExtraDM[$Element]['add'] * 100)); } } if (!CheckModule(18)) { foreach ($reslist['officier'] as $Element) { if (($Result = $this->IsOfficierAccessible($Element)) === 0) { continue; } $OfficierList[] = array('id' => $Element, 'level' => $USER[$resource[$Element]], 'name' => $LNG['tech'][$Element], 'desc' => $LNG['res']['descriptions'][$Element], 'Result' => $Result); } } $template->assign_vars(array('ExtraDMList' => $ExtraDMList, 'OfficierList' => $OfficierList, 'user_darkmatter' => floor($USER['darkmatter'] / DM_PRO_OFFICIER_LEVEL), 'of_max_lvl' => $LNG['of_max_lvl'], 'of_recruit' => $LNG['of_recruit'], 'of_darkmatter' => sprintf($LNG['of_points_per_thousand_darkmatter'], DM_PRO_OFFICIER_LEVEL, $LNG['Darkmatter']), 'of_available_points' => $LNG['of_available_points'], 'alv_points' => $LNG['alv_points'], 'of_lvl' => $LNG['of_lvl'], 'in_dest_durati' => $LNG['in_dest_durati'], 'of_still' => $LNG['of_still'], 'of_active' => $LNG['of_active'], 'of_update' => $LNG['of_update'], 'in_dest_durati' => $LNG['in_dest_durati'], 'of_dm_trade' => sprintf($LNG['of_dm_trade'], $LNG['Darkmatter']))); $template->show("officier_overview.tpl"); }
/** * 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 ShowResourcesPage() { global $LNG, $ProdGrid, $resource, $reslist, $CONF, $db, $ExtraDM, $USER, $PLANET, $OfficerInfo; if ($PLANET['planet_type'] == 3 || $USER['urlaubs_modus'] == 1) { $CONF['metal_basic_income'] = 0; $CONF['crystal_basic_income'] = 0; $CONF['deuterium_basic_income'] = 0; } $SubQry = ""; if ($_POST && $USER['urlaubs_modus'] == 0) { foreach ($_POST as $Field => $Value) { $FieldName = $Field . "_porcent"; if (isset($PLANET[$FieldName]) && in_array($Value, $reslist['procent'])) { $Value = $Value / 10; $PLANET[$FieldName] = $Value; $SubQry .= ", `" . $FieldName . "` = '" . $Value . "'"; } } if (isset($SubQry)) { $QryUpdatePlanet = "UPDATE " . PLANETS . " SET "; $QryUpdatePlanet .= "`id` = '" . $PLANET['id'] . "' "; $QryUpdatePlanet .= $SubQry; $QryUpdatePlanet .= "WHERE "; $QryUpdatePlanet .= "`id` = '" . $PLANET['id'] . "';"; $db->query($QryUpdatePlanet); } redirectTo("game.php?page=resources"); exit; } $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $PlanetRess->SavePlanetToDB(); $template = new template(); if ($PLANET['energy_max'] == 0 && $PLANET['energy_used'] > 0) { $post_porcent = 0; } elseif ($PLANET['energy_max'] > 0 && abs($PLANET['energy_used']) > $PLANET['energy_max']) { $post_porcent = floor($PLANET['energy_max'] / ($PLANET['energy_used'] * -1) * 100); } elseif ($PLANET['energy_max'] == 0 && abs($PLANET['energy_used']) > $PLANET['energy_max']) { $post_porcent = 0; } else { $post_porcent = 100; } if ($post_porcent > 100) { $post_porcent = 100; } $BuildTemp = $PLANET['temp_max']; $BuildEnergy = $USER[$resource[113]]; $metal = array(); $crystal = array(); $deuterium = array(); $deu_en = array(); $energy = array(); $energy_en = array(); foreach ($reslist['prod'] as $ProdID) { if ($PLANET[$resource[$ProdID]] > 0 && isset($ProdGrid[$ProdID])) { $BuildLevelFactor = $PLANET[$resource[$ProdID] . "_porcent"]; $BuildLevel = $PLANET[$resource[$ProdID]]; $metal[$ProdID] = floor(eval($ProdGrid[$ProdID]['formule']['metal']) * (0.01 * $post_porcent) * $CONF['resource_multiplier']); $crystal[$ProdID] = floor(eval($ProdGrid[$ProdID]['formule']['crystal']) * (0.01 * $post_porcent) * $CONF['resource_multiplier']); if ($ProdID < 4) { $deuterium[$ProdID] = floor(eval($ProdGrid[$ProdID]['formule']['deuterium']) * (0.01 * $post_porcent) * $CONF['resource_multiplier']); $energy[$ProdID] = floor(eval($ProdGrid[$ProdID]['formule']['energy']) * $CONF['resource_multiplier']); } else { if ($ProdID == 12 && $PLANET['deuterium'] == 0) { continue; } $deu_en[$ProdID] = floor(eval($ProdGrid[$ProdID]['formule']['deuterium']) * $CONF['resource_multiplier']); $energy_en[$ProdID] = floor(eval($ProdGrid[$ProdID]['formule']['energy']) * $CONF['resource_multiplier']); } $thisdeu = isset($deuterium[$ProdID]) ? $deuterium[$ProdID] : $deu_en[$ProdID]; $thisenergy = isset($energy[$ProdID]) ? $energy[$ProdID] : $energy_en[$ProdID]; $CurrPlanetList[] = array('name' => $resource[$ProdID], 'type' => $LNG['tech'][$ProdID], 'level' => $ProdID > 200 ? $LNG['rs_amount'] : $LNG['rs_lvl'], 'level_type' => $PLANET[$resource[$ProdID]], 'metal_type' => colorNumber(pretty_number($metal[$ProdID])), 'crystal_type' => colorNumber(pretty_number($crystal[$ProdID])), 'deuterium_type' => colorNumber(pretty_number($thisdeu)), 'energy_type' => colorNumber(pretty_number($thisenergy)), 'optionsel' => $PLANET[$resource[$ProdID] . "_porcent"] * 10); } } $metal_total = $PLANET['metal_perhour'] + $CONF['metal_basic_income'] * $CONF['resource_multiplier']; $crystal_total = $PLANET['crystal_perhour'] + $CONF['crystal_basic_income'] * $CONF['resource_multiplier']; $deuterium_total = $PLANET['deuterium_perhour'] + $CONF['deuterium_basic_income'] * $CONF['resource_multiplier']; $energy_total = $PLANET['energy_max'] + $CONF['energy_basic_income'] * $CONF['resource_multiplier'] - abs($PLANET['energy_used']); foreach ($reslist['procent'] as $procent) { $OptionSelector[$procent] = $procent . "%"; } $template->assign_vars(array('bonus_metal' => colorNumber(pretty_number(array_sum($metal) * ($USER['rpg_geologue'] * $OfficerInfo[601]['info'] + $USER['metal_proc_tech'] * 0.02 + (TIMESTAMP - $USER[$resource[703]] <= 0 ? $ExtraDM[703]['add'] : 0)))), 'bonus_crystal' => colorNumber(pretty_number(array_sum($crystal) * ($USER['rpg_geologue'] * $OfficerInfo[601]['info'] + $USER['crystal_proc_tech'] * 0.02 + (TIMESTAMP - $USER[$resource[703]] <= 0 ? $ExtraDM[703]['add'] : 0)))), 'bonus_deuterium' => colorNumber(pretty_number(array_sum($deuterium) * ($USER['rpg_geologue'] * $OfficerInfo[601]['info'] + $USER['deuterium_proc_tech'] * 0.02 + (TIMESTAMP - $USER[$resource[703]] <= 0 ? $ExtraDM[703]['add'] : 0)))), 'bonus_energy' => colorNumber(pretty_number(array_sum($energy_en) * ($USER['rpg_ingenieur'] * $OfficerInfo[603]['info'] + (TIMESTAMP - $USER[$resource[704]] <= 0 ? $ExtraDM[704]['add'] : 0)))), 'CurrPlanetList' => $CurrPlanetList, 'Production_of_resources_in_the_planet' => str_replace('%s', $PLANET['name'], $LNG['rs_production_on_planet']), 'metal_basic_income' => $CONF['metal_basic_income'] * $CONF['resource_multiplier'], 'crystal_basic_income' => $CONF['crystal_basic_income'] * $CONF['resource_multiplier'], 'deuterium_basic_income' => $CONF['deuterium_basic_income'] * $CONF['resource_multiplier'], 'energy_basic_income' => $CONF['energy_basic_income'] * $CONF['resource_multiplier'], 'metalmax' => colorNumber($PLANET['metal_max'] / 1000, pretty_number($PLANET['metal_max'] / 1000) . "k"), 'crystalmax' => colorNumber($PLANET['crystal_max'] / 1000, pretty_number($PLANET['crystal_max'] / 1000) . "k"), 'deuteriummax' => colorNumber($PLANET['deuterium_max'] / 1000, pretty_number($PLANET['deuterium_max'] / 1000) . "k"), 'metal_total' => colorNumber(pretty_number($metal_total)), 'crystal_total' => colorNumber(pretty_number($crystal_total)), 'option' => $OptionSelector, 'deuterium_total' => colorNumber(pretty_number($deuterium_total)), 'energy_total' => colorNumber(pretty_number($energy_total)), 'daily_metal' => colorNumber(pretty_number(floor($metal_total * 24))), 'weekly_metal' => colorNumber(pretty_number(floor($metal_total * 24 * 7))), 'daily_crystal' => colorNumber(pretty_number(floor($crystal_total * 24))), 'weekly_crystal' => colorNumber(pretty_number(floor($crystal_total * 24 * 7))), 'daily_deuterium' => colorNumber(pretty_number(floor($deuterium_total * 24))), 'weekly_deuterium' => colorNumber(pretty_number(floor($deuterium_total * 24 * 7))), 'Metal' => $LNG['Metal'], 'Crystal' => $LNG['Crystal'], 'Deuterium' => $LNG['Deuterium'], 'Energy' => $LNG['Energy'], 'rs_basic_income' => $LNG['rs_basic_income'], 'rs_storage_capacity' => $LNG['rs_storage_capacity'], 'rs_sum' => $LNG['rs_sum'], 'rs_daily' => $LNG['rs_daily'], 'rs_weekly' => $LNG['rs_weekly'], 'rs_calculate' => $LNG['rs_calculate'], 'rs_ress_bonus' => $LNG['rs_ress_bonus'])); $template->show("resources_overview.tpl"); }
public function __construct() { global $USER, $PLANET, $LNG, $db, $UNI; $parse = $LNG; $mode = request_var('mode', ''); $a = request_var('a', 1); $sort1 = request_var('sort1', ''); $sort2 = request_var('sort2', ''); $edit = request_var('edit', ''); $rank = request_var('rank', ''); $kick = request_var('kick', ''); $id = request_var('id', ''); $action = request_var('action', ''); $allyid = request_var('allyid', ''); $tag = request_var('tag', ''); $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $PlanetRess->SavePlanetToDB(); $template = new template(); if ($USER['ally_id'] != 0 && $USER['ally_request'] != 0) { $db->query("UPDATE `" . USERS . "` SET `ally_id` = 0 WHERE `id` = " . $USER['id'] . ";"); redirectTo("game.php?page=alliance"); } switch ($USER['ally_id']) { case 0: switch ($mode) { case 'ainfo': $allyrow = $db->uniquequery("SELECT * FROM " . ALLIANCE . " WHERE ally_tag='" . $db->sql_escape($tag) . "' OR id='" . $db->sql_escape($a) . "';"); if (!$allyrow) { die(redirectTo("game.php?page=alliance")); } $this->ainfo($allyrow, $template); break; case 'make': if ($USER['ally_request'] == 0) { if ($action == "send") { $atag = request_var('atag', '', UTF8_SUPPORT); $aname = request_var('aname', '', UTF8_SUPPORT); if (empty($atag)) { $template->message($LNG['al_tag_required'], "?page=alliance&mode=make", 3); } if (empty($aname)) { $template->message($LNG['al_name_required'], "?page=alliance&mode=make", 3); } if (!CheckName($aname) || !CheckName($atag)) { $template->message(UTF8_SUPPORT ? $LNG['al_newname_no_space'] : $LNG['al_newname_alphanum'], "?page=alliance&mode=make", 3); } $tagquery = $db->countquery("SELECT COUNT(*) FROM `" . ALLIANCE . "` WHERE `ally_universe` = '" . $UNI . "' AND (ally_tag = '" . $db->sql_escape($atag) . "' OR ally_name = '" . $db->sql_escape($aname) . "');"); if ($tagquery == 0) { $template->message(sprintf($LNG['al_already_exists'], $aname), "?page=alliance&mode=make", 3); } $db->multi_query("INSERT INTO " . ALLIANCE . " SET\r\n `ally_name`='" . $db->sql_escape($aname) . "',\r\n `ally_tag`='" . $db->sql_escape($atag) . "' ,\r\n `ally_owner`='" . $USER['id'] . "',\r\n `ally_owner_range`='Leader',\r\n `ally_members`='1',\r\n `ally_register_time`='" . TIMESTAMP . "',\r\n\t\t\t\t\t\t\t\t`ally_universe` ='" . $UNI . "';\r\n UPDATE " . USERS . " SET\r\n `ally_id`= (SELECT `id` FROM " . ALLIANCE . " WHERE ally_name = '" . $db->sql_escape($aname) . "'),\r\n `ally_name` = '" . $db->sql_escape($aname) . "',\r\n `ally_register_time` = '" . TIMESTAMP . "'\r\n WHERE `id` = '" . $USER['id'] . "';\r\n UPDATE " . STATPOINTS . " SET\r\n `id_ally` = (SELECT `id` FROM " . ALLIANCE . " WHERE ally_name = '" . $db->sql_escape($aname) . "')\r\n WHERE `id_owner` = '" . $USER['id'] . "';"); $template->message(sprintf($LNG['al_created'], $atag), "?page=alliance", 3); } else { $template->assign_vars(array('al_make_alliance' => $LNG['al_make_alliance'], 'al_make_ally_tag_required' => $LNG['al_make_ally_tag_required'], 'al_make_ally_name_required' => $LNG['al_make_ally_name_required'], 'al_make_submit' => $LNG['al_make_submit'])); $template->show("alliance_make.tpl"); } } else { redirectTo("game.php?page=alliance"); } break; case 'search': if ($USER['ally_request'] == 0) { $searchtext = request_var('searchtext', '', UTF8_SUPPORT); if (!empty($searchtext)) { $Search = $db->query("SELECT id, ally_tag, ally_name, ally_members FROM " . ALLIANCE . " WHERE ally_name LIKE '%" . $db->sql_escape($searchtext, true) . "%' OR ally_tag LIKE '%" . $db->sql_escape($searchtext, true) . "%' LIMIT 30;"); $SeachResult = array(); while ($CurrRow = $db->fetch_array($Search)) { $SeachResult[] = array('id' => $CurrRow['id'], 'tag' => $CurrRow['ally_tag'], 'name' => $CurrRow['ally_name'], 'members' => $CurrRow['ally_members']); } } $template->assign_vars(array('searchtext' => $searchtext, 'SeachResult' => $SeachResult, 'al_find_submit' => $LNG['al_find_submit'], 'al_find_text' => $LNG['al_find_text'], 'al_find_alliances' => $LNG['al_find_alliances'], 'al_make_submit' => $LNG['al_make_submit'], 'al_find_no_alliances' => $LNG['al_find_no_alliances'], 'al_ally_info_members' => $LNG['al_ally_info_members'], 'al_ally_info_name' => $LNG['al_ally_info_name'], 'al_ally_info_tag' => $LNG['al_ally_info_tag'])); $template->show("alliance_searchform.tpl"); } else { redirectTo("game.php" . "?page=alliance"); } break; case 'apply': if ($USER['ally_request'] == 0) { $text = request_var('text', '', true); $allyrow = $db->uniquequery("SELECT `ally_tag`, `ally_request`, `ally_request_notallow` FROM " . ALLIANCE . " WHERE id='" . $db->sql_escape($allyid) . "';"); if (!$allyrow) { redirectTo("game.php?page=alliance"); } if ($allyrow['ally_request_notallow'] == 1) { $template->message($LNG['al_alliance_closed']); exit; } else { if ($action == "send") { $db->query("UPDATE " . USERS . " SET `ally_request`='" . $db->sql_escape($allyid) . "', ally_request_text='" . $db->sql_escape($text) . "', ally_register_time='" . TIMESTAMP . "' WHERE `id`='" . $USER['id'] . "';"); $template->message($LNG['al_request_confirmation_message'], "?page=alliance"); } else { $template->assign_vars(array('allyid' => $allyid, 'al_your_request_title' => $LNG['al_your_request_title'], 'applytext' => !empty($allyrow['ally_request']) ? $allyrow['ally_request'] : $LNG['al_default_request_text'], 'al_write_request' => sprintf($LNG['al_write_request'], $allyrow['ally_tag']), 'al_applyform_reload' => $LNG['al_applyform_reload'], 'al_applyform_send' => $LNG['al_applyform_send'], 'al_message' => $LNG['al_message'])); $template->show("alliance_applyform.tpl"); } } } else { redirectTo("game.php?page=alliance"); } break; default: if ($USER['ally_request'] != 0) { $allyquery = $db->uniquequery("SELECT ally_tag FROM " . ALLIANCE . " WHERE id = '" . $USER['ally_request'] . "' ORDER BY `id`;"); $bcancel = request_var('bcancel', ''); if ($bcancel) { $db->query("UPDATE " . USERS . " SET `ally_request`= 0 WHERE `id`='" . $USER['id'] . "';"); $template->assign_vars(array('al_your_request_title' => $LNG['al_your_request_title'], 'button_text' => $LNG['al_continue'], 'request_text' => sprintf($LNG['al_request_deleted'], $allyquery['ally_tag']), 'al_make_submit' => $LNG['al_continue'])); } else { $template->assign_vars(array('al_your_request_title' => $LNG['al_your_request_title'], 'button_text' => $LNG['al_delete_request'], 'request_text' => sprintf($LNG['al_request_wait_message'], $allyquery['ally_tag']), 'al_make_submit' => $LNG['al_make_submit'])); } $template->show("alliance_apply_waitform.tpl"); } else { $template->assign_vars(array('al_alliance_search' => $LNG['al_alliance_search'], 'al_alliance_make' => $LNG['al_alliance_make'], 'al_alliance' => $LNG['al_alliance'])); $template->show("alliance_defaultmenu.tpl"); } break; } break; default: $ally = $db->uniquequery("SELECT * FROM " . ALLIANCE . " WHERE id='" . $USER['ally_id'] . "';"); if (!$ally) { $db->query("UPDATE `" . USERS . "` SET `ally_id` = 0 WHERE `id` = " . $USER['id'] . ";"); redirectTo("game.php?page=alliance"); } $ally_ranks = unserialize($ally['ally_ranks']); $USER['rights']['memberlist_on'] = $ally_ranks[$USER['ally_rank_id'] - 1]['onlinestatus'] == 1 || $ally['ally_owner'] == $USER['id'] ? true : false; $USER['rights']['memberlist'] = $ally_ranks[$USER['ally_rank_id'] - 1]['memberlist'] == 1 || $ally['ally_owner'] == $USER['id'] ? true : false; $USER['rights']['roundmail'] = $ally_ranks[$USER['ally_rank_id'] - 1]['mails'] == 1 || $ally['ally_owner'] == $USER['id'] ? true : false; $USER['rights']['kick'] = $ally_ranks[$USER['ally_rank_id'] - 1]['kick'] == 1 || $ally['ally_owner'] == $USER['id'] ? true : false; $USER['rights']['righthand'] = $ally_ranks[$USER['ally_rank_id'] - 1]['rechtehand'] == 1 || $ally['ally_owner'] == $USER['id'] ? true : false; $USER['rights']['close'] = $ally_ranks[$USER['ally_rank_id'] - 1]['delete'] == 1 || $ally['ally_owner'] == $USER['id'] ? true : false; $USER['rights']['seeapply'] = $ally_ranks[$USER['ally_rank_id'] - 1]['bewerbungen'] == 1 || $ally['ally_owner'] == $USER['id'] ? true : false; $USER['rights']['changeapply'] = $ally_ranks[$USER['ally_rank_id'] - 1]['bewerbungenbearbeiten'] == 1 || $ally['ally_owner'] == $USER['id'] ? true : false; $USER['rights']['admin'] = $ally_ranks[$USER['ally_rank_id'] - 1]['administrieren'] == 1 || $ally['ally_owner'] == $USER['id'] ? true : false; switch ($mode) { case 'ainfo': $allyrow = $db->uniquequery("SELECT * FROM " . ALLIANCE . " WHERE ally_tag='" . $db->sql_escape($tag) . "' OR id='" . $db->sql_escape($a) . "';"); if (!$allyrow) { redirectTo("game.php?page=alliance"); } $this->ainfo($allyrow, $template); break; case 'exit': if ($ally['ally_owner'] == $USER['id']) { $template->message($LNG['al_founder_cant_leave_alliance'], "?page=alliance", 3); } elseif ($action = "send") { $db->multi_query("UPDATE " . USERS . " SET `ally_id` = 0, `ally_name` = '', ally_rank_id = 0 WHERE `id`='" . $USER['id'] . "';UPDATE " . ALLIANCE . " SET `ally_members` = `ally_members` - 1 WHERE `id`='" . $ally['id'] . "';UPDATE " . STATPOINTS . " SET `id_ally` = '0' WHERE `id_ally` = '" . $ally['id'] . "' AND `id_owner` = '" . $USER['id'] . "';"); $template->message(sprintf($LNG['al_leave_sucess'], $ally['ally_name']), "game.php?page=alliance", 2); } else { $template->message(sprintf($LNG['al_do_you_really_want_to_go_out'], $ally['ally_name']) . "<br><a href=\"?page=alliance&mode=exit&action=send\">" . $LNG['al_go_out_yes'] . "</a>"); } break; case 'memberslist': if (!$USER['rights']['memberlist']) { redirectTo("game.php?page=alliance"); } if ($sort1 && $sort2) { switch ($sort1) { case 1: $sort = " ORDER BY `username`"; break; case 2: $sort = " ORDER BY `ally_rank_id`"; break; case 3: $sort = " ORDER BY `total_points`"; break; case 4: $sort = " ORDER BY `ally_register_time`"; break; case 5: $sort = " ORDER BY `onlinetime`"; break; default: $sort = " ORDER BY `id`"; break; } if ($sort2 == 1) { $sort .= " DESC;"; } elseif ($sort2 == 2) { $sort .= " ASC;"; } $listuser = $db->query("SELECT DISTINCT u.id, u.username,u.galaxy, u.system, u.planet, u.ally_register_time, u.onlinetime, u.ally_rank_id, s.total_points FROM `" . USERS . "` as u LEFT JOIN " . STATPOINTS . " as s ON s.`stat_type` = '1' AND s.`id_owner` = u.`id` WHERE ally_id = '" . $USER['ally_id'] . "'" . $sort . ";"); } else { $listuser = $db->query("SELECT DISTINCT u.id, u.username,u.galaxy, u.system, u.planet, u.ally_register_time, u.onlinetime, u.ally_rank_id, s.total_points FROM `" . USERS . "` as u LEFT JOIN " . STATPOINTS . " as s ON s.`stat_type` = '1' AND s.`id_owner` = u.`id` WHERE `ally_id` = '" . $USER['ally_id'] . "';"); } while ($UserRow = $db->fetch_array($listuser)) { if ($ally['ally_owner'] == $UserRow['id']) { $UserRow['ally_range'] = $ally['ally_owner_range'] == '' ? $LNG['al_founder_rank_text'] : $ally['ally_owner_range']; } elseif ($UserRow['ally_rank_id'] != 0) { $UserRow['ally_range'] = $ally_ranks[$UserRow['ally_rank_id'] - 1]['name']; } else { $UserRow['ally_range'] = $LNG['al_new_member_rank_text']; } $Memberlist[] = array('id' => $UserRow['id'], 'username' => $UserRow['username'], 'galaxy' => $UserRow['galaxy'], 'system' => $UserRow['system'], 'planet' => $UserRow['planet'], 'register_time' => date(TDFORMAT, $UserRow['ally_register_time']), 'points' => pretty_number($UserRow['total_points']), 'range' => $UserRow['ally_range'], 'onlinetime' => floor((TIMESTAMP - $UserRow['onlinetime']) / 60)); } if (count($Memberlist) != $ally['ally_members']) { $db->query("UPDATE " . ALLIANCE . " SET `ally_members`='" . count($Memberlist) . "' WHERE `id`='" . $ally['id'] . "';"); } $template->assign_vars(array('Memberlist' => $Memberlist, 'sort' => $sort2 == 1 ? 2 : 1, 'seeonline' => $USER['rights']['memberlist_on'], 'al_users_list' => sprintf($LNG['al_users_list'], count($Memberlist)), 'al_num' => $LNG['al_num'], 'al_back' => $LNG['al_back'], 'al_message' => $LNG['al_message'], 'al_member' => $LNG['al_member'], 'al_position' => $LNG['al_position'], 'al_points' => $LNG['al_points'], 'al_coords' => $LNG['al_coords'], 'al_member_since' => $LNG['al_member_since'], 'al_estate' => $LNG['al_estate'], 'al_memberlist_on' => $LNG['al_memberlist_on'], 'al_memberlist_off' => $LNG['al_memberlist_off'], 'al_memberlist_min' => $LNG['al_memberlist_min'])); $template->show("alliance_memberslist.tpl"); break; case 'circular': if (!$USER['rights']['roundmail']) { redirectTo("game.php?page=alliance"); } if ($action == "send") { $r = request_var('r', 0); $subject = request_var('subject', '', true); $text = makebr(request_var('text', '', true)); $sq = $r == 0 ? $db->query("SELECT id, username FROM " . USERS . " WHERE `ally_id` = '" . $USER['ally_id'] . "';") : $db->query("SELECT id, username FROM " . USERS . " WHERE `ally_id` = '" . $USER['ally_id'] . "' AND `ally_rank_id` = '" . $r . "';"); $list = ''; $title = $LNG['al_circular_alliance'] . $ally['ally_tag']; $text = sprintf($LNG['al_circular_front_text'], $USER['username']) . "<br>" . $text; while ($u = $db->fetch_array($sq)) { SendSimpleMessage($u['id'], $USER['id'], '', 2, $title, $subject, $text); $list .= "\n" . $u['username']; } exit($LNG['al_circular_sended'] . $list); } $RangeList[] = $LNG['al_all_players']; if (is_array($ally_ranks)) { foreach ($ally_ranks as $id => $array) { $RangeList[$id + 1] = $array['name']; } } $template->assign_vars(array('RangeList' => $RangeList, 'al_circular_send_ciruclar' => $LNG['al_circular_send_ciruclar'], 'al_circular_reset' => $LNG['al_circular_reset'], 'al_receiveral_message' => $LNG['al_receiveral_message'], 'al_circular_send_submit' => $LNG['al_circular_send_submit'], 'al_characters' => $LNG['al_characters'], 'al_receiver' => $LNG['al_receiver'], 'mg_subject' => $LNG['mg_subject'], 'mg_no_subject' => $LNG['mg_no_subject'], 'mg_empty_text' => $LNG['mg_empty_text'])); $template->show("alliance_circular.tpl"); break; case 'admin': if (!$USER['rights']['admin']) { exit(redirectTo("game.php?page=alliance")); } switch ($edit) { case 'rights': if (!$USER['rights']['righthand']) { exit(redirectTo("game.php?page=alliance")); } $rankname = request_var('newrangname', '', UTF8_SUPPORT); $pid = $_POST['id']; $d = request_var('d', 1337); if (!empty($rankname)) { $pid = request_var('id', ''); $ally_ranks[] = array('name' => $rankname, 'mails' => 0, 'delete' => 0, 'kick' => 0, 'bewerbungen' => 0, 'administrieren' => 0, 'bewerbungenbearbeiten' => 0, 'memberlist' => 0, 'onlinestatus' => 0, 'rechtehand' => 0); $ranks = serialize($ally_ranks); $db->query("UPDATE " . ALLIANCE . " SET `ally_ranks`='" . $ranks . "' WHERE `id`='" . $ally['id'] . "';"); redirectTo("game.php?page=alliance&mode=admin&edit=rights"); exit; } elseif (is_array($pid)) { $ally_ranks_new = array(); foreach ($pid as $id) { $ally_ranks_new[$id]['name'] = $ally_ranks[$id]['name']; $ally_ranks_new[$id]['delete'] = isset($_POST['u' . $id . 'r0']) && $USER['rights']['close'] ? 1 : 0; $ally_ranks_new[$id]['kick'] = isset($_POST['u' . $id . 'r1']) && $USER['rights']['kick'] ? 1 : 0; $ally_ranks_new[$id]['bewerbungen'] = isset($_POST['u' . $id . 'r2']) && $USER['rights']['seeapply'] ? 1 : 0; $ally_ranks_new[$id]['memberlist'] = isset($_POST['u' . $id . 'r3']) && $USER['rights']['memberlist'] ? 1 : 0; $ally_ranks_new[$id]['bewerbungenbearbeiten'] = isset($_POST['u' . $id . 'r4']) && $USER['rights']['changeapply'] ? 1 : 0; $ally_ranks_new[$id]['administrieren'] = isset($_POST['u' . $id . 'r5']) && $USER['rights']['admin'] ? 1 : 0; $ally_ranks_new[$id]['onlinestatus'] = isset($_POST['u' . $id . 'r6']) && $USER['rights']['memberlist_on'] ? 1 : 0; $ally_ranks_new[$id]['mails'] = isset($_POST['u' . $id . 'r7']) && $USER['rights']['roundmail'] ? 1 : 0; $ally_ranks_new[$id]['rechtehand'] = isset($_POST['u' . $id . 'r8']) && $USER['rights']['righthand'] ? 1 : 0; } $ranks = serialize($ally_ranks_new); $db->query("UPDATE " . ALLIANCE . " SET `ally_ranks`='" . $ranks . "' WHERE `id`='" . $ally['id'] . "';"); redirectTo("game.php?page=alliance&mode=admin&edit=rights"); exit; } elseif (isset($ally_ranks[$d])) { unset($ally_ranks[$d]); $db->query("UPDATE " . ALLIANCE . " SET `ally_ranks`='" . serialize($ally_ranks) . "' WHERE `id`='" . $ally['id'] . "';"); } if (is_array($ally_ranks)) { foreach ($ally_ranks as $a => $b) { $AllyRanks[] = array('id' => $a, 'name' => $b['name'], 'memberlist_on' => $b['onlinestatus'], 'memberlist' => $b['memberlist'], 'roundmail' => $b['mails'], 'kick' => $b['kick'], 'righthand' => $b['rechtehand'], 'close' => $b['delete'], 'seeapply' => $b['bewerbungen'], 'changeapply' => $b['bewerbungenbearbeiten'], 'admin' => $b['administrieren']); } } $template->assign_vars(array('AllyRanks' => $AllyRanks, 'memberlist_on' => $USER['rights']['memberlist_on'], 'memberlist' => $USER['rights']['memberlist'], 'roundmail' => $USER['rights']['roundmail'], 'kick' => $USER['rights']['kick'], 'righthand' => $USER['rights']['righthand'], 'close' => $USER['rights']['close'], 'seeapply' => $USER['rights']['seeapply'], 'changeapply' => $USER['rights']['changeapply'], 'admin' => $USER['rights']['admin'], 'al_configura_ranks' => $LNG['al_configura_ranks'], 'al_save' => $LNG['al_configura_ranks'], 'Delete_range' => $LNG['Delete_range'], 'al_rank_name' => $LNG['al_rank_name'], 'al_dlte' => $LNG['al_dlte'], 'al_create' => $LNG['al_create'], 'al_rank_name' => $LNG['al_rank_name'], 'al_create_new_rank' => $LNG['al_create_new_rank'], 'al_back' => $LNG['al_back'], 'al_legend' => $LNG['al_legend'], 'al_no_ranks_defined' => $LNG['al_no_ranks_defined'], 'al_legend_kick_users' => $LNG['al_legend_kick_users'], 'al_legend_disolve_alliance' => $LNG['al_legend_disolve_alliance'], 'al_legend_see_requests' => $LNG['al_legend_see_requests'], 'al_legend_see_users_list' => $LNG['al_legend_see_users_list'], 'al_legend_check_requests' => $LNG['al_legend_check_requests'], 'al_legend_admin_alliance' => $LNG['al_legend_admin_alliance'], 'al_legend_see_connected_users' => $LNG['al_legend_see_connected_users'], 'al_legend_create_circular' => $LNG['al_legend_create_circular'], 'al_legend_right_hand' => $LNG['al_legend_right_hand'])); $template->show("alliance_admin_ranks.tpl"); break; case 'members': $NewRang = request_var('newrang', ''); if ($NewRang != '') { $q = $db->uniquequery("SELECT id FROM " . USERS . " WHERE id='" . $db->sql_escape($id) . "';"); isset($ally_ranks[$NewRang - 1]) && $q['id'] != $ally['ally_owner'] ? $db->query("UPDATE " . USERS . " SET `ally_rank_id`='" . $db->sql_escape($NewRang) . "' WHERE `id`='" . $db->sql_escape($id) . "';") : ''; } elseif ($action == "kick" && !empty($id) && $USER['rights']['kick']) { $u = $db->uniquequery("SELECT id FROM " . USERS . " WHERE id = '" . $db->sql_escape($id) . "' AND `ally_id` = '" . $ally['id'] . "' AND 'id' != '" . $ally['ally_owner'] . "';"); !empty($u['id']) ? $db->multi_query("UPDATE " . USERS . " SET `ally_id` = '0', `ally_name` = '', `ally_rank_id` = 0 WHERE `id` = '" . $u['id'] . "';UPDATE " . ALLIANCE . " SET `ally_members` = ally_members - 1 WHERE `id` = '" . $ally['id'] . "';UPDATE " . STATPOINTS . " SET `id_ally` = '0' WHERE `id_ally` = '" . $ally['id'] . "' AND `id_owner` = '" . $u['id'] . "';") : ''; } if ($sort1 && $sort2) { switch ($sort1) { case 1: $sort = " ORDER BY `username`"; break; case 2: $sort = " ORDER BY `ally_rank_id`"; break; case 3: $sort = " ORDER BY `total_points`"; break; case 4: $sort = " ORDER BY `ally_register_time`"; break; case 5: $sort = " ORDER BY `onlinetime`"; break; default: $sort = " ORDER BY `id`"; break; } if ($sort2 == 1) { $sort .= " DESC;"; } elseif ($sort2 == 2) { $sort .= " ASC;"; } $listuser = $db->query("SELECT DISTINCT u.id, u.username,u.galaxy, u.system, u.planet, u.ally_register_time, u.ally_rank_id, u.onlinetime, s.total_points FROM `" . USERS . "` as u LEFT JOIN " . STATPOINTS . " as s ON s.`stat_type` = '1' AND s.`id_owner` = u.`id` WHERE ally_id = '" . $USER['ally_id'] . "'" . $sort . ";"); } else { $listuser = $db->query("SELECT DISTINCT u.id, u.username,u.galaxy, u.system, u.planet, u.ally_register_time, u.ally_rank_id, u.onlinetime, s.total_points FROM `" . USERS . "` as u LEFT JOIN " . STATPOINTS . " as s ON s.`stat_type` = '1' AND s.`id_owner` = u.`id` WHERE `ally_id` = '" . $USER['ally_id'] . "';"); } $Selector[0] = $LNG['al_new_member_rank_text']; if (is_array($ally_ranks)) { foreach ($ally_ranks as $a => $b) { $Selector[$a + 1] = $b['name']; } } while ($UserRow = $db->fetch_array($listuser)) { if ($ally['ally_owner'] == $UserRow['id']) { $UserRow['ally_range'] = $ally['ally_owner_range'] == '' ? $LNG['al_founder_rank_text'] : $ally['ally_owner_range']; } elseif ($UserRow['ally_rank_id'] == 0) { $UserRow['ally_range'] = $LNG['al_new_member_rank_text']; } else { $UserRow['ally_range'] = $ally_ranks[$UserRow['ally_rank_id'] - 1]['name']; } $Memberlist[] = array('id' => $UserRow['id'], 'username' => $UserRow['username'], 'galaxy' => $UserRow['galaxy'], 'system' => $UserRow['system'], 'planet' => $UserRow['planet'], 'rank_id' => $UserRow['ally_rank_id'] - 1, 'register_time' => date(TDFORMAT, $UserRow['ally_register_time']), 'points' => pretty_number($UserRow['total_points']), 'range' => $UserRow['ally_range'], 'onlinetime' => sprintf("%d d", floor(TIMESTAMP - $UserRow['onlinetime']) / 86400), 'action' => $ally['ally_owner'] == $UserRow['id'] || $rank == $UserRow['id'] ? 0 : ($USER['rights']['kick'] == 1 ? 2 : 1), 'kick' => sprintf($LNG['al_kick_player'], $UserRow['username'])); } count($Memberlist) != $ally['ally_members'] ? $db->query("UPDATE " . ALLIANCE . " SET `ally_members`='" . count($Memberlist) . "' WHERE `id`='" . $ally['id'] . "';") : ''; $template->assign_vars(array('Selector' => $Selector, 'Memberlist' => $Memberlist, 'sort' => $sort2 == 1 ? 2 : 1, 'seeonline' => $USER['rights']['memberlist_on'], 'al_users_list' => sprintf($LNG['al_users_list'], count($Memberlist)), 'id' => $NewRang == '' ? $id : 0, 'al_num' => $LNG['al_num'], 'al_back' => $LNG['al_back'], 'al_message' => $LNG['al_message'], 'al_member' => $LNG['al_member'], 'al_position' => $LNG['al_position'], 'al_points' => $LNG['al_points'], 'al_coords' => $LNG['al_coords'], 'al_member_since' => $LNG['al_member_since'], 'al_estate' => $LNG['al_estate'], 'al_actions' => $LNG['al_actions'], 'al_ok' => $LNG['al_ok'])); $template->show("alliance_admin_members.tpl"); break; case 'diplo': !$USER['rights']['righthand'] ? redirectTo("game.php?page=alliance") : ''; $action = request_var('action', ''); $id = request_var('id', 0); $Level = request_var('level', 0); $DiploInfo = $this->GetDiplo($ally['id']); switch ($action) { case 'new': if (!empty($id)) { $text = request_var('text', '', true); $Alliances = $db->uniquequery("SELECT `ally_tag`, `ally_name` FROM " . ALLIANCE . " WHERE id = '" . $id . "';"); if ($Level == 4) { $AllyUsers = $db->query("SELECT `id` FROM " . USERS . " as s WHERE s.ally_id = '" . $ally['id'] . "' OR s.ally_id = '" . $id . "';"); while ($User = $db->fetch_array($AllyUsers)) { SendSimpleMessage($User['id'], $USER['id'], '', 2, $LNG['al_circular_alliance'] . $ally['ally_tag'] . " & " . $Alliances['ally_tag'], $LNG['al_diplo_war'], sprintf($LNG['al_diplo_war_mes'], $ally['ally_name'], $Alliances['ally_name'], $LNG['al_diplo_level'][$Level], $text)); } } else { $RanksRAW = $db->uniquequery("SELECT `ally_ranks`, `ally_owner` FROM " . ALLIANCE . " WHERE id = '" . $id . "';"); $Ranks = unserialize($RanksRAW['ally_ranks']); if (is_array($Ranks)) { foreach ($Ranks as $ID => $RankInfo) { if ($RankInfo['rechtehand'] == 0) { continue; } $SendRank[1] = "`ally_rank_id` ='" . ($ID + 1) . "' OR "; } } if (is_array($ally_ranks)) { foreach ($ally_ranks as $ID => $RankInfo) { if ($RankInfo['rechtehand'] == 0) { continue; } $SendRank[0] = "`ally_rank_id` ='" . ($ID + 1) . "' OR "; } } $AllyUsers = $db->query("SELECT `id` FROM " . USERS . " WHERE (ally_id = '" . $ally['id'] . "' AND (" . $SendRank[0] . "`id` = '" . $ally['ally_owner'] . "')) OR (ally_id = '" . $id . "' AND (" . $SendRank[1] . "`id` = '" . $RanksRAW['ally_owner'] . "'));"); while ($User = $db->fetch_array($AllyUsers)) { SendSimpleMessage($User['id'], $USER['id'], '', 2, $LNG['al_circular_alliance'] . $ally['ally_tag'] . " & " . $Alliances['ally_tag'], $LNG['al_diplo_ask'], sprintf($LNG['al_diplo_ask_mes'], $LNG['al_diplo_level'][$Level], $ally['ally_name'], $Alliances['ally_name'], $text)); } } $db->query("INSERT INTO " . DIPLO . " (`id` ,`owner_1` ,`owner_2` ,`level` ,`accept` ,`accept_text`) VALUES (NULL , '" . $ally['id'] . "', '" . $id . "', '" . $Level . "', '" . ($Level == 4 ? 1 : 0) . "', '" . $db->sql_escape($text) . "');"); exit($LNG['al_diplo_create_done']); } $Alliances = $db->query("SELECT `id`, `ally_name` FROM " . ALLIANCE . " WHERE id != '" . $ally['id'] . "';"); while ($Alliance = $db->fetch_array($Alliances)) { $AllianceList[$Alliance['id']] = $Alliance['ally_name']; } $template->assign_vars(array('AllianceList' => $AllianceList, 'al_diplo_create' => $LNG['al_diplo_create'], 'al_diplo_ally' => $LNG['al_diplo_ally'], 'al_diplo_level' => $LNG['al_diplo_level'], 'al_diplo_text' => $LNG['al_diplo_text'], 'al_diplo_level_des' => $LNG['al_diplo_level_des'], 'al_applyform_send' => $LNG['al_applyform_send'], 'mg_empty_text' => $LNG['mg_empty_text'])); $template->show("alliance_admin_diplo_form.tpl"); break; case 'accept': if (!empty($id)) { $AllyUsers = $db->query("SELECT `id` FROM " . USERS . " as s WHERE s.ally_id = '" . $ally['id'] . "' OR s.ally_id = '" . $DiploInfo[5][$id][1] . "';"); while ($User = $db->fetch_array($AllyUsers)) { SendSimpleMessage($User['id'], $USER['id'], '', 2, $LNG['al_circular_alliance'] . $ally['ally_tag'] . " & " . $DiploInfo[5][$id][5], $LNG['al_diplo_accept_yes'], sprintf($LNG['al_diplo_accept_yes_mes'], $LNG['al_diplo_level'][$Level], $ally['ally_name'], $DiploInfo[5][$id][0])); } $db->query("UPDATE " . DIPLO . " SET `accept` = '1', `accept_text` = '' WHERE `id`='" . $id . "' LIMIT 1;"); } redirectTo("game.php?page=alliance&mode=admin&edit=diplo"); break; case 'decline': if (!empty($id)) { $AllyUsers = $db->query("SELECT `id` FROM " . USERS . " as s WHERE s.ally_id = '" . $ally['id'] . "' OR s.ally_id = '" . $DiploInfo[5][$id][1] . "';"); while ($User = $db->fetch_array($AllyUsers)) { SendSimpleMessage($User['id'], $USER['id'], '', 2, $LNG['al_circular_alliance'] . $ally['ally_tag'] . " & " . $DiploInfo[5][$id][5], $LNG['al_diplo_accept_no'], sprintf($LNG['al_diplo_accept_no_mes'], $LNG['al_diplo_level'][$Level], $ally['ally_name'], $DiploInfo[5][$id][0])); } $db->query("DELETE FROM " . DIPLO . " WHERE `id` ='" . $id . "' LIMIT 1;"); } redirectTo("game.php?page=alliance&mode=admin&edit=diplo"); break; case 'delete': if (!empty($id)) { if (isset($DiploInfo[$Level][$id][1])) { $AllyUsers = $db->query("SELECT `id` FROM " . USERS . " as s WHERE s.ally_id = '" . $ally['id'] . "' OR s.ally_id = '" . $DiploInfo[$Level][$id][1] . "';"); while ($User = $db->fetch_array($AllyUsers)) { SendSimpleMessage($User['id'], $USER['id'], '', 2, $LNG['al_circular_alliance'] . $ally['ally_tag'] . " & " . $DiploInfo[$Level][$id][3], $LNG['al_diplo_delete'], sprintf($LNG['al_diplo_delete_mes'], $LNG['al_diplo_level'][$Level], $ally['ally_name'], $DiploInfo[$Level][$id][0])); } } $db->query("DELETE FROM " . DIPLO . " WHERE `id` ='" . $id . "' LIMIT 1;"); } redirectTo("game.php?page=alliance&mode=admin&edit=diplo"); break; default: $template->assign_vars(array('DiploInfo' => $DiploInfo, 'al_diplo_create' => $LNG['al_diplo_create'], 'al_diplo_level' => $LNG['al_diplo_level'], 'al_diplo_accept' => $LNG['al_diplo_accept'], 'al_diplo_accept_send' => $LNG['al_diplo_accept_send'], 'al_diplo_no_entry' => $LNG['al_diplo_no_entry'], 'al_diplo_no_accept' => $LNG['al_diplo_no_accept'], 'al_diplo_confirm_delete' => $LNG['al_diplo_confirm_delete'], 'al_diplo_accept_yes_confirm' => $LNG['al_diplo_accept_yes_confirm'], 'al_diplo_accept_no_confirm' => $LNG['al_diplo_accept_no_confirm'], 'al_diplo_ground' => $LNG['al_diplo_ground'], 'al_back' => $LNG['al_back'], 'ally_id' => $ally['id'])); $template->show("alliance_admin_diplo.tpl"); break; } break; case 'requests': !$USER['rights']['seeapply'] || !$USER['rights']['changeapply'] ? redirectTo("game.php?page=alliance") : ''; $text = makebr(request_var('text', '', true)); if ($action == $LNG['al_acept_request']) { $db->multi_query("UPDATE " . ALLIANCE . " SET `ally_members` = `ally_members` + 1 WHERE id='" . $ally['id'] . "';UPDATE " . USERS . " SET ally_name='" . $ally['ally_name'] . "', ally_request_text='', ally_request='0', ally_id='" . $ally['id'] . "' WHERE id='" . $db->sql_escape($id) . "';UPDATE " . STATPOINTS . " SET `id_ally` = '" . $ally['id'] . "' WHERE `id_owner` = '" . $id . "';"); SendSimpleMessage($id, $USER['id'], '', 2, $ally['ally_tag'], $LNG['al_you_was_acceted'] . $ally['ally_name'], $LNG['al_hi_the_alliance'] . $ally['ally_name'] . $LNG['al_has_accepted'] . $text); redirectTo('game.php?page=alliance&mode=admin&edit=ally'); } elseif ($action == $LNG['al_decline_request']) { $db->query("UPDATE " . USERS . " SET ally_request_text='',ally_request='0',ally_id='0' WHERE id='" . $db->sql_escape($id) . "';"); SendSimpleMessage($id, $USER['id'], '', 2, $ally['ally_tag'], $LNG['al_you_was_declined'] . $ally['ally_name'], $LNG['al_hi_the_alliance'] . $ally['ally_name'] . $LNG['al_has_declined'] . $text); redirectTo('game.php?page=alliance&mode=admin&edit=ally'); } $query = $db->query("SELECT id,username,ally_request_text,ally_register_time FROM " . USERS . " WHERE ally_request='" . $ally['id'] . "';"); while ($RequestRow = $db->fetch_array($query)) { $RequestList[] = array('username' => $RequestRow['username'], 'text' => makebr($RequestRow['ally_request_text']), 'id' => $RequestRow['id'], 'time' => date(TDFORMAT, $RequestRow['ally_register_time'])); } $template->assign_vars(array('RequestList' => $RequestList, 'requestcount' => sprintf($LNG['al_no_request_pending'], count($RequestList)), 'al_no_requests' => $LNG['al_no_requests'], 'al_candidate' => $LNG['al_candidate'], 'al_request_date' => $LNG['al_request_date'], 'al_request_list' => $LNG['al_request_list'], 'al_back' => $LNG['al_back'], 'al_reason' => $LNG['al_reason'], 'al_characters' => $LNG['al_characters'], 'al_request_from_user' => $LNG['al_request_from_user'], 'al_acept_request' => $LNG['al_acept_request'], 'al_decline_request' => $LNG['al_decline_request'], 'al_reply_to_request' => $LNG['al_reply_to_request'])); $template->show("alliance_admin_request.tpl"); break; case 'tag': $name = request_var('newname', '', UTF8_SUPPORT); !empty($name) ? $db->query("UPDATE " . ALLIANCE . " SET `ally_tag` = '" . $db->sql_escape($name) . "' WHERE `id` = '" . $USER['ally_id'] . "';") : ''; $template->assign_vars(array('caso' => $LNG['al_tag'], 'caso_titulo' => $LNG['al_new_tag'], 'al_change_submit' => $LNG['al_change_submit'], 'al_back' => $LNG['al_back'])); $template->show("alliance_admin_rename.tpl"); break; case 'name': $name = request_var('newname', '', UTF8_SUPPORT); !empty($name) ? $db->multi_query("UPDATE " . ALLIANCE . " SET `ally_name` = '" . $db->sql_escape($name) . "' WHERE `id` = '" . $USER['ally_id'] . "';UPDATE " . USERS . " SET `ally_name` = '" . $db->sql_escape($name) . "' WHERE `ally_id` = '" . $ally['id'] . "';") : ''; $template->assign_vars(array('caso' => $LNG['al_name'], 'caso_titulo' => $LNG['al_new_name'], 'al_change_submit' => $LNG['al_change_submit'], 'al_back' => $LNG['al_back'])); $template->show("alliance_admin_rename.tpl"); break; case 'exit': !$USER['rights']['close'] ? redirectTo("game.php?page=alliance") : ''; $db->multi_query("UPDATE " . USERS . " SET `ally_name` = '', `ally_id` = '0' WHERE `ally_id`='" . $ally['id'] . "';UPDATE " . STATPOINTS . " SET `id_ally` = '0' WHERE `id_ally` = '" . $ally['id'] . "';DELETE FROM " . ALLIANCE . " WHERE id = '" . $ally['id'] . "';DELETE FROM " . DIPLO . " WHERE `owner_1` = '" . $ally['id'] . "' OR `owner_2` = '" . $ally['id'] . "';"); redirectTo("game.php?page=alliance"); break; case 'transfer': $ally['ally_owner'] != $USER['id'] ? redirectTo("game.php?page=alliance") : ''; $postleader = request_var('newleader', 0); if (!empty($postleader)) { $Rank = $db->uniquequery("SELECT `ally_rank_id` FROM " . USERS . " WHERE `id` = '" . $postleader . "';"); $db->multi_query("UPDATE " . USERS . " SET `ally_rank_id` = '" . $Rank['ally_rank_id'] . "' WHERE `id` = '" . $USER['id'] . "';UPDATE " . USERS . " SET `ally_rank_id`= '0' WHERE `id` = '" . $postleader . "';UPDATE " . ALLIANCE . " SET `ally_owner` = '" . $postleader . "' WHERE `id` = '" . $USER['ally_id'] . "';"); redirectTo("game.php?page=alliance"); } else { $listuser = $db->query("SELECT id,ally_rank_id,username FROM " . USERS . " WHERE ally_id = '" . $USER['ally_id'] . "';"); while ($u = $db->fetch_array($listuser)) { $TransferUsers[$u['id']] = !empty($u['ally_rank_id']) && $ally['ally_owner'] != $u['id'] && $ally_ranks[$u['ally_rank_id'] - 1]['rechtehand'] == 1 ? $u['username'] . " [" . $ally_ranks[$u['ally_rank_id'] - 1]['name'] . "]" : ''; } $template->assign_vars(array('TransferUsers' => $TransferUsers, 'al_transfer_alliance' => $LNG['al_transfer_alliance'], 'al_transfer_to' => $LNG['al_transfer_to'], 'al_back' => $LNG['al_back'], 'al_transfer_submit' => $LNG['al_transfer_submit'])); $template->show("alliance_admin_transfer.tpl"); } break; default: $text = request_var('text', '0', true); $t = request_var('t', 1); if (isset($_POST['options'])) { $ally['ally_owner_range'] = request_var('owner_range', '', true); $ally['ally_web'] = request_var('web', ''); $ally['ally_image'] = request_var('image', ''); $ally['ally_request_notallow'] = request_var('request_notallow', 0); $ally['ally_stats'] = request_var('stats', 0); $ally['ally_diplo'] = request_var('diplo', 0); if ($ally['ally_request_notallow'] != 0 && $ally['ally_request_notallow'] != 1) { exit(redirectTo("game.php" . "?page=alliance")); } $db->query("UPDATE " . ALLIANCE . " SET\r\n\t\t\t\t\t\t\t\t\t`ally_owner_range` = '" . $db->sql_escape($ally['ally_owner_range']) . "',\r\n\t\t\t\t\t\t\t\t\t`ally_image` = '" . $db->sql_escape($ally['ally_image']) . "',\r\n\t\t\t\t\t\t\t\t\t`ally_web` = '" . $db->sql_escape($ally['ally_web']) . "',\r\n\t\t\t\t\t\t\t\t\t`ally_request_notallow` = '" . $ally['ally_request_notallow'] . "',\r\n\t\t\t\t\t\t\t\t\t`ally_stats` = '" . $ally['ally_stats'] . "',\r\n\t\t\t\t\t\t\t\t\t`ally_diplo` = '" . $ally['ally_diplo'] . "'\r\n\t\t\t\t\t\t\t\t\tWHERE `id`='" . $ally['id'] . "';"); } elseif ($text !== '0') { $QryText = "UPDATE " . ALLIANCE . " SET "; if ($t == 3) { $QryText .= "`ally_request`='" . $db->sql_escape($text) . "' "; } elseif ($t == 2) { $QryText .= "`ally_text`='" . $db->sql_escape($text) . "' "; } else { $QryText .= "`ally_description`='" . $db->sql_escape($text) . "' "; } $QryText .= "WHERE `id`='" . $ally['id'] . "';"; $db->query($QryText); } switch ($t) { case 2: $text = $text !== '0' ? $text : $ally['ally_text']; break; case 3: $text = $text !== '0' ? $text : $ally['ally_request']; break; default: $text = $text !== '0' ? $text : $ally['ally_description']; break; } $template->loadscript('alliance.js'); $template->execscript("\$('#cntChars').text(\$('#text').val().length);"); $template->assign_vars(array('al_characters' => $LNG['al_characters'], 'al_manage_alliance' => $LNG['al_manage_alliance'], 'al_texts' => $LNG['al_texts'], 'al_message' => $LNG['al_message'], 'al_manage_ranks' => $LNG['al_manage_ranks'], 'al_manage_members' => $LNG['al_manage_members'], 'al_manage_change_tag' => $LNG['al_manage_change_tag'], 'al_manage_change_name' => $LNG['al_manage_change_name'], 'al_outside_text' => $LNG['al_outside_text'], 'al_inside_text' => $LNG['al_inside_text'], 'al_request_text' => $LNG['al_request_text'], 'al_circular_reset' => $LNG['al_circular_reset'], 'al_save' => $LNG['al_save'], 'al_continue' => $LNG['al_continue'], 'al_manage_options' => $LNG['al_manage_options'], 'al_web_site' => $LNG['al_web_site'], 'al_manage_image' => $LNG['al_manage_image'], 'al_manage_requests' => $LNG['al_manage_requests'], 'al_manage_founder_rank' => $LNG['al_manage_founder_rank'], 'al_manage_diplo' => $LNG['al_manage_diplo'], 'al_view_stats' => $LNG['al_view_stats'], 'al_view_diplo' => $LNG['al_view_diplo'], 'al_disolve_alliance' => $LNG['al_disolve_alliance'], 'al_transfer_alliance' => $LNG['al_transfer_alliance'], 'al_close_ally' => $LNG['al_close_ally'], 'al_message' => $t == 2 ? $LNG['al_inside_text'] : ($t == 3 ? $LNG['al_request_text'] : $LNG['al_outside_text']), 'RequestSelector' => array(0 => $LNG['al_requests_allowed'], 1 => $LNG['al_requests_not_allowed']), 'YesNoSelector' => array(1 => $LNG['al_go_out_yes'], 0 => $LNG['al_go_out_no']), 't' => $t, 'text' => $text, 'righthand' => $USER['rights']['righthand'], 'ally_web' => $ally['ally_web'], 'ally_image' => $ally['ally_image'], 'ally_request_notallow' => $ally['ally_request_notallow'], 'ally_owner_range' => $ally['ally_owner_range'], 'ally_stats_data' => $ally['ally_stats'], 'ally_diplo_data' => $ally['ally_diplo'])); $template->show("alliance_admin.tpl"); break; } break; default: require_once ROOT_PATH . 'includes/functions/BBCode.php'; if ($ally['ally_owner'] == $USER['id']) { $range = $ally['ally_owner_range'] != '' ? $ally['ally_owner_range'] : $LNG['al_founder_rank_text']; } elseif ($USER['ally_rank_id'] != 0 && isset($ally_ranks[$USER['ally_rank_id'] - 1]['name'])) { $range = $ally_ranks[$USER['ally_rank_id'] - 1]['name']; } else { $range = $LNG['al_new_member_rank_text']; } $StatsData = $db->uniquequery("SELECT SUM(wons) as wons, SUM(loos) as loos, SUM(draws) as draws, SUM(kbmetal) as kbmetal, SUM(kbcrystal) as kbcrystal, SUM(kbnorio) as kbnorio, SUM(lostunits) as lostunits, SUM(desunits) as desunits FROM " . USERS . " WHERE ally_id='" . $ally['id'] . "';"); $Reuqests = $db->uniquequery("SELECT COUNT(*) as state FROM " . USERS . " WHERE ally_request='" . $ally['id'] . "';"); $template->assign_vars(array('DiploInfo' => $this->GetDiplo($ally['id']), 'al_diplo_level' => $LNG['al_diplo_level'], 'al_diplo' => $LNG['al_diplo'], 'ally_web' => $ally['ally_web'], 'ally_tag' => $ally['ally_tag'], 'ally_members' => $ally['ally_members'], 'ally_name' => $ally['ally_name'], 'ally_image' => $ally['ally_image'], 'ally_description' => bbcode($ally['ally_description']), 'ally_text' => bbcode($ally['ally_text']), 'range' => $range, 'requests' => sprintf($LNG['al_new_requests'], $Reuqests['state']), 'req_count' => $Reuqests['state'], 'al_requests' => $LNG['al_requests'], 'al_leave_alliance' => $LNG['al_leave_alliance'], 'al_rank' => $LNG['al_rank'], 'al_ally_info_tag' => $LNG['al_ally_info_tag'], 'al_user_list' => $LNG['al_user_list'], 'al_ally_info_name' => $LNG['al_ally_info_name'], 'al_ally_info_members' => $LNG['al_ally_info_members'], 'al_manage_alliance' => $LNG['al_manage_alliance'], 'al_your_ally' => $LNG['al_your_ally'], 'al_Allyquote' => $LNG['al_Allyquote'], 'al_web_text' => $LNG['al_web_text'], 'al_circular_message' => $LNG['al_circular_message'], 'al_send_circular_message' => $LNG['al_send_circular_message'], 'al_description_message' => $LNG['al_description_message'], 'al_inside_section' => $LNG['al_inside_section'], 'pl_totalfight' => $LNG['pl_totalfight'], 'pl_fightwon' => $LNG['pl_fightwon'], 'pl_fightlose' => $LNG['pl_fightlose'], 'pl_fightdraw' => $LNG['pl_fightdraw'], 'pl_unitsshot' => $LNG['pl_unitsshot'], 'pl_unitslose' => $LNG['pl_unitslose'], 'pl_dermetal' => $LNG['pl_dermetal'], 'pl_dercrystal' => $LNG['pl_dercrystal'], 'pl_dernorio' => $LNG['pl_dernorio'], 'al_goto_chat' => $LNG['al_goto_chat'], 'al_continue' => $LNG['al_continue'], 'al_leave_alliance' => $LNG['al_leave_alliance'], 'al_leave_ally' => $LNG['al_leave_ally'], 'totalfight' => $StatsData['wons'] + $StatsData['loos'] + $StatsData['draws'], 'fightwon' => $StatsData['wons'], 'fightlose' => $StatsData['loos'], 'fightdraw' => $StatsData['draws'], 'unitsshot' => pretty_number($StatsData['desunits']), 'unitslose' => pretty_number($StatsData['lostunits']), 'dermetal' => pretty_number($StatsData['kbmetal']), 'dercrystal' => pretty_number($StatsData['kbcrystal']), 'dernorio' => pretty_number($StatsData['kbnorio']), 'isowner' => $ally['ally_owner'] != $USER['id'] ? true : false, 'rights' => $USER['rights'])); $template->show("alliance_frontpage.tpl"); break; } break; } }
public function SetNextQueueTechOnTop() { global $resource, $LNG; if (empty($this->USER['b_tech_queue'])) { $this->USER['b_tech'] = 0; $this->USER['b_tech_id'] = 0; $this->USER['b_tech_planet'] = 0; $this->USER['b_tech_queue'] = ''; return false; } $CurrentQueue = unserialize($this->USER['b_tech_queue']); $Loop = true; while ($Loop == true) { $ListIDArray = $CurrentQueue[0]; $isAnotherPlanet = $ListIDArray[4] != $this->PLANET['id']; if ($isAnotherPlanet) { $sql = 'SELECT * FROM %%PLANETS%% WHERE id = :planetId;'; $PLANET = Database::get()->selectSingle($sql, array(':planetId' => $ListIDArray[4])); $RPLANET = new ResourceUpdate(true, false); list(, $PLANET) = $RPLANET->CalcResource($this->USER, $PLANET, false, $this->USER['b_tech']); } else { $PLANET = $this->PLANET; } $PLANET[$resource[31] . '_inter'] = self::getNetworkLevel($this->USER, $PLANET); $Element = $ListIDArray[0]; $Level = $ListIDArray[1]; $costResources = BuildFunctions::getElementPrice($this->USER, $PLANET, $Element); $BuildTime = BuildFunctions::getBuildingTime($this->USER, $PLANET, $Element, $costResources); $HaveResources = BuildFunctions::isElementBuyable($this->USER, $PLANET, $Element, $costResources); $BuildEndTime = $this->USER['b_tech'] + $BuildTime; $CurrentQueue[0] = array($Element, $Level, $BuildTime, $BuildEndTime, $PLANET['id']); if ($HaveResources == true) { if (isset($costResources[901])) { $PLANET[$resource[901]] -= $costResources[901]; } if (isset($costResources[902])) { $PLANET[$resource[902]] -= $costResources[902]; } if (isset($costResources[903])) { $PLANET[$resource[903]] -= $costResources[903]; } if (isset($costResources[921])) { $this->USER[$resource[921]] -= $costResources[921]; } $this->USER['b_tech_id'] = $Element; $this->USER['b_tech'] = $BuildEndTime; $this->USER['b_tech_planet'] = $PLANET['id']; $this->USER['b_tech_queue'] = serialize($CurrentQueue); $Loop = false; } else { if ($this->USER['hof'] == 1) { if (!isset($costResources[901])) { $costResources[901] = 0; } if (!isset($costResources[902])) { $costResources[902] = 0; } if (!isset($costResources[903])) { $costResources[903] = 0; } $Message = sprintf($LNG['sys_notenough_money'], $PLANET['name'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $LNG['tech'][$Element], pretty_number($PLANET['metal']), $LNG['tech'][901], pretty_number($PLANET['crystal']), $LNG['tech'][902], pretty_number($PLANET['deuterium']), $LNG['tech'][903], pretty_number($costResources[901]), $LNG['tech'][901], pretty_number($costResources[902]), $LNG['tech'][902], pretty_number($costResources[903]), $LNG['tech'][903]); PlayerUtil::sendMessage($this->USER['id'], 0, $this->USER['b_tech'], 99, $LNG['sys_techlist'], $LNG['sys_buildlist_fail'], $Message); } array_shift($CurrentQueue); if (count($CurrentQueue) == 0) { $this->USER['b_tech'] = 0; $this->USER['b_tech_id'] = 0; $this->USER['b_tech_planet'] = 0; $this->USER['b_tech_queue'] = ''; $Loop = false; } else { $BaseTime = $BuildEndTime - $BuildTime; $NewQueue = array(); foreach ($CurrentQueue as $ListIDArray) { $ListIDArray[2] = BuildFunctions::getBuildingTime($this->USER, $PLANET, $ListIDArray[0]); $BaseTime += $ListIDArray[2]; $ListIDArray[3] = $BaseTime; $NewQueue[] = $ListIDArray; } $CurrentQueue = $NewQueue; } } if ($isAnotherPlanet) { $RPLANET->SavePlanetToDB($this->USER, $PLANET); $RPLANET = NULL; unset($RPLANET); } else { $this->PLANET = $PLANET; } } return true; }
public function show() { global $ProdGrid, $LNG, $resource, $reslist, $PLANET, $USER, $pricelist; $TheCommand = HTTP::_GP('cmd', ''); // wellformed buildURLs if (!empty($TheCommand) && $_SERVER['REQUEST_METHOD'] === 'POST' && $USER['urlaubs_modus'] == 0) { $Element = HTTP::_GP('building', 0); $ListID = HTTP::_GP('listid', 0); switch ($TheCommand) { case 'cancel': $this->CancelBuildingFromQueue(); break; case 'remove': $this->RemoveBuildingFromQueue($ListID); break; case 'insert': $this->AddBuildingToQueue($Element, true); break; case 'destroy': $this->AddBuildingToQueue($Element, false); break; } $this->redirectTo('game.php?page=buildings'); } $config = Config::get(); $queueData = $this->getQueueData(); $Queue = $queueData['queue']; $QueueCount = count($Queue); $CanBuildElement = isVacationMode($USER) || $config->max_elements_build == 0 || $QueueCount < $config->max_elements_build; $CurrentMaxFields = CalculateMaxPlanetFields($PLANET); $RoomIsOk = $PLANET['field_current'] < $CurrentMaxFields - $QueueCount; $BuildEnergy = $USER[$resource[113]]; $BuildLevelFactor = 10; $BuildTemp = $PLANET['temp_max']; $BuildInfoList = array(); $Elements = $reslist['allow'][$PLANET['planet_type']]; foreach ($Elements as $Element) { if (!BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element)) { continue; } $infoEnergy = ""; if (isset($queueData['quickinfo'][$Element])) { $levelToBuild = $queueData['quickinfo'][$Element]; } else { $levelToBuild = $PLANET[$resource[$Element]]; } if (in_array($Element, $reslist['prod'])) { $BuildLevel = $PLANET[$resource[$Element]]; $Need = eval(ResourceUpdate::getProd($ProdGrid[$Element]['production'][911])); $BuildLevel = $levelToBuild + 1; $Prod = eval(ResourceUpdate::getProd($ProdGrid[$Element]['production'][911])); $requireEnergy = $Prod - $Need; $requireEnergy = round($requireEnergy * $config->energySpeed); if ($requireEnergy < 0) { $infoEnergy = sprintf($LNG['bd_need_engine'], pretty_number(abs($requireEnergy)), $LNG['tech'][911]); } else { $infoEnergy = sprintf($LNG['bd_more_engine'], pretty_number(abs($requireEnergy)), $LNG['tech'][911]); } } $costResources = BuildFunctions::getElementPrice($USER, $PLANET, $Element, false, $levelToBuild); $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costResources); $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costResources); $destroyResources = BuildFunctions::getElementPrice($USER, $PLANET, $Element, true); $destroyTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $destroyResources); $destroyOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $destroyResources); $buyable = $QueueCount != 0 || BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costResources); $BuildInfoList[$Element] = array('level' => $PLANET[$resource[$Element]], 'maxLevel' => $pricelist[$Element]['max'], 'infoEnergy' => $infoEnergy, 'costResources' => $costResources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'destroyResources' => $destroyResources, 'destroyTime' => $destroyTime, 'destroyOverflow' => $destroyOverflow, 'buyable' => $buyable, 'levelToBuild' => $levelToBuild); } if ($QueueCount != 0) { $this->tplObj->loadscript('buildlist.js'); } $this->assign(array('BuildInfoList' => $BuildInfoList, 'CanBuildElement' => $CanBuildElement, 'RoomIsOk' => $RoomIsOk, 'Queue' => $Queue, 'isBusy' => array('shipyard' => !empty($PLANET['b_hangar_id']), 'research' => $USER['b_tech_planet'] != 0), 'HaveMissiles' => (bool) $PLANET[$resource[503]] + $PLANET[$resource[502]])); $this->display('page.buildings.default.tpl'); }
protected function save() { if (isset($this->ecoObj)) { $this->ecoObj->SavePlanetToDB(); } }
/** FLEET FUNCTIONS **/ function SendFleet($FleetData) { $FleetData = array_merge(array('mission' => 3, 'galaxy' => 0, 'system' => 0, 'planet' => 0, 'planettype' => 0, 'fleetgroup' => 0, 'speed' => 10, 'metal' => 0, 'crystal' => 0, 'deuterium' => 0, 'holdingtime' => 0, 'fleet' => array()), $FleetData); $mission = $FleetData['mission']; $galaxy = $FleetData['galaxy']; $system = $FleetData['system']; $planet = $FleetData['planet']; $planettype = $FleetData['planettype']; $fleet_group = $FleetData['fleetgroup']; $GenFleetSpeed = $FleetData['speed']; $TransportMetal = $FleetData['metal']; $TransportCrystal = $FleetData['crystal']; $TransportDeuterium = $FleetData['deuterium']; $holdingtime = $FleetData['holdingtime']; $rawfleetarray = $FleetData['fleet']; if ($planettype != 1 && $planettype != 3) { return false; } if ($this->PLANET['galaxy'] == $galaxy && $this->PLANET['system'] == $system && $this->PLANET['planet'] == $planet && $this->PLANET['planet_type'] == $planettype) { return false; } if ($galaxy > $CONF['max_galaxy'] || $galaxy < 1 || $system > $CONF['max_system'] || $system < 1 || $planet > $CONF['max_planets'] + 1 || $planet < 1) { return false; } if (empty($mission)) { return false; } $ActualFleets = parent::GetCurrentFleets($USER['id']); if (parent::GetMaxFleetSlots($USER) <= $ActualFleets) { return false; } $fleet_group_mr = 0; if (!empty($fleet_group) && $mission == 2) { $aks_count_mr = $db->uniquequery("SELECT COUNT(*) as state FROM " . AKS . " WHERE `id` = '" . $fleet_group . "' AND `eingeladen` LIKE '%" . $USER['id'] . "%';"); if ($aks_count_mr['state'] > 0) { $fleet_group_mr = $fleet_group; } else { $mission = 1; } } $ActualFleets = parent::GetCurrentFleets($USER['id']); $TargetPlanet = $db->uniquequery("SELECT `id`, `id_owner`,`destruyed`,`ally_deposit` FROM " . PLANETS . " WHERE `universe` = '" . $UNI . "' AND `galaxy` = '" . $galaxy . "' AND `system` = '" . $system . "' AND `planet` = '" . $planet . "' AND `planet_type` = '" . ($planettype == 2 ? 1 : $planettype) . "';"); if ($mission != 15 && $TargetPlanet["destruyed"] != 0 || $mission != 15 && $mission != 7 && empty($TargetPlanet['id_owner'])) { return false; } $MyDBRec = $USER; $FleetArray = parent::GetFleetArray($rawfleetarray); if (!is_array($FleetArray)) { return false; } $FleetStorage = 0; $FleetShipCount = 0; $fleet_array = ""; $FleetSubQRY = ""; foreach ($FleetArray as $Ship => $Count) { if ($Count > $this->PLANET[$resource[$Ship]] || $Count < 0) { return false; } $FleetStorage += $pricelist[$Ship]["capacity"] * $Count; $FleetShipCount += $Count; $fleet_array .= $Ship . "," . $Count . ";"; $FleetSubQRY .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` - '" . floattostring($Count) . "', "; } $error = 0; $fleetmission = $mission; $YourPlanet = false; $UsedPlanet = false; if ($mission == 11) { $maxexpde = parent::GetCurrentFleets($USER['id'], 11); if ($maxexpde >= $CONF['max_dm_missions']) { return false; } } elseif ($mission == 15) { $MaxExpedition = $USER[$resource[124]]; if ($MaxExpedition == 0) { return false; } $ExpeditionEnCours = parent::GetCurrentFleets($USER['id'], 15); $EnvoiMaxExpedition = floor(sqrt($MaxExpedition)); if ($ExpeditionEnCours >= $EnvoiMaxExpedition) { return false; } } $YourPlanet = isset($TargetPlanet['id_owner']) && $TargetPlanet['id_owner'] == $USER['id'] ? true : false; $UsedPlanet = isset($TargetPlanet['id_owner']) ? true : false; $HeDBRec = $YourPlanet ? $MyDBRec : GetUserByID($TargetPlanet['id_owner'], array('id', 'onlinetime', 'ally_id', 'urlaubs_modus', 'banaday', 'authattack')); if ($HeDBRec['urlaubs_modus'] && $mission != 8) { return false; } if (!$YourPlanet && ($mission == 1 || $mission == 2 || $mission == 5 || $mission == 6 || $mission == 9)) { if ($CONF['adm_attack'] == 1 && $UsedPlanet['authattack'] > $USER['authlevel']) { return false; } $UserPoints = $USER; $User2Points = $db->uniquequery("SELECT `total_points` FROM " . STATPOINTS . " WHERE `stat_type` = '1' AND `id_owner` = '" . $HeDBRec['id'] . "';"); $IsNoobProtec = CheckNoobProtec($UserPoints, $User2Points, $HeDBRec); if ($IsNoobProtec['NoobPlayer']) { return false; } elseif ($IsNoobProtec['StrongPlayer']) { return false; } } if ($mission == 5) { if ($TargetPlanet['ally_deposit'] < 1) { return false; } $buddy = $db->uniquequery("SELECT COUNT(*) as state FROM " . BUDDY . " WHERE `active` = '1' AND (`owner` = '" . $HeDBRec['id'] . "' AND `sender` = '" . $MyDBRec['id'] . "') OR (`owner` = '" . $MyDBRec['id'] . "' AND `sender` = '" . $HeDBRec['id'] . "');"); if ($HeDBRec['ally_id'] != $MyDBRec['ally_id'] && $buddy['state'] == 0) { return false; } } if (!parent::CheckUserSpeed($GenFleetSpeed) || !array_key_exists($mission, parent::GetAvailableMissions(array('CurrentUser' => $USER, 'galaxy' => $galaxy, 'system' => $system, 'planet' => $planet, 'planettype' => $planettype, 'IsAKS' => $fleet_group, 'Ship' => $FleetArray)))) { return false; } $MaxFleetSpeed = parent::GetFleetMaxSpeed($FleetArray, $USER); $SpeedFactor = parent::GetGameSpeedFactor(); $distance = parent::GetTargetDistance($this->PLANET['galaxy'], $galaxy, $this->PLANET['system'], $system, $this->PLANET['planet'], $planet); $duration = parent::GetMissionDuration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor, $USER); $consumption = parent::GetFleetConsumption($FleetArray, $duration, $distance, $MaxFleetSpeed, $USER, $SpeedFactor); $fleet['start_time'] = $duration + TIMESTAMP; if ($mission == 15) { $StayDuration = max($holdingtime, 1) * 3600 / $CONF['halt_speed']; $StayTime = $fleet['start_time'] + $StayDuration; } elseif ($mission == 5) { $StayDuration = $holdingtime * 3600; $StayTime = $fleet['start_time'] + $StayDuration; } elseif ($mission == 11) { $StayDuration = 3600 / $CONF['halt_speed']; $StayTime = $fleet['start_time'] + $StayDuration; } else { $StayDuration = 0; $StayTime = 0; } $fleet['end_time'] = $StayDuration + 2 * $duration + TIMESTAMP; $FleetStorage -= $consumption; $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $TransportMetal = min($TransportMetal, $this->PLANET['metal']); $TransportCrystal = min($TransportCrystal, $this->PLANET['crystal']); $TransportDeuterium = min($TransportDeuterium, $this->PLANET['deuterium'] - $consumption); $StorageNeeded = $TransportMetal + $TransportCrystal + $TransportDeuterium; $StockMetal = $this->PLANET['metal']; $StockCrystal = $this->PLANET['crystal']; $StockDeuterium = $this->PLANET['deuterium']; $StockDeuterium -= $consumption; if ($this->PLANET['deuterium'] < $consumption) { return false; } if ($StorageNeeded > $FleetStorage) { return false; } $this->PLANET['metal'] -= $TransportMetal; $this->PLANET['crystal'] -= $TransportCrystal; $this->PLANET['deuterium'] -= $TransportDeuterium + $consumption; if ($fleet_group_mr != 0) { $AksStartTime = $db->uniquequery("SELECT MAX(`fleet_start_time`) AS Start FROM " . FLEETS . " WHERE `fleet_group` = '" . $fleet_group_mr . "' AND '" . $CONF['max_fleets_per_acs'] . "' > (SELECT COUNT(*) FROM " . FLEETS . " WHERE `fleet_group` = '" . $fleet_group_mr . "');"); if (isset($AksStartTime)) { if ($AksStartTime['Start'] >= $fleet['start_time']) { $fleet['end_time'] += $AksStartTime['Start'] - $fleet['start_time']; $fleet['start_time'] = $AksStartTime['Start']; } else { $SQLFleets = "UPDATE " . FLEETS . " SET "; $SQLFleets .= "`fleet_start_time` = '" . $fleet['start_time'] . "', "; $SQLFleets .= "`fleet_end_time` = fleet_end_time + '" . ($fleet['start_time'] - $AksStartTime['Start']) . "' "; $SQLFleets .= "WHERE "; $SQLFleets .= "`fleet_group` = '" . $fleet_group_mr . "';"; $db->query($SQLFleets); $fleet['end_time'] += $fleet['start_time'] - $AksStartTime['Start']; } } else { $mission = 1; } } $QryInsertFleet = "LOCK TABLE " . FLEETS . " WRITE, " . PLANETS . " WRITE;\n\t\t\t\t\t\t\tINSERT INTO " . FLEETS . " SET \n\t\t\t\t\t\t\t`fleet_owner` = '" . $USER['id'] . "', \n\t\t\t\t\t\t\t`fleet_mission` = '" . $mission . "',\n\t\t\t\t\t\t\t`fleet_amount` = '" . $FleetShipCount . "',\n\t\t\t\t\t\t `fleet_array` = '" . $fleet_array . "',\n\t\t\t\t\t\t `fleet_universe` = '" . $UNI . "',\n\t\t\t\t\t\t\t`fleet_start_time` = '" . $fleet['start_time'] . "',\n\t\t\t\t\t\t\t`fleet_start_id` = '" . $this->PLANET['id'] . "',\n\t\t\t\t\t\t\t`fleet_start_galaxy` = '" . $this->PLANET['galaxy'] . "',\n\t\t\t\t\t\t\t`fleet_start_system` = '" . $this->PLANET['system'] . "',\n\t\t\t\t\t\t\t`fleet_start_planet` = '" . $this->PLANET['planet'] . "',\n\t\t\t\t\t\t\t`fleet_start_type` = '" . $this->PLANET['planet_type'] . "',\n\t\t\t\t\t\t\t`fleet_end_time` = '" . $fleet['end_time'] . "',\n\t\t\t\t\t\t\t`fleet_end_stay` = '" . $StayTime . "',\n\t\t\t\t\t\t\t`fleet_end_id` = '" . (int) $TargetPlanet['id'] . "',\n\t\t\t\t\t\t\t`fleet_end_galaxy` = '" . $galaxy . "',\n\t\t\t\t\t\t\t`fleet_end_system` = '" . $system . "',\n\t\t\t\t\t\t\t`fleet_end_planet` = '" . $planet . "',\n\t\t\t\t\t\t\t`fleet_end_type` = '" . $planettype . "',\n\t\t\t\t\t\t\t`fleet_resource_metal` = '" . floattostring($TransportMetal) . "',\n\t\t\t\t\t\t\t`fleet_resource_crystal` = '" . floattostring($TransportCrystal) . "',\n\t\t\t\t\t\t\t`fleet_resource_deuterium` = '" . floattostring($TransportDeuterium) . "',\n\t\t\t\t\t\t\t`fleet_target_owner` = '" . ($planettype == 2 ? 0 : (int) $TargetPlanet['id_owner']) . "',\n\t\t\t\t\t\t\t`fleet_group` = '" . $fleet_group_mr . "',\n\t\t\t\t\t\t\t`start_time` = '" . TIMESTAMP . "';\n\t\t\t\t\t\t\tUPDATE `" . PLANETS . "` SET\n\t\t\t\t\t\t\t" . substr($FleetSubQRY, 0, -2) . "\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t`id` = " . $this->PLANET['id'] . " LIMIT 1;\n\t\t\t\t\t\t\tUNLOCK TABLES;"; $db->multi_query($QryInsertFleet); return true; }
function ShowBattleSimPage() { global $USER, $PLANET, $reslist, $pricelist, $LNG, $db, $ExtraDM, $LANG, $CONF; $action = request_var('action', ''); $Slots = request_var('slots', 1); if (isset($_REQUEST['im'])) { $Array = $_REQUEST['im']; foreach ($Array as $ID => $Count) { $BattleArray[0][1][$ID] = floattostring($Count); } } elseif (isset($_REQUEST['battleinput'])) { $BattleArray = $_REQUEST['battleinput']; } else { $BattleArray = array(); } if ($action == 'send') { $Counts = array(0, 0); foreach ($BattleArray as $BattleSlotID => $BattleSlot) { if (isset($BattleSlot[0]) && (array_sum($BattleSlot[0]) > 0 || $BattleSlotID == 0)) { $Att = mt_rand(1, 1000); $attack[$Att]['fleet'] = array('fleet_start_galaxy' => 1, 'fleet_start_system' => 33, 'fleet_start_planet' => 7, 'fleet_end_galaxy' => 1, 'fleet_end_system' => 33, 'fleet_end_planet' => 7, 'metal' => 0, 'crystal' => 0, 'deuterium' => 0); $attack[$Att]['user'] = array('username' => $LNG['bs_atter'] . ' Nr.' . ($BattleSlotID + 1), 'military_tech' => $BattleSlot[0][109], 'defence_tech' => $BattleSlot[0][110], 'shield_tech' => $BattleSlot[0][111], 0, 'dm_defensive' => 0, 'dm_attack' => 0); foreach ($BattleSlot[0] as $ID => $Count) { if (!in_array($ID, $reslist['fleet']) || $BattleSlot[0][$ID] <= 0) { unset($BattleSlot[0][$ID]); } } if ($Counts[0] == 0 && $BattleSlotID != 0) { exit('ERROR'); } $Counts[0] = $Counts[0] + array_sum($BattleSlot[1]); $attack[$Att]['detail'] = $BattleSlot[0]; } if (isset($BattleSlot[1]) && (array_sum($BattleSlot[1]) > 0 || $BattleSlotID == 0)) { $Def = mt_rand(1, 1000); $defense[$Def]['fleet'] = array('fleet_start_galaxy' => 1, 'fleet_start_system' => 33, 'fleet_start_planet' => 7, 'fleet_end_galaxy' => 1, 'fleet_end_system' => 33, 'fleet_end_planet' => 7, 'metal' => 0, 'crystal' => 0, 'deuterium' => 0); $defense[$Def]['user'] = array('username' => $LNG['bs_deffer'] . ' Nr.' . ($BattleSlotID + 1), 'military_tech' => $BattleSlot[1][109], 'defence_tech' => $BattleSlot[1][110], 'shield_tech' => $BattleSlot[1][111], 0, 'dm_defensive' => 0, 'dm_attack' => 0); foreach ($BattleSlot[1] as $ID => $Count) { if (!in_array($ID, $reslist['fleet']) && !in_array($ID, $reslist['defense'])) { unset($BattleSlot[1][$ID]); } } if ($Countd[1] == 0 && $BattleSlotID != 0) { exit('ERROR'); } $Countd[1] = $Countd[1] + array_sum($BattleSlot[1]); $defense[$Def]['def'] = $BattleSlot[1]; } } $LANG->includeLang(array('FLEET')); require_once ROOT_PATH . 'includes/classes/missions/calculateAttack.php'; require_once ROOT_PATH . 'includes/classes/missions/calculateSteal.php'; require_once ROOT_PATH . 'includes/classes/missions/GenerateReport.php'; $start = microtime(true); $result = calculateAttack($attack, $defense, $CONF['Fleet_Cdr'], $CONF['Defs_Cdr']); $totaltime = microtime(true) - $start; $steal = $result['won'] == "a" ? calculateSteal($attack, array('metal' => $BattleArray[0][1][1], 'crystal' => $BattleArray[0][1][2], 'deuterium' => $BattleArray[0][1][3]), true) : array('metal' => 0, 'crystal' => 0, 'deuterium' => 0); $FleetDebris = $result['debree']['att'][0] + $result['debree']['def'][0] + $result['debree']['att'][1] + $result['debree']['def'][1]; $StrAttackerUnits = sprintf($LNG['sys_attacker_lostunits'], $result['lost']['att']); $StrDefenderUnits = sprintf($LNG['sys_defender_lostunits'], $result['lost']['def']); $StrRuins = sprintf($LNG['sys_gcdrunits'], $result['debree']['def'][0] + $result['debree']['att'][0], $LNG['Metal'], $result['debree']['def'][1] + $result['debree']['att'][1], $LNG['Crystal']); $DebrisField = $StrAttackerUnits . "<br>" . $StrDefenderUnits . "<br>" . $StrRuins; $MoonChance = min(round($FleetDebris / 100000, 0), 20); $AllSteal = array_sum($steal); $RaportInfo = sprintf($LNG['bs_derbis_raport'], ceil($FleetDebris / $pricelist[219]['capacity']), $LNG['tech'][219], ceil($FleetDebris / $pricelist[209]['capacity']), $LNG['tech'][209]) . "<br>"; $RaportInfo .= sprintf($LNG['bs_steal_raport'], ceil($AllSteal / $pricelist[202]['capacity']), $LNG['tech'][202], ceil($AllSteal / $pricelist[203]['capacity']), $LNG['tech'][203], ceil($AllSteal / $pricelist[217]['capacity']), $LNG['tech'][217]) . "<br>"; $INFO['moon']['battlesim'] = $RaportInfo; $INFO['steal'] = $steal; $INFO['fleet_start_time'] = TIMESTAMP; $INFO['moon']['des'] = 0; $INFO['moon']['chance'] = $MoonChance; $raport = GenerateReport($result, $INFO); $rid = md5(microtime(true)); file_put_contents(ROOT_PATH . 'raports/raport_' . $rid . '.php', '<?php' . "\n" . '$raport = ' . $raport . ';' . "\n" . '?>'); $SQLQuery = "INSERT INTO " . RW . " SET "; $SQLQuery .= "`time` = '" . TIMESTAMP . "', "; $SQLQuery .= "`owners` = '" . $USER['id'] . ",0', "; $SQLQuery .= "`rid` = '" . $rid . "';"; $db->query($SQLQuery); echo $rid; exit; } $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $PlanetRess->SavePlanetToDB(); foreach ($reslist['fleet'] as $ID) { $GetFleet[$ID] = $LNG['tech'][$ID]; } foreach ($reslist['defense'] as $ID) { if ($ID >= 501) { break; } $GetDef[$ID] = $LNG['tech'][$ID]; } $template = new template(); $template->loadscript('battlesim.js'); $template->assign_vars(array('lm_battlesim' => $LNG['lm_battlesim'], 'bs_names' => $LNG['bs_names'], 'bs_atter' => $LNG['bs_atter'], 'bs_deffer' => $LNG['bs_deffer'], 'bs_steal' => $LNG['bs_steal'], 'bs_techno' => $LNG['bs_techno'], 'bs_send' => $LNG['bs_send'], 'bs_cancel' => $LNG['bs_cancel'], 'bs_wait' => $LNG['bs_wait'], 'Metal' => $LNG['Metal'], 'Crystal' => $LNG['Crystal'], 'Deuterium' => $LNG['Deuterium'], 'attack_tech' => $LNG['tech'][109], 'shield_tech' => $LNG['tech'][110], 'tank_tech' => $LNG['tech'][111], 'GetFleet' => $GetFleet, 'GetDef' => $GetDef, 'Slots' => $Slots, 'battleinput' => $BattleArray)); $template->show("battlesim.tpl"); }
function TargetEvent() { global $resource, $reslist; $db = Database::get(); $fleetAttack = array(); $fleetDefend = array(); $userAttack = array(); $userDefend = array(); $incomingFleets = array(); $stealResource = array(901 => 0, 902 => 0, 903 => 0); $debris = array(); $planetDebris = array(); $debrisResource = array(901, 902); $messageHTML = <<<HTML <div class="raportMessage"> \t<table> \t\t<tr> \t\t\t<td colspan="2"><a href="game.php?page=raport&raport=%s" target="_blank"><span class="%s">%s %s (%s)</span></a></td> \t\t</tr> \t\t<tr> \t\t\t<td>%s</td><td><span class="%s">%s: %s</span> <span class="%s">%s: %s</span></td> \t\t</tr> \t\t<tr> \t\t\t<td>%s</td><td><span>%s: <span class="reportSteal element901">%s</span> </span><span>%s: <span class="reportSteal element902">%s</span> </span><span>%s: <span class="reportSteal element903">%s</span></span></td> \t\t</tr> \t\t<tr> \t\t\t<td>%s</td><td><span>%s: <span class="reportDebris element901">%s</span> </span><span>%s: <span class="reportDebris element902">%s</span></span></td> \t\t</tr> \t</table> </div> HTML; //Minize HTML $messageHTML = str_replace(array("\n", "\t", "\r"), "", $messageHTML); $sql = "SELECT * FROM %%PLANETS%% WHERE id = :planetId;"; $targetPlanet = $db->selectSingle($sql, array(':planetId' => $this->_fleet['fleet_end_id'])); $sql = "SELECT * FROM %%USERS%% WHERE id = :userId;"; $targetUser = $db->selectSingle($sql, array(':userId' => $targetPlanet['id_owner'])); $targetUser['factor'] = getFactors($targetUser, 'basic', $this->_fleet['fleet_start_time']); $planetUpdater = new ResourceUpdate(); list($targetUser, $targetPlanet) = $planetUpdater->CalcResource($targetUser, $targetPlanet, true, $this->_fleet['fleet_start_time']); if ($this->_fleet['fleet_group'] != 0) { $sql = "DELETE FROM %%AKS%% WHERE id = :acsId;"; $db->delete($sql, array(':acsId' => $this->_fleet['fleet_group'])); $sql = "SELECT * FROM %%FLEETS%% WHERE fleet_group = :acsId;"; $incomingFleetsResult = $db->select($sql, array(':acsId' => $this->_fleet['fleet_group'])); foreach ($incomingFleetsResult as $incomingFleetRow) { $incomingFleets[$incomingFleetRow['fleet_id']] = $incomingFleetRow; } unset($incomingFleetsResult); } else { $incomingFleets = array($this->_fleet['fleet_id'] => $this->_fleet); } foreach ($incomingFleets as $fleetID => $fleetDetail) { $sql = "SELECT * FROM %%USERS%% WHERE id = :userId;"; $fleetAttack[$fleetID]['player'] = $db->selectSingle($sql, array(':userId' => $fleetDetail['fleet_owner'])); $fleetAttack[$fleetID]['player']['factor'] = getFactors($fleetAttack[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']); $fleetAttack[$fleetID]['fleetDetail'] = $fleetDetail; $fleetAttack[$fleetID]['unit'] = FleetFunctions::unserialize($fleetDetail['fleet_array']); $userAttack[$fleetAttack[$fleetID]['player']['id']] = $fleetAttack[$fleetID]['player']['username']; } $sql = "SELECT * FROM %%FLEETS%%\n\t\tWHERE fleet_mission\t\t= :mission\n\t\tAND fleet_end_id\t\t= :fleetEndId\n\t\tAND fleet_start_time \t<= :timeStamp\n\t\tAND fleet_end_stay \t\t>= :timeStamp;"; $targetFleetsResult = $db->select($sql, array(':mission' => 5, ':fleetEndId' => $this->_fleet['fleet_end_id'], ':timeStamp' => TIMESTAMP)); foreach ($targetFleetsResult as $fleetDetail) { $fleetID = $fleetDetail['fleet_id']; $sql = "SELECT * FROM %%USERS%% WHERE id = :userId;"; $fleetDefend[$fleetID]['player'] = $db->selectSingle($sql, array(':userId' => $fleetDetail['fleet_owner'])); $fleetDefend[$fleetID]['player']['factor'] = getFactors($fleetDefend[$fleetID]['player'], 'attack', $this->_fleet['fleet_start_time']); $fleetDefend[$fleetID]['fleetDetail'] = $fleetDetail; $fleetDefend[$fleetID]['unit'] = FleetFunctions::unserialize($fleetDetail['fleet_array']); $userDefend[$fleetDefend[$fleetID]['player']['id']] = $fleetDefend[$fleetID]['player']['username']; } unset($targetFleetsResult); $fleetDefend[0]['player'] = $targetUser; $fleetDefend[0]['player']['factor'] = getFactors($fleetDefend[0]['player'], 'attack', $this->_fleet['fleet_start_time']); $fleetDefend[0]['fleetDetail'] = array('fleet_start_galaxy' => $targetPlanet['galaxy'], 'fleet_start_system' => $targetPlanet['system'], 'fleet_start_planet' => $targetPlanet['planet'], 'fleet_start_type' => $targetPlanet['planet_type']); $fleetDefend[0]['unit'] = array(); foreach (array_merge($reslist['fleet'], $reslist['defense']) as $elementID) { if (empty($targetPlanet[$resource[$elementID]])) { continue; } $fleetDefend[0]['unit'][$elementID] = $targetPlanet[$resource[$elementID]]; } $userDefend[$fleetDefend[0]['player']['id']] = $fleetDefend[0]['player']['username']; require_once 'includes/classes/missions/functions/calculateAttack.php'; $fleetIntoDebris = Config::get($this->_fleet['fleet_universe'])->Fleet_Cdr; $defIntoDebris = Config::get($this->_fleet['fleet_universe'])->Defs_Cdr; $combatResult = calculateAttack($fleetAttack, $fleetDefend, $fleetIntoDebris, $defIntoDebris); foreach ($fleetAttack as $fleetID => $fleetDetail) { $fleetArray = ''; $totalCount = 0; $fleetDetail['unit'] = array_filter($fleetDetail['unit']); foreach ($fleetDetail['unit'] as $elementID => $amount) { $fleetArray .= $elementID . ',' . floattostring($amount) . ';'; $totalCount += $amount; } if ($totalCount == 0) { if ($this->_fleet['fleet_id'] == $fleetID) { $this->KillFleet(); } else { $sql = 'DELETE %%FLEETS%%, %%FLEETS_EVENT%% FROM %%FLEETS%% INNER JOIN %%FLEETS_EVENT%% ON fleetID = fleet_id WHERE fleet_id = :fleetId;'; $db->delete($sql, array(':fleetId' => $fleetID)); } $sql = 'UPDATE %%LOG_FLEETS%% SET fleet_state = :fleetState WHERE fleet_id = :fleetId;'; $db->update($sql, array(':fleetId' => $fleetID, ':fleetState' => FLEET_HOLD)); unset($fleetAttack[$fleetID]); } elseif ($totalCount > 0) { $sql = "UPDATE %%FLEETS%% fleet, %%LOG_FLEETS%% log SET\n\t\t\t\tfleet.fleet_array\t= :fleetData,\n\t\t\t\tfleet.fleet_amount\t= :fleetCount,\n\t\t\t\tlog.fleet_array\t\t= :fleetData,\n\t\t\t\tlog.fleet_amount\t= :fleetCount\n\t\t\t\tWHERE log.fleet_id = :fleetId AND log.fleet_id = :fleetId;"; $db->update($sql, array(':fleetData' => substr($fleetArray, 0, -1), ':fleetCount' => $totalCount, ':fleetId' => $fleetID)); } else { throw new OutOfRangeException("Negative Fleet amount ...."); } } foreach ($fleetDefend as $fleetID => $fleetDetail) { if ($fleetID != 0) { // Stay fleet $fleetArray = ''; $totalCount = 0; $fleetDetail['unit'] = array_filter($fleetDetail['unit']); foreach ($fleetDetail['unit'] as $elementID => $amount) { $fleetArray .= $elementID . ',' . floattostring($amount) . ';'; $totalCount += $amount; } if ($totalCount == 0) { $sql = 'DELETE %%FLEETS%%, %%FLEETS_EVENT%% FROM %%FLEETS%% INNER JOIN %%FLEETS_EVENT%% ON fleetID = fleet_id WHERE fleet_id = :fleetId;'; $db->delete($sql, array(':fleetId' => $fleetID)); $sql = 'UPDATE %%LOG_FLEETS%% SET fleet_state = :fleetState WHERE fleet_id = :fleetId;'; $db->update($sql, array(':fleetId' => $fleetID, ':fleetState' => FLEET_HOLD)); unset($fleetAttack[$fleetID]); } elseif ($totalCount > 0) { $sql = "UPDATE %%FLEETS%% fleet, %%LOG_FLEETS%% log SET\n\t\t\t\t\tfleet.fleet_array\t= :fleetData,\n\t\t\t\t\tfleet.fleet_amount\t= :fleetCount,\n\t\t\t\t\tlog.fleet_array\t\t= :fleetData,\n\t\t\t\t\tlog.fleet_amount\t= :fleetCount\n\t\t\t\t\tWHERE log.fleet_id = :fleetId AND log.fleet_id = :fleetId;"; $db->update($sql, array(':fleetData' => substr($fleetArray, 0, -1), ':fleetCount' => $totalCount, ':fleetId' => $fleetID)); } else { throw new OutOfRangeException("Negative Fleet amount ...."); } } else { $params = array(':planetId' => $this->_fleet['fleet_end_id']); // Planet fleet $fleetArray = array(); foreach ($fleetDetail['unit'] as $elementID => $amount) { $fleetArray[] = '`' . $resource[$elementID] . '` = :' . $resource[$elementID]; $params[':' . $resource[$elementID]] = $amount; } if (!empty($fleetArray)) { $sql = 'UPDATE %%PLANETS%% SET ' . implode(', ', $fleetArray) . ' WHERE id = :planetId;'; $db->update($sql, $params); } } } if ($combatResult['won'] == "a") { require_once 'includes/classes/missions/functions/calculateSteal.php'; $stealResource = calculateSteal($fleetAttack, $targetPlanet); } if ($this->_fleet['fleet_end_type'] == 3) { // Use planet debris, if attack on moons $sql = "SELECT der_metal, der_crystal FROM %%PLANETS%% WHERE id_luna = :moonId;"; $targetDebris = $db->selectSingle($sql, array(':moonId' => $this->_fleet['fleet_end_id'])); $targetPlanet += $targetDebris; } foreach ($debrisResource as $elementID) { $debris[$elementID] = $combatResult['debris']['attacker'][$elementID] + $combatResult['debris']['defender'][$elementID]; $planetDebris[$elementID] = $targetPlanet['der_' . $resource[$elementID]] + $debris[$elementID]; } $reportInfo = array('thisFleet' => $this->_fleet, 'debris' => $debris, 'stealResource' => $stealResource, 'moonChance' => NULL, 'moonDestroy' => true, 'moonName' => NULL, 'moonDestroyChance' => NULL, 'moonDestroySuccess' => NULL, 'fleetDestroyChance' => NULL, 'fleetDestroySuccess' => false); switch ($combatResult['won']) { case "a": $moonDestroyChance = round((100 - sqrt($targetPlanet['diameter'])) * sqrt($fleetAttack[$this->_fleet['fleet_id']]['unit'][214]), 1); // Max 100% | Min 0% $moonDestroyChance = min($moonDestroyChance, 100); $moonDestroyChance = max($moonDestroyChance, 0); $randChance = mt_rand(1, 100); if ($randChance <= $moonDestroyChance) { $sql = 'SELECT id FROM %%PLANETS%% WHERE id_luna = :moonId;'; $planetID = $db->selectSingle($sql, array(':moonId' => $targetPlanet['id']), 'id'); $sql = 'UPDATE %%FLEETS%% SET fleet_start_type = 1, fleet_start_id = :planetId WHERE fleet_start_id = :moonId;'; $db->update($sql, array(':planetId' => $planetID, ':moonId' => $targetPlanet['id'])); $sql = 'UPDATE %%FLEETS%% SET fleet_end_type = 1, fleet_end_id = :moonId, fleet_mission = IF(fleet_mission = 9, 1, fleet_mission) WHERE fleet_end_id = :planetId AND fleet_id != :fleetId;'; $db->update($sql, array(':planetId' => $planetID, ':moonId' => $targetPlanet['id'], ':fleetId' => $this->_fleet['fleet_id'])); $sql = "UPDATE %%AKS%% SET target = :planetId WHERE target = :moonId;"; $db->update($sql, array(':planetId' => $planetID, ':moonId' => $targetPlanet['id'])); PlayerUtil::deletePlanet($targetPlanet['id']); $reportInfo['moonDestroySuccess'] = 1; } else { $reportInfo['moonDestroySuccess'] = 0; } $fleetDestroyChance = round(sqrt($targetPlanet['diameter']) / 2); $randChance = mt_rand(1, 100); if ($randChance <= $fleetDestroyChance) { $this->KillFleet(); $reportInfo['fleetDestroySuccess'] = true; } else { $reportInfo['fleetDestroySuccess'] = false; } $reportInfo['moonDestroyChance'] = $moonDestroyChance; $reportInfo['fleetDestroyChance'] = $fleetDestroyChance; // Win $attackStatus = 'wons'; $defendStatus = 'loos'; $class = array('raportWin', 'raportLose'); break; case "r": // Lose $attackStatus = 'loos'; $defendStatus = 'wons'; $class = array('raportLose', 'raportWin'); $reportInfo['moonDestroySuccess'] = -1; break; default: // Draw $attackStatus = 'draws'; $defendStatus = 'draws'; $class = array('raportDraw', 'raportDraw'); $reportInfo['moonDestroySuccess'] = -1; break; } require_once 'includes/classes/missions/functions/GenerateReport.php'; $reportData = GenerateReport($combatResult, $reportInfo); $reportID = md5(uniqid('', true) . TIMESTAMP); $sql = 'INSERT INTO %%RW%% SET rid = :reportId, raport = :reportData, time = :time, attacker = :attackers, defender = :defenders;'; $db->insert($sql, array(':reportId' => $reportID, ':reportData' => serialize($reportData), ':time' => $this->_fleet['fleet_start_time'], ':attackers' => implode(',', array_keys($userAttack)), ':defenders' => implode(',', array_keys($userDefend)))); $i = 0; foreach (array($userAttack, $userDefend) as $data) { $thisClass = $class[$i]; foreach ($data as $userID => $userName) { $LNG = $this->getLanguage(NULL, $userID); $message = sprintf($messageHTML, $reportID, $thisClass[$i], $LNG['sys_mess_attack_report'], sprintf($LNG['sys_adress_planet'], $this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet']), $LNG['type_planet_short'][$this->_fleet['fleet_end_type']], $LNG['sys_lost'], $thisClass[0], $LNG['sys_attack_attacker_pos'], pretty_number($combatResult['unitLost']['attacker']), $thisClass[1], $LNG['sys_attack_defender_pos'], pretty_number($combatResult['unitLost']['defender']), $LNG['sys_gain'], $LNG['tech'][901], pretty_number($stealResource[901]), $LNG['tech'][902], pretty_number($stealResource[902]), $LNG['tech'][903], pretty_number($stealResource[903]), $LNG['sys_debris'], $LNG['tech'][901], pretty_number($debris[901]), $LNG['tech'][902], pretty_number($debris[902])); PlayerUtil::sendMessage($userID, 0, $LNG['sys_mess_tower'], 3, $LNG['sys_mess_attack_report'], $message, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']); $sql = "INSERT INTO %%TOPKB_USERS%% SET\n\t\t\t\trid\t\t\t= :reportId,\n\t\t\t\trole\t\t= :userRole,\n\t\t\t\tusername\t= :username,\n\t\t\t\tuid\t\t\t= :userId;"; $db->insert($sql, array(':reportId' => $reportID, ':userRole' => 1, ':username' => $userName, ':userId' => $userID)); } $i++; } if ($this->_fleet['fleet_end_type'] == 3) { $debrisType = 'id_luna'; } else { $debrisType = 'id'; } $sql = 'UPDATE %%PLANETS%% SET der_metal = :metal, der_crystal = :crystal WHERE ' . $debrisType . ' = :planetId;'; $db->update($sql, array(':metal' => $planetDebris[901], ':crystal' => $planetDebris[902], ':planetId' => $this->_fleet['fleet_end_id'])); $sql = 'UPDATE %%PLANETS%% SET metal = metal - :metal, crystal = crystal - :crystal, deuterium = deuterium - :deuterium WHERE id = :planetId;'; $db->update($sql, array(':metal' => $stealResource[901], ':crystal' => $stealResource[902], ':deuterium' => $stealResource[903], ':planetId' => $this->_fleet['fleet_end_id'])); $sql = 'INSERT INTO %%TOPKB%% SET units = :units, rid = :reportId, time = :time, universe = :universe, result = :result;'; $db->insert($sql, array(':units' => $combatResult['unitLost']['attacker'] + $combatResult['unitLost']['defender'], ':reportId' => $reportID, ':time' => $this->_fleet['fleet_start_time'], ':universe' => $this->_fleet['fleet_universe'], ':result' => $combatResult['won'])); $sql = 'UPDATE %%USERS%% SET `' . $attackStatus . '` = `' . $attackStatus . '` + 1, kbmetal = kbmetal + :debrisMetal, kbcrystal = kbcrystal + :debrisCrystal, lostunits = lostunits + :lostUnits, desunits = desunits + :destroyedUnits WHERE id IN (' . implode(',', array_keys($userAttack)) . ');'; $db->update($sql, array(':debrisMetal' => $debris[901], ':debrisCrystal' => $debris[902], ':lostUnits' => $combatResult['unitLost']['attacker'], ':destroyedUnits' => $combatResult['unitLost']['defender'])); $sql = 'UPDATE %%USERS%% SET `' . $defendStatus . '` = `' . $defendStatus . '` + 1, kbmetal = kbmetal + :debrisMetal, kbcrystal = kbcrystal + :debrisCrystal, lostunits = lostunits + :lostUnits, desunits = desunits + :destroyedUnits WHERE id IN (' . implode(',', array_keys($userDefend)) . ');'; $db->update($sql, array(':debrisMetal' => $debris[901], ':debrisCrystal' => $debris[902], ':lostUnits' => $combatResult['unitLost']['defender'], ':destroyedUnits' => $combatResult['unitLost']['attacker'])); $this->setState(FLEET_RETURN); $this->SaveFleet(); }
function ShowOverviewPage() { global $CONF, $LNG, $PLANET, $USER, $db, $resource; $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $PlanetRess->SavePlanetToDB(); $template = new template(); $template->getplanets(); $AdminsOnline = $AllPlanets = $Moon = array(); foreach ($template->UserPlanets as $ID => $CPLANET) { if ($ID == $_SESSION['planet'] || $CPLANET['planet_type'] == 3) { continue; } if (!empty($CPLANET['b_building']) && $CPLANET['b_building'] > TIMESTAMP) { $Queue = explode(';', $CPLANET['b_building_id']); $CurrBuild = explode(',', $Queue[0]); $BuildPlanet = $LNG['tech'][$CurrBuild[0]] . " (" . $CurrBuild[1] . ")<br><span style=\"color:#7F7F7F;\">(" . pretty_time($CurrBuild[3] - TIMESTAMP) . ")</span>"; } else { $BuildPlanet = $LNG['ov_free']; } $AllPlanets[] = array('id' => $CPLANET['id'], 'name' => $CPLANET['name'], 'image' => $CPLANET['image'], 'build' => $BuildPlanet); } if ($PLANET['id_luna'] != 0) { $Moon = $db->uniquequery("SELECT `id`, `name` FROM " . PLANETS . " WHERE `id` = '" . $PLANET['id_luna'] . "';"); } if (!empty($PLANET['b_building'])) { $Queue = explode(';', $PLANET['b_building_id']); $CurrBuild = explode(',', $Queue[0]); $Build = $LNG['tech'][$CurrBuild[0]] . ' (' . $CurrBuild[1] . ')<br><div id="blc">"' . pretty_time($PLANET['b_building'] - TIMESTAMP) . '</div>'; $template->execscript('BuildTime();'); } else { $Build = $LNG['ov_free']; } $Teamspeak = ''; if ($CONF['ts_modon'] == 1) { if ($CONF['ts_version'] == 2) { include_once ROOT_PATH . "includes/libs/teamspeak/class.teamspeak2." . PHP_EXT; $ts = new cyts(); if ($ts->connect($CONF['ts_server'], $CONF['ts_tcpport'], $CONF['ts_udpport'], $CONF['ts_timeout'])) { $tsdata = $ts->info_serverInfo(); $tsdata2 = $ts->info_globalInfo(); $ts->disconnect(); $trafges = pretty_number($tsdata2["total_bytessend"] / 1024 / 1024 + $tsdata2["total_bytesreceived"] / 1024 / 1024); $Teamspeak = sprintf($LNG['ov_teamspeak_v2'], $CONF['ts_server'], $CONF['ts_udpport'], $USER['username'], $tsdata["server_currentusers"], $tsdata["server_maxusers"], $tsdata["server_currentchannels"], $trafges); } else { $Teamspeak = $LNG['ov_teamspeak_not_online']; } } elseif ($CONF['ts_version'] == 3) { $ip = $CONF['ts_server']; $port = $CONF['ts_tcpport']; $t_port = $CONF['ts_udpport']; $sid = $CONF['ts_timeout']; require_once ROOT_PATH . "includes/libs/teamspeak/class.teamspeak3." . PHP_EXT; $tsAdmin = new ts3admin($ip, $t_port); if ($tsAdmin->connect()) { $tsAdmin->selectServer($sid); #$tsAdmin->login($username, $password); Insert the SA Account Details, if Teamspeak banned you. $sinfo = $tsAdmin->serverInfo(); $tsAdmin->logout(); $tsAdmin->quit(); $trafges = round($sinfo['connection_bytes_received_total'] / 1024 / 1024 + $sinfo['connection_bytes_sent_total'] / 1024 / 1024, 2); $Debug = $tsAdmin->getDebugLog(); if ($Debug == "Error while fetching: 'error id=518 msg=not logged in'<br>") { $Teamspeak = sprintf($LNG['ov_teamspeak_v3'], $ip, $port, $USER['username'], $sinfo['virtualserver_password'], $sinfo['virtualserver_clientsonline'] - 1, $sinfo['virtualserver_maxclients'], $sinfo['virtualserver_channelsonline'], $trafges); } else { $Teamspeak = $Debug; } } else { $Teamspeak = $LNG['ov_teamspeak_not_online']; } } } $OnlineAdmins = $db->query("SELECT `id`,`username` FROM " . USERS . " WHERE `onlinetime` >= '" . (TIMESTAMP - 10 * 60) . "' AND `authlevel` > '0';"); while ($AdminRow = $db->fetch_array($OnlineAdmins)) { $AdminsOnline[$AdminRow['id']] = $AdminRow['username']; } $db->free_result($OnlineAdmins); $template->loadscript('mbContainer.js'); $template->loadscript('overview.js'); $template->execscript('GetFleets(true);'); $template->page_header(); $template->page_topnav(); $template->page_leftmenu(); $template->page_planetmenu(); $template->page_footer(); $template->assign_vars(array('user_rank' => sprintf($LNG['ov_userrank_info'], pretty_number($USER['total_points']), $LNG['ov_place'], $USER['total_rank'], $USER['total_rank'], $LNG['ov_of'], $CONF['users_amount']), 'is_news' => $CONF['OverviewNewsFrame'], 'news' => makebr($CONF['OverviewNewsText']), 'planetname' => $PLANET['name'], 'planetimage' => $PLANET['image'], 'galaxy' => $PLANET['galaxy'], 'system' => $PLANET['system'], 'planet' => $PLANET['planet'], 'buildtime' => $PLANET['b_building'], 'userid' => $USER['id'], 'username' => $USER['username'], 'build' => $Build, 'Moon' => $Moon, 'AllPlanets' => $AllPlanets, 'AdminsOnline' => $AdminsOnline, 'Teamspeak' => $Teamspeak, 'messages' => $USER['new_message'] > 0 ? $USER['new_message'] == 1 ? $LNG['ov_have_new_message'] : sprintf($LNG['ov_have_new_messages'], pretty_number($USER['new_message'])) : false, 'planet_diameter' => pretty_number($PLANET['diameter']), 'planet_field_current' => $PLANET['field_current'], 'planet_field_max' => CalculateMaxPlanetFields($PLANET), 'planet_temp_min' => $PLANET['temp_min'], 'planet_temp_max' => $PLANET['temp_max'], 'ov_news' => $LNG['ov_news'], 'fcm_moon' => $LNG['fcm_moon'], 'ov_server_time' => $LNG['ov_server_time'], 'ov_planet' => $LNG['ov_planet'], 'ov_planetmenu' => $LNG['ov_planetmenu'], 'ov_diameter' => $LNG['ov_diameter'], 'ov_distance_unit' => $LNG['ov_distance_unit'], 'ov_developed_fields' => $LNG['ov_developed_fields'], 'ov_max_developed_fields' => $LNG['ov_max_developed_fields'], 'ov_fields' => $LNG['ov_fields'], 'ov_temperature' => $LNG['ov_temperature'], 'ov_aprox' => $LNG['ov_aprox'], 'ov_temp_unit' => $LNG['ov_temp_unit'], 'ov_to' => $LNG['ov_to'], 'ov_position' => $LNG['ov_position'], 'ov_points' => $LNG['ov_points'], 'ov_events' => $LNG['ov_events'], 'ov_admins_online' => $LNG['ov_admins_online'], 'ov_no_admins_online' => $LNG['ov_no_admins_online'], 'ov_userbanner' => $LNG['ov_userbanner'], 'ov_teamspeak' => $LNG['ov_teamspeak'], 'ov_your_planet' => $LNG['ov_your_planet'], 'ov_coords' => $LNG['ov_coords'], 'ov_planet_name' => $LNG['ov_planet_name'], 'ov_actions' => $LNG['ov_actions'], 'ov_abandon_planet' => $LNG['ov_abandon_planet'], 'ov_planet_rename' => $LNG['ov_planet_rename'], 'ov_planet_rename_action' => $LNG['ov_planet_rename_action'], 'ov_password' => $LNG['ov_password'], 'ov_with_pass' => $LNG['ov_with_pass'], 'ov_security_confirm' => $LNG['ov_security_confirm'], 'ov_security_request' => $LNG['ov_security_request'], 'ov_delete_planet' => $LNG['ov_delete_planet'], 'ov_planet_abandoned' => $LNG['ov_planet_abandoned'], 'path' => PROTOCOL . $_SERVER['HTTP_HOST'] . HTTP_ROOT)); $template->show("overview_body.tpl"); }
public function __construct() { global $ProdGrid, $LNG, $resource, $reslist, $CONF, $db, $PLANET, $USER; include_once ROOT_PATH . 'includes/functions/IsTechnologieAccessible.php'; include_once ROOT_PATH . 'includes/functions/GetElementPrice.php'; $TheCommand = request_var('cmd', ''); $Element = request_var('building', 0); $ListID = request_var('listid', 0); $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); if (!empty($Element) && $USER['urlaubs_modus'] == 0 && (IsTechnologieAccessible($USER, $PLANET, $Element) && in_array($Element, $reslist['allow'][$PLANET['planet_type']])) || $TheCommand == "cancel" || $TheCommand == "remove") { if ($Element == 31 && $USER["b_tech_planet"] != 0 || ($Element == 15 || $Element == 21) && !empty($PLANET['b_hangar_id'])) { $TheCommand = ''; } switch ($TheCommand) { case 'cancel': $this->CancelBuildingFromQueue($PlanetRess); break; case 'remove': $this->RemoveBuildingFromQueue($ListID, $PlanetRess); break; case 'insert': $this->AddBuildingToQueue($Element, true); break; case 'destroy': $this->AddBuildingToQueue($Element, false); break; } } $PlanetRess->SavePlanetToDB(); $Queue = $this->ShowBuildingQueue(); $template = new template(); $CanBuildElement = count($Queue) < MAX_BUILDING_QUEUE_SIZE ? true : false; $BuildingPage = ""; $CurrentMaxFields = CalculateMaxPlanetFields($PLANET); $RoomIsOk = $PLANET["field_current"] < $CurrentMaxFields - count($Queue) ? true : false; $BuildEnergy = $USER[$resource[113]]; $BuildLevelFactor = 10; $BuildTemp = $PLANET['temp_max']; foreach ($reslist['allow'][$PLANET['planet_type']] as $ID => $Element) { if (!IsTechnologieAccessible($USER, $PLANET, $Element)) { continue; } $HaveRessources = IsElementBuyable($USER, $PLANET, $Element, true, false); if (in_array($Element, $reslist['prod'])) { $BuildLevel = $PLANET[$resource[$Element]]; $Need = floor(eval($ProdGrid[$Element]['formule']['energy']) * $CONF['resource_multiplier']) * (1 + ($this->TIME - $this->USER[$resource[704]] <= 0) ? 1 + $ExtraDM[704]['add'] : 1); $BuildLevel += 1; $Prod = floor(eval($ProdGrid[$Element]['formule']['energy']) * $CONF['resource_multiplier']) * (1 + ($this->TIME - $this->USER[$resource[704]] <= 0) ? 1 + $ExtraDM[704]['add'] : 1); $EnergyNeed = $Prod - $Need; } else { unset($EnergyNeed); } $parse['click'] = ''; $NextBuildLevel = $PLANET[$resource[$Element]] + 1; if ($RoomIsOk && $CanBuildElement) { $parse['click'] = $HaveRessources == true ? "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><span style=\"color:#00FF00\">" . ($PLANET['b_building'] != 0 ? $LNG['bd_add_to_list'] : ($NextBuildLevel == 1 ? $LNG['bd_build'] : $LNG['bd_build_next_level'] . $NextBuildLevel)) . "</span></a>" : "<span style=\"color:#FF0000\">" . ($NextBuildLevel == 1 ? $LNG['bd_build'] : $LNG['bd_build_next_level'] . $NextBuildLevel) . "</span>"; } elseif ($RoomIsOk && !$CanBuildElement) { $parse['click'] = "<span style=\"color:#FF0000\">" . ($NextBuildLevel == 1 ? $LNG['bd_build'] : $LNG['bd_build_next_level'] . $NextBuildLevel) . "</span>"; } else { $parse['click'] = "<span style=\"color:#FF0000\">" . $LNG['bd_no_more_fields'] . "</span>"; } if (($Element == 6 || $Element == 31) && $USER['b_tech'] > TIMESTAMP) { $parse['click'] = "<span style=\"color:#FF0000\">" . $LNG['bd_working'] . "</span>"; } elseif (($Element == 15 || $Element == 21) && !empty($PLANET['b_hangar_id'])) { $parse['click'] = "<span style=\"color:#FF0000\">" . $LNG['bd_working'] . "</span>"; } $BuildInfoList[] = array('id' => $Element, 'name' => $LNG['tech'][$Element], 'descriptions' => $LNG['res']['descriptions'][$Element], 'level' => $PLANET[$resource[$Element]], 'destroyress' => array_map('pretty_number', GetBuildingPrice($USER, $PLANET, $Element, true, true)), 'destroytime' => pretty_time(GetBuildingTime($USER, $PLANET, $Element, true)), 'price' => GetElementPrice($USER, $PLANET, $Element, true), 'time' => pretty_time(GetBuildingTime($USER, $PLANET, $Element)), 'EnergyNeed' => isset($EnergyNeed) ? sprintf($EnergyNeed < 0 ? $LNG['bd_need_engine'] : $LNG['bd_more_engine'], pretty_number(abs($EnergyNeed)), $LNG['Energy']) : "", 'BuildLink' => $parse['click'], 'restprice' => $this->GetRestPrice($Element)); } if ($PLANET['b_building'] != 0) { $template->execscript('ReBuildView();Buildlist();'); $template->loadscript('buildlist.js'); $template->assign_vars(array('data' => json_encode(array('bd_cancel' => $LNG['bd_cancel'], 'bd_continue' => $LNG['bd_continue'], 'bd_finished' => $LNG['bd_finished'], 'build' => $Queue)))); } $template->assign_vars(array('BuildInfoList' => $BuildInfoList, 'bd_lvl' => $LNG['bd_lvl'], 'bd_next_level' => $LNG['bd_next_level'], 'Metal' => $LNG['Metal'], 'Crystal' => $LNG['Crystal'], 'Deuterium' => $LNG['Deuterium'], 'Norio' => $LNG['Norio'], 'Darkmatter' => $LNG['Darkmatter'], 'bd_dismantle' => $LNG['bd_dismantle'], 'fgf_time' => $LNG['fgf_time'], 'bd_remaining' => $LNG['bd_remaining'], 'bd_jump_gate_action' => $LNG['bd_jump_gate_action'], 'bd_price_for_destroy' => $LNG['bd_price_for_destroy'], 'bd_destroy_time' => $LNG['bd_destroy_time'])); $template->show("buildings_overview.tpl"); }
public static function ShowFleet3Page() { global $USER, $PLANET, $resource, $pricelist, $reslist, $CONF, $db, $LNG; include_once ROOT_PATH . 'includes/functions/IsVacationMode.' . PHP_EXT; $template = new template(); $template->loadscript('flotten.js'); $template->gotoside('?page=fleet'); $template->page_header(); $template->page_topnav(); $template->page_leftmenu(); $template->page_planetmenu(); $template->page_footer(); $mission = request_var('mission', 3); $galaxy = request_var('galaxy', 0); $system = request_var('system', 0); $planet = request_var('planet', 0); $planettype = request_var('planettype', 0); $fleet_group = request_var('fleet_group', 0); $GenFleetSpeed = request_var('speed', 0); $TransportMetal = round(request_var('metal', 0.0), 0); $TransportCrystal = round(request_var('crystal', 0.0), 0); $TransportDeuterium = round(request_var('deuterium', 0.0), 0); $holdingtime = request_var('holdingtime', 0); $rawfleetarray = request_var('usedfleet', '', true); $thisgalaxy = $PLANET['galaxy']; $thissystem = $PLANET['system']; $thisplanet = $PLANET['planet']; $thisplanettype = $PLANET['planet_type']; if (IsVacationMode($USER)) { exit($template->message($LNG['fl_vacation_mode_active'], 'game.php?page=overview', 2)); } if ($_SESSION['db']['user_side'] != 'game.php?page=fleet2') { parent::GotoFleetPage(); } if (!($planettype >= 1 || $planettype <= 3)) { parent::GotoFleetPage(); } if ($PLANET['galaxy'] == $galaxy && $PLANET['system'] == $system && $PLANET['planet'] == $planet && $PLANET['planet_type'] == $planettype) { parent::GotoFleetPage(); } if ($galaxy > MAX_GALAXY_IN_WORLD || $galaxy < 1 || $system > MAX_SYSTEM_IN_GALAXY || $system < 1 || $planet > MAX_PLANET_IN_SYSTEM + 1 || $planet < 1) { parent::GotoFleetPage(); } if (empty($mission)) { parent::GotoFleetPage(); } if (!is_numeric($TransportMetal) || !is_numeric($TransportCrystal) || !is_numeric($TransportDeuterium)) { parent::GotoFleetPage(); } if ($TransportMetal + $TransportCrystal + $TransportDeuterium < 1 && $mission == 3) { $template->message("<font color=\"lime\"><b>" . $LNG['fl_empty_transport'] . "</b></font>", "game." . PHP_EXT . "?page=fleet", 1); exit; } $ActualFleets = parent::GetCurrentFleets($USER['id']); if (parent::GetMaxFleetSlots($USER) <= $ActualFleets) { $template->message($LNG['fl_no_slots'], "game." . PHP_EXT . "?page=fleet", 1); exit; } $fleet_group_mr = 0; if (!empty($fleet_group) && $mission == 2) { $aks_count_mr = $db->uniquequery("SELECT COUNT(*) as state FROM " . AKS . " WHERE `id` = '" . $fleet_group . "' AND `eingeladen` LIKE '%" . $USER['id'] . "%';"); if ($aks_count_mr['state'] > 0) { $fleet_group_mr = $fleet_group; } else { $mission = 1; } } $ActualFleets = parent::GetCurrentFleets($USER['id']); $TargetPlanet = $db->uniquequery("SELECT `id_owner`,`id_level`,`destruyed`,`ally_deposit` FROM " . PLANETS . " WHERE `galaxy` = '" . $db->sql_escape($galaxy) . "' AND `system` = '" . $db->sql_escape($system) . "' AND `planet` = '" . $db->sql_escape($planet) . "' AND `planet_type` = '" . $db->sql_escape($planettype) . "';"); if ($mission != 15 && $mission != 8 && $TargetPlanet["destruyed"] != 0 || $mission != 15 && $mission != 7 && $mission != 8 && empty($TargetPlanet['id_owner'])) { parent::GotoFleetPage(); } $MyDBRec = $USER; $FleetArray = parent::GetFleetArray($rawfleetarray); if (!is_array($FleetArray)) { parent::GotoFleetPage(); } $FleetStorage = 0; $FleetShipCount = 0; $fleet_array = ""; $FleetSubQRY = ""; foreach ($FleetArray as $Ship => $Count) { if ($Count > $PLANET[$resource[$Ship]] || $Count < 0) { parent::GotoFleetPage(); } $FleetStorage += $pricelist[$Ship]["capacity"] * $Count; $FleetShipCount += $Count; $fleet_array .= $Ship . "," . $Count . ";"; $FleetSubQRY .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` - '" . floattostring($Count) . "', "; } $error = 0; $fleetmission = $mission; $YourPlanet = false; $UsedPlanet = false; if ($mission == 11) { $maxexpde = parent::GetCurrentFleets($USER['id'], 11); if ($maxexpde >= MAX_DM_MISSIONS) { $template->message("<font color=\"red\"><b>" . $LNG['fl_expedition_fleets_limit'] . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2); exit; } } elseif ($mission == 15) { $MaxExpedition = $USER[$resource[124]]; if ($MaxExpedition == 0) { $template->message("<font color=\"red\"><b>" . $LNG['fl_expedition_tech_required'] . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2); exit; } $ExpeditionEnCours = parent::GetCurrentFleets($USER['id'], 15); $EnvoiMaxExpedition = floor(sqrt($MaxExpedition)); if ($ExpeditionEnCours >= $EnvoiMaxExpedition) { $template->message("<font color=\"red\"><b>" . $LNG['fl_expedition_fleets_limit'] . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2); exit; } } $YourPlanet = isset($TargetPlanet['id_owner']) && $TargetPlanet['id_owner'] == $USER['id'] ? true : false; $UsedPlanet = isset($TargetPlanet['id_owner']) ? true : false; $HeDBRec = $YourPlanet ? $MyDBRec : GetUserByID($TargetPlanet['id_owner'], array('id', 'onlinetime', 'ally_id', 'urlaubs_modus')); if ($HeDBRec['urlaubs_modus'] && $mission != 8) { $template->message("<font color=\"lime\"><b>" . $LNG['fl_in_vacation_player'] . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2); exit; } if (!$YourPlanet && ($mission == 1 || $mission == 2 || $mission == 5 || $mission == 6 || $mission == 9)) { if ($TargetPlanet['id_level'] > $USER['authlevel'] && $CONF['adm_attack'] == 0) { $template->message("<font color=\"red\"><b>" . $LNG['fl_admins_cannot_be_attacked'] . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2); exit; } $UserPoints = $USER; $User2Points = $db->uniquequery("SELECT `total_points` FROM " . STATPOINTS . " WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $HeDBRec['id'] . "';"); $IsNoobProtec = CheckNoobProtec($UserPoints, $User2Points, $HeDBRec['onlinetime']); if ($IsNoobProtec['NoobPlayer']) { $template->message("<font color=\"lime\"><b>" . $LNG['fl_week_player'] . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2); exit; } elseif ($IsNoobProtec['StrongPlayer']) { $template->message("<font color=\"red\"><b>" . $LNG['fl_strong_player'] . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2); exit; } } if ($mission == 5) { if ($TargetPlanet['ally_deposit'] < 1) { $template->message("<font color=\"red\"><b>" . $LNG['fl_not_ally_deposit'] . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2); exit; } $buddy = $db->uniquequery("SELECT COUNT(*) as state FROM " . BUDDY . " WHERE `active` = '1' AND (`owner` = '" . $HeDBRec['id'] . "' AND `sender` = '" . $MyDBRec['id'] . "') OR (`owner` = '" . $MyDBRec['id'] . "' AND `sender` = '" . $HeDBRec['id'] . "');"); if ($HeDBRec['ally_id'] != $MyDBRec['ally_id'] && $buddy['state'] == 0) { $template->message("<font color=\"red\"><b>" . $LNG['fl_no_same_alliance'] . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2); exit; } } if (parent::CheckUserSpeed() || !array_key_exists($mission, parent::GetAvailableMissions(array('CurrentUser' => $USER, 'galaxy' => $galaxy, 'system' => $system, 'planet' => $planet, 'planettype' => $planettype, 'IsAKS' => $fleet_group, 'Ship' => $FleetArray)))) { parent::GotoFleetPage(); } $MaxFleetSpeed = parent::GetFleetMaxSpeed($FleetArray, $USER); $SpeedFactor = parent::GetGameSpeedFactor(); $distance = parent::GetTargetDistance($thisgalaxy, $galaxy, $thissystem, $system, $thisplanet, $planet); $duration = parent::GetMissionDuration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor, $USER); $consumption = parent::GetFleetConsumption($FleetArray, $duration, $distance, $MaxFleetSpeed, $USER, $SpeedFactor); $fleet['start_time'] = $duration + TIMESTAMP; if ($mission == 15) { $StayDuration = max($holdingtime, 1) * 3600 / $CONF['halt_speed']; $StayTime = $fleet['start_time'] + $StayDuration; } elseif ($mission == 5) { $StayDuration = $holdingtime * 3600; $StayTime = $fleet['start_time'] + $StayDuration; } elseif ($mission == 11) { $StayDuration = 3600 / $CONF['halt_speed']; $StayTime = $fleet['start_time'] + $StayDuration; } else { $StayDuration = 0; $StayTime = 0; } $fleet['end_time'] = $StayDuration + 2 * $duration + TIMESTAMP; $FleetStorage -= $consumption; $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $TransportMetal = min($TransportMetal, $PLANET['metal']); $TransportCrystal = min($TransportCrystal, $PLANET['crystal']); $TransportDeuterium = min($TransportDeuterium, $PLANET['deuterium'] - $consumption); $StorageNeeded = $TransportMetal + $TransportCrystal + $TransportDeuterium; $StockMetal = $PLANET['metal']; $StockCrystal = $PLANET['crystal']; $StockDeuterium = $PLANET['deuterium']; $StockDeuterium -= $consumption; if ($PLANET['deuterium'] < $consumption) { $template->message("<font color=\"red\"><b>" . sprintf($LNG['fl_no_enought_deuterium'], $LNG['Deuterium'], pretty_number($consumption - $PLANET['deuterium']), $LNG['Deuterium']) . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2); exit; } if ($StorageNeeded > $FleetStorage) { $template->message("<font color=\"red\"><b>" . $LNG['fl_no_enought_cargo_capacity'] . pretty_number($StorageNeeded - $FleetStorage) . "</b></font>", "game." . PHP_EXT . "?page=fleet", 2); exit; } if ($TargetPlanet['id_level'] > $USER['authlevel'] && $CONF['adm_attack'] == 0) { $template->message($LNG['fl_admins_cannot_be_attacked'], "game." . PHP_EXT . "?page=fleet", 2); exit; } $PLANET['metal'] -= $TransportMetal; $PLANET['crystal'] -= $TransportCrystal; $PLANET['deuterium'] -= $TransportDeuterium + $consumption; $PlanetRess->SavePlanetToDB(); if (connection_aborted()) { exit; } if ($fleet_group_mr != 0) { $AksStartTime = $db->uniquequery("SELECT MAX(`fleet_start_time`) AS Start FROM " . FLEETS . " WHERE `fleet_group` = '" . $fleet_group_mr . "' AND '" . MAX_FLEETS_PER_ACS . "' > (SELECT COUNT(*) FROM " . FLEETS . " WHERE `fleet_group` = '" . $fleet_group_mr . "');"); if (isset($AksStartTime)) { if ($AksStartTime['Start'] >= $fleet['start_time']) { $fleet['end_time'] += $AksStartTime['Start'] - $fleet['start_time']; $fleet['start_time'] = $AksStartTime['Start']; } else { $QryUpdateFleets = "UPDATE " . FLEETS . " SET "; $QryUpdateFleets .= "`fleet_start_time` = '" . $fleet['start_time'] . "', "; $QryUpdateFleets .= "`fleet_end_time` = fleet_end_time + '" . ($fleet['start_time'] - $AksStartTime['Start']) . "' "; $QryUpdateFleets .= "WHERE "; $QryUpdateFleets .= "`fleet_group` = '" . $fleet_group_mr . "';"; $db->query($QryUpdateFleets); $fleet['end_time'] += $fleet['start_time'] - $AksStartTime['Start']; } } else { $mission = 1; } } $QryInsertFleet = "LOCK TABLE " . FLEETS . " WRITE, " . PLANETS . " WRITE;\r\n\t\t\t\t\t\t\tINSERT INTO " . FLEETS . " SET \r\n\t\t\t\t\t\t\t`fleet_owner` = '" . $USER['id'] . "', \r\n\t\t\t\t\t\t\t`fleet_mission` = '" . $mission . "',\r\n\t\t\t\t\t\t\t`fleet_amount` = '" . $FleetShipCount . "',\r\n\t\t\t\t\t\t `fleet_array` = '" . $fleet_array . "',\r\n\t\t\t\t\t\t\t`fleet_start_time` = '" . $fleet['start_time'] . "',\r\n\t\t\t\t\t\t\t`fleet_start_galaxy` = '" . $thisgalaxy . "',\r\n\t\t\t\t\t\t\t`fleet_start_system` = '" . $thissystem . "',\r\n\t\t\t\t\t\t\t`fleet_start_planet` = '" . $thisplanet . "',\r\n\t\t\t\t\t\t\t`fleet_start_type` = '" . $thisplanettype . "',\r\n\t\t\t\t\t\t\t`fleet_end_time` = '" . $fleet['end_time'] . "',\r\n\t\t\t\t\t\t\t`fleet_end_stay` = '" . $StayTime . "',\r\n\t\t\t\t\t\t\t`fleet_end_galaxy` = '" . $galaxy . "',\r\n\t\t\t\t\t\t\t`fleet_end_system` = '" . $system . "',\r\n\t\t\t\t\t\t\t`fleet_end_planet` = '" . $planet . "',\r\n\t\t\t\t\t\t\t`fleet_end_type` = '" . $planettype . "',\r\n\t\t\t\t\t\t\t`fleet_resource_metal` = '" . floattostring($TransportMetal) . "',\r\n\t\t\t\t\t\t\t`fleet_resource_crystal` = '" . floattostring($TransportCrystal) . "',\r\n\t\t\t\t\t\t\t`fleet_resource_deuterium` = '" . floattostring($TransportDeuterium) . "',\r\n\t\t\t\t\t\t\t`fleet_target_owner` = '" . $TargetPlanet['id_owner'] . "',\r\n\t\t\t\t\t\t\t`fleet_group` = '" . $fleet_group_mr . "',\r\n\t\t\t\t\t\t\t`start_time` = '" . TIMESTAMP . "';\r\n\t\t\t\t\t\t\tUPDATE `" . PLANETS . "` SET\r\n\t\t\t\t\t\t\t" . substr($FleetSubQRY, 0, -2) . "\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t`id` = " . $PLANET['id'] . " LIMIT 1;\r\n\t\t\t\t\t\t\tUNLOCK TABLES;"; $db->multi_query($QryInsertFleet); foreach ($FleetArray as $Ship => $Count) { $FleetList[$LNG['tech'][$Ship]] = pretty_number($Count); } $template->assign_vars(array('mission' => $LNG['type_mission'][$mission], 'distance' => pretty_number($distance), 'consumption' => pretty_number($consumption), 'from' => $thisgalaxy . ":" . $thissystem . ":" . $thisplanet, 'destination' => $galaxy . ":" . $system . ":" . $planet, 'start_time' => date("M D d H:i:s", $fleet['start_time']), 'end_time' => date("M D d H:i:s", $fleet['end_time']), 'speedallsmin' => $MaxFleetSpeed, 'FleetList' => $FleetList, 'fl_fleet_sended' => $LNG['fl_fleet_sended'], 'fl_mission' => $LNG['fl_mission'], 'fl_from' => $LNG['fl_from'], 'fl_destiny' => $LNG['fl_destiny'], 'fl_distance' => $LNG['fl_distance'], 'fl_fleet_speed' => $LNG['fl_fleet_speed'], 'fl_fuel_consumption' => $LNG['fl_fuel_consumption'], 'fl_fromfl_destiny' => $LNG['fl_fromfl_destiny'], 'fl_arrival_time' => $LNG['fl_arrival_time'], 'fl_return_time' => $LNG['fl_return_time'], 'fl_fleet' => $LNG['fl_fleet'])); $template->show('fleet3_table.tpl'); }
function TargetEvent() { global $pricelist, $reslist, $resource; $db = Database::get(); $sql = 'SELECT * FROM %%USERS%% WHERE id = :userId;'; $senderUser = $db->selectSingle($sql, array(':userId' => $this->_fleet['fleet_owner'])); $targetUser = $db->selectSingle($sql, array(':userId' => $this->_fleet['fleet_target_owner'])); $sql = 'SELECT * FROM %%PLANETS%% WHERE id = :planetId;'; $targetPlanet = $db->selectSingle($sql, array(':planetId' => $this->_fleet['fleet_end_id'])); $sql = 'SELECT name FROM %%PLANETS%% WHERE id = :planetId;'; $senderPlanetName = $db->selectSingle($sql, array(':planetId' => $this->_fleet['fleet_start_id']), 'name'); $LNG = $this->getLanguage($senderUser['lang']); $senderUser['factor'] = getFactors($senderUser, 'basic', $this->_fleet['fleet_start_time']); $targetUser['factor'] = getFactors($targetUser, 'basic', $this->_fleet['fleet_start_time']); $planetUpdater = new ResourceUpdate(); list($targetUser, $targetPlanet) = $planetUpdater->CalcResource($targetUser, $targetPlanet, true, $this->_fleet['fleet_start_time']); $sql = 'SELECT * FROM %%FLEETS%% WHERE fleet_end_id = :planetId AND fleet_mission = 5 AND fleet_end_stay > :time;'; $targetStayFleets = $db->select($sql, array(':planetId' => $this->_fleet['fleet_end_id'], ':time' => $this->_fleet['fleet_start_time'])); foreach ($targetStayFleets as $fleetRow) { $fleetData = FleetFunctions::unserialize($fleetRow['fleet_array']); foreach ($fleetData as $shipId => $shipAmount) { $targetPlanet[$resource[$shipId]] += $shipAmount; } } $fleetAmount = $this->_fleet['fleet_amount'] * (1 + $senderUser['factor']['SpyPower']); $senderSpyTech = max($senderUser['spy_tech'], 1); $targetSpyTech = max($targetUser['spy_tech'], 1); $techDifference = abs($senderSpyTech - $targetSpyTech); $MinAmount = ($senderSpyTech > $targetSpyTech ? -1 : 1) * pow($techDifference * SPY_DIFFENCE_FACTOR, 2); $SpyFleet = $fleetAmount >= $MinAmount; $SpyDef = $fleetAmount >= $MinAmount + 1 * SPY_VIEW_FACTOR; $SpyBuild = $fleetAmount >= $MinAmount + 3 * SPY_VIEW_FACTOR; $SpyTechno = $fleetAmount >= $MinAmount + 5 * SPY_VIEW_FACTOR; $classIDs[900] = array_merge($reslist['resstype'][1], $reslist['resstype'][2]); if ($SpyFleet) { $classIDs[200] = $reslist['fleet']; } if ($SpyDef) { $classIDs[400] = array_merge($reslist['defense'], $reslist['missile']); } if ($SpyBuild) { $classIDs[0] = $reslist['build']; } if ($SpyTechno) { $classIDs[100] = $reslist['tech']; } $targetChance = mt_rand(0, min($fleetAmount / 4 * ($targetSpyTech / $senderSpyTech), 100)); $spyChance = mt_rand(0, 100); $spyData = array(); foreach ($classIDs as $classID => $elementIDs) { foreach ($elementIDs as $elementID) { if (isset($targetUser[$resource[$elementID]])) { $spyData[$classID][$elementID] = $targetUser[$resource[$elementID]]; } else { $spyData[$classID][$elementID] = $targetPlanet[$resource[$elementID]]; } } if ($senderUser['spyMessagesMode'] == 1) { $spyData[$classID] = array_filter($spyData[$classID]); } } // I'm use template class here, because i want to exclude HTML in PHP. require_once 'includes/classes/class.template.php'; $template = new template(); $template->caching = true; $template->compile_id = $senderUser['lang']; $template->loadFilter('output', 'trimwhitespace'); list($tplDir) = $template->getTemplateDir(); $template->setTemplateDir($tplDir . 'game/'); $template->assign_vars(array('spyData' => $spyData, 'targetPlanet' => $targetPlanet, 'targetChance' => $targetChance, 'spyChance' => $spyChance, 'isBattleSim' => ENABLE_SIMULATOR_LINK == true && isModuleAvailable(MODULE_SIMULATOR), 'title' => sprintf($LNG['sys_mess_head'], $targetPlanet['name'], $targetPlanet['galaxy'], $targetPlanet['system'], $targetPlanet['planet'], _date($LNG['php_tdformat'], $this->_fleet['fleet_end_time'], $targetUser['timezone'], $LNG)))); $template->assign_vars(array('LNG' => $LNG), false); $spyReport = $template->fetch('shared.mission.spyReport.tpl'); PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_mess_qg'], 0, $LNG['sys_mess_spy_report'], $spyReport, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']); $LNG = $this->getLanguage($targetUser['lang']); $targetMessage = $LNG['sys_mess_spy_ennemyfleet'] . " " . $senderPlanetName; if ($this->_fleet['fleet_start_type'] == 3) { $targetMessage .= $LNG['sys_mess_spy_report_moon'] . ' '; } $text = '<a href="game.php?page=galaxy&galaxy=%1$s&system=%2$s">[%1$s:%2$s:%3$s]</a> %7$s %8$s <a href="game.php?page=galaxy&galaxy=%4$s&system=%5$s">[%4$s:%5$s:%6$s]</a> %9$s'; $targetMessage .= sprintf($text, $this->_fleet['fleet_start_galaxy'], $this->_fleet['fleet_start_system'], $this->_fleet['fleet_start_planet'], $this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet'], $LNG['sys_mess_spy_seen_at'], $targetPlanet['name'], $LNG['sys_mess_spy_seen_at2']); PlayerUtil::sendMessage($this->_fleet['fleet_target_owner'], 0, $LNG['sys_mess_spy_control'], 0, $LNG['sys_mess_spy_activity'], $targetMessage, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']); if ($targetChance >= $spyChance) { $config = Config::get($this->_fleet['fleet_universe']); $whereCol = $this->_fleet['fleet_end_type'] == 3 ? "id_luna" : "id"; $sql = 'UPDATE %%PLANETS%% SET der_metal = der_metal + :metal, der_crystal = der_crystal + :crystal WHERE ' . $whereCol . ' = :planetId;'; $db->update($sql, array(':metal' => $fleetAmount * $pricelist[210]['cost'][901] * $config->Fleet_Cdr / 100, ':crystal' => $fleetAmount * $pricelist[210]['cost'][902] * $config->Fleet_Cdr / 100, ':planetId' => $this->_fleet['fleet_end_id'])); $this->KillFleet(); } else { $this->setState(FLEET_RETURN); $this->SaveFleet(); } }