/** * method build_page * param * return main method, loads everything */ private function build_page() { $resource = parent::$objects->getObjects(); $reslist = parent::$objects->getObjectsList(); ##################################################################################################### // SOME DEFAULT VALUES ##################################################################################################### // QUERYS $count = parent::$db->queryFetch("SELECT\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT COUNT(fleet_owner) AS `actcnt`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_owner` = '" . (int) $this->_current_user['user_id'] . "') AS max_fleet,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT COUNT(fleet_owner) AS `expedi`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_owner` = '" . (int) $this->_current_user['user_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `fleet_mission` = '15') AS max_expeditions"); // LOAD TEMPLATES REQUIRED $inputs_template = parent::$page->get_template('fleet/fleet1_inputs'); $ships_row_template = parent::$page->get_template('fleet/fleet1_row_ships'); // LANGUAGE $this->_lang['js_path'] = XGP_ROOT . JS_PATH; $parse = $this->_lang; $MaxFlyingFleets = $count['max_fleet']; $MaxExpedition = $this->_current_user[$resource[124]]; if ($MaxExpedition >= 1) { $ExpeditionEnCours = $count['max_expeditions']; $EnvoiMaxExpedition = FleetsLib::get_max_expeditions($MaxExpedition); } else { $ExpeditionEnCours = 0; $EnvoiMaxExpedition = 0; } $MaxFlottes = FleetsLib::get_max_fleets($this->_current_user[$resource[108]], $this->_current_user['premium_officier_admiral']); $missiontype = FleetsLib::get_missions(); $galaxy = isset($_GET['galaxy']) ? (int) $_GET['galaxy'] : $this->_current_planet['planet_galaxy']; $system = isset($_GET['system']) ? (int) $_GET['system'] : $this->_current_planet['planet_system']; $planet = isset($_GET['planet']) ? (int) $_GET['planet'] : $this->_current_planet['planet_planet']; $planettype = isset($_GET['planettype']) ? (int) $_GET['planettype'] : $this->_current_planet['planet_type']; $target_mission = isset($_GET['target_mission']) ? (int) $_GET['target_mission'] : FALSE; $parse['flyingfleets'] = $MaxFlyingFleets; $parse['maxfleets'] = $MaxFlottes; $parse['currentexpeditions'] = $ExpeditionEnCours; $parse['maxexpeditions'] = $EnvoiMaxExpedition; $parse['message_nofreeslot'] = $MaxFlottes == $MaxFlyingFleets ? parent::$page->parse_template(parent::$page->get_template('fleet/fleet1_noslots_row'), $parse) : ''; $ships = $this->_lang; $ShipData = ''; $ship_inputs = ''; $ships_row = ''; foreach ($reslist['fleet'] as $n => $i) { if ($this->_current_planet[$resource[$i]] > 0) { if ($i == 212) { $ships['fleet_max_speed'] = '-'; } else { $ships['fleet_max_speed'] = FleetsLib::fleet_max_speed("", $i, $this->_current_user); } $ships['ship'] = $this->_lang['tech'][$i]; $ships['amount'] = FormatLib::pretty_number($this->_current_planet[$resource[$i]]); $inputs['i'] = $i; $inputs['maxship'] = $this->_current_planet[$resource[$i]]; $inputs['consumption'] = FleetsLib::ship_consumption($i, $this->_current_user); $inputs['speed'] = FleetsLib::fleet_max_speed("", $i, $this->_current_user); $inputs['capacity'] = isset($pricelist[$i]['capacity']) ? $pricelist[$i]['capacity'] : 0; if ($i == 212) { $ships['max_ships'] = ''; $ships['set_ships'] = ''; } else { $ships['max_ships'] = "<a href=\"javascript:maxShip('ship" . $i . "'); shortInfo();\">" . $this->_lang['fl_max'] . "</a>"; $ships['set_ships'] = "<input name=\"ship" . $i . "\" size=\"10\" value=\"0\" onfocus=\"javascript:if(this.value == '0') this.value='';\" onblur=\"javascript:if(this.value == '') this.value='0';\" alt=\"" . $this->_lang['tech'][$i] . $this->_current_planet[$resource[$i]] . "\" onChange=\"shortInfo()\" onKeyUp=\"shortInfo()\" />"; } $ship_inputs .= parent::$page->parse_template($inputs_template, $inputs); $ships_row .= parent::$page->parse_template($ships_row_template, $ships); } $have_ships = TRUE; } if (!$have_ships) { $parse['noships_row'] = parent::$page->parse_template(parent::$page->get_template('fleet/fleet1_noships_row'), $this->_lang); } else { if ($MaxFlottes > $MaxFlyingFleets) { $parse['none_max_selector'] = parent::$page->parse_template(parent::$page->get_template('fleet/fleet_selectors'), $this->_lang); $parse['continue_button'] = parent::$page->parse_template(parent::$page->get_template('fleet/fleet1_button'), $this->_lang); } } $parse['body'] = $ships_row; $parse['shipdata'] = $ship_inputs; $parse['galaxy'] = $galaxy; $parse['system'] = $system; $parse['planet'] = $planet; $parse['planettype'] = $planettype; $parse['target_mission'] = $target_mission; $parse['envoimaxexpedition'] = $EnvoiMaxExpedition; $parse['expeditionencours'] = $ExpeditionEnCours; $parse['target_mission'] = $target_mission; parent::$page->display(parent::$page->parse_template(parent::$page->get_template('fleet/fleet1_table'), $parse)); }
/** * method build_page * param * return main method, loads everything */ private function build_page() { $resource = parent::$objects->getObjects(); $pricelist = parent::$objects->getPrice(); $reslist = parent::$objects->getObjectsList(); $parse = $this->_lang; if (parent::$users->is_on_vacations($this->_current_user)) { exit(FunctionsLib::message($this->_lang['fl_vacation_mode_active'], "game.php?page=overview", 2)); } $fleet_group_mr = 0; if ($_POST['fleet_group'] > 0) { if ($_POST['mission'] == 2) { $target = 'g' . (int) $_POST['galaxy'] . 's' . (int) $_POST['system'] . 'p' . (int) $_POST['planet'] . 't' . (int) $_POST['planettype']; if ($_POST['acs_target_mr'] == $target) { $aks_count_mr = parent::$db->query("SELECT COUNT(`acs_fleet_id`)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . ACS_FLEETS . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `acs_fleet_id` = '" . (int) $_POST['fleet_group'] . "'"); if ($aks_count_mr > 0) { $fleet_group_mr = $_POST['fleet_group']; } } } } if ($_POST['fleet_group'] == 0 && $_POST['mission'] == 2) { $_POST['mission'] = 1; } $TargetPlanet = parent::$db->queryFetch("SELECT `planet_user_id`,`planet_destroyed`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . PLANETS . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE `planet_galaxy` = '" . (int) $_POST['galaxy'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t`planet_system` = '" . (int) $_POST['system'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t`planet_planet` = '" . (int) $_POST['planet'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t`planet_type` = '" . (int) $_POST['planettype'] . "';"); $MyDBRec = parent::$db->queryFetch("SELECT u.`user_id`, u.`user_onlinetime`, u.`user_ally_id`, s.`setting_vacations_status`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . " AS u, " . SETTINGS . " AS s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE u.`user_id` = '" . $this->_current_user['user_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND s.`setting_user_id` = '" . $this->_current_user['user_id'] . "';"); $fleetarray = unserialize(base64_decode(str_rot13($_POST['usedfleet']))); if ($TargetPlanet['planet_destroyed'] != 0) { FunctionsLib::redirect('game.php?page=movement'); } if (!is_array($fleetarray)) { FunctionsLib::redirect('game.php?page=movement'); } foreach ($fleetarray as $Ship => $Count) { $Count = intval($Count); if ($Count > $this->_current_planet[$resource[$Ship]]) { FunctionsLib::redirect('game.php?page=movement'); } } $error = 0; $galaxy = (int) $_POST['galaxy']; $system = (int) $_POST['system']; $planet = (int) $_POST['planet']; $planettype = (int) $_POST['planettype']; $fleetmission = (int) $_POST['mission']; //fix by jstar if ($fleetmission == 7 && !isset($fleetarray[208])) { FunctionsLib::redirect('game.php?page=movement'); } if ($planettype != 1 && $planettype != 2 && $planettype != 3) { FunctionsLib::redirect('game.php?page=movement'); } //fix invisible debris like ogame by jstar if ($fleetmission == 8) { $YourPlanet = FALSE; $UsedPlanet = FALSE; $select = parent::$db->queryFetch("SELECT COUNT(*) AS count, p.*\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . PLANETS . "` AS p\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . $galaxy . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . $system . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . $planet . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = 1;"); if ($select['planet_debris_metal'] == 0 && $select['planet_debris_crystal'] == 0 && time() > $select['planet_invisible_start_time'] + DEBRIS_LIFE_TIME) { FunctionsLib::redirect('game.php?page=movement'); } } else { $YourPlanet = FALSE; $UsedPlanet = FALSE; $select = parent::$db->queryFetch("SELECT COUNT(*) AS count, p.`planet_user_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . PLANETS . "` AS p\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . $galaxy . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . $system . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . $planet . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = '" . $planettype . "'"); } if ($this->_current_planet['planet_galaxy'] == $galaxy && $this->_current_planet['planet_system'] == $system && $this->_current_planet['planet_planet'] == $planet && $this->_current_planet['planet_type'] == $planettype) { FunctionsLib::redirect('game.php?page=movement'); } if ($_POST['mission'] != 15) { if ($select['count'] < 1 && $fleetmission != 7) { FunctionsLib::redirect('game.php?page=movement'); } elseif ($fleetmission == 9 && $select['count'] < 1) { FunctionsLib::redirect('game.php?page=movement'); } } else { $MaxExpedition = $this->_current_user[$resource[124]]; if ($MaxExpedition >= 1) { $maxexpde = parent::$db->queryFetch("SELECT COUNT(fleet_owner) AS `expedi`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_owner` = '" . $this->_current_user['user_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `fleet_mission` = '15';"); $ExpeditionEnCours = $maxexpde['expedi']; $EnvoiMaxExpedition = FleetsLib::get_max_expeditions($MaxExpedition); } else { $ExpeditionEnCours = 0; $EnvoiMaxExpedition = 0; } if ($EnvoiMaxExpedition == 0) { FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_expedition_tech_required'] . "</b></font>", "game.php?page=movement", 2); } elseif ($ExpeditionEnCours >= $EnvoiMaxExpedition) { FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_expedition_fleets_limit'] . "</b></font>", "game.php?page=movement", 2); } } if ($select['planet_user_id'] == $this->_current_user['user_id']) { $YourPlanet = TRUE; $UsedPlanet = TRUE; } elseif (!empty($select['planet_user_id'])) { $YourPlanet = FALSE; $UsedPlanet = TRUE; } else { $YourPlanet = FALSE; $UsedPlanet = FALSE; } //fix by jstar if ($fleetmission == 9) { $countfleettype = count($fleetarray); if ($YourPlanet or !$UsedPlanet or $planettype != 3) { FunctionsLib::redirect('game.php?page=movement'); } elseif ($countfleettype == 1 && !isset($fleetarray[214])) { FunctionsLib::redirect('game.php?page=movement'); } elseif ($countfleettype == 2 && !isset($fleetarray[214])) { FunctionsLib::redirect('game.php?page=movement'); } elseif ($countfleettype > 2) { FunctionsLib::redirect('game.php?page=movement'); } } if (empty($fleetmission)) { FunctionsLib::redirect('game.php?page=movement'); } if ($TargetPlanet['planet_user_id'] == '') { $HeDBRec = $MyDBRec; } elseif ($TargetPlanet['planet_user_id'] != '') { $HeDBRec = parent::$db->queryFetch("SELECT u.`user_id`, u.`user_onlinetime`, u.`user_ally_id`, s.`setting_vacations_status`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . " AS u, " . SETTINGS . " AS s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE u.`user_id` = '" . $TargetPlanet['planet_user_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND s.`setting_user_id` ='" . $TargetPlanet['planet_user_id'] . "';"); } $user_points = $this->_noob->return_points($MyDBRec['user_id'], $HeDBRec['user_id']); $MyGameLevel = $user_points['user_points']; $HeGameLevel = $user_points['target_points']; if ($HeDBRec['user_onlinetime'] >= time() - 60 * 60 * 24 * 7) { if ($this->_noob->is_weak($MyGameLevel, $HeGameLevel) && $TargetPlanet['planet_user_id'] != '' && ($_POST['mission'] == 1 or $_POST['mission'] == 6 or $_POST['mission'] == 9)) { FunctionsLib::message("<font color=\"lime\"><b>" . $this->_lang['fl_week_player'] . "</b></font>", "game.php?page=movement", 2); } if ($this->_noob->is_strong($MyGameLevel, $HeGameLevel) && $TargetPlanet['planet_user_id'] != '' && ($_POST['mission'] == 1 or $_POST['mission'] == 5 or $_POST['mission'] == 6 or $_POST['mission'] == 9)) { FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_strong_player'] . "</b></font>", "game.php?page=movement", 2); } } if ($HeDBRec['setting_vacations_status'] && $_POST['mission'] != 8) { FunctionsLib::message("<font color=\"lime\"><b>" . $this->_lang['fl_in_vacation_player'] . "</b></font>", "game.php?page=movement", 2); } $FlyingFleets = parent::$db->queryFetch("SELECT COUNT(fleet_id) as Number\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_owner`='" . $this->_current_user['user_id'] . "'"); $ActualFleets = $FlyingFleets['Number']; if (FleetsLib::get_max_fleets($this->_current_user[$resource[108]], $this->_current_user['premium_officier_admiral']) <= $ActualFleets) { FunctionsLib::message($this->_lang['fl_no_slots'], "game.php?page=movement", 1); } if ($_POST['resource1'] + $_POST['resource2'] + $_POST['resource3'] < 1 && $_POST['mission'] == 3) { FunctionsLib::message("<font color=\"lime\"><b>" . $this->_lang['fl_empty_transport'] . "</b></font>", "game.php?page=movement", 1); } if ($_POST['mission'] != 15) { if ($TargetPlanet['planet_user_id'] == '' && $_POST['mission'] < 7) { FunctionsLib::redirect('game.php?page=movement'); } if ($TargetPlanet['planet_user_id'] != '' && $_POST['mission'] == 7) { FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_planet_populed'] . "</b></font>", "game.php?page=movement", 2); } if ($HeDBRec['user_ally_id'] != $MyDBRec['user_ally_id'] && $_POST['mission'] == 4) { FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_stay_not_on_enemy'] . "</b></font>", "game.php?page=movement", 2); } if ($TargetPlanet['planet_user_id'] == $this->_current_planet['planet_user_id'] && ($_POST['mission'] == 1 or $_POST['mission'] == 6)) { FunctionsLib::redirect('game.php?page=movement'); } if ($TargetPlanet['planet_user_id'] != $this->_current_planet['planet_user_id'] && $_POST['mission'] == 4) { FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_deploy_only_your_planets'] . "</b></font>", "game.php?page=movement", 2); } if ($_POST['mission'] == 5) { $buddy = parent::$db->queryFetch("SELECT COUNT( * ) AS buddys\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . BUDDY . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbuddy_sender ='" . intval($this->_current_planet['planet_user_id']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND buddy_receiver ='" . intval($TargetPlanet['planet_user_id']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tOR (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbuddy_sender ='" . intval($TargetPlanet['planet_user_id']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND buddy_receiver ='" . intval($this->_current_planet['planet_user_id']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND buddy_status =1"); if ($HeDBRec['user_ally_id'] != $MyDBRec['user_ally_id'] && $buddy['buddys'] < 1) { FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_stay_not_on_enemy'] . "</b></font>", "game.php?page=movement", 2); } } } $missiontype = FleetsLib::get_missions(); $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1); $AllFleetSpeed = FleetsLib::fleet_max_speed($fleetarray, 0, $this->_current_user); $GenFleetSpeed = $_POST['speed']; $SpeedFactor = FunctionsLib::fleet_speed_factor(); $MaxFleetSpeed = min($AllFleetSpeed); if (!in_array($GenFleetSpeed, $speed_possible)) { FunctionsLib::redirect('game.php?page=movement'); } if ($MaxFleetSpeed != $_POST['speedallsmin']) { FunctionsLib::redirect('game.php?page=movement'); } if (!$_POST['planettype']) { FunctionsLib::redirect('game.php?page=movement'); } if (!$_POST['galaxy'] || !is_numeric($_POST['galaxy']) || $_POST['galaxy'] > MAX_GALAXY_IN_WORLD || $_POST['galaxy'] < 1) { FunctionsLib::redirect('game.php?page=movement'); } if (!$_POST['system'] || !is_numeric($_POST['system']) || $_POST['system'] > MAX_SYSTEM_IN_GALAXY || $_POST['system'] < 1) { FunctionsLib::redirect('game.php?page=movement'); } if (!$_POST['planet'] || !is_numeric($_POST['planet']) || $_POST['planet'] > MAX_PLANET_IN_SYSTEM + 1 || $_POST['planet'] < 1) { FunctionsLib::redirect('game.php?page=movement'); } if ($_POST['thisgalaxy'] != $this->_current_planet['planet_galaxy'] | $_POST['thissystem'] != $this->_current_planet['planet_system'] | $_POST['thisplanet'] != $this->_current_planet['planet_planet'] | $_POST['thisplanettype'] != $this->_current_planet['planet_type']) { FunctionsLib::redirect('game.php?page=movement'); } if (!isset($fleetarray)) { FunctionsLib::redirect('game.php?page=movement'); } $distance = FleetsLib::target_distance($_POST['thisgalaxy'], $_POST['galaxy'], $_POST['thissystem'], $_POST['system'], $_POST['thisplanet'], $_POST['planet']); $duration = FleetsLib::mission_duration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor); $consumption = FleetsLib::fleet_consumption($fleetarray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $this->_current_user); $fleet['start_time'] = $duration + time(); // START CODE BY JSTAR if ($_POST['mission'] == 15) { $StayDuration = floor($_POST['expeditiontime']); if ($StayDuration > 0) { $StayDuration = $StayDuration * 3600; $StayTime = $fleet['start_time'] + $StayDuration; } else { FunctionsLib::redirect('game.php?page=movement'); } } elseif ($_POST['mission'] == 5) { $StayDuration = $_POST['holdingtime'] * 3600; $StayTime = $fleet['start_time'] + $_POST['holdingtime'] * 3600; } else { $StayDuration = 0; $StayTime = 0; } $fleet['end_time'] = $StayDuration + 2 * $duration + time(); $FleetStorage = 0; $FleetShipCount = 0; $fleet_array = ""; $FleetSubQRY = ""; //fix by jstar $haveSpyProbos = FALSE; foreach ($fleetarray as $Ship => $Count) { $Count = intval($Count); if ($Ship == 210) { $haveSpyProbos = TRUE; } $FleetStorage += $pricelist[$Ship]['capacity'] * $Count; $FleetShipCount += $Count; $fleet_array .= $Ship . "," . $Count . ";"; $FleetSubQRY .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` - " . $Count . ", "; } if (!$haveSpyProbos && $_POST['mission'] == 6) { FunctionsLib::redirect('game.php?page=movement'); } $FleetStorage -= $consumption; $StorageNeeded = 0; $_POST['resource1'] = max(0, (int) trim($_POST['resource1'])); $_POST['resource2'] = max(0, (int) trim($_POST['resource2'])); $_POST['resource3'] = max(0, (int) trim($_POST['resource3'])); if ($_POST['resource1'] < 1) { $TransMetal = 0; } else { $TransMetal = $_POST['resource1']; $StorageNeeded += $TransMetal; } if ($_POST['resource2'] < 1) { $TransCrystal = 0; } else { $TransCrystal = $_POST['resource2']; $StorageNeeded += $TransCrystal; } if ($_POST['resource3'] < 1) { $TransDeuterium = 0; } else { $TransDeuterium = $_POST['resource3']; $StorageNeeded += $TransDeuterium; } $StockMetal = $this->_current_planet['planet_metal']; $StockCrystal = $this->_current_planet['planet_crystal']; $StockDeuterium = $this->_current_planet['planet_deuterium']; $StockDeuterium -= $consumption; $StockOk = FALSE; if ($StockMetal >= $TransMetal) { if ($StockCrystal >= $TransCrystal) { if ($StockDeuterium >= $TransDeuterium) { $StockOk = TRUE; } } } if (!$StockOk) { FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_no_enought_deuterium'] . FormatLib::pretty_number($consumption) . "</b></font>", "game.php?page=movement", 2); } if ($StorageNeeded > $FleetStorage) { FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_no_enought_cargo_capacity'] . FormatLib::pretty_number($StorageNeeded - $FleetStorage) . "</b></font>", "game.php?page=movement", 2); } if (FunctionsLib::read_config('adm_attack') != 0) { FunctionsLib::message($this->_lang['fl_admins_cannot_be_attacked'], "game.php?page=movement", 2); } if ($fleet_group_mr != 0) { $AksStartTime = parent::$db->queryFetch("SELECT MAX(`fleet_start_time`) AS Start\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_group` = '" . $fleet_group_mr . "';"); if ($AksStartTime['Start'] >= $fleet['start_time']) { $fleet['end_time'] += $AksStartTime['Start'] - $fleet['start_time']; $fleet['start_time'] = $AksStartTime['Start']; } else { parent::$db->query("UPDATE " . FLEETS . " SET\n\t\t\t\t\t\t\t\t\t\t`fleet_start_time` = '" . $fleet['start_time'] . "',\n\t\t\t\t\t\t\t\t\t\t`fleet_end_time` = fleet_end_time + '" . ($fleet['start_time'] - $AksStartTime['Start']) . "'\n\t\t\t\t\t\t\t\t\t\tWHERE `fleet_group` = '" . $fleet_group_mr . "';"); $fleet['end_time'] += $fleet['start_time'] - $AksStartTime['Start']; } } parent::$db->query("INSERT INTO " . FLEETS . " SET\n\t\t\t\t\t\t\t`fleet_owner` = '" . $this->_current_user['user_id'] . "',\n\t\t\t\t\t\t\t`fleet_mission` = '" . (int) $_POST['mission'] . "',\n\t\t\t\t\t\t\t`fleet_amount` = '" . (int) $FleetShipCount . "',\n\t\t\t\t\t\t\t`fleet_array` = '" . $fleet_array . "',\n\t\t\t\t\t\t\t`fleet_start_time` = '" . $fleet['start_time'] . "',\n\t\t\t\t\t\t\t`fleet_start_galaxy` = '" . (int) $_POST['thisgalaxy'] . "',\n\t\t\t\t\t\t\t`fleet_start_system` = '" . (int) $_POST['thissystem'] . "',\n\t\t\t\t\t\t\t`fleet_start_planet` = '" . (int) $_POST['thisplanet'] . "',\n\t\t\t\t\t\t\t`fleet_start_type` = '" . (int) $_POST['thisplanettype'] . "',\n\t\t\t\t\t\t\t`fleet_end_time` = '" . (int) $fleet['end_time'] . "',\n\t\t\t\t\t\t\t`fleet_end_stay` = '" . (int) $StayTime . "',\n\t\t\t\t\t\t\t`fleet_end_galaxy` = '" . (int) $_POST['galaxy'] . "',\n\t\t\t\t\t\t\t`fleet_end_system` = '" . (int) $_POST['system'] . "',\n\t\t\t\t\t\t\t`fleet_end_planet` = '" . (int) $_POST['planet'] . "',\n\t\t\t\t\t\t\t`fleet_end_type` = '" . (int) $_POST['planettype'] . "',\n\t\t\t\t\t\t\t`fleet_resource_metal` = '" . $TransMetal . "',\n\t\t\t\t\t\t\t`fleet_resource_crystal` = '" . $TransCrystal . "',\n\t\t\t\t\t\t\t`fleet_resource_deuterium` = '" . $TransDeuterium . "',\n\t\t\t\t\t\t\t`fleet_target_owner` = '" . (int) $TargetPlanet['planet_user_id'] . "',\n\t\t\t\t\t\t\t`fleet_group` = '" . (int) $fleet_group_mr . "',\n\t\t\t\t\t\t\t`fleet_creation` = '" . time() . "';"); parent::$db->query("UPDATE `" . PLANETS . "` AS p\n\t\t\t\t\t\t\t\tINNER JOIN " . SHIPS . " AS s ON s.ship_planet_id = p.`planet_id` SET\n\t\t\t\t\t\t\t\t{$FleetSubQRY}\n\t\t\t\t\t\t\t\t`planet_metal` = `planet_metal` - " . $TransMetal . ",\n\t\t\t\t\t\t\t\t`planet_crystal` = `planet_crystal` - " . $TransCrystal . ",\n\t\t\t\t\t\t\t\t`planet_deuterium` = `planet_deuterium` - " . ($TransDeuterium + $consumption) . "\n\t\t\t\t\t\t\t\tWHERE `planet_id` = " . $this->_current_planet['planet_id'] . ";"); FunctionsLib::redirect('game.php?page=movement'); }
/** * method build_page * param * return main method, loads everything */ private function build_page() { ##################################################################################################### // SOME DEFAULT VALUES ##################################################################################################### // ELEMENTS $resource = parent::$objects->getObjects(); // QUERYS $count = parent::$db->queryFetch("SELECT\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT COUNT(fleet_owner) AS `actcnt`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_owner` = '" . $this->_current_user['user_id'] . "') AS max_fleet,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT COUNT(fleet_owner) AS `expedi`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_owner` = '" . $this->_current_user['user_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `fleet_mission` = '15') AS max_expeditions"); // LANGUAGE $this->_lang['js_path'] = XGP_ROOT . JS_PATH; $parse = $this->_lang; $MaxFlyingFleets = $count['max_fleet']; $MaxExpedition = $this->_current_user[$resource[124]]; if ($MaxExpedition >= 1) { $ExpeditionEnCours = $count['max_expeditions']; $EnvoiMaxExpedition = FleetsLib::get_max_expeditions($MaxExpedition); } else { $ExpeditionEnCours = 0; $EnvoiMaxExpedition = 0; } $MaxFlottes = FleetsLib::get_max_fleets($this->_current_user[$resource[108]], $this->_current_user['premium_officier_admiral']); $missiontype = FleetsLib::get_missions(); $ShipData = ''; $parse['flyingfleets'] = $MaxFlyingFleets; $parse['maxfleets'] = $MaxFlottes; $parse['currentexpeditions'] = $ExpeditionEnCours; $parse['maxexpeditions'] = $EnvoiMaxExpedition; $i = 0; $flying_fleets = ''; if ($count['max_fleet'] != 0 or $MaxExpedition != 0) { $fq = parent::$db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n\t\t\t\t\t\t\t\t\t\tWHERE fleet_owner = '" . $this->_current_user['user_id'] . "'"); while ($f = parent::$db->fetchArray($fq)) { $i++; $parse['num'] = $i; $parse['fleet_mission'] = $missiontype[$f['fleet_mission']]; if (FleetsLib::is_fleet_returning($f)) { $parse['tooltip'] = $this->_lang['fl_returning']; $parse['title'] = $this->_lang['fl_r']; } else { $parse['tooltip'] = $this->_lang['fl_onway']; $parse['title'] = $this->_lang['fl_a']; } $fleet = explode(";", $f['fleet_array']); $e = 0; $parse['fleet'] = ''; foreach ($fleet as $a => $b) { if ($b != '') { $e++; $a = explode(",", $b); $parse['fleet'] .= $this->_lang['tech'][$a[0]] . ":" . $a[1] . "\n"; if ($e > 1) { $parse['fleet'] .= "\t"; } } } $parse['fleet_amount'] = FormatLib::pretty_number($f['fleet_amount']); $parse['fleet_start'] = FormatLib::pretty_coords($f['fleet_start_galaxy'], $f['fleet_start_system'], $f['fleet_start_planet']); $parse['fleet_start_time'] = date(FunctionsLib::read_config('date_format_extended'), $f['fleet_creation']); $parse['fleet_end'] = FormatLib::pretty_coords($f['fleet_end_galaxy'], $f['fleet_end_system'], $f['fleet_end_planet']); $parse['fleet_end_time'] = date(FunctionsLib::read_config('date_format_extended'), $f['fleet_start_time']); $parse['fleet_arrival'] = date(FunctionsLib::read_config('date_format_extended'), $f['fleet_end_time']); //now we can view the call back button for ships in maintaing position (2) if ($f['fleet_mess'] == 0 or $f['fleet_mess'] == 2) { $parse['inputs'] = '<form action="game.php?page=movement&action=return" method="post">'; $parse['inputs'] .= '<input name="fleetid" value="' . $f['fleet_id'] . '" type="hidden">'; $parse['inputs'] .= '<input value="' . $this->_lang['fl_send_back'] . '" type="submit" name="send">'; $parse['inputs'] .= '</form>'; if ($f['fleet_mission'] == 1) { $parse['inputs'] .= '<a href="#" onClick="f(\'game.php?page=federationlayer&union=' . $f['fleet_group'] . '&fleet=' . $f['fleet_id'] . '\', \'\')">'; $parse['inputs'] .= '<input value="' . $this->_lang['fl_acs'] . '" type="button">'; $parse['inputs'] .= '</a>'; } } else { $parse['inputs'] = ' - '; } $flying_fleets .= parent::$page->parse_template(parent::$page->get_template('movement/fleet_row_fleets'), $parse); } } if ($i == 0) { $parse['num'] = '-'; $parse['fleet_mission'] = '-'; $parse['title'] = ''; $parse['fleet_amount'] = '-'; $parse['fleet_start'] = '-'; $parse['fleet_start_time'] = '-'; $parse['fleet_end'] = '-'; $parse['fleet_end_time'] = '-'; $parse['fleet_arrival'] = '-'; $parse['inputs'] = '-'; $flying_fleets .= parent::$page->parse_template(parent::$page->get_template('movement/fleet_row_fleets'), $parse); } $parse['fleetpagerow'] = $flying_fleets; $parse['envoimaxexpedition'] = $EnvoiMaxExpedition; $parse['expeditionencours'] = $ExpeditionEnCours; parent::$page->display(parent::$page->parse_template(parent::$page->get_template('movement/fleet_table'), $parse)); }