Example #1
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $resource = parent::$objects->get_objects();
     $pricelist = parent::$objects->get_price();
     $reslist = parent::$objects->get_objects_list();
     $parse = $this->_lang;
     if (parent::$users->is_on_vacations($this->_current_user)) {
         exit(Functions_Lib::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->query_fetch("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->query_fetch("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) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     if (!is_array($fleetarray)) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     foreach ($fleetarray as $Ship => $Count) {
         $Count = intval($Count);
         if ($Count > $this->_current_planet[$resource[$Ship]]) {
             Functions_Lib::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])) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     if ($planettype != 1 && $planettype != 2 && $planettype != 3) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     //fix invisible debris like ogame by jstar
     if ($fleetmission == 8) {
         $YourPlanet = FALSE;
         $UsedPlanet = FALSE;
         $select = parent::$db->query_fetch("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) {
             Functions_Lib::redirect('game.php?page=movement');
         }
     } else {
         $YourPlanet = FALSE;
         $UsedPlanet = FALSE;
         $select = parent::$db->query_fetch("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) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     if ($_POST['mission'] != 15) {
         if ($select['count'] < 1 && $fleetmission != 7) {
             Functions_Lib::redirect('game.php?page=movement');
         } elseif ($fleetmission == 9 && $select['count'] < 1) {
             Functions_Lib::redirect('game.php?page=movement');
         }
     } else {
         $MaxExpedition = $this->_current_user[$resource[124]];
         if ($MaxExpedition >= 1) {
             $maxexpde = parent::$db->query_fetch("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 = Fleets_Lib::get_max_expeditions($MaxExpedition);
         } else {
             $ExpeditionEnCours = 0;
             $EnvoiMaxExpedition = 0;
         }
         if ($EnvoiMaxExpedition == 0) {
             Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_expedition_tech_required'] . "</b></font>", "game.php?page=movement", 2);
         } elseif ($ExpeditionEnCours >= $EnvoiMaxExpedition) {
             Functions_Lib::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) {
             Functions_Lib::redirect('game.php?page=movement');
         } elseif ($countfleettype == 1 && !isset($fleetarray[214])) {
             Functions_Lib::redirect('game.php?page=movement');
         } elseif ($countfleettype == 2 && !isset($fleetarray[214])) {
             Functions_Lib::redirect('game.php?page=movement');
         } elseif ($countfleettype > 2) {
             Functions_Lib::redirect('game.php?page=movement');
         }
     }
     if (empty($fleetmission)) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     if ($TargetPlanet['planet_user_id'] == '') {
         $HeDBRec = $MyDBRec;
     } elseif ($TargetPlanet['planet_user_id'] != '') {
         $HeDBRec = parent::$db->query_fetch("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)) {
             Functions_Lib::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)) {
             Functions_Lib::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) {
         Functions_Lib::message("<font color=\"lime\"><b>" . $this->_lang['fl_in_vacation_player'] . "</b></font>", "game.php?page=movement", 2);
     }
     $FlyingFleets = parent::$db->query_fetch("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 (Fleets_Lib::get_max_fleets($this->_current_user[$resource[108]], $this->_current_user['premium_officier_admiral']) <= $ActualFleets) {
         Functions_Lib::message($this->_lang['fl_no_slots'], "game.php?page=movement", 1);
     }
     if ($_POST['resource1'] + $_POST['resource2'] + $_POST['resource3'] < 1 && $_POST['mission'] == 3) {
         Functions_Lib::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) {
             Functions_Lib::redirect('game.php?page=movement');
         }
         if ($TargetPlanet['planet_user_id'] != '' && $_POST['mission'] == 7) {
             Functions_Lib::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) {
             Functions_Lib::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)) {
             Functions_Lib::redirect('game.php?page=movement');
         }
         if ($TargetPlanet['planet_user_id'] != $this->_current_planet['planet_user_id'] && $_POST['mission'] == 4) {
             Functions_Lib::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->query_fetch("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) {
                 Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_stay_not_on_enemy'] . "</b></font>", "game.php?page=movement", 2);
             }
         }
     }
     $missiontype = Fleets_Lib::get_missions();
     $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
     $AllFleetSpeed = Fleets_Lib::fleet_max_speed($fleetarray, 0, $this->_current_user);
     $GenFleetSpeed = $_POST['speed'];
     $SpeedFactor = Functions_Lib::fleet_speed_factor();
     $MaxFleetSpeed = min($AllFleetSpeed);
     if (!in_array($GenFleetSpeed, $speed_possible)) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     if ($MaxFleetSpeed != $_POST['speedallsmin']) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     if (!$_POST['planettype']) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     if (!$_POST['galaxy'] || !is_numeric($_POST['galaxy']) || $_POST['galaxy'] > MAX_GALAXY_IN_WORLD || $_POST['galaxy'] < 1) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     if (!$_POST['system'] || !is_numeric($_POST['system']) || $_POST['system'] > MAX_SYSTEM_IN_GALAXY || $_POST['system'] < 1) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     if (!$_POST['planet'] || !is_numeric($_POST['planet']) || $_POST['planet'] > MAX_PLANET_IN_SYSTEM + 1 || $_POST['planet'] < 1) {
         Functions_Lib::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']) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     if (!isset($fleetarray)) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     $distance = Fleets_Lib::target_distance($_POST['thisgalaxy'], $_POST['galaxy'], $_POST['thissystem'], $_POST['system'], $_POST['thisplanet'], $_POST['planet']);
     $duration = Fleets_Lib::mission_duration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor);
     $consumption = Fleets_Lib::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 {
             Functions_Lib::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) {
         Functions_Lib::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) {
         Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_no_enought_deuterium'] . Format_Lib::pretty_number($consumption) . "</b></font>", "game.php?page=movement", 2);
     }
     if ($StorageNeeded > $FleetStorage) {
         Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_no_enought_cargo_capacity'] . Format_Lib::pretty_number($StorageNeeded - $FleetStorage) . "</b></font>", "game.php?page=movement", 2);
     }
     if (Functions_Lib::read_config('adm_attack') != 0) {
         Functions_Lib::message($this->_lang['fl_admins_cannot_be_attacked'], "game.php?page=movement", 2);
     }
     if ($fleet_group_mr != 0) {
         $AksStartTime = parent::$db->query_fetch("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'] . ";");
     Functions_Lib::redirect('game.php?page=movement');
 }
Example #2
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     if (!isset($_POST) or empty($_POST)) {
         Functions_Lib::redirect('game.php?page=fleet1');
     }
     $resource = parent::$objects->get_objects();
     $pricelist = parent::$objects->get_price();
     $reslist = parent::$objects->get_objects_list();
     $lang = $this->_lang;
     #####################################################################################################
     // SOME DEFAULT VALUES
     #####################################################################################################
     // ARRAYS
     $exp_values = array(1, 2, 3, 4, 5);
     $hold_values = array(0, 1, 2, 4, 8, 16, 32);
     // LANG
     $this->_lang['js_path'] = XGP_ROOT . JS_PATH;
     $parse = $this->_lang;
     // LOAD TEMPLATES REQUIRED
     $mission_row_template = parent::$page->get_template('fleet/fleet3_mission_row');
     $input_template = parent::$page->get_template('fleet/fleet3_inputs');
     $stay_template = parent::$page->get_template('fleet/fleet3_stay_row');
     $options_template = parent::$page->get_template('fleet/fleet_options');
     // OTHER VALUES
     $galaxy = (int) $_POST['galaxy'];
     $system = (int) $_POST['system'];
     $planet = (int) $_POST['planet'];
     $planettype = (int) $_POST['planettype'];
     $fleet_acs = (int) $_POST['fleet_group'];
     $YourPlanet = FALSE;
     $UsedPlanet = FALSE;
     $MissionSelector = '';
     // QUERYS
     $select = parent::$db->query_fetch("SELECT `planet_user_id`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . PLANETS . "`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . $galaxy . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `planet_system` = '" . $system . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `planet_planet` = '" . $planet . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `planet_type` = '" . $planettype . "';");
     if ($select) {
         if ($select['planet_user_id'] == $this->_current_user['user_id']) {
             $YourPlanet = TRUE;
             $UsedPlanet = TRUE;
         } else {
             $UsedPlanet = TRUE;
         }
     }
     if ($_POST['planettype'] == 2) {
         if ($_POST['ship209'] >= 1) {
             $missiontype = array(8 => $this->_lang['type_mission'][8]);
         } else {
             $missiontype = array();
         }
     } elseif ($_POST['planettype'] == 1 or $_POST['planettype'] == 3) {
         if ($_POST['ship208'] >= 1 && !$UsedPlanet) {
             $missiontype = array(7 => $this->_lang['type_mission'][7]);
         } elseif ($_POST['ship210'] >= 1 && !$YourPlanet) {
             $missiontype = array(6 => $this->_lang['type_mission'][6]);
         }
         if ($_POST['ship202'] >= 1 or $_POST['ship203'] >= 1 or $_POST['ship204'] >= 1 or $_POST['ship205'] >= 1 or $_POST['ship206'] >= 1 or $_POST['ship207'] >= 1 or $_POST['ship210'] >= 1 or $_POST['ship211'] >= 1 or $_POST['ship213'] >= 1 or $_POST['ship214'] >= 1 or $_POST['ship215'] >= 1) {
             if (!$YourPlanet) {
                 $missiontype[1] = $this->_lang['type_mission'][1];
             }
             $missiontype[3] = $this->_lang['type_mission'][3];
             $missiontype[5] = $this->_lang['type_mission'][5];
         }
     } elseif ($_POST['ship209'] >= 1 or $_POST['ship208']) {
         $missiontype[3] = $this->_lang['type_mission'][3];
     }
     if ($YourPlanet) {
         $missiontype[4] = $this->_lang['type_mission'][4];
     }
     if ($_POST['planettype'] == 3 || $_POST['planettype'] == 1 && $fleet_acs > 0 && $UsedPlanet) {
         $acs = parent::$db->query_fetch("SELECT `acs_fleet_galaxy`, `acs_fleet_planet``, `acs_fleet_system`, `acs_fleet_planet_type`\r\n\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . ACS_FLEETS . "`\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `acs_fleet_id` = '" . $fleet_acs . "';");
         if ($acs['acs_fleet_galaxy'] == $galaxy && $acs['acs_fleet_planet'] == $planet && $acs['acs_fleet_system'] == $system && $acs['acs_fleet_planet_type'] == $planettype) {
             $missiontype[2] = $this->_lang['type_mission'][2];
         }
     }
     if ($_POST['planettype'] == 3 && $_POST['ship214'] >= 1 && !$YourPlanet && $UsedPlanet) {
         $missiontype[9] = $this->_lang['type_mission'][9];
     }
     $fleetarray = unserialize(base64_decode(str_rot13($_POST['usedfleet'])));
     $mission = $_POST['target_mission'];
     $SpeedFactor = $_POST['speedfactor'];
     $AllFleetSpeed = Fleets_Lib::fleet_max_speed($fleetarray, 0, $this->_current_user);
     $GenFleetSpeed = $_POST['speed'];
     $MaxFleetSpeed = min($AllFleetSpeed);
     $distance = Fleets_Lib::target_distance($_POST['thisgalaxy'], $_POST['galaxy'], $_POST['thissystem'], $_POST['system'], $_POST['thisplanet'], $_POST['planet']);
     $duration = Fleets_Lib::mission_duration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor);
     $consumption = Fleets_Lib::fleet_consumption($fleetarray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $this->_current_user);
     #####################################################################################################
     // INPUTS DATA
     #####################################################################################################
     $parse['metal'] = floor($this->_current_planet['planet_metal']);
     $parse['crystal'] = floor($this->_current_planet['planet_crystal']);
     $parse['deuterium'] = floor($this->_current_planet['planet_deuterium']);
     $parse['consumption'] = $consumption;
     $parse['distance'] = $distance;
     $parse['speedfactor'] = $_POST['speedfactor'];
     $parse['thisgalaxy'] = $_POST['thisgalaxy'];
     $parse['thissystem'] = $_POST['thissystem'];
     $parse['thisplanet'] = $_POST['thisplanet'];
     $parse['galaxy'] = $_POST['galaxy'];
     $parse['system'] = $_POST['system'];
     $parse['planet'] = $_POST['planet'];
     $parse['thisplanettype'] = $_POST['thisplanettype'];
     $parse['planettype'] = $_POST['planettype'];
     $parse['speedallsmin'] = $_POST['speedallsmin'];
     $parse['speed'] = $_POST['speed'];
     $parse['speedfactor'] = $_POST['speedfactor'];
     $parse['usedfleet'] = $_POST['usedfleet'];
     $parse['maxepedition'] = $_POST['maxepedition'];
     $parse['curepedition'] = $_POST['curepedition'];
     $parse['fleet_group'] = $_POST['fleet_group'];
     $parse['acs_target_mr'] = $_POST['acs_target_mr'];
     #####################################################################################################
     // EXTRA INPUTS
     #####################################################################################################
     $input_extra = '';
     foreach ($fleetarray as $Ship => $Count) {
         $input_parse['ship'] = $Ship;
         $input_parse['amount'] = $Count;
         $input_parse['capacity'] = $pricelist[$Ship]['capacity'];
         $input_parse['consumption'] = Fleets_Lib::ship_consumption($Ship, $this->_current_user);
         $input_parse['speed'] = Fleets_Lib::fleet_max_speed("", $Ship, $this->_current_user);
         $input_extra .= parent::$page->parse_template($input_template, $input_parse);
     }
     #####################################################################################################
     // TOP TABLE TITLE
     #####################################################################################################
     if ($_POST['thisplanettype'] == 1) {
         $parse['title'] = "" . $_POST['thisgalaxy'] . ":" . $_POST['thissystem'] . ":" . $_POST['thisplanet'] . " - " . $this->_lang['fl_planet'] . "";
     } elseif ($_POST['thisplanettype'] == 3) {
         $parse['title'] = "" . $_POST['thisgalaxy'] . ":" . $_POST['thissystem'] . ":" . $_POST['thisplanet'] . " - " . $this->_lang['fl_moon'] . "";
     }
     #####################################################################################################
     // MISSION TYPES
     #####################################################################################################
     if (count($missiontype) > 0) {
         if ($planet == 16) {
             $parse_mission['value'] = 15;
             $parse_mission['mission'] = $this->_lang['type_mission'][15];
             $parse_mission['expedition_message'] = $this->_lang['fl_expedition_alert_message'];
             $parse_mission['id'] = ' ';
             $parse_mission['checked'] = ' checked="checked"';
             $MissionSelector .= parent::$page->parse_template($mission_row_template, $parse_mission);
         } else {
             $i = 0;
             foreach ($missiontype as $a => $b) {
                 $parse_mission['value'] = $a;
                 $parse_mission['mission'] = $b;
                 $parse_mission['expedition_message'] = '';
                 $parse_mission['id'] = ' id="inpuT_' . $i . '" ';
                 $parse_mission['checked'] = $mission == $a ? ' checked="checked"' : '';
                 $i++;
                 $MissionSelector .= parent::$page->parse_template($mission_row_template, $parse_mission);
             }
         }
     } else {
         Functions_Lib::redirect('game.php?page=fleet1');
     }
     #####################################################################################################
     // STAY / EXPEDITION BLOCKS
     #####################################################################################################
     $stay_row['options'] = '';
     if ($planet == 16) {
         $stay_row['stay_type'] = 'expeditiontime';
         foreach ($exp_values as $value) {
             $stay['value'] = $value;
             $stay['selected'] = '';
             $stay['title'] = $value;
             $stay_row['options'] .= parent::$page->parse_template($options_template, $stay);
         }
         $StayBlock = parent::$page->parse_template($stay_template, array_merge($stay_row, $this->_lang));
     } elseif ($missiontype[5] != '') {
         $stay_row['stay_type'] = 'holdingtime';
         foreach ($hold_values as $value) {
             $stay['value'] = $value;
             $stay['selected'] = $value == 1 ? ' selected' : '';
             $stay['title'] = $value;
             $stay_row['options'] .= parent::$page->parse_template($options_template, $stay);
         }
         $StayBlock = parent::$page->parse_template($stay_template, array_merge($stay_row, $this->_lang));
     }
     $parse['input_extra'] = $input_extra;
     $parse['missionselector'] = $MissionSelector;
     $parse['stayblock'] = $StayBlock;
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('fleet/fleet3_table'), $parse));
 }