/** * 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(); ##################################################################################################### // SOME DEFAULT VALUES ##################################################################################################### // QUERYS $getCurrentAcs = parent::$db->query("SELECT *\n\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\tWHERE acs_fleet_members = '" . $this->_current_user['user_id'] . "'"); // ARRAYS $speed_values = array(10 => 100, 9 => 90, 8 => 80, 7 => 70, 6 => 60, 5 => 50, 4 => 40, 3 => 30, 2 => 20, 1 => 10); $planet_type = array('fl_planet', 'fl_debris', 'fl_moon'); // LOAD TEMPLATES REQUIRED $inputs_template = parent::$page->get_template('fleet/fleet2_inputs'); $options_template = parent::$page->get_template('fleet/fleet_options'); $shortcut_template = parent::$page->get_template('fleet/fleet2_shortcuts'); $shortcut_row_template = parent::$page->get_template('fleet/fleet2_shortcuts_row'); $shortcut_noshortcuts = parent::$page->get_template('fleet/fleet2_shortcuts_noshortcuts_row'); $shortcut_acs_row = parent::$page->get_template('fleet/fleet2_shortcut_acs_row'); // LANGUAGE $this->_lang['js_path'] = XGP_ROOT . JS_PATH; $parse = $this->_lang; // COORDS $g = $_POST['galaxy'] == '' ? $this->_current_planet['planet_galaxy'] : $_POST['galaxy']; $s = $_POST['system'] == '' ? $this->_current_planet['planet_system'] : $_POST['system']; $p = $_POST['planet'] == '' ? $this->_current_planet['planet_planet'] : $_POST['planet']; $t = $_POST['planet_type'] == '' ? $this->_current_planet['planet_type'] : $_POST['planet_type']; // OTHER VALUES $value = 0; $FleetHiddenBlock = ''; ##################################################################################################### // END DEFAULT VALUES ##################################################################################################### ##################################################################################################### // LOAD SHIPS INPUTS ##################################################################################################### $fleet['fleetlist'] = ''; $fleet['amount'] = 0; $fleet['consumption'] = 0; foreach ($reslist['fleet'] as $n => $i) { if (isset($_POST["ship{$i}"]) && $i >= 201 && $i <= 215 && $_POST["ship{$i}"] > "0") { if ($_POST["ship{$i}"] > $this->_current_planet[$resource[$i]] or !ctype_digit($_POST["ship{$i}"])) { FunctionsLib::redirect('game.php?page=fleet1'); } else { $fleet['fleetarray'][$i] = $_POST["ship{$i}"]; $fleet['fleetlist'] .= $i . "," . $_POST["ship{$i}"] . ";"; $fleet['amount'] += $_POST["ship{$i}"]; $fleet['i'] = $i; $fleet['consumption'] += FleetsLib::ship_consumption($i, $this->_current_user); $fleet['speed'] = FleetsLib::fleet_max_speed('', $i, $this->_current_user); $fleet['capacity'] = $pricelist[$i]['capacity']; $fleet['ship'] = $_POST["ship{$i}"]; $speedalls[$i] = FleetsLib::fleet_max_speed('', $i, $this->_current_user); $FleetHiddenBlock .= parent::$page->parse_template($inputs_template, $fleet); } } } if (!$fleet['fleetlist']) { FunctionsLib::redirect('game.php?page=fleet1'); } else { $speedallsmin = min($speedalls); } ##################################################################################################### // LOAD PLANET TYPES OPTIONS ##################################################################################################### $parse['options_planettype'] = ''; foreach ($planet_type as $type) { $value++; $options['value'] = $value; if ($value == $t) { $options['selected'] = 'SELECTED'; } else { $options['selected'] = ''; } $options['title'] = $this->_lang[$type]; $parse['options_planettype'] .= parent::$page->parse_template($options_template, $options); } ##################################################################################################### // LOAD SPEED OPTIONS ##################################################################################################### $parse['options'] = ''; foreach ($speed_values as $value => $porcentage) { $speed_porcentage['value'] = $value; $speed_porcentage['selected'] = ''; $speed_porcentage['title'] = $porcentage; $parse['options'] .= parent::$page->parse_template($options_template, $speed_porcentage); } ##################################################################################################### // PARSE THE REST OF THE OPTIONS ##################################################################################################### $parse['fleetblock'] = $FleetHiddenBlock; $parse['speedallsmin'] = $speedallsmin; $parse['fleetarray'] = str_rot13(base64_encode(serialize($fleet['fleetarray']))); $parse['galaxy'] = $this->_current_planet['planet_galaxy']; $parse['system'] = $this->_current_planet['planet_system']; $parse['planet'] = $this->_current_planet['planet_planet']; $parse['galaxy_post'] = (int) $_POST['galaxy']; $parse['system_post'] = (int) $_POST['system']; $parse['planet_post'] = (int) $_POST['planet']; $parse['speedfactor'] = FunctionsLib::fleet_speed_factor(); $parse['planet_type'] = $this->_current_planet['planet_type']; $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['g'] = $g; $parse['s'] = $s; $parse['p'] = $p; ##################################################################################################### // LOAD FLEET SHORTCUTS ##################################################################################################### if (OfficiersLib::isOfficierActive($this->_current_user['premium_officier_commander'])) { if ($this->_current_user['user_fleet_shortcuts']) { $scarray = explode(";", $this->_current_user['user_fleet_shortcuts']); foreach ($scarray as $a => $b) { if ($b != "") { $c = explode(',', $b); $shortcut['description'] = $c[0] . " " . $c[1] . ":" . $c[2] . ":" . $c[3] . " "; switch ($c[4]) { case 1: $shortcut['description'] .= $this->_lang['fl_planet_shortcut']; break; case 2: $shortcut['description'] .= $this->_lang['fl_debris_shortcut']; break; case 3: $shortcut['description'] .= $this->_lang['fl_moon_shortcut']; break; default: $shortcut['description'] .= ''; break; } $shortcut['select'] = 'shortcuts'; $shortcut['selected'] = ''; $shortcut['value'] = $c['1'] . ';' . $c['2'] . ';' . $c['3'] . ';' . $c['4']; $shortcut['title'] = $shortcut['description']; $shortcut['shortcut_options'] .= parent::$page->parse_template($options_template, $shortcut); } } $parse['shortcuts_rows'] = parent::$page->parse_template($shortcut_row_template, $shortcut); $parse['shortcut'] = parent::$page->parse_template($shortcut_template, $parse); } else { $parse['fl_shorcut_message'] = $this->_lang['fl_no_shortcuts']; $parse['shortcuts_rows'] = parent::$page->parse_template($shortcut_noshortcuts, $parse); $parse['shortcut'] = parent::$page->parse_template($shortcut_template, $parse); } } ##################################################################################################### // LOAD COLONY SHORTCUTS ##################################################################################################### $colony['select'] = 'colonies'; $colony['shortcut_options'] = FunctionsLib::build_planet_list($this->_current_user, $this->_current_planet['planet_id']); $parse['colonylist'] = parent::$page->parse_template($shortcut_row_template, $colony); if ($colony['shortcut_options'] === FALSE) { $parse['fl_shorcut_message'] = $this->_lang['fl_no_colony']; $parse['colonylist'] = parent::$page->parse_template($shortcut_noshortcuts, $parse); } ##################################################################################################### // LOAD SAC SHORTCUTS ##################################################################################################### $acs_fleets = ''; while ($row = parent::$db->fetchArray($getCurrentAcs)) { $members = explode(",", $row['acs_fleet_invited']); foreach ($members as $a => $b) { if ($b == $this->_current_user['user_id']) { $acs['galaxy'] = $row['acs_fleet_galaxy']; $acs['system'] = $row['acs_fleet_system']; $acs['planet'] = $row['acs_fleet_planet']; $acs['planet_type'] = $row['acs_fleet_planet_type']; $acs['id'] = $row['acs_fleet_id']; $acs['name'] = $row['acs_fleet_name']; $acs_fleets .= parent::$page->parse_template($shortcut_acs_row, $acs); } } } $parse['asc'] = $acs_fleets; $parse['maxepedition'] = $_POST['maxepedition']; $parse['curepedition'] = $_POST['curepedition']; $parse['target_mission'] = $_POST['target_mission']; parent::$page->display(parent::$page->parse_template(parent::$page->get_template('fleet/fleet2_table'), $parse)); }
/** * method send_fleet * param * return send fleet routine */ private function send_fleet() { $max_spy_probes = $this->_current_user['setting_probes_amount']; $UserSpyProbes = $this->_current_planet['ship_espionage_probe']; $UserRecycles = $this->_current_planet['ship_recycler']; $UserDeuterium = $this->_current_planet['planet_deuterium']; $UserMissiles = $this->_current_planet['defense_interplanetary_missile']; $fleet = array(); $speedalls = array(); $PartialFleet = FALSE; $PartialCount = 0; $order = isset($_POST['order']) ? $_POST['order'] : NULL; $ResultMessage = ''; $fleet['fleetlist'] = ''; $fleet['amount'] = ''; switch ($order) { case 6: $_POST['ship210'] = $_POST['shipcount']; break; case 7: $_POST['ship208'] = $_POST['shipcount']; break; case 8: $_POST['ship209'] = $_POST['shipcount']; break; } foreach ($this->_reslist['fleet'] as $Node => $ShipID) { $TName = "ship" . $ShipID; if (isset($_POST[$TName]) && $ShipID > 200 && $ShipID < 300 && $_POST[$TName] > 0) { if ($_POST[$TName] > $this->_current_planet[$this->_resource[$ShipID]]) { $fleet['fleetarray'][$ShipID] = $this->_current_planet[$this->_resource[$ShipID]]; $fleet['fleetlist'] .= $ShipID . "," . $this->_current_planet[$this->_resource[$ShipID]] . ";"; $fleet['amount'] += $this->_current_planet[$this->_resource[$ShipID]]; $PartialCount += $this->_current_planet[$this->_resource[$ShipID]]; $PartialFleet = TRUE; } else { $fleet['fleetarray'][$ShipID] = $_POST[$TName]; $fleet['fleetlist'] .= $ShipID . "," . $_POST[$TName] . ";"; $fleet['amount'] += $_POST[$TName]; $speedalls[$ShipID] = $_POST[$TName]; } } } $errors_types = array(600 => $this->_lang['gl_success'], 601 => $this->_lang['gl_error'], 602 => $this->_lang['gl_no_moon'], 603 => $this->_lang['gl_noob_protection'], 604 => $this->_lang['gl_too_strong'], 605 => $this->_lang['gl_vacation_mode'], 610 => $this->_lang['gl_only_amount_ships'], 611 => $this->_lang['gl_no_ships'], 612 => $this->_lang['gl_no_slots'], 613 => $this->_lang['gl_no_deuterium'], 614 => $this->_lang['gl_no_planet'], 615 => $this->_lang['gl_not_enough_storage'], 616 => $this->_lang['gl_multi_alarm']); if ($PartialFleet == TRUE) { if ($PartialCount < 1) { die("611 "); } } $galaxy = isset($_POST['galaxy']) ? (int) $_POST['galaxy'] : 0; $system = isset($_POST['system']) ? (int) $_POST['system'] : 0; $planet = isset($_POST['planet']) ? (int) $_POST['planet'] : 0; $FleetArray = isset($fleet['fleetarray']) ? $fleet['fleetarray'] : NULL; if ($galaxy > MAX_GALAXY_IN_WORLD or $galaxy < 1 or ($system > MAX_SYSTEM_IN_GALAXY or $system < 1) or ($planet > MAX_PLANET_IN_SYSTEM or $planet < 1) or is_null($FleetArray)) { die("614 "); } $CurrentFlyingFleets = parent::$db->queryFetch("SELECT COUNT(fleet_id) AS `Nbre`\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'] . "';"); $CurrentFlyingFleets = $CurrentFlyingFleets['Nbre']; $TargetRow = parent::$db->queryFetch("SELECT *\n\t\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\tWHERE `planet_galaxy` = '" . parent::$db->escapeValue($_POST['galaxy']) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . parent::$db->escapeValue($_POST['system']) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . parent::$db->escapeValue($_POST['planet']) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = '" . parent::$db->escapeValue($_POST['planettype']) . "';"); if ($TargetRow['planet_user_id'] == '') { $TargetUser = $this->_current_user; } elseif ($TargetRow['planet_user_id'] != '') { $TargetUser = parent::$db->queryFetch("SELECT u.`user_id`, u.`user_onlinetime`, u.`user_authlevel`, s.`setting_vacations_status`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . " AS u\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . SETTINGS . " AS s ON s.setting_user_id = u.user_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `user_id` = '" . $TargetRow['planet_user_id'] . "';"); } // invisible debris by jstar if ($order == 8) { $TargetGPlanet = parent::$db->queryFetch("SELECT planet_invisible_start_time, planet_debris_metal, planet_debris_crystal\n\t\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\tWHERE planet_galaxy = '" . parent::$db->escapeValue($_POST['galaxy']) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tplanet_system = '" . parent::$db->escapeValue($_POST['system']) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tplanet_planet = '" . parent::$db->escapeValue($_POST['planet']) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tplanet_type = 1;"); if ($TargetGPlanet['planet_debris_metal'] == 0 && $TargetGPlanet['planet_debris_crystal'] == 0 && time() > $TargetGPlanet['planet_invisible_start_time'] + DEBRIS_LIFE_TIME) { die; } } $user_points = $this->_noob->return_points($this->_current_user['user_id'], $TargetUser['user_id']); $CurrentPoints = $user_points['user_points']; $TargetPoints = $user_points['target_points']; $TargetVacat = $TargetUser['setting_vacations_status']; if (FleetsLib::get_max_fleets($this->_current_user[$this->_resource[108]], $this->_current_user['premium_officier_admiral']) <= $CurrentFlyingFleets) { die("612 "); } if (!is_array($FleetArray)) { die("611 "); } if (!($order == 6 or $order == 8)) { die("601 "); } if ($TargetVacat && $order != 8 or $this->_current_user['setting_vacations_status']) { die("605 "); } if ($TargetUser['user_onlinetime'] >= time() - 60 * 60 * 24 * 7) { if ($this->_noob->is_weak($CurrentPoints, $TargetPoints) && $TargetRow['planet_user_id'] != '' && $order == 6) { die("603 "); } if ($this->_noob->is_strong($CurrentPoints, $TargetPoints) && $TargetRow['planet_user_id'] != '' && $order == 6) { die("604 "); } } if ($TargetRow['planet_user_id'] == '' && $order != 8) { die("601 "); } if ($TargetRow['planet_user_id'] == $this->_current_planet['planet_user_id'] && $order == 6) { die("601 "); } $Distance = FleetsLib::target_distance($this->_current_planet['planet_galaxy'], $_POST['galaxy'], $this->_current_planet['planet_system'], $_POST['system'], $this->_current_planet['planet_planet'], $_POST['planet']); $speedall = FleetsLib::fleet_max_speed($FleetArray, 0, $this->_current_user); $SpeedAllMin = min($speedall); $Duration = FleetsLib::mission_duration(10, $SpeedAllMin, $Distance, FunctionsLib::fleet_speed_factor()); $fleet['fly_time'] = $Duration; $fleet['start_time'] = $Duration + time(); $fleet['end_time'] = $Duration * 2 + time(); $FleetShipCount = 0; $FleetDBArray = ""; $FleetSubQRY = ""; $consumption = 0; $SpeedFactor = FunctionsLib::fleet_speed_factor(); foreach ($FleetArray as $Ship => $Count) { if ($Ship != '') { $ShipSpeed = $this->_pricelist[$Ship]['speed']; $spd = 35000 / ($Duration * $SpeedFactor - 10) * sqrt($Distance * 10 / $ShipSpeed); $basicConsumption = $this->_pricelist[$Ship]['consumption'] * $Count; $consumption += $basicConsumption * $Distance / 35000 * ($spd / 10 + 1) * ($spd / 10 + 1); $FleetShipCount += $Count; $FleetDBArray .= $Ship . "," . $Count . ";"; $FleetSubQRY .= "`" . $this->_resource[$Ship] . "` = `" . $this->_resource[$Ship] . "` - " . $Count . " , "; } } $consumption = round($consumption) + 1; if ($UserDeuterium < $consumption) { die("613 "); } if (FunctionsLib::read_config('adm_attack') == 1 && $TargetUser['user_authlevel'] > 0) { die("601 "); } parent::$db->query("INSERT INTO " . FLEETS . " SET\n\t\t\t\t\t\t\t\t`fleet_owner` = '" . $this->_current_user['user_id'] . "',\n\t\t\t\t\t\t\t\t`fleet_mission` = '" . intval($order) . "',\n\t\t\t\t\t\t\t\t`fleet_amount` = '" . $FleetShipCount . "',\n\t\t\t\t\t\t\t\t`fleet_array` = '" . $FleetDBArray . "',\n\t\t\t\t\t\t\t\t`fleet_start_time` = '" . $fleet['start_time'] . "',\n\t\t\t\t\t\t\t\t`fleet_start_galaxy` = '" . $this->_current_planet['planet_galaxy'] . "',\n\t\t\t\t\t\t\t\t`fleet_start_system` = '" . $this->_current_planet['planet_system'] . "',\n\t\t\t\t\t\t\t\t`fleet_start_planet` = '" . $this->_current_planet['planet_planet'] . "',\n\t\t\t\t\t\t\t\t`fleet_start_type` = '" . $this->_current_planet['planet_type'] . "',\n\t\t\t\t\t\t\t\t`fleet_end_time` = '" . $fleet['end_time'] . "',\n\t\t\t\t\t\t\t\t`fleet_end_galaxy` = '" . intval($_POST['galaxy']) . "',\n\t\t\t\t\t\t\t\t`fleet_end_system` = '" . intval($_POST['system']) . "',\n\t\t\t\t\t\t\t\t`fleet_end_planet` = '" . intval($_POST['planet']) . "',\n\t\t\t\t\t\t\t\t`fleet_end_type` = '" . intval($_POST['planettype']) . "',\n\t\t\t\t\t\t\t\t`fleet_target_owner` = '" . $TargetRow['planet_user_id'] . "',\n\t\t\t\t\t\t\t\t`fleet_creation` = '" . time() . "';"); $UserDeuterium -= $consumption; 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\tp.`planet_deuterium` = '" . ($UserDeuterium < 1 ? 0 : $UserDeuterium) . "'\n\t\t\t\t\t\t\t\tWHERE p.`planet_id` = '" . $this->_current_planet['planet_id'] . "';"); $CurrentFlyingFleets++; foreach ($FleetArray as $Ships => $Count) { if ($max_spy_probes > $this->_current_planet[$this->_resource[$Ships]]) { $ResultMessage = "610 " . $FleetShipCount; } } if ($ResultMessage == '') { $ResultMessage = "600 " . $Ships; } die($ResultMessage); }
/** * 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'); }