示例#1
0
 /**
  * method recycle_mission
  * param $fleet_row
  * return the recycle result
  */
 public function recycle_mission($fleet_row)
 {
     if ($fleet_row['fleet_mess'] == '0') {
         if ($fleet_row['fleet_start_time'] <= time()) {
             $recycled_resources = $this->calculate_capacity($fleet_row);
             parent::$db->query("UPDATE " . PLANETS . ", " . FLEETS . " SET\r\n\t\t\t\t\t\t\t\t\t\t`planet_debris_metal` = `planet_debris_metal` - '" . $recycled_resources['metal'] . "',\r\n\t\t\t\t\t\t\t\t\t\t`planet_debris_crystal` = `planet_debris_crystal` - '" . $recycled_resources['crystal'] . "',\r\n\t\t\t\t\t\t\t\t\t\t`fleet_resource_metal` = `fleet_resource_metal` + '" . $recycled_resources['metal'] . "',\r\n\t\t\t\t\t\t\t\t\t\t`fleet_resource_crystal` = `fleet_resource_crystal` + '" . $recycled_resources['crystal'] . "',\r\n\t\t\t\t\t\t\t\t\t\t`fleet_mess` = '1'\r\n\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . $fleet_row['fleet_end_galaxy'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . $fleet_row['fleet_end_system'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . $fleet_row['fleet_end_planet'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = 1 AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t`fleet_id` = '" . (int) $fleet_row['fleet_id'] . "'");
             $message = sprintf($this->_lang['sys_recy_gotten'], Format_Lib::pretty_number($recycled_resources['metal']), $this->_lang['Metal'], Format_Lib::pretty_number($recycled_resources['crystal']), $this->_lang['Crystal']);
             $this->recycle_message($fleet_row['fleet_owner'], $message, $fleet_row['fleet_start_time'], $this->_lang['sys_recy_report']);
         }
     } elseif ($fleet_row['fleet_end_time'] <= time()) {
         $message = sprintf($this->_lang['sys_tran_mess_owner'], $TargetName, Fleets_Lib::target_link($fleet_row, ''), Format_Lib::pretty_number($fleet_row['fleet_resource_metal']), $this->_lang['Metal'], Format_Lib::pretty_number($fleet_row['fleet_resource_crystal']), $this->_lang['Crystal'], Format_Lib::pretty_number($fleet_row['fleet_resource_deuterium']), $this->_lang['Deuterium']);
         $this->recycle_message($fleet_row['fleet_owner'], $message, $fleet_row['fleet_end_time'], $this->_lang['sys_mess_fleetback']);
         parent::restore_fleet($fleet_row, TRUE);
         parent::remove_fleet($fleet_row['fleet_id']);
     }
 }
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $parse = $this->_lang;
     $update = Functions_Lib::read_config('stat_last_update');
     $backup = Functions_Lib::read_config('last_backup');
     $cleanup = Functions_Lib::read_config('last_cleanup');
     $modules = explode(';', Functions_Lib::read_config('modules'));
     $count_modules = 0;
     // COUNT MODULES
     foreach ($modules as $module) {
         if ($module == 1) {
             $count_modules++;
         }
     }
     // LOAD STATISTICS
     $inactive_time = time() - 60 * 60 * 24 * 7;
     $users_count = parent::$db->query_fetch("SELECT (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT COUNT(user_id)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ) AS users_count,\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ( SELECT COUNT(user_id)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\tFROM " . USERS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\tWHERE user_onlinetime < {$inactive_time} AND user_onlinetime <> 0\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ) AS inactive_count,\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ( SELECT COUNT(setting_user_id)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\tFROM " . SETTINGS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\tWHERE setting_vacations_status <> 0\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ) AS on_vacation,\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ( SELECT COUNT(setting_user_id)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\tFROM " . SETTINGS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\tWHERE setting_delete_account <> 0\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ) AS to_delete,\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ( SELECT COUNT(user_id)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\tFROM " . USERS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\tWHERE user_banned <> 0\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ) AS banned_users,\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ( SELECT COUNT(fleet_id)\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 ) AS fleets_count");
     // LOAD STATISTICS
     $db_tables = parent::$db->query("SHOW TABLE STATUS");
     $db_size = 0;
     while ($row = parent::$db->fetch_array($db_tables)) {
         $db_size += $row['Data_length'] + $row['Index_length'];
     }
     // PARSE STATISTICS
     $parse['info_points'] = date(Functions_Lib::read_config('date_format_extended'), $update) . ' | ' . Format_Lib::pretty_time(time() - $update);
     $parse['info_backup'] = date(Functions_Lib::read_config('date_format_extended'), $backup) . ' | ' . Format_Lib::pretty_time(time() - $backup);
     $parse['info_cleanup'] = date(Functions_Lib::read_config('date_format_extended'), $cleanup) . ' | ' . Format_Lib::pretty_time(time() - $cleanup);
     $parse['info_modules'] = $count_modules . '/' . (count($modules) - 1);
     $parse['info_total_users'] = $users_count['users_count'];
     $parse['info_inactive_users'] = $users_count['inactive_count'];
     $parse['info_vacation_users'] = $users_count['on_vacation'];
     $parse['info_delete_mode_users'] = $users_count['to_delete'];
     $parse['info_banned_users'] = $users_count['banned_users'];
     $parse['info_flying_fleets'] = $users_count['fleets_count'];
     $parse['info_database_size'] = round($db_size / 1024, 1) . ' kb';
     $parse['info_database_server'] = 'MySQL ' . parent::$db->server_info();
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template("adm/information_view"), $parse));
 }
示例#3
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $resource = parent::$objects->get_objects();
     $reslist = parent::$objects->get_objects_list();
     $planetsrow = parent::$db->query("SELECT `planet_id`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_name`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_galaxy`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_image`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_field_current`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_field_max`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_metal`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_metal_perhour`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_crystal`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_crystal_perhour`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_deuterium`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_deuterium_perhour`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_energy_used`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_energy_max`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_metal_mine`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_crystal_mine`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_deuterium_sintetizer`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_solar_plant`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_fusion_reactor`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_robot_factory`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_nano_factory`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_hangar`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_metal_store`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_crystal_store`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_deuterium_tank`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_laboratory`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_terraformer`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_ally_deposit`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_missile_silo`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_mondbasis`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_phalanx`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_jump_gate`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_rocket_launcher`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_light_laser`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_heavy_laser`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_gauss_cannon`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_ion_cannon`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_plasma_turret`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_small_shield_dome`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_large_shield_dome`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_anti-ballistic_missile`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_interplanetary_missile`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_small_cargo_ship`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_big_cargo_ship`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_light_fighter`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_heavy_fighter`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_cruiser`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_battleship`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_colony_ship`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_recycler`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_espionage_probe`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_bomber`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_solar_satellite`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_destroyer`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_deathstar`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_battlecruiser`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . " AS p\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . BUILDINGS . " AS b ON b.building_planet_id = p.`planet_id`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . DEFENSES . " AS d ON d.defense_planet_id = p.`planet_id`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . SHIPS . " AS s ON s.ship_planet_id = p.`planet_id`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_user_id` = '" . (int) $this->_current_user['user_id'] . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `planet_destroyed` = 0;");
     $parse = $this->_lang;
     $planet = array();
     $r = array();
     $EmpireRowTPL = parent::$page->get_template('empire/empire_row');
     $f = array('file_images', 'file_names', 'file_coordinates', 'file_fields', 'file_metal', 'file_crystal', 'file_deuterium', 'file_energy');
     $m = array('build', 'tech', 'fleet', 'defense');
     $n = array('building_row', 'technology_row', 'fleet_row', 'defense_row');
     while ($p = parent::$db->fetch_array($planetsrow)) {
         $planet[] = $p;
     }
     $parse['mount'] = count($planet) + 1;
     foreach ($planet as $p) {
         $datat = array('<a href="game.php?page=overview&cp=' . $p['planet_id'] . '&amp;re=0"><img src="' . DPATH . 'planets/small/s_' . $p['planet_image'] . '.jpg" border="0" height="80" width="80"></a>', $p['planet_name'], "[<a href=\"game.php?page=galaxy&mode=3&galaxy={$p['planet_galaxy']}&system={$p['planet_system']}\">{$p['planet_galaxy']}:{$p['planet_system']}:{$p['planet_planet']}</a>]", $p['planet_field_current'] . '/' . $p['planet_field_max'], '<a href="game.php?page=resources&cp=' . $p['planet_id'] . '&amp;re=0&amp;planettype=' . $p['planet_type'] . '">' . Format_Lib::pretty_number($p['planet_metal']) . '</a> / ' . Format_Lib::pretty_number($p['planet_metal_perhour'] + Functions_Lib::read_config('metal_basic_income')), '<a href="game.php?page=resources&cp=' . $p['planet_id'] . '&amp;re=0&amp;planettype=' . $p['planet_type'] . '">' . Format_Lib::pretty_number($p['planet_crystal']) . '</a> / ' . Format_Lib::pretty_number($p['planet_crystal_perhour'] + Functions_Lib::read_config('crystal_basic_income')), '<a href="game.php?page=resources&cp=' . $p['planet_id'] . '&amp;re=0&amp;planettype=' . $p['planet_type'] . '">' . Format_Lib::pretty_number($p['planet_deuterium']) . '</a> / ' . Format_Lib::pretty_number($p['planet_deuterium_perhour'] + Functions_Lib::read_config('deuterium_basic_income')), Format_Lib::pretty_number($p['planet_energy_max'] - $p['planet_energy_used']) . ' / ' . Format_Lib::pretty_number($p['planet_energy_max']));
         for ($k = 0; $k < 8; $k++) {
             $parse[$f[$k]] = isset($parse[$f[$k]]) ? $parse[$f[$k]] : '';
             $data['text'] = $datat[$k];
             $parse[$f[$k]] .= parent::$page->parse_template($EmpireRowTPL, $data);
         }
         foreach ($resource as $i => $res) {
             $r[$i] = isset($r[$i]) ? $r[$i] : '';
             $data['text'] = !isset($p[$resource[$i]]) && !isset($this->_current_user[$resource[$i]]) ? '0' : (in_array($i, $reslist['build']) ? "<a href=\"game.php?page=" . Developments_Lib::set_building_page($i) . "&cp={$p['planet_id']}&amp;re=0&amp;planettype={$p['planet_type']}\">{$p[$resource[$i]]}</a>" : (in_array($i, $reslist['tech']) ? "<a href=\"game.php?page=research&cp={$p['planet_id']}&amp;re=0&amp;planettype={$p['planet_type']}\">{$this->_current_user[$resource[$i]]}</a>" : (in_array($i, $reslist['fleet']) ? "<a href=\"game.php?page=shipyard&cp={$p['planet_id']}&amp;re=0&amp;planettype={$p['planet_type']}\">{$p[$resource[$i]]}</a>" : (in_array($i, $reslist['defense']) ? "<a href=\"game.php?page=defense&cp={$p['planet_id']}&amp;re=0&amp;planettype={$p['planet_type']}\">{$p[$resource[$i]]}</a>" : '0'))));
             $r[$i] .= parent::$page->parse_template($EmpireRowTPL, $data);
         }
     }
     for ($j = 0; $j < 4; $j++) {
         foreach ($reslist[$m[$j]] as $a => $i) {
             $parse[$n[$j]] = isset($parse[$n[$j]]) ? $parse[$n[$j]] : '';
             $data['text'] = $this->_lang['tech'][$i];
             $parse[$n[$j]] .= "<tr>" . parent::$page->parse_template($EmpireRowTPL, $data) . $r[$i] . "</tr>";
         }
     }
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('empire/empire_table'), $parse), FALSE);
 }
示例#4
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $parse = $this->_lang;
     $page = '';
     $header_template = parent::$page->get_template('techtree/techtree_head');
     $row_template = parent::$page->get_template('techtree/techtree_row');
     foreach ($this->_lang['tech'] as $element => $element_name) {
         if ($element < 600) {
             $parse['tt_name'] = $element_name;
             if (!isset($this->_resource[$element])) {
                 $parse['Requirements'] = $this->_lang['tt_requirements'];
                 $page .= parent::$page->parse_template($header_template, $parse);
             } else {
                 if (isset($this->_requeriments[$element])) {
                     $list = '';
                     foreach ($this->_requeriments[$element] as $requirement => $level) {
                         if (isset($this->_current_user[$this->_resource[$requirement]]) && $this->_current_user[$this->_resource[$requirement]] >= $level) {
                             $list .= Format_Lib::color_green($this->set_level_format($level, $this->_lang['tech'][$requirement]));
                         } elseif (isset($this->_current_planet[$this->_resource[$requirement]]) && $this->_current_planet[$this->_resource[$requirement]] >= $level) {
                             $list .= Format_Lib::color_green($this->set_level_format($level, $this->_lang['tech'][$requirement]));
                         } else {
                             $list .= Format_Lib::color_red($this->set_level_format($level, $this->_lang['tech'][$requirement]));
                         }
                         $list .= '<br/>';
                     }
                     $parse['required_list'] = $list;
                 } else {
                     $parse['required_list'] = '';
                     $parse['tt_detail'] = '';
                 }
                 $parse['tt_info'] = $element;
                 $page .= parent::$page->parse_template($row_template, $parse);
             }
         }
     }
     $parse['techtree_list'] = $page;
     return parent::$page->display(parent::$page->parse_template(parent::$page->get_template('techtree/techtree_body'), $parse));
 }
示例#5
0
 /**
  * method deploy_mission
  * param $fleet_row
  * return the deploy result
  */
 public function deploy_mission($fleet_row)
 {
     if ($fleet_row['fleet_mess'] == 0) {
         if ($fleet_row['fleet_start_time'] <= time()) {
             $target_coords = sprintf($this->_lang['sys_adress_planet'], $fleet_row['fleet_end_galaxy'], $fleet_row['fleet_end_system'], $fleet_row['fleet_end_planet']);
             $target_resources = sprintf($this->_lang['sys_stay_mess_goods'], $this->_lang['Metal'], Format_Lib::pretty_number($fleet_row['fleet_resource_metal']), $this->_lang['Crystal'], Format_Lib::pretty_number($fleet_row['fleet_resource_crystal']), $this->_lang['Deuterium'], Format_Lib::pretty_number($fleet_row['fleet_resource_deuterium']));
             $target_message = $this->_lang['sys_stay_mess_start'] . "<a href=\"game.php?page=galaxy&mode=3&galaxy=" . $fleet_row['fleet_end_galaxy'] . "&system=" . $fleet_row['fleet_end_system'] . "\">";
             $target_message .= $target_coords . "</a>" . $this->_lang['sys_stay_mess_end'] . "<br />" . $target_resources;
             Functions_Lib::send_message($fleet_row['fleet_target_owner'], '', $fleet_row['fleet_start_time'], 5, $this->_lang['sys_mess_qg'], $this->_lang['sys_stay_mess_stay'], $target_message);
             parent::restore_fleet($fleet_row, FALSE);
             parent::remove_fleet($fleet_row['fleet_id']);
         }
     } else {
         if ($fleet_row['fleet_end_time'] <= time()) {
             $target_coords = sprintf($this->_lang['sys_adress_planet'], $fleet_row['fleet_start_galaxy'], $fleet_row['fleet_start_system'], $fleet_row['fleet_start_planet']);
             $target_resources = sprintf($this->_lang['sys_stay_mess_goods'], $this->_lang['Metal'], Format_Lib::pretty_number($fleet_row['fleet_resource_metal']), $this->_lang['Crystal'], Format_Lib::pretty_number($fleet_row['fleet_resource_crystal']), $this->_lang['Deuterium'], Format_Lib::pretty_number($fleet_row['fleet_resource_deuterium']));
             $target_message = $this->_lang['sys_stay_mess_back'] . "<a href=\"game.php?page=galaxy&mode=3&galaxy=" . $fleet_row['fleet_start_galaxy'] . "&system=" . $fleet_row['fleet_start_system'] . "\">";
             $target_message .= $target_coords . "</a>" . $this->_lang['sys_stay_mess_bend'] . "<br />" . $target_resources;
             Functions_Lib::send_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_end_time'], 5, $this->_lang['sys_mess_qg'], $this->_lang['sys_mess_fleetback'], $target_message);
             parent::restore_fleet($fleet_row, TRUE);
             parent::remove_fleet($fleet_row['fleet_id']);
         }
     }
 }
示例#6
0
 /**
  * method spy_target
  * param $target_data
  * param $mode
  * param $TitleString
  * return the spy result
  */
 private function spy_target($target_data, $mode, $TitleString)
 {
     $LookAtLoop = TRUE;
     $Count = 0;
     switch ($mode) {
         case 0:
             $String = "<table width=\"440\"><tr><td class=\"c\" colspan=\"5\">";
             $String .= $TitleString . " " . $target_data['planet_name'];
             $String .= " <a href=\"game.php?page=galaxy&mode=3&galaxy=" . $target_data['planet_galaxy'] . "&system=" . $target_data['planet_system'] . "\">";
             $String .= "[" . $target_data['planet_galaxy'] . ":" . $target_data['planet_system'] . ":" . $target_data['planet_planet'] . "]</a>";
             $String .= $this->_lang['sys_the'] . date(Functions_Lib::read_config('date_format_extended'), time()) . "</td>";
             $String .= "</tr><tr>";
             $String .= "<td width=220>" . $this->_lang['Metal'] . "</td><td width=220 align=right>" . Format_Lib::pretty_number($target_data['planet_metal']) . "</td><td>&nbsp;</td>";
             $String .= "<td width=220>" . $this->_lang['Crystal'] . "</td></td><td width=220 align=right>" . Format_Lib::pretty_number($target_data['planet_crystal']) . "</td>";
             $String .= "</tr><tr>";
             $String .= "<td width=220>" . $this->_lang['Deuterium'] . "</td><td width=220 align=right>" . Format_Lib::pretty_number($target_data['planet_deuterium']) . "</td><td>&nbsp;</td>";
             $String .= "<td width=220>" . $this->_lang['Energy'] . "</td><td width=220 align=right>" . Format_Lib::pretty_number($target_data['planet_energy_max']) . "</td>";
             $String .= "</tr>";
             $LookAtLoop = FALSE;
             break;
         case 1:
             $ResFrom[0] = 200;
             $ResTo[0] = 299;
             $Loops = 1;
             break;
         case 2:
             $ResFrom[0] = 400;
             $ResTo[0] = 499;
             $ResFrom[1] = 500;
             $ResTo[1] = 599;
             $Loops = 2;
             break;
         case 3:
             $ResFrom[0] = 1;
             $ResTo[0] = 99;
             $Loops = 1;
             break;
         case 4:
             $ResFrom[0] = 100;
             $ResTo[0] = 199;
             $Loops = 1;
             break;
     }
     if ($LookAtLoop == TRUE) {
         $String = "<table width=\"440\" cellspacing=\"1\"><tr><td class=\"c\" colspan=\"" . (2 * 2 + (2 - 1)) . "\">" . $TitleString . "</td></tr>";
         $Count = 0;
         $CurrentLook = 0;
         while ($CurrentLook < $Loops) {
             $row = 0;
             for ($Item = $ResFrom[$CurrentLook]; $Item <= $ResTo[$CurrentLook]; $Item++) {
                 if (isset($this->_resource[$Item]) && $target_data[$this->_resource[$Item]] > 0) {
                     if ($row == 0) {
                         $String .= "<tr>";
                     }
                     $String .= "<td align=left>" . $this->_lang['tech'][$Item] . "</td><td align=right>" . $target_data[$this->_resource[$Item]] . "</td>";
                     if ($row < 2 - 1) {
                         $String .= "<td>&nbsp;</td>";
                     }
                     $Count += $target_data[$this->_resource[$Item]];
                     $row++;
                     if ($row == 2) {
                         $String .= "</tr>";
                         $row = 0;
                     }
                 }
             }
             while ($row != 0) {
                 $String .= "<td>&nbsp;</td><td>&nbsp;</td>";
                 $row++;
                 if ($row == 2) {
                     $String .= "</tr>";
                     $row = 0;
                 }
             }
             $CurrentLook++;
         }
     }
     $String .= "</table>";
     $return['String'] = $String;
     $return['Count'] = $Count;
     return $return;
 }
示例#7
0
 /**
  * method do_command
  * param $have_fields
  * param $full_queue
  * param $building
  * param $queue
  * return (string) $action
  */
 private function set_action_button($have_fields, $full_queue, $building, $queue)
 {
     // all field occupied
     $action = Format_Lib::color_red($this->_lang['bd_no_more_fields']);
     // with fields
     if ($have_fields && !$full_queue) {
         if ($queue['lenght'] == 0) {
             if (Developments_Lib::is_development_payable($this->_current_user, $this->_current_planet, $building, TRUE, FALSE) && !parent::$users->is_on_vacations($this->_current_user)) {
                 $action = Functions_Lib::set_url('game.php?page=' . $this->_current_page . '&cmd=insert&building=' . $building, '', Format_Lib::color_green($this->_lang['bd_build']));
             } else {
                 $action = Format_Lib::color_red($this->_lang['bd_build']);
             }
         } else {
             $action = Functions_Lib::set_url('game.php?page=' . $this->_current_page . '&cmd=insert&building=' . $building, '', Format_Lib::color_green($this->_lang['bd_add_to_list']));
         }
     }
     if ($have_fields && $full_queue) {
         $action = Format_Lib::color_red($this->_lang['bd_build']);
     }
     if ($building == 31 && Developments_Lib::is_lab_working($this->_current_user) or ($building == 21 or $building == 14 or $building == 15) && Developments_Lib::is_shipyard_working($this->_current_planet)) {
         $action = Format_Lib::color_red($this->_lang['bd_working']);
     }
     return $action;
 }
示例#8
0
 /**
  * method attack_mission
  * param $fleet_row
  * return the attack result
  */
 public function attack_mission($fleet_row)
 {
     // null == use default handlers
     $errorHandler = null;
     $exceptionHandler = null;
     if ($fleet_row['fleet_mess'] == 0 && $fleet_row['fleet_start_time'] <= time()) {
         $base = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR;
         require $base . 'utils' . DIRECTORY_SEPARATOR . 'includer.php';
         $target_planet = parent::$db->query_fetch("SELECT *\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\tINNER JOIN " . BUILDINGS . " AS b ON b.building_planet_id = p.`planet_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . SHIPS . " AS s ON s.ship_planet_id = p.`planet_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . DEFENSES . " AS d ON d.defense_planet_id = p.`planet_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = " . (int) $fleet_row['fleet_end_galaxy'] . " AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = " . (int) $fleet_row['fleet_end_system'] . " AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = " . (int) $fleet_row['fleet_end_type'] . " AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = " . (int) $fleet_row['fleet_end_planet'] . ";");
         if ($fleet_row['fleet_group'] > 0) {
             parent::$db->query("DELETE FROM `" . ACS_FLEETS . "`\n\t\t\t\t\t\t\t\t\t\tWHERE `acs_fleet_id` = '" . (int) $fleet_row['fleet_group'] . "'");
             parent::$db->query("UPDATE `" . FLEETS . "` SET\n\t\t\t\t\t\t\t\t\t\t`fleet_mess` = '1'\n\t\t\t\t\t\t\t\t\t\tWHERE `fleet_group` = '" . $fleet_row['fleet_group'] . "'");
         } else {
             parent::return_fleet($fleet_row['fleet_id']);
         }
         $target_user = doquery('SELECT * FROM {{table}} WHERE id=' . $target_planet['id_owner'], 'users', true);
         $target_userID = $target_user['id'];
         PlanetResourceUpdate($target_user, $target_planet, time());
         // attackers fleet sum
         $attackers = new PlayerGroup();
         if ($fleet_row['fleet_group'] != 0) {
             $fleets = doquery('SELECT * FROM {{table}} WHERE fleet_group=' . $fleet_row['fleet_group'], 'fleets');
             $attackers = get_player_group_from_query($fleets);
         } else {
             $attackers = get_player_group($fleet_row);
         }
         //defenders fleet sum
         $def = doquery('SELECT * FROM {{table}} WHERE `fleet_end_galaxy` = ' . $fleet_row['fleet_end_galaxy'] . ' AND `fleet_end_system` = ' . $fleet_row['fleet_end_system'] . ' AND `fleet_end_type` = ' . $fleet_row['fleet_end_type'] . ' AND `fleet_end_planet` = ' . $fleet_row['fleet_end_planet'] . ' AND fleet_start_time<' . time() . ' AND fleet_end_stay>=' . time(), 'fleets');
         $defenders = get_player_group_from_query($def, true, $target_user);
         //defenses sum
         $homeFleet = new HomeFleet(0);
         for ($i = self::DEFENSE_MIN_ID; $i < self::DEFENSE_MAX_ID; $i++) {
             if (isset($this->_resource[$i]) && isset($target_planet[$this->_resource[$i]])) {
                 if ($target_planet[$this->_resource[$i]] != 0) {
                     $homeFleet->add(get_ship_type($i, $target_planet[$this->_resource[$i]]));
                 }
             }
         }
         for ($i = self::SHIP_MIN_ID; $i < self::SHIP_MAX_ID; $i++) {
             if (isset($this->_resource[$i]) && isset($target_planet[$this->_resource[$i]])) {
                 if ($target_planet[$this->_resource[$i]] != 0) {
                     $homeFleet->add(get_ship_type($i, $target_planet[$this->_resource[$i]]));
                 }
             }
         }
         if (!$defenders->existPlayer($target_userID)) {
             $player = new Player($target_userID, array($homeFleet));
             $player->setTech($target_user['military_tech'], $target_user['shield_tech'], $target_user['defence_tech']);
             $defenders->addPlayer($player);
         } else {
             $defenders->getPlayer($target_userID)->addDefense($homeFleet);
         }
         //start of battle
         $battle = new Battle($attackers, $defenders);
         $startBattle = DebugManager::runDebugged(array($battle, 'startBattle'), $errorHandler, $exceptionHandler);
         $startBattle();
         //end of battle
         $report = $battle->getReport();
         $steal = $this->update_attackers($report->getPresentationAttackersFleetOnRound('START'), $report->getAfterBattleAttackers(), $target_planet);
         $this->update_defenders($report->getPresentationDefendersFleetOnRound('START'), $report->getAfterBattleDefenders(), $target_planet, $steal);
         $this->updateDebris($fleet_row, $report);
         $this->update_moon($fleet_row, $report, '', $target_userID, $target_planet);
         $this->send_message($fleet_row, $report);
     } elseif ($fleet_row['fleet_end_time'] <= time()) {
         $message = sprintf($this->_lang['sys_fleet_won'], $target_planet['planet_name'], Fleets_Lib::target_link($fleet_row, ''), Format_Lib::pretty_number($fleet_row['fleet_resource_metal']), $this->_lang['Metal'], Format_Lib::pretty_number($fleet_row['fleet_resource_crystal']), $this->_lang['Crystal'], Format_Lib::pretty_number($fleet_row['fleet_resource_deuterium']), $this->_lang['Deuterium']);
         Functions_Lib::send_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_end_time'], 1, $this->_lang['sys_mess_tower'], $this->_lang['sys_mess_fleetback'], $message);
         parent::restore_fleet($fleet_row);
         parent::remove_fleet($fleet_row['fleet_id']);
     }
 }
    /**
     * method build_page
     * param
     * return the statistics page
     */
    private function build_page()
    {
        $parse = $this->_lang;
        $who = isset($_POST['who']) ? $_POST['who'] : (isset($_GET['who']) ? $_GET['who'] : 1);
        $type = isset($_POST['type']) ? $_POST['type'] : (isset($_GET['type']) ? $_GET['type'] : 1);
        $range = isset($_POST['range']) ? $_POST['range'] : (isset($_GET['range']) ? $_GET['range'] : 1);
        $parse['who'] = "<option value=\"1\"" . ($who == "1" ? " SELECTED" : "") . ">" . $this->_lang['st_player'] . "</option>";
        $parse['who'] .= "<option value=\"2\"" . ($who == "2" ? " SELECTED" : "") . ">" . $this->_lang['st_alliance'] . "</option>";
        $parse['type'] = "<option value=\"1\"" . ($type == "1" ? " SELECTED" : "") . ">" . $this->_lang['st_points'] . "</option>";
        $parse['type'] .= "<option value=\"2\"" . ($type == "2" ? " SELECTED" : "") . ">" . $this->_lang['st_fleets'] . "</option>";
        $parse['type'] .= "<option value=\"3\"" . ($type == "3" ? " SELECTED" : "") . ">" . $this->_lang['st_researh'] . "</option>";
        $parse['type'] .= "<option value=\"4\"" . ($type == "4" ? " SELECTED" : "") . ">" . $this->_lang['st_buildings'] . "</option>";
        $parse['type'] .= "<option value=\"5\"" . ($type == "5" ? " SELECTED" : "") . ">" . $this->_lang['st_defenses'] . "</option>";
        $data = $this->ranking_type($type);
        $Order = $data['order'];
        $Points = $data['points'];
        $Rank = $data['rank'];
        $OldRank = $data['oldrank'];
        if ($who == 2) {
            $MaxAllys = parent::$db->query_fetch("SELECT COUNT(`alliance_id`) AS `count`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . ALLIANCE . ";");
            $parse['range'] = $this->build_range_list($MaxAllys['count'], $range);
            $parse['stat_header'] = parent::$page->parse_template(parent::$page->get_template('stat/stat_alliancetable_header'), $parse);
            $start = floor($range / 100 % 100) * 100;
            $query = parent::$db->query('SELECT s.*,
																	a.alliance_id,
																	a.alliance_tag,
																	a.alliance_name,
																	a.alliance_request_notallow,
																	(SELECT COUNT(user_id) AS `ally_members` FROM `' . USERS . '` WHERE `user_ally_id` = a.`alliance_id`) AS `ally_members`
																FROM ' . ALLIANCE_STATISTICS . ' AS s
																INNER JOIN  ' . ALLIANCE . ' AS a ON a.alliance_id = s.alliance_statistic_alliance_id
																ORDER BY `alliance_statistic_' . $Order . '` DESC, `alliance_statistic_total_rank` ASC
																LIMIT ' . $start . ',100;');
            $start++;
            $parse['stat_date'] = date(Functions_Lib::read_config('date_format_extended'), Functions_Lib::read_config('stat_last_update'));
            $parse['stat_values'] = "";
            $StatAllianceTableTPL = parent::$page->get_template('stat/stat_alliancetable');
            while ($StatRow = parent::$db->fetch_assoc($query)) {
                $parse['ally_rank'] = $start;
                $ranking = $StatRow['alliance_statistic_' . $OldRank] - $StatRow['alliance_statistic_' . $Rank];
                $parse['ally_rankplus'] = $this->rank_difference($ranking);
                $parse['ally_id'] = $StatRow['alliance_id'];
                $parse['alliance_name'] = $StatRow['alliance_name'];
                $parse['ally_members'] = $StatRow['ally_members'];
                $parse['ally_action'] = $StatRow['alliance_request_notallow'] == 0 ? '<a href="game.php?page=alliance&mode=apply&allyid=' . $StatRow['alliance_id'] . '"><img src="' . DPATH . 'img/m.gif" border="0" title="' . $this->_lang['st_ally_request'] . '" /></a>' : '';
                $parse['ally_points'] = Format_Lib::pretty_number($StatRow['alliance_statistic_' . $Order]);
                $parse['ally_members_points'] = Format_Lib::pretty_number(floor($StatRow['alliance_statistic_' . $Order] / $StatRow['ally_members']));
                $parse['stat_values'] .= parent::$page->parse_template($StatAllianceTableTPL, $parse);
                $start++;
            }
        } else {
            $parse['range'] = $this->build_range_list($this->_current_planet['stats_users'], $range);
            $parse['stat_header'] = parent::$page->parse_template(parent::$page->get_template('stat/stat_playertable_header'), $parse);
            $start = floor($range / 100 % 100) * 100;
            $query = parent::$db->query('SELECT s.*, u.user_id, u.user_name, u.user_ally_id, a.alliance_name
												FROM ' . USERS_STATISTICS . ' as s
												INNER JOIN ' . USERS . ' as u ON u.user_id = s.user_statistic_user_id
												LEFT JOIN ' . ALLIANCE . ' AS a ON a.alliance_id = u.user_ally_id
												ORDER BY `user_statistic_' . $Order . '` DESC, `user_statistic_total_rank` ASC
												LIMIT ' . $start . ',100;');
            $start++;
            $parse['stat_date'] = date(Functions_Lib::read_config('date_format_extended'), Functions_Lib::read_config('stat_last_update'));
            $parse['stat_values'] = "";
            $previusId = 0;
            $StatPlayerTableTPL = parent::$page->get_template('stat/stat_playertable');
            while ($StatRow = parent::$db->fetch_assoc($query)) {
                $parse['player_rank'] = $start;
                $ranking = $StatRow['user_statistic_' . $OldRank] - $StatRow['user_statistic_' . $Rank];
                if ($StatRow['user_id'] == $this->_current_user['user_id']) {
                    $parse['player_name'] = "<font color=\"lime\">" . $StatRow['user_name'] . "</font>";
                } else {
                    $parse['player_name'] = $StatRow['user_name'];
                }
                if ($StatRow['user_id'] != $this->_current_user['user_id']) {
                    $parse['player_mes'] = '<a href="game.php?page=messages&mode=write&id=' . $StatRow['user_id'] . '"><img src="' . DPATH . 'img/m.gif" border="0" title="' . $this->_lang['write_message'] . '" /></a>';
                } else {
                    $parse['player_mes'] = "";
                }
                if ($StatRow['alliance_name'] != '') {
                    if ($StatRow['alliance_name'] == $this->_current_user['alliance_name']) {
                        $parse['player_alliance'] = '<a href="game.php?page=alliance&mode=ainfo&allyid=' . $StatRow['user_ally_id'] . '"><font color="#33CCFF">[' . $StatRow['alliance_name'] . ']</font></a>';
                    } else {
                        $parse['player_alliance'] = '<a href="game.php?page=alliance&mode=ainfo&allyid=' . $StatRow['user_ally_id'] . '">[' . $StatRow['alliance_name'] . ']</a>';
                    }
                } else {
                    $parse['player_alliance'] = '';
                }
                $parse['player_rankplus'] = $this->rank_difference($ranking);
                $parse['player_points'] = Format_Lib::pretty_number($StatRow['user_statistic_' . $Order]);
                $parse['stat_values'] .= parent::$page->parse_template($StatPlayerTableTPL, $parse);
                $start++;
            }
        }
        parent::$page->display(parent::$page->parse_template(parent::$page->get_template('stat/stat_body'), $parse));
    }
示例#10
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');
 }
示例#11
0
 /**
  * method get_user_rank
  * param
  * return the current user rank
  */
 private function get_user_rank()
 {
     $stats_available = Functions_Lib::read_config('stat');
     $user_rank = '-';
     $total_rank = $this->_current_user['user_statistic_total_rank'] == '' ? $this->_current_planet['stats_users'] : $this->_current_user['user_statistic_total_rank'];
     if ($stats_available && $this->_current_user['user_authlevel'] <= Functions_Lib::read_config('stat_level') or !$stats_available && $this->_current_user['user_authlevel'] == 0) {
         $user_rank = Format_Lib::pretty_number($this->_current_user['user_statistic_total_points']) . " (" . $this->_lang['ov_place'] . ' ' . Functions_Lib::set_url('game.php?page=statistics&range=' . $total_rank, $total_rank, $total_rank) . ' ' . $this->_lang['ov_of'] . ' ' . $this->_current_planet['stats_users'] . ")";
     }
     return $user_rank;
 }
示例#12
0
 private function ShowProductionTable($Template)
 {
     $BuildLevelFactor = $this->_current_planet['planet_' . $this->_resource[$this->_element_id] . '_porcent'];
     $BuildTemp = $this->_current_planet['planet_temp_max'];
     $CurrentBuildtLvl = $this->_current_planet[$this->_resource[$this->_element_id]];
     $BuildLevel = $CurrentBuildtLvl > 0 ? $CurrentBuildtLvl : 1;
     $BuildEnergy = $this->_current_user['research_energy_technology'];
     // BOOST
     $geologe_boost = 1 + 1 * (Officiers_Lib::is_officier_active($this->_current_user['premium_officier_geologist']) ? GEOLOGUE : 0);
     $engineer_boost = 1 + 1 * (Officiers_Lib::is_officier_active($this->_current_user['premium_officier_engineer']) ? ENGINEER_ENERGY : 0);
     // PRODUCTION FORMULAS
     $metal_prod = eval($this->_prod_grid[$this->_element_id]['formule']['metal']);
     $crystal_prod = eval($this->_prod_grid[$this->_element_id]['formule']['crystal']);
     $deuterium_prod = eval($this->_prod_grid[$this->_element_id]['formule']['deuterium']);
     $energy_prod = eval($this->_prod_grid[$this->_element_id]['formule']['energy']);
     // PRODUCTION
     $Prod[1] = ProductionLib::production_amount($metal_prod, $geologe_boost);
     $Prod[2] = ProductionLib::production_amount($crystal_prod, $geologe_boost);
     $Prod[3] = ProductionLib::production_amount($deuterium_prod, $geologe_boost);
     if ($this->_element_id >= 4) {
         $Prod[4] = ProductionLib::production_amount($energy_prod, $engineer_boost, TRUE);
         $ActualProd = floor($Prod[4]);
     } else {
         $Prod[4] = ProductionLib::production_amount($energy_prod, 1, TRUE);
         $ActualProd = floor($Prod[$this->_element_id]);
     }
     if ($this->_element_id != 12) {
         $ActualNeed = floor($Prod[4]);
     } else {
         $ActualNeed = floor($Prod[3]);
     }
     $BuildStartLvl = $CurrentBuildtLvl - 2;
     if ($BuildStartLvl < 1) {
         $BuildStartLvl = 1;
     }
     $Table = "";
     $ProdFirst = 0;
     for ($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 15; $BuildLevel++) {
         if ($this->_element_id != 42) {
             // PRODUCTION FORMULAS
             $metal_prod = eval($this->_prod_grid[$this->_element_id]['formule']['metal']);
             $crystal_prod = eval($this->_prod_grid[$this->_element_id]['formule']['crystal']);
             $deuterium_prod = eval($this->_prod_grid[$this->_element_id]['formule']['deuterium']);
             $energy_prod = eval($this->_prod_grid[$this->_element_id]['formule']['energy']);
             // PRODUCTION
             $Prod[1] = ProductionLib::production_amount($metal_prod, $geologe_boost);
             $Prod[2] = ProductionLib::production_amount($crystal_prod, $geologe_boost);
             $Prod[3] = ProductionLib::production_amount($deuterium_prod, $geologe_boost);
             if ($this->_element_id >= 4) {
                 $Prod[4] = ProductionLib::production_amount($energy_prod, $engineer_boost, TRUE);
             } else {
                 $Prod[4] = ProductionLib::production_amount($energy_prod, 1, TRUE);
             }
             $bloc['build_lvl'] = $CurrentBuildtLvl == $BuildLevel ? "<font color=\"#ff0000\">" . $BuildLevel . "</font>" : $BuildLevel;
             if ($ProdFirst > 0) {
                 if ($this->_element_id != 12) {
                     $bloc['build_gain'] = "<font color=\"lime\">(" . Format_Lib::pretty_number(floor($Prod[$this->_element_id] - $ProdFirst)) . ")</font>";
                 } else {
                     $bloc['build_gain'] = "<font color=\"lime\">(" . Format_Lib::pretty_number(floor($Prod[4] - $ProdFirst)) . ")</font>";
                 }
             } else {
                 $bloc['build_gain'] = "";
             }
             if ($this->_element_id != 12) {
                 $bloc['build_prod'] = Format_Lib::pretty_number(floor($Prod[$this->_element_id]));
                 $bloc['build_prod_diff'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($Prod[$this->_element_id] - $ActualProd)));
                 $bloc['build_need'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($Prod[4])));
                 $bloc['build_need_diff'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($Prod[4] - $ActualNeed)));
             } else {
                 $bloc['build_prod'] = Format_Lib::pretty_number(floor($Prod[4]));
                 $bloc['build_prod_diff'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($Prod[4] - $ActualProd)));
                 $bloc['build_need'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($Prod[3])));
                 $bloc['build_need_diff'] = Format_Lib::color_number(Format_Lib::pretty_number(floor($Prod[3] - $ActualNeed)));
             }
             if ($ProdFirst == 0) {
                 if ($this->_element_id != 12) {
                     $ProdFirst = floor($Prod[$this->_element_id]);
                 } else {
                     $ProdFirst = floor($Prod[4]);
                 }
             }
         } else {
             $bloc['build_lvl'] = $CurrentBuildtLvl == $BuildLevel ? "<font color=\"#ff0000\">" . $BuildLevel . "</font>" : $BuildLevel;
             $bloc['build_range'] = $BuildLevel * $BuildLevel - 1;
         }
         $Table .= parent::$page->parse_template($Template, $bloc);
     }
     return $Table;
 }
示例#13
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     if (isset($_GET['fleet']) && $_GET['fleet'] == 'true') {
         $this->send_fleet();
     }
     if (isset($_GET['missiles']) && $_GET['missiles'] == 'true') {
         $this->send_missiles();
     }
     $fleetmax = Fleets_Lib::get_max_fleets($this->_current_user['research_computer_technology'], $this->_current_user['premium_officier_admiral']);
     $CurrentPlID = $this->_current_planet['planet_id'];
     $CurrentSP = $this->_current_planet['ship_espionage_probe'];
     $maxfleet = parent::$db->query("SELECT `fleet_id`\r\n\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_owner` = '" . intval($this->_current_user['user_id']) . "';");
     $maxfleet_count = parent::$db->num_rows($maxfleet);
     if (!isset($mode)) {
         if (isset($_GET['mode'])) {
             $mode = intval($_GET['mode']);
         } else {
             $mode = 0;
         }
     }
     $setted_position = $this->validate_position($mode);
     $this->_galaxy = $setted_position['galaxy'];
     $this->_system = $setted_position['system'];
     $planet = $setted_position['planet'];
     $psystem = $setted_position['psystem'];
     // START FIX BY alivan
     if ($mode != 2) {
         if ($this->_current_planet['planet_system'] != $psystem - 1 && ($this->_current_planet['planet_system'] != isset($_GET['system']) or $this->_current_planet['planet_galaxy'] != isset($_GET['galaxy'])) && $mode != 0 && $this->_current_planet['planet_deuterium'] < 10) {
             die(Functions_Lib::message($this->_lang['gl_no_deuterium_to_view_galaxy'], "game.php?page=galaxy&mode=0", 2));
         } elseif ($this->_current_planet['planet_system'] != $psystem - 1 && ($this->_current_planet['planet_system'] != isset($_GET['system']) or $this->_current_planet['planet_galaxy'] != isset($_GET['galaxy'])) && $mode != 0) {
             $this->reduce_deuterium();
         }
     } elseif ($mode == 2 && $this->_current_planet['defense_interplanetary_missile'] < 1) {
         die(Functions_Lib::message($this->_lang['ma_no_missiles'], "game.php?page=galaxy&mode=0", 2));
     }
     // END FIX BY alivan
     $this->_galaxy_data = parent::$db->query("SELECT\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT CONCAT ( GROUP_CONCAT(buddy_receiver) , ',' , GROUP_CONCAT(buddy_sender) ) AS buddys FROM " . BUDDY . " AS b WHERE (b.buddy_receiver = u.user_id OR b.buddy_sender = u.user_id ) ) AS buddys,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.planet_debris_metal AS metal,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.planet_debris_crystal AS crystal,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.`planet_id` AS id_planet,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.planet_galaxy,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.planet_system,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.planet_planet,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.planet_type,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.planet_destroyed,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.planet_name,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.planet_image,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.planet_last_update,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.planet_user_id,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tu.user_id,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tu.user_ally_id,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tu.user_banned,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tse.setting_vacations_status,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tu.user_onlinetime,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tu.user_name,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ts.user_statistic_total_rank,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ts.user_statistic_total_points,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tm.planet_id AS id_luna,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tm.planet_diameter,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tm.planet_temp_min,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tm.planet_destroyed AS destruyed_moon,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tm.planet_name AS name_moon,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ta.alliance_name,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ta.alliance_tag,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ta.alliance_web,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT COUNT(user_id) AS `ally_members` FROM `" . USERS . "` WHERE `user_ally_id` = a.`alliance_id`) AS `ally_members`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . " AS p\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . USERS . " AS u ON p.planet_user_id = u.user_id\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . SETTINGS . " AS se ON se.setting_user_id = u.user_id\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . USERS_STATISTICS . " AS s ON s.user_statistic_user_id = u.user_id\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN " . ALLIANCE . " AS a ON a.alliance_id = u.user_ally_id\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN " . PLANETS . " AS m ON m.planet_id = (SELECT mp.`planet_id`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . " AS mp\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE (mp.planet_galaxy=p.planet_galaxy AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tmp.planet_system=p.planet_system AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tmp.planet_planet=p.planet_planet AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tmp.planet_type=3))\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE (p.planet_galaxy='" . $this->_galaxy . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.planet_system='" . $this->_system . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.planet_type='1' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(p.planet_planet>'0' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tp.planet_planet<='" . MAX_PLANET_IN_SYSTEM . "'))\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY p.planet_planet;");
     $parse = $this->_lang;
     $parse['js_path'] = XGP_ROOT . JS_PATH;
     $parse['galaxy'] = $this->_galaxy;
     $parse['system'] = $this->_system;
     $parse['planet'] = $planet;
     $parse['currentmip'] = $this->_current_planet['defense_interplanetary_missile'];
     $parse['maxfleetcount'] = $maxfleet_count;
     $parse['fleetmax'] = $fleetmax;
     $parse['recyclers'] = Format_Lib::pretty_number($this->_current_planet['ship_recycler']);
     $parse['spyprobes'] = Format_Lib::pretty_number($CurrentSP);
     $parse['missile_count'] = sprintf($this->_lang['gl_missil_to_launch'], $this->_current_planet['defense_interplanetary_missile']);
     $parse['current'] = isset($_GET['current']) ? $_GET['current'] : NULL;
     $parse['current_galaxy'] = $this->_current_planet['planet_galaxy'];
     $parse['current_system'] = $this->_current_planet['planet_system'];
     $parse['current_planet'] = $this->_current_planet['planet_planet'];
     $parse['planet_type'] = $this->_current_planet['planet_type'];
     $parse['mip'] = $mode == 2 ? parent::$page->parse_template(parent::$page->get_template('galaxy/galaxy_missile_selector'), $parse) : " ";
     $parse['galaxyrows'] = $this->show_row();
     $parse['planetcount'] = $this->_planet_count . " " . $this->_lang['gl_populed_planets'];
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('galaxy/galaxy_body'), $parse), FALSE);
 }
示例#14
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $parse = $this->_lang;
     $type = isset($_POST['type']) ? $_POST['type'] : '';
     $searchtext = parent::$db->escape_value(isset($_POST['searchtext']) ? $_POST['searchtext'] : '');
     $search_results = '';
     if ($_POST) {
         switch ($type) {
             case 'playername':
             default:
                 $table = parent::$page->get_template('search/search_user_table');
                 $row = parent::$page->get_template('search/search_user_row');
                 $search = parent::$db->query("SELECT u.user_id AS user_id, u.user_name, p.planet_name, p.planet_galaxy, p.planet_system, p.planet_planet, s.user_statistic_total_rank AS rank, a.alliance_id, a.alliance_name\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . " AS u\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . USERS_STATISTICS . " AS s ON s.user_statistic_user_id = u.user_id\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . PLANETS . " AS p ON p.`planet_id` = u.user_home_planet_id\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN " . ALLIANCE . " AS a ON a.alliance_id = u.user_ally_id\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE u.user_name LIKE '%" . $searchtext . "%' LIMIT 25;");
                 break;
             case 'planetname':
                 $table = parent::$page->get_template('search/search_user_table');
                 $row = parent::$page->get_template('search/search_user_row');
                 $search = parent::$db->query("SELECT u.user_id AS user_id, u.user_name, p.planet_name, p.planet_galaxy, p.planet_system, p.planet_planet, s.user_statistic_total_rank AS rank, a.alliance_id, a.alliance_name\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . " AS u\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . USERS_STATISTICS . " AS s ON s.user_statistic_user_id = u.user_id\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . PLANETS . " AS p ON p.`planet_id` = u.user_home_planet_id\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN " . ALLIANCE . " AS a ON a.alliance_id = u.user_ally_id\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE p.planet_name LIKE '%" . $searchtext . "%' LIMIT 25;");
                 break;
             case 'allytag':
                 $table = parent::$page->get_template('search/search_ally_table');
                 $row = parent::$page->get_template('search/search_ally_row');
                 $search = parent::$db->query("SELECT a.alliance_id,\r\n                    \t\t\t\t\t\t\t\t\ta.alliance_name,\r\n                    \t\t\t\t\t\t\t\t\ta.alliance_tag,\r\n                    \t\t\t\t\t\t\t\t\ts.alliance_statistic_total_points as points,\r\n                    \t\t\t\t\t\t\t\t\t(SELECT COUNT(user_id) AS `ally_members` FROM `" . USERS . "` WHERE `user_ally_id` = a.`alliance_id`) AS `ally_members`\r\n                    \t\t\t\t\t\t\t\tFROM " . ALLIANCE . " AS a\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN " . ALLIANCE_STATISTICS . " AS s ON a.alliance_id = s.alliance_statistic_alliance_id\r\n                    \t\t\t\t\t\t\t\tWHERE a.alliance_tag LIKE '%" . $searchtext . "%' LIMIT 25;");
                 break;
             case 'allyname':
                 $table = parent::$page->get_template('search/search_ally_table');
                 $row = parent::$page->get_template('search/search_ally_row');
                 $search = parent::$db->query("SELECT a.alliance_id,\r\n                    \t\t\t\t\t\t\t\t\t\ta.alliance_name,\r\n                    \t\t\t\t\t\t\t\t\t\ta.alliance_tag,\r\n                    \t\t\t\t\t\t\t\t\t\ts.alliance_statistic_total_points as points,\r\n                    \t\t\t\t\t\t\t\t\t\t(SELECT COUNT(user_id) AS `ally_members` FROM `" . USERS . "` WHERE `user_ally_id` = a.`alliance_id`) AS `ally_members`\r\n                    \t\t\t\t\t\t\t\tFROM " . ALLIANCE . " AS a\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN " . ALLIANCE_STATISTICS . " AS s ON a.alliance_id = s.alliance_statistic_alliance_id\r\n                    \t\t\t\t\t\t\t\tWHERE a.alliance_name LIKE '%" . $searchtext . "%' LIMIT 25;");
                 break;
         }
     }
     if (isset($searchtext) && isset($type) && isset($search)) {
         $result_list = '';
         while ($s = parent::$db->fetch_array($search)) {
             if ($type == 'playername' or $type == 'planetname') {
                 if ($this->_current_user['user_id'] != $s['user_id']) {
                     $s['actions'] = '<a href="game.php?page=messages&mode=write&id=' . $s['user_id'] . '" title="' . $this->_lang['write_message'] . '"><img src="' . DPATH . 'img/m.gif"/></a>&nbsp;';
                     $s['actions'] .= '<a href="#" title="' . $this->_lang['sh_buddy_request'] . '" onClick="f(\'game.php?page=buddy&mode=2&u=' . $s['user_id'] . '\', \'' . $this->_lang['sh_buddy_request'] . '\')"><img src="' . DPATH . 'img/b.gif" border="0"></a>';
                 }
                 $s['planet_name'] = $s['planet_name'];
                 $s['username'] = $s['user_name'];
                 $s['alliance_name'] = $s['alliance_name'] != '' ? "<a href=\"game.php?page=alliance&mode=ainfo&allyid={$s['alliance_id']}\">{$s['alliance_name']}</a>" : '';
                 $s['position'] = "<a href=\"game.php?page=statistics&start=" . $s['rank'] . "\">" . $s['rank'] . "</a>";
                 $s['coordinated'] = "{$s['planet_galaxy']}:{$s['planet_system']}:{$s['planet_planet']}";
                 $result_list .= parent::$page->parse_template($row, $s);
             } elseif ($type == 'allytag' or $type == 'allyname') {
                 $s['ally_points'] = Format_Lib::pretty_number($s['points']);
                 $s['ally_tag'] = "<a href=\"game.php?page=alliance&mode=ainfo&allyid={$s['alliance_id']}\">{$s['alliance_tag']}</a>";
                 $result_list .= parent::$page->parse_template($row, $s);
             }
         }
         if ($result_list != '') {
             $parse['result_list'] = $result_list;
             $search_results = parent::$page->parse_template($table, $parse);
         }
     }
     $parse['type_playername'] = $type == "playername" ? " selected" : "";
     $parse['type_planetname'] = $type == "planetname" ? " selected" : "";
     $parse['type_allytag'] = $type == "allytag" ? " selected" : "";
     $parse['type_allyname'] = $type == "allyname" ? " selected" : "";
     $parse['searchtext'] = $searchtext;
     $parse['search_results'] = $search_results;
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('search/search_body'), $parse));
 }
示例#15
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $resource = parent::$objects->get_objects();
     $reslist = parent::$objects->get_objects_list();
     #####################################################################################################
     // SOME DEFAULT VALUES
     #####################################################################################################
     // QUERYS
     $count = parent::$db->query_fetch("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 = Fleets_Lib::get_max_expeditions($MaxExpedition);
     } else {
         $ExpeditionEnCours = 0;
         $EnvoiMaxExpedition = 0;
     }
     $MaxFlottes = Fleets_Lib::get_max_fleets($this->_current_user[$resource[108]], $this->_current_user['premium_officier_admiral']);
     $missiontype = Fleets_Lib::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'] = Fleets_Lib::fleet_max_speed("", $i, $this->_current_user);
             }
             $ships['ship'] = $this->_lang['tech'][$i];
             $ships['amount'] = Format_Lib::pretty_number($this->_current_planet[$resource[$i]]);
             $inputs['i'] = $i;
             $inputs['maxship'] = $this->_current_planet[$resource[$i]];
             $inputs['consumption'] = Fleets_Lib::ship_consumption($i, $this->_current_user);
             $inputs['speed'] = Fleets_Lib::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));
 }
示例#16
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     #####################################################################################################
     // SOME DEFAULT VALUES
     #####################################################################################################
     //	ELEMENTS
     $resource = parent::$objects->get_objects();
     // QUERYS
     $count = parent::$db->query_fetch("SELECT\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT COUNT(fleet_owner) AS `actcnt`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\r\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,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT COUNT(fleet_owner) AS `expedi`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_owner` = '" . $this->_current_user['user_id'] . "'\r\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 = Fleets_Lib::get_max_expeditions($MaxExpedition);
     } else {
         $ExpeditionEnCours = 0;
         $EnvoiMaxExpedition = 0;
     }
     $MaxFlottes = Fleets_Lib::get_max_fleets($this->_current_user[$resource[108]], $this->_current_user['premium_officier_admiral']);
     $missiontype = Fleets_Lib::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 *\r\n\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\r\n\t\t\t\t\t\t\t\t\t\tWHERE fleet_owner = '" . $this->_current_user['user_id'] . "'");
         while ($f = parent::$db->fetch_array($fq)) {
             $i++;
             $parse['num'] = $i;
             $parse['fleet_mission'] = $missiontype[$f['fleet_mission']];
             if (Fleets_Lib::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'] = Format_Lib::pretty_number($f['fleet_amount']);
             $parse['fleet_start'] = Format_Lib::pretty_coords($f['fleet_start_galaxy'], $f['fleet_start_system'], $f['fleet_start_planet']);
             $parse['fleet_start_time'] = date(Functions_Lib::read_config('date_format_extended'), $f['fleet_creation']);
             $parse['fleet_end'] = Format_Lib::pretty_coords($f['fleet_end_galaxy'], $f['fleet_end_system'], $f['fleet_end_planet']);
             $parse['fleet_end_time'] = date(Functions_Lib::read_config('date_format_extended'), $f['fleet_start_time']);
             $parse['fleet_arrival'] = date(Functions_Lib::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'] = '&nbsp;-&nbsp;';
             }
             $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));
 }
示例#17
0
 /**
  * method fleet_ships_popup
  * param $fleet_row
  * param $text
  * param $fleet_type
  * param $current_user
  * return creates the link with the coordinates of the target planet
  */
 public static function fleet_ships_popup($fleet_row, $text, $fleet_type, $current_user = '')
 {
     $ships = explode(";", $fleet_row['fleet_array']);
     $pop_up = "<a href='#' onmouseover=\"return overlib('";
     $pop_up .= "<table width=200>";
     $espionage_tech = Officiers_Lib::get_max_espionage($current_user['research_espionage_technology'], $current_user['premium_officier_technocrat']);
     if ($espionage_tech < 2 && $fleet_row['fleet_owner'] != $current_user['user_id']) {
         $pop_up .= "<tr><td width=50% align=left><font color=white>" . parent::$lang['cff_no_fleet_data'] . "<font></td></tr>";
     } elseif ($espionage_tech >= 2 && $espionage_tech < 4 && $fleet_row['fleet_owner'] != $current_user['user_id']) {
         $pop_up .= "<tr><td width=50% align=left><font color=white>" . parent::$lang['cff_aproaching'] . $fleet_row['fleet_amount'] . parent::$lang['cff_ships'] . "<font></td></tr>";
     } else {
         if ($fleet_row['fleet_owner'] != $current_user['user_id']) {
             $pop_up .= "<tr><td width=100% align=left><font color=white>" . parent::$lang['cff_aproaching'] . $fleet_row['fleet_amount'] . parent::$lang['cff_ships'] . ":<font></td></tr>";
         }
         foreach ($ships as $item => $group) {
             if ($group != '') {
                 $ship = explode(',', $group);
                 if ($fleet_row['fleet_owner'] == $current_user['user_id']) {
                     $pop_up .= "<tr><td width=50% align=left><font color=white>" . parent::$lang['tech'][$ship[0]] . ":<font></td><td width=50% align=right><font color=white>" . Format_Lib::pretty_number($ship[1]) . "<font></td></tr>";
                 } elseif ($fleet_row['fleet_owner'] != $current_user['user_id']) {
                     if ($espionage_tech >= 4 && $espionage_tech < 8) {
                         $pop_up .= "<tr><td width=50% align=left><font color=white>" . parent::$lang['tech'][$ship[0]] . "<font></td></tr>";
                     } elseif ($espionage_tech >= 8) {
                         $pop_up .= "<tr><td width=50% align=left><font color=white>" . parent::$lang['tech'][$ship[0]] . ":<font></td><td width=50% align=right><font color=white>" . Format_Lib::pretty_number($ship[1]) . "<font></td></tr>";
                     }
                 }
             }
         }
     }
     $pop_up .= "</table>";
     $pop_up .= "');\" onmouseout=\"return nd();\" class=\"" . $fleet_type . "\">" . $text . "</a>";
     return $pop_up;
 }
示例#18
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $parse = $this->_lang;
     $tech_row_template = parent::$page->get_template('buildings/buildings_research_row');
     $tech_script_template = parent::$page->get_template('buildings/buildings_research_script');
     $technology_list = '';
     // time to do something
     $this->do_command();
     // build the page
     foreach ($this->_lang['tech'] as $tech => $tech_name) {
         if ($tech > 105 && $tech <= 199) {
             if (Developments_Lib::is_development_allowed($this->_current_user, $this->_current_planet, $tech)) {
                 $RowParse['dpath'] = DPATH;
                 $RowParse['tech_id'] = $tech;
                 $building_level = $this->_current_user[$this->_resource[$tech]];
                 $RowParse['tech_level'] = Developments_Lib::set_level_format($building_level, $tech, $this->_current_user);
                 $RowParse['tech_name'] = $tech_name;
                 $RowParse['tech_descr'] = $this->_lang['res']['descriptions'][$tech];
                 $RowParse['tech_price'] = Developments_Lib::formated_development_price($this->_current_user, $this->_current_planet, $tech);
                 $SearchTime = Developments_Lib::development_time($this->_current_user, $this->_current_planet, $tech, FALSE, $this->_lab_level);
                 $RowParse['search_time'] = Developments_Lib::formated_development_time($SearchTime);
                 if (!$this->_is_working['is_working']) {
                     if (Developments_Lib::is_development_payable($this->_current_user, $this->_current_planet, $tech) && !parent::$users->is_on_vacations($this->_current_user)) {
                         if (!$this->is_laboratory_in_queue()) {
                             $action_link = Format_Lib::color_red($this->_lang['bd_research']);
                         } else {
                             $action_link = Functions_Lib::set_url('game.php?page=research&cmd=search&tech=' . $tech, '', Format_Lib::color_green($this->_lang['bd_research']));
                         }
                     } else {
                         $action_link = Format_Lib::color_red($this->_lang['bd_research']);
                     }
                 } else {
                     if ($this->_is_working['working_on']['planet_b_tech_id'] == $tech) {
                         $bloc = $this->_lang;
                         if ($this->_is_working['working_on']['id'] != $this->_current_planet['planet_id']) {
                             $bloc['tech_time'] = $this->_is_working['working_on']['planet_b_tech'] - time();
                             $bloc['tech_name'] = $this->_lang['bd_from'] . $this->_is_working['working_on']['planet_name'] . '<br /> ' . Format_Lib::pretty_coords($this->_is_working['working_on']['planet_galaxy'], $this->_is_working['working_on']['planet_system'], $this->_is_working['working_on']['planet_planet']);
                             $bloc['tech_home'] = $this->_is_working['working_on']['id'];
                             $bloc['tech_id'] = $this->_is_working['working_on']['planet_b_tech_id'];
                         } else {
                             $bloc['tech_time'] = $this->_current_planet['planet_b_tech'] - time();
                             $bloc['tech_name'] = '';
                             $bloc['tech_home'] = $this->_current_planet['planet_id'];
                             $bloc['tech_id'] = $this->_current_planet['planet_b_tech_id'];
                         }
                         $action_link = parent::$page->parse_template($tech_script_template, $bloc);
                     } else {
                         $action_link = "<center>-</center>";
                     }
                 }
                 $RowParse['tech_link'] = $action_link;
                 $technology_list .= parent::$page->parse_template($tech_row_template, $RowParse);
             }
         }
     }
     $parse['noresearch'] = !$this->is_laboratory_in_queue() ? $this->_lang['bd_building_lab'] : '';
     $parse['technolist'] = $technology_list;
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('buildings/buildings_research'), $parse));
 }
示例#19
0
 /**
  * buildReportLink
  *
  * @param string $color Color
  * @param string $rid   Report ID
  * @param int    $g     Galaxy
  * @param int    $s     System
  * @param int    $p     Planet
  *
  * @return string
  */
 private function buildReportLink($color, $rid, $g, $s, $p)
 {
     $style = 'style="color:' . $color . ';"';
     $js = "OnClick=\\'f(\"game.php?page=combatreport&report=" . $rid . "\", \"\");\\'";
     $content = $this->_lang['sys_mess_attack_report'] . ' ' . Format_Lib::pretty_coords($g, $s, $p);
     return Functions_Lib::set_url('', '', $content, $style . ' ' . $js);
 }
示例#20
0
 /**
  * method debris_block
  * param
  * return debris link and information for the current planet
  */
 private function debris_block()
 {
     if ($this->_row_data['metal'] + $this->_row_data['crystal'] >= DEBRIS_MIN_VISIBLE_SIZE) {
         $recyclers_needed = ceil(($this->_row_data['metal'] + $this->_row_data['crystal']) / $this->_pricelist[209]['capacity']);
         if ($recyclers_needed < $this->_current_planet['ship_recycler']) {
             $recyclers_sended = $recyclers_needed;
         } elseif ($recyclers_needed >= $this->_current_planet['ship_recycler']) {
             $recyclers_sended = $this->_current_planet['ship_recycler'];
         }
         $parse = $this->_lang;
         $parse['dpath'] = DPATH;
         $parse['galaxy'] = $this->_galaxy;
         $parse['system'] = $this->_system;
         $parse['planet'] = $this->_planet;
         $parse['planettype'] = self::DEBRIS_TYPE;
         $parse['recsended'] = $recyclers_sended;
         $parse['planet_debris_metal'] = Format_Lib::pretty_number($this->_row_data['metal']);
         $parse['planet_debris_crystal'] = Format_Lib::pretty_number($this->_row_data['crystal']);
         return $parse;
     }
     return '';
 }
示例#21
0
 /**
  * method hazard_resources
  * param $fleet_row
  * param $fleet_capacity
  * return the blackhole resources result
  */
 private function hazard_resources($fleet_row, $fleet_capacity)
 {
     $fleet_current_capacity = $fleet_row['fleet_resource_metal'] + $fleet_row['fleet_resource_crystal'] + $fleet_row['fleet_resource_deuterium'];
     $fleet_capacity -= $fleet_current_capacity;
     if ($fleet_capacity > 5000) {
         $min_capacity = $fleet_capacity - 5000;
         $max_capacity = $fleet_capacity;
         $found_resources = mt_rand($min_capacity, $max_capacity);
         $found_metal = intval($found_resources / 2);
         $found_crystal = intval($found_resources / 4);
         $found_deuterium = intval($found_resources / 6);
         $found_darkmatter = $fleet_capacity > 10000 ? intval(3 * log($fleet_capacity / 10000) * 100) : 0;
         $found_darkmatter = mt_rand($found_darkmatter / 2, $found_darkmatter);
         parent::$db->query("UPDATE " . FLEETS . " AS f\r\n\t\t\t\t\t\t\t\t\tINNER JOIN " . PREMIUM . " AS pr ON pr.premium_user_id = f.fleet_owner SET\r\n\t\t\t\t\t\t\t\t\t`fleet_resource_metal` = `fleet_resource_metal` + '" . $found_metal . "',\r\n\t\t\t\t\t\t\t\t\t`fleet_resource_crystal` = `fleet_resource_crystal` + '" . $found_crystal . "',\r\n\t\t\t\t\t\t\t\t\t`fleet_resource_deuterium` = `fleet_resource_deuterium` + '" . $found_deuterium . "',\r\n\t\t\t\t\t\t\t\t\t`premium_dark_matter` = `premium_dark_matter` + '" . $found_darkmatter . "',\r\n\t\t\t\t\t\t\t\t\t`fleet_mess` = '1'\r\n\t\t\t\t\t\t\t\t\tWHERE `fleet_id` = '" . $fleet_row['fleet_id'] . "';");
         $message = sprintf($this->_lang['sys_expe_found_goods'], Format_Lib::pretty_number($found_metal), $this->_lang['Metal'], Format_Lib::pretty_number($found_crystal), $this->_lang['Crystal'], Format_Lib::pretty_number($found_deuterium), $this->_lang['Deuterium'], Format_Lib::pretty_number($found_darkmatter), $this->_lang['Darkmatter']);
         $this->expedition_message($fleet_row['fleet_owner'], $message, $fleet_row['fleet_end_stay']);
     }
 }
示例#22
0
    /**
     * method acs_steal
     * param $attackFleets
     * param $defenderPlanet
     * param $ForSim
     * return the steal result
     */
    private function acs_steal($attackFleets, $defenderPlanet, $ForSim = FALSE)
    {
        $SortFleets = array();
        foreach ($attackFleets as $FleetID => $Attacker) {
            foreach ($Attacker['detail'] as $Element => $amount) {
                if ($Element != 210) {
                    //fix probos capacity in attack by jstar
                    $SortFleets[$FleetID] += $this->_pricelist[$Element]['capacity'] * $amount;
                }
            }
            $SortFleets[$FleetID] -= $Attacker['fleet']['fleet_resource_metal'] - $Attacker['fleet']['fleet_resource_crystal'] - $Attacker['fleet']['fleet_resource_deuterium'];
        }
        $Sumcapacity = array_sum($SortFleets);
        //FIX JTSAMPER
        $booty['deuterium'] = min($Sumcapacity / 3, $defenderPlanet['planet_deuterium'] / 2);
        $Sumcapacity -= $booty['deuterium'];
        $booty['crystal'] = min($Sumcapacity / 2, $defenderPlanet['planet_crystal'] / 2);
        $Sumcapacity -= $booty['crystal'];
        $booty['metal'] = min($Sumcapacity, $defenderPlanet['planet_metal'] / 2);
        $Sumcapacity -= $booty['metal'];
        $oldMetalBooty = $booty['crystal'];
        $booty['crystal'] += min($Sumcapacity / 2, max($defenderPlanet['planet_crystal'] / 2 - $booty['crystal'], 0));
        $Sumcapacity += $oldMetalBooty - $booty['crystal'];
        $booty['metal'] += min($Sumcapacity, max($defenderPlanet['planet_metal'] / 2 - $booty['metal'], 0));
        $booty['metal'] = max($booty['metal'], 0);
        $booty['crystal'] = max($booty['crystal'], 0);
        $booty['deuterium'] = max($booty['deuterium'], 0);
        //END FIX
        $steal = array_map('floor', $booty);
        if ($ForSim) {
            return $steal;
        }
        $AllCapacity = array_sum($SortFleets);
        $QryUpdateFleet = '';
        if ($AllCapacity != 0) {
            foreach ($SortFleets as $FleetID => $Capacity) {
                parent::$db->query('UPDATE ' . FLEETS . ' SET
										`fleet_resource_metal` = `fleet_resource_metal` + ' . Format_Lib::float_to_string($steal['metal'] * ($Capacity / $AllCapacity)) . ',
										`fleet_resource_crystal` = `fleet_resource_crystal` +' . Format_Lib::float_to_string($steal['crystal'] * ($Capacity / $AllCapacity)) . ',
										`fleet_resource_deuterium` = `fleet_resource_deuterium` +' . Format_Lib::float_to_string($steal['deuterium'] * ($Capacity / $AllCapacity)) . '
										WHERE fleet_id = ' . $FleetID . '
										LIMIT 1;');
            }
        } else {
            $steal = 0;
        }
        return $steal;
    }
 /**
  * method topnav_bar
  * param
  * return get the top navigation bar data and parses it
  */
 private function game_navbar()
 {
     $parse = $this->_lang;
     $parse['dpath'] = DPATH;
     $parse['image'] = $this->_current_planet['planet_image'];
     $parse['planetlist'] = Functions_Lib::build_planet_list($this->_current_user);
     // VACATION MODE & DELETE MODE MESSAGES
     if ($this->_current_user['setting_vacations_status'] && $this->_current_user['setting_delete_account']) {
         $parse['show_umod_notice'] .= $this->_current_user['setting_delete_account'] ? '<table width="100%" style="border: 2px solid red; text-align:center;background:transparent;"><tr style="background:transparent;"><td style="background:transparent;">' . $this->_lang['tn_delete_mode'] . date(Functions_Lib::read_config('date_format_extended'), $this->_current_user['setting_delete_account'] + 60 * 60 * 24 * 7) . '</td></tr></table>' : '';
     } else {
         if ($this->_current_user['setting_vacations_status'] < time()) {
             $parse['show_umod_notice'] = $this->_current_user['setting_vacations_status'] ? '<table width="100%" style="border: 2px solid #1DF0F0; text-align:center;background:transparent;"><tr style="background:transparent;"><td style="background:transparent;">' . $this->_lang['tn_vacation_mode'] . date(Functions_Lib::read_config('date_format_extended'), $this->_current_user['setting_vacations_until']) . '</td></tr></table><br>' : '';
         }
         $parse['show_umod_notice'] .= $this->_current_user['setting_delete_account'] ? '<table width="100%" style="border: 2px solid red; text-align:center;background:transparent;"><tr style="background:transparent;"><td style="background:transparent;">' . $this->_lang['tn_delete_mode'] . date(Functions_Lib::read_config('date_format_extended'), $this->_current_user['setting_delete_account'] + 60 * 60 * 24 * 7) . '</td></tr></table>' : '';
     }
     // RESOURCES FORMAT
     $metal = Format_Lib::pretty_number($this->_current_planet['planet_metal']);
     $crystal = Format_Lib::pretty_number($this->_current_planet['planet_crystal']);
     $deuterium = Format_Lib::pretty_number($this->_current_planet['planet_deuterium']);
     $darkmatter = Format_Lib::pretty_number($this->_current_user['premium_dark_matter']);
     $energy = Format_Lib::pretty_number($this->_current_planet['planet_energy_max'] + $this->_current_planet['planet_energy_used']) . "/" . Format_Lib::pretty_number($this->_current_planet['planet_energy_max']);
     // OFFICERS AVAILABILITY
     $commander = Officiers_Lib::is_officier_active($this->_current_user['premium_officier_commander']) ? '' : '_un';
     $admiral = Officiers_Lib::is_officier_active($this->_current_user['premium_officier_admiral']) ? '' : '_un';
     $engineer = Officiers_Lib::is_officier_active($this->_current_user['premium_officier_engineer']) ? '' : '_un';
     $geologist = Officiers_Lib::is_officier_active($this->_current_user['premium_officier_geologist']) ? '' : '_un';
     $technocrat = Officiers_Lib::is_officier_active($this->_current_user['premium_officier_technocrat']) ? '' : '_un';
     // METAL
     if ($this->_current_planet['planet_metal'] >= $this->_current_planet['planet_metal_max']) {
         $metal = Format_Lib::color_red($metal);
     }
     // CRYSTAL
     if ($this->_current_planet['planet_crystal'] >= $this->_current_planet['planet_crystal_max']) {
         $crystal = Format_Lib::color_red($crystal);
     }
     // DEUTERIUM
     if ($this->_current_planet['planet_deuterium'] >= $this->_current_planet['planet_deuterium_max']) {
         $deuterium = Format_Lib::color_red($deuterium);
     }
     // ENERGY
     if ($this->_current_planet['planet_energy_max'] + $this->_current_planet['planet_energy_used'] < 0) {
         $energy = Format_Lib::color_red($energy);
     }
     $parse['metal'] = $metal;
     $parse['crystal'] = $crystal;
     $parse['deuterium'] = $deuterium;
     $parse['darkmatter'] = $darkmatter;
     $parse['energy'] = $energy;
     $parse['img_commander'] = $commander;
     $parse['img_admiral'] = $admiral;
     $parse['img_engineer'] = $engineer;
     $parse['img_geologist'] = $geologist;
     $parse['img_technocrat'] = $technocrat;
     return $this->parse_template($this->get_template('general/topnav'), $parse);
 }
示例#24
0
 /**
  * method resource_color
  * param1 $current_amount
  * param2 $max_amount
  * return color depending on the current storage capacity
  */
 private function resource_color($current_amount, $max_amount)
 {
     if ($max_amount < $current_amount) {
         return Format_Lib::color_red(Format_Lib::pretty_number($max_amount / 1000) . 'k');
     } else {
         return Format_Lib::color_green(Format_Lib::pretty_number($max_amount / 1000) . 'k');
     }
 }
示例#25
0
 /**
  * method build_page
  * param
  * return the statistics page
  */
 private function build_page()
 {
     $parse = $this->_lang;
     $parse['dpath'] = DPATH;
     $bloc = $this->_lang;
     $mode = isset($_GET['mode']) ? $_GET['mode'] : '';
     $time = isset($_GET['time']) ? $_GET['time'] : '';
     if ($mode == 2 && ($time == 'month' or $time == 'week')) {
         $Selected = $_GET['offi'];
         $time = 'darkmatter_' . $time;
         $set_time = $time == 'darkmatter_month' ? 3600 * 24 * 30 * 3 : 3600 * 24 * 7;
         if (in_array($Selected, $this->_reslist['officier'])) {
             $Result = $this->is_officier_accesible($Selected, $time);
             $Price = $this->get_officier_price($Selected, $time);
             if ($Result !== FALSE) {
                 $this->_current_user['premium_dark_matter'] -= $Price;
                 // IF THE OFFICIER IS ACTIVE
                 if (Officiers_Lib::is_officier_active($this->_current_user[$this->_resource[$Selected]])) {
                     $this->_current_user[$this->_resource[$Selected]] += $set_time;
                     // ADD TIME
                 } else {
                     $this->_current_user[$this->_resource[$Selected]] = time() + $set_time;
                     // SET TIME
                 }
                 parent::$db->query("UPDATE " . PREMIUM . " SET\n\t\t\t\t\t\t\t\t\t\t\t`premium_dark_matter` = '" . $this->_current_user['premium_dark_matter'] . "',\n\t\t\t\t\t\t\t\t\t\t\t`" . $this->_resource[$Selected] . "` = '" . $this->_current_user[$this->_resource[$Selected]] . "'\n\t\t\t\t\t\t\t\t\t\t\tWHERE `premium_user_id` = '" . $this->_current_user['user_id'] . "';");
             }
         }
         Functions_Lib::redirect('game.php?page=officier');
     } else {
         $OfficierRowTPL = parent::$page->get_template('officier/officier_row');
         $parse['disp_off_tbl'] = '';
         $parse['premium_pay_url'] = Functions_Lib::read_config('premium_url') != '' ? Functions_Lib::read_config('premium_url') : 'game.php?page=officier';
         foreach ($this->_lang['tech'] as $Element => $ElementName) {
             if ($Element >= 601 && $Element <= 605) {
                 $bloc['dpath'] = DPATH;
                 $bloc['off_id'] = $Element;
                 $bloc['off_status'] = Officiers_Lib::is_officier_active($this->_current_user[$this->_resource[$Element]]) ? '<font color=lime>' . $this->_lang['of_active'] . ' ' . date(Functions_Lib::read_config('date_format'), $this->_current_user[$this->_resource[$Element]]) . '</font>' : '<font color=red>' . $this->_lang['of_inactive'] . '</font>';
                 $bloc['off_name'] = $ElementName;
                 $bloc['off_desc'] = $this->_lang['res']['descriptions'][$Element];
                 $bloc['off_desc_short'] = $this->_lang['info'][$Element]['description'];
                 $bloc['month_price'] = Format_Lib::pretty_number($this->get_officier_price($Element, 'darkmatter_month'));
                 $bloc['week_price'] = Format_Lib::pretty_number($this->get_officier_price($Element, 'darkmatter_week'));
                 $bloc['img_big'] = $this->get_officier_image($Element, 'img_big');
                 $bloc['img_small'] = $this->get_officier_image($Element, 'img_small');
                 $bloc['off_link_month'] = "game.php?page=officier&mode=2&offi=" . $Element . "&time=month";
                 $bloc['off_link_week'] = "game.php?page=officier&mode=2&offi=" . $Element . "&time=week";
                 $parse['disp_off_tbl'] .= parent::$page->parse_template($OfficierRowTPL, $bloc);
             }
         }
     }
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('officier/officier_table'), $parse));
 }
示例#26
0
 /**
  * method ally_admin
  * param
  * return the admin page for someone with an alliance
  */
 private function ally_admin()
 {
     $parse = $this->_lang;
     if ($this->_current_user['user_ally_id'] != 0 && $this->_current_user['user_ally_request'] == 0) {
         $edit = isset($_GET['edit']) ? $_GET['edit'] : NULL;
         switch ($edit) {
             case $edit == 'rights' && $this->have_access($this->_ally['alliance_owner'], $this->permissions['right_hand']) === TRUE:
                 $d = isset($_GET['d']) && is_numeric($_GET['d']) && $_GET['d'] >= 0 ? $_GET['d'] : NULL;
                 $alliance_ranks = unserialize($this->_ally['alliance_ranks']);
                 if (!empty($_POST['newrangname'])) {
                     $name = parent::$db->escape_value(strip_tags($_POST['newrangname']));
                     $alliance_ranks[] = array('name' => $name, 'mails' => 0, 'delete' => 0, 'kick' => 0, 'bewerbungen' => 0, 'administrieren' => 0, 'bewerbungenbearbeiten' => 0, 'memberlist' => 0, 'onlinestatus' => 0, 'rechtehand' => 0);
                     $ranks = serialize($alliance_ranks);
                     parent::$db->query("UPDATE " . ALLIANCE . " SET\r\n\t\t\t\t\t\t\t\t\t\t\t\t`alliance_ranks`='" . $ranks . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `alliance_id` = " . (int) $this->_ally['alliance_id']);
                     $goto = $_SERVER['PHP_SELF'] . "?" . str_replace('&amp;', '&', $_SERVER['QUERY_STRING']);
                     Functions_Lib::redirect($goto);
                 } elseif (isset($_POST['id']) && $_POST['id'] != '' && is_array($_POST['id'])) {
                     $ally_ranks_new = array();
                     foreach ($_POST['id'] as $id) {
                         $name = $alliance_ranks[$id]['name'];
                         $ally_ranks_new[$id]['name'] = $name;
                         $ally_ranks_new[$id]['delete'] = isset($_POST['u' . $id . 'r0']) ? 1 : 0;
                         $ally_ranks_new[$id]['kick'] = isset($_POST['u' . $id . 'r1']) && $this->_ally['alliance_owner'] == $this->_current_user['user_id'] ? 1 : 0;
                         $ally_ranks_new[$id]['bewerbungen'] = isset($_POST['u' . $id . 'r2']) ? 1 : 0;
                         $ally_ranks_new[$id]['memberlist'] = isset($_POST['u' . $id . 'r3']) ? 1 : 0;
                         $ally_ranks_new[$id]['bewerbungenbearbeiten'] = isset($_POST['u' . $id . 'r4']) ? 1 : 0;
                         $ally_ranks_new[$id]['administrieren'] = isset($_POST['u' . $id . 'r5']) ? 1 : 0;
                         $ally_ranks_new[$id]['onlinestatus'] = isset($_POST['u' . $id . 'r6']) ? 1 : 0;
                         $ally_ranks_new[$id]['mails'] = isset($_POST['u' . $id . 'r7']) ? 1 : 0;
                         $ally_ranks_new[$id]['rechtehand'] = isset($_POST['u' . $id . 'r8']) ? 1 : 0;
                     }
                     $ranks = serialize($ally_ranks_new);
                     parent::$db->query("UPDATE " . ALLIANCE . " SET\r\n\t\t\t\t\t\t\t\t\t\t\t\t`alliance_ranks`='" . $ranks . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `alliance_id`= " . $this->_ally['alliance_id']);
                     $goto = $_SERVER['PHP_SELF'] . "?" . str_replace('&amp;', '&', $_SERVER['QUERY_STRING']);
                     Functions_Lib::redirect($goto);
                 } elseif (isset($d) && isset($alliance_ranks[$d])) {
                     unset($alliance_ranks[$d]);
                     $this->_ally['ally_rank'] = serialize($alliance_ranks);
                     parent::$db->query("UPDATE " . ALLIANCE . " SET\r\n\t\t\t\t\t\t\t\t\t\t\t\t`alliance_ranks`='" . $this->_ally['ally_rank'] . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `alliance_id` = " . $this->_ally['alliance_id'] . "");
                 }
                 $i = 0;
                 $list = '';
                 if (count($alliance_ranks) != 0 && $alliance_ranks != '') {
                     foreach ($alliance_ranks as $a => $b) {
                         if ($this->_ally['alliance_owner'] == $this->_current_user['user_id']) {
                             $r1 = "<input type=checkbox name=\"u{$a}r0\"" . ($b['delete'] == 1 ? ' checked="checked"' : '') . ">";
                         } else {
                             $r1 = "<b>-</b>";
                         }
                         $this->_lang['id'] = $a;
                         $this->_lang['r0'] = $b['name'];
                         $this->_lang['delete'] = "<a href=\"game.php?page=alliance&mode=admin&edit=rights&d={$a}\"><img src=\"" . DPATH . "alliance/abort.gif\" border=0></a>";
                         $this->_lang['a'] = $a;
                         $this->_lang['r1'] = $r1;
                         $this->_lang['r2'] = "<input type=checkbox name=\"u{$a}r1\"" . ($b['kick'] == 1 ? ' checked="checked"' : '') . ">";
                         $this->_lang['r3'] = "<input type=checkbox name=\"u{$a}r2\"" . ($b['bewerbungen'] == 1 ? ' checked="checked"' : '') . ">";
                         $this->_lang['r4'] = "<input type=checkbox name=\"u{$a}r3\"" . ($b['memberlist'] == 1 ? ' checked="checked"' : '') . ">";
                         $this->_lang['r5'] = "<input type=checkbox name=\"u{$a}r4\"" . ($b['bewerbungenbearbeiten'] == 1 ? ' checked="checked"' : '') . ">";
                         $this->_lang['r6'] = "<input type=checkbox name=\"u{$a}r5\"" . ($b['administrieren'] == 1 ? ' checked="checked"' : '') . ">";
                         $this->_lang['r7'] = "<input type=checkbox name=\"u{$a}r6\"" . ($b['onlinestatus'] == 1 ? ' checked="checked"' : '') . ">";
                         $this->_lang['r8'] = "<input type=checkbox name=\"u{$a}r7\"" . ($b['mails'] == 1 ? ' checked="checked"' : '') . ">";
                         $this->_lang['r9'] = "<input type=checkbox name=\"u{$a}r8\"" . ($b['rechtehand'] == 1 ? ' checked="checked"' : '') . ">";
                         $list .= parent::$page->parse_template(parent::$page->get_template('alliance/alliance_admin_laws_row'), $this->_lang);
                     }
                 }
                 $this->_lang['list'] = $list;
                 $this->_lang['dpath'] = DPATH;
                 return parent::$page->parse_template(parent::$page->get_template('alliance/alliance_admin_laws'), $this->_lang);
                 break;
             case '':
             case 'ally':
             default:
                 $t = isset($_GET['t']) ? (int) $_GET['t'] : NULL;
                 if ($t != 1 && $t != 2 && $t != 3) {
                     $t = 1;
                 }
                 if ($_POST) {
                     $_POST['owner_range'] = isset($_POST['owner_range']) ? stripslashes($_POST['owner_range']) : '';
                     $_POST['web'] = isset($_POST['web']) ? stripslashes($_POST['web']) : '';
                     $_POST['image'] = isset($_POST['image']) ? stripslashes($_POST['image']) : '';
                     $_POST['text'] = isset($_POST['text']) ? Functions_Lib::format_text($_POST['text']) : '';
                 }
                 if (isset($_POST['options'])) {
                     $this->_ally['alliance_owner_range'] = parent::$db->escape_value(htmlspecialchars(strip_tags($_POST['owner_range'])));
                     $this->_ally['alliance_web'] = parent::$db->escape_value(htmlspecialchars(strip_tags($_POST['web'])));
                     $this->_ally['alliance_image'] = parent::$db->escape_value(htmlspecialchars(strip_tags($_POST['image'])));
                     $this->_ally['alliance_request_notallow'] = (int) $_POST['request_notallow'];
                     if ($this->_ally['alliance_request_notallow'] != 0 && $this->_ally['alliance_request_notallow'] != 1) {
                         Functions_Lib::redirect('game.php?page=alliance?mode=admin&edit=ally');
                     }
                     parent::$db->query("UPDATE " . ALLIANCE . " SET\r\n\t\t\t\t\t\t\t\t\t\t\t\t`alliance_owner_range`='" . $this->_ally['alliance_owner_range'] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t`alliance_image`='" . $this->_ally['alliance_image'] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t`alliance_web`='" . $this->_ally['alliance_web'] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t`alliance_request_notallow`='" . $this->_ally['alliance_request_notallow'] . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `alliance_id` = '" . $this->_ally['alliance_id'] . "'");
                 } elseif (isset($_POST['t'])) {
                     if ($t == 3) {
                         $this->_ally['alliance_request'] = $_POST['text'];
                         parent::$db->query("UPDATE " . ALLIANCE . " SET\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`alliance_request`='" . $this->_ally['alliance_request'] . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `alliance_id` = '" . $this->_ally['alliance_id'] . "'");
                         Functions_Lib::redirect('game.php?page=alliance&mode=admin&edit=ally&t=3');
                     } elseif ($t == 2) {
                         $this->_ally['alliance_text'] = $_POST['text'];
                         parent::$db->query("UPDATE " . ALLIANCE . " SET\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`alliance_text`='" . $this->_ally['alliance_text'] . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `alliance_id` = '" . $this->_ally['alliance_id'] . "'");
                         Functions_Lib::redirect('game.php?page=alliance&mode=admin&edit=ally&t=2');
                     } else {
                         $this->_ally['alliance_description'] = $_POST['text'];
                         parent::$db->query("UPDATE " . ALLIANCE . " SET\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`alliance_description`='" . $this->_ally['alliance_description'] . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `alliance_id` = '" . $this->_ally['alliance_id'] . "'");
                         Functions_Lib::redirect('game.php?page=alliance&mode=admin&edit=ally&t=1');
                     }
                 }
                 $this->_lang['dpath'] = DPATH;
                 if ($t == 3) {
                     $this->_lang['request_type'] = $this->_lang['al_request_text'];
                 } elseif ($t == 2) {
                     $this->_lang['request_type'] = $this->_lang['al_inside_text'];
                 } else {
                     $this->_lang['request_type'] = $this->_lang['al_outside_text'];
                 }
                 if ($t == 2) {
                     $this->_lang['text'] = $this->_ally['alliance_text'];
                 } else {
                     $this->_lang['text'] = $this->_ally['alliance_description'];
                 }
                 if ($t == 3) {
                     $this->_lang['text'] = $this->_ally['alliance_request'];
                 }
                 $this->_lang['t'] = $t;
                 $this->_lang['alliance_web'] = $this->_ally['alliance_web'];
                 $this->_lang['alliance_image'] = $this->_ally['alliance_image'];
                 $this->_lang['alliance_request_notallow_0'] = $this->_ally['alliance_request_notallow'] == 1 ? ' SELECTED' : '';
                 $this->_lang['alliance_request_notallow_1'] = $this->_ally['alliance_request_notallow'] == 0 ? ' SELECTED' : '';
                 $this->_lang['alliance_owner_range'] = $this->_ally['alliance_owner_range'];
                 return parent::$page->parse_template(parent::$page->get_template('alliance/alliance_admin'), $this->_lang);
                 break;
             case $edit == 'members' && $this->have_access($this->_ally['alliance_owner'], $this->permissions['admin_alliance']) === TRUE:
                 $rank = isset($_GET['rank']) ? (int) $_GET['rank'] : NULL;
                 $kick = isset($_GET['kick']) ? (int) $_GET['kick'] : NULL;
                 $id = isset($_GET['id']) ? (int) $_GET['id'] : NULL;
                 $sort1 = isset($_GET['sort1']) ? (int) $_GET['sort1'] : NULL;
                 $sort2 = isset($_GET['sort2']) ? (int) $_GET['sort2'] : NULL;
                 if (isset($kick)) {
                     $this->have_access($this->_ally['alliance_owner'], $this->permissions['kick_users']);
                     $u = parent::$db->query_fetch("SELECT `user_ally_id`, `user_id`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . USERS . "`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `user_id` = '" . (int) $kick . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1");
                     if ($u['user_ally_id'] == $this->_ally['alliance_id'] && $u['user_id'] != $this->_ally['alliance_owner']) {
                         parent::$db->query("UPDATE " . USERS . " SET\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`user_ally_id`='0',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`user_ally_rank_id` = 0\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `user_id`='" . (int) $u['id'] . "' LIMIT 1;");
                     }
                 } elseif (isset($_POST['newrang'])) {
                     $u = isset($id) ? $id : '';
                     $q = parent::$db->query_fetch("SELECT `user_id`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . "\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `user_id` = '" . (int) $u . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1");
                     if ((isset($alliance_ranks[$_POST['newrang'] - 1]) or $_POST['newrang'] == 0) && $q['user_id'] != $this->_ally['alliance_owner']) {
                         parent::$db->query("UPDATE " . USERS . " SET\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t`user_ally_rank_id` = '" . parent::$db->escape_value($_POST['newrang']) . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `user_id`='" . $q['user_id'] . "'");
                     }
                 }
                 if ($sort2) {
                     $sort = $this->return_sort($sort1, $sort2);
                 } else {
                     $sort = '';
                 }
                 $listuser = parent::$db->query("SELECT u.user_id, u.user_onlinetime, u.user_name, u.user_galaxy, u.user_system, u.user_planet, u.user_ally_register_time, u.user_ally_rank_id, s.user_statistic_total_points\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . USERS . "` AS u\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN `" . USERS_STATISTICS . "`AS s ON u.user_id = s.user_statistic_user_id\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE u.user_ally_id='" . $this->_current_user['user_ally_id'] . "'" . $sort);
                 $i = 0;
                 $r = $this->_lang;
                 $s = $this->_lang;
                 $this->_lang['i'] = parent::$db->num_rows($listuser);
                 $page_list = '';
                 $r['options'] = '';
                 while ($u = parent::$db->fetch_array($listuser)) {
                     $u['i'] = ++$i;
                     $u['points'] = Format_Lib::pretty_number($u['user_statistic_total_points']);
                     $days = floor((time() - $u['user_onlinetime']) / (3600 * 24));
                     $u['user_onlinetime'] = str_replace("%s", $days, "%s d");
                     if ($this->_ally['alliance_owner'] == $u['user_id']) {
                         $ally_range = $this->_ally['alliance_owner_range'] == '' ? $this->_lang['al_founder_rank_text'] : $this->_ally['alliance_owner_range'];
                     } elseif ($u['user_ally_rank_id'] == 0 or !isset($alliance_ranks[$u['user_ally_rank_id'] - 1]['name'])) {
                         $ally_range = $this->_lang['al_new_member_rank_text'];
                     } else {
                         $ally_range = $alliance_ranks[$u['user_ally_rank_id'] - 1]['name'];
                     }
                     if ($this->_ally['alliance_owner'] == $u['user_id'] or $rank == $u['user_id']) {
                         $u['acciones'] = '-';
                     } elseif ($alliance_ranks[$this->_current_user['user_ally_rank_id'] - 1]['kick'] == 1 && $alliance_ranks[$this->_current_user['user_ally_rank_id'] - 1]['administrieren'] == 1 or $this->_ally['alliance_owner'] == $this->_current_user['user_id']) {
                         $u['acciones'] = "<a href=\"game.php?page=alliance&mode=admin&edit=members&kick=" . $u['user_id'] . "\" onclick=\"javascript:return confirm('" . str_replace('%s', $u['user_name'], $this->_lang['al_confirm_remove_member']) . "');\"><img src=\"" . DPATH . "alliance/abort.gif\" border=\"0\"></a> <a href=\"game.php?page=alliance&mode=admin&edit=members&rank=" . $u['user_id'] . "\"><img src=\"" . DPATH . "alliance/key.gif\" border=\"0\"></a>";
                     } elseif ($alliance_ranks[$this->_current_user['user_ally_rank_id'] - 1]['administrieren'] == 1) {
                         $u['acciones'] = "<a href=\"game.php?page=alliance&mode=admin&edit=members&kick=" . $u['user_id'] . "\" onclick=\"javascript:return confirm('" . str_replace('%s', $u['user_name'], $this->_lang['al_confirm_remove_member']) . "');\"><img src=\"" . DPATH . "alliance/abort.gif\" border=\"0\"></a> <a href=\"game.php?page=alliance&mode=admin&edit=members&rank=" . $u['user_id'] . "\"><img src=\"" . DPATH . "alliance/key.gif\" border=\"0\"></a>";
                     } else {
                         $u['acciones'] = '-';
                     }
                     $u['dpath'] = DPATH;
                     $u['alliance_register_time'] = date(Functions_Lib::read_config('date_format_extended'), $u['user_ally_register_time']);
                     if ($rank == $u['user_id']) {
                         $r['options'] .= "<option onclick=\"document.editar_usu_rango.submit();\" value=\"0\">" . $this->_lang['al_new_member_rank_text'] . "</option>";
                         if ($alliance_ranks != NULL) {
                             foreach ($alliance_ranks as $a => $b) {
                                 $r['options'] .= "<option onclick=\"document.editar_usu_rango.submit();\" value=\"" . ($a + 1) . "\"";
                                 if ($u['user_ally_rank_id'] - 1 == $a) {
                                     $r['options'] .= ' selected=selected';
                                 }
                                 $r['options'] .= ">{$b['name']}</option>";
                             }
                         }
                         $r['id'] = $u['user_id'];
                         $editar_miembros = parent::$page->parse_template(parent::$page->get_template('alliance/alliance_admin_members_row_edit'), $r);
                     }
                     if ($rank != $u['user_id']) {
                         $u['ally_range'] = $ally_range;
                     } else {
                         $u['ally_range'] = $editar_miembros;
                     }
                     $page_list .= parent::$page->parse_template(parent::$page->get_template('alliance/alliance_admin_members_row'), $u);
                 }
                 if ($sort2 == 1) {
                     $s = 2;
                 } elseif ($sort2 == 2) {
                     $s = 1;
                 } else {
                     $s = 1;
                 }
                 $this->_lang['memberslist'] = $page_list;
                 $this->_lang['s'] = $s;
                 return parent::$page->parse_template(parent::$page->get_template('alliance/alliance_admin_members_table'), $this->_lang);
                 break;
             case $edit == 'requests' && $this->have_access($this->_ally['alliance_owner'], $this->permissions['check_requests']) === TRUE:
                 $show = isset($_GET['show']) ? (int) $_GET['show'] : NULL;
                 if (isset($_POST['action']) && $_POST['action'] == $this->_lang['al_acept_request']) {
                     $_POST['text'] = trim(nl2br(strip_tags($_POST['text'], '<br>')));
                     $_POST['text'] = str_replace('rn', '\\r\\n', $_POST['text']);
                     parent::$db->query("UPDATE " . USERS . " SET\r\n\t\t\t\t\t\t\t\t\t\t\t\tuser_ally_request_text = '',\r\n\t\t\t\t\t\t\t\t\t\t\t\tuser_ally_request = '0',\r\n\t\t\t\t\t\t\t\t\t\t\t\tuser_ally_id = '" . $this->_ally['alliance_id'] . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE user_id = '" . $show . "'");
                     Functions_Lib::send_message($show, $this->_current_user['user_id'], '', 3, $this->_ally['alliance_tag'], $this->_lang['al_you_was_acceted'] . $this->_ally['alliance_name'], $this->_lang['al_hi_the_alliance'] . $this->_ally['alliance_name'] . $this->_lang['al_has_accepted'] . $_POST['text']);
                     Functions_Lib::redirect('game.php?page=alliance&mode=admin&edit=ally');
                 } elseif (isset($_POST['action']) && $_POST['action'] == $this->_lang['al_decline_request'] && $_POST['action'] != '') {
                     $_POST['text'] = trim(nl2br(strip_tags($_POST['text'], '<br>')));
                     $_POST['text'] = str_replace('rn', '\\r\\n', $_POST['text']);
                     parent::$db->query("UPDATE " . USERS . " SET\r\n\t\t\t\t\t\t\t\t\t\t\t\tuser_ally_request_text='',\r\n\t\t\t\t\t\t\t\t\t\t\t\tuser_ally_request='0',\r\n\t\t\t\t\t\t\t\t\t\t\t\tuser_ally_id='0'\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE user_id = '" . (int) $show . "'");
                     Functions_Lib::send_message($show, $this->_current_user['user_id'], '', 3, $this->_ally['alliance_tag'], $this->_lang['al_you_was_declined'] . $this->_ally['alliance_name'], $this->_lang['al_hi_the_alliance'] . $this->_ally['alliance_name'] . $this->_lang['al_has_declined'] . $_POST['text']);
                     Functions_Lib::redirect('game.php?page=alliance&mode=admin&edit=ally');
                 }
                 $i = 0;
                 $query = parent::$db->query("SELECT user_id, user_name, user_ally_request_text, user_ally_register_time\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . "\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE user_ally_request = '" . $this->_ally['alliance_id'] . "'");
                 /***start fix by jstar***/
                 $s = array();
                 $parse['list'] = '';
                 while ($r = parent::$db->fetch_array($query)) {
                     if (isset($show) && $r['user_id'] == $show) {
                         $s[$show]['username'] = $r['user_name'];
                         $s[$show]['ally_request_text'] = nl2br($r['user_ally_request_text']);
                         $s[$show]['id'] = $r['user_id'];
                     }
                     $r['time'] = date(Functions_Lib::read_config('date_format_extended'), $r['alliance_register_time']);
                     $parse['list'] .= parent::$page->parse_template(parent::$page->get_template('alliance/alliance_admin_request_row'), $r);
                     $i++;
                 }
                 if ($parse['list'] == '') {
                     $parse['list'] = "<tr><th colspan=2>" . $this->_lang['al_no_requests'] . "</th></tr>";
                 }
                 if (isset($show) && $show != 0 && $parse['list'] != '') {
                     $s[$show]['Request_from'] = str_replace('%s', $s[$show]['username'], $this->_lang['al_request_from']);
                     $parse['request'] = parent::$page->parse_template(parent::$page->get_template('alliance/alliance_admin_request_form'), array_merge($s[$show], $this->_lang));
                 } else {
                     $parse['request'] = '';
                 }
                 $parse['ally_tag'] = $this->_ally['alliance_tag'];
                 $parse['There_is_hanging_request'] = str_replace('%n', $i, $this->_lang['al_no_request_pending']);
                 return parent::$page->parse_template(parent::$page->get_template('alliance/alliance_admin_request_table'), $parse);
                 break;
             case $edit == 'name' && $this->have_access($this->_ally['alliance_owner'], $this->permissions['admin_alliance']) === TRUE:
                 $alliance_name = '';
                 if ($_POST) {
                     $alliance_name = $this->check_name($_POST['nametag']);
                     parent::$db->query("UPDATE " . ALLIANCE . " AS a SET\r\n\t\t\t\t\t\t\t\t\t\t\t\ta.`alliance_name` = '" . $alliance_name . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE a.`alliance_id` = '" . $this->_ally['alliance_id'] . "';");
                 }
                 $parse['caso'] = $alliance_name == '' ? str_replace('%s', $this->_ally['alliance_name'], $this->_lang['al_change_title']) : str_replace('%s', $alliance_name, $this->_lang['al_change_title']);
                 $parse['caso_titulo'] = $this->_lang['al_new_name'];
                 return parent::$page->parse_template(parent::$page->get_template('alliance/alliance_admin_rename'), $parse);
                 break;
             case $edit == 'tag' && $this->have_access($this->_ally['alliance_owner'], $this->permissions['admin_alliance']) === TRUE:
                 $alliance_tag = '';
                 if ($_POST) {
                     $alliance_tag = $this->check_tag($_POST['nametag']);
                     parent::$db->query("UPDATE " . ALLIANCE . " SET\r\n\t\t\t\t\t\t\t\t\t\t\t\t`alliance_tag` = '" . $alliance_tag . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `alliance_id` = '" . $this->_current_user['user_ally_id'] . "';");
                 }
                 $parse['caso'] = $alliance_tag == '' ? str_replace('%s', $this->_ally['alliance_tag'], $this->_lang['al_change_title']) : str_replace('%s', $alliance_tag, $this->_lang['al_change_title']);
                 $parse['caso_titulo'] = $this->_lang['al_new_tag'];
                 return parent::$page->parse_template(parent::$page->get_template('alliance/alliance_admin_rename'), $parse);
                 break;
             case $edit == 'exit' && $this->have_access($this->_ally['alliance_owner'], $this->permissions['disolve_alliance']) === TRUE:
                 parent::$db->query("UPDATE `" . USERS . "` SET\r\n\t\t\t\t\t\t\t\t\t\t\t`user_ally_id` = '0'\r\n\t\t\t\t\t\t\t\t\t\t\tWHERE `user_ally_id` = '" . $this->_ally['alliance_id'] . "'");
                 parent::$db->query("DELETE FROM " . ALLIANCE . "\r\n\t\t\t\t\t\t\t\t\t\t\tWHERE `alliance_id` = '" . $this->_ally['alliance_id'] . "'\r\n\t\t\t\t\t\t\t\t\t\t\tLIMIT 1");
                 Functions_Lib::redirect('game.php?page=alliance');
                 break;
             case $edit == 'transfer' && $this->have_access($this->_ally['alliance_owner'], $this->permissions['admin_alliance']) === TRUE:
                 if (isset($_POST['newleader'])) {
                     parent::$db->query("UPDATE " . USERS . " AS u1, " . ALLIANCE . " AS a, " . USERS . " AS u2 SET\r\n\t\t\t\t\t\t\t\t\t\t\t\tu1.`user_ally_rank_id` = '0',\r\n\t\t\t\t\t\t\t\t\t\t\t\ta.`alliance_owner` = '" . parent::$db->escape_value(strip_tags($_POST['newleader'])) . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\tu2.`user_ally_rank_id` = '0'\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE u1.`user_id`=" . $this->_current_user['user_id'] . " AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ta.`alliance_id`=" . $this->_current_user['user_ally_id'] . " AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tu2.user_id`='" . parent::$db->escape_value(strip_tags($_POST['newleader'])) . "'");
                     Functions_Lib::redirect('game.php?page=alliance');
                 }
                 $page_list = '';
                 if ($this->_ally['alliance_owner'] != $this->_current_user['user_id']) {
                     Functions_Lib::redirect('game.php?page=alliance');
                 } else {
                     $listuser = parent::$db->query("SELECT *\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . "\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE user_ally_id = '" . $this->_current_user['user_ally_id'] . "'");
                     $righthand = $this->_lang;
                     while ($u = parent::$db->fetch_array($listuser)) {
                         if ($this->_ally['alliance_owner'] != $u['user_id']) {
                             if ($u['ally_rank_id'] != 0) {
                                 if ($alliance_ranks[$u['user_ally_rank_id'] - 1]['rechtehand'] == 1) {
                                     $righthand['righthand'] .= "\n<option value=\"" . $u['user_id'] . "\"";
                                     $righthand['righthand'] .= ">";
                                     $righthand['righthand'] .= "" . $u['user_name'];
                                     $righthand['righthand'] .= "&nbsp;[" . $alliance_ranks[$u['user_ally_rank_id'] - 1]['name'];
                                     $righthand['righthand'] .= "]&nbsp;&nbsp;</option>";
                                 }
                             }
                         }
                         $righthand['dpath'] = DPATH;
                     }
                     $page_list .= parent::$page->parse_template(parent::$page->get_template('alliance/alliance_admin_transfer_row'), $righthand);
                     $parse['list'] = $page_list;
                     return parent::$page->parse_template(parent::$page->get_template('alliance/alliance_admin_transfer'), $parse);
                 }
                 break;
         }
     }
 }
示例#27
0
 /**
  * method ships_pop_up
  * param
  * return the ships fleet popup
  */
 private function ships_pop_up($title, $content)
 {
     $ships = explode(';', $content['fleet_array']);
     $pop_up = '';
     foreach ($ships as $item => $group) {
         if ($group != '') {
             $ship = explode(',', $group);
             $pop_up .= $this->_lang['tech'][$ship[0]] . ': ' . Format_Lib::pretty_number($ship[1]) . '<br />';
         }
     }
     $parse['popup_title'] = $title;
     $parse['popup_content'] = $pop_up;
     return parent::$page->parse_template(parent::$page->get_template('adm/fleet_popup_view'), $parse);
 }
示例#28
0
 private function ElementBuildListBox($current_page)
 {
     $ElementQueue = explode(';', $this->_current_planet['planet_b_hangar_id']);
     $NbrePerType = '';
     $NamePerType = '';
     $TimePerType = '';
     $QueueTime = 0;
     foreach ($ElementQueue as $ElementLine => $Element) {
         if ($Element != '') {
             $Element = explode(',', $Element);
             $ElementTime = Developments_Lib::development_time($this->_current_user, $this->_current_planet, $Element[0]);
             $QueueTime += $ElementTime * $Element[1];
             $TimePerType .= "" . $ElementTime . ",";
             $NamePerType .= "'" . html_entity_decode($this->_lang['tech'][$Element[0]], ENT_COMPAT, "utf-8") . "',";
             $NbrePerType .= "" . $Element[1] . ",";
         }
     }
     $parse = $this->_lang;
     $parse['a'] = $NbrePerType;
     $parse['b'] = $NamePerType;
     $parse['c'] = $TimePerType;
     $parse['b_hangar_id_plus'] = $this->_current_planet['planet_b_hangar'];
     $parse['current_page'] = $current_page;
     $parse['pretty_time_b_hangar'] = Format_Lib::pretty_time($QueueTime - $this->_current_planet['planet_b_hangar']);
     return parent::$page->parse_template(parent::$page->get_template('buildings/buildings_script'), $parse);
 }
 /**
  * method set_level_format
  * param $level
  * param $element
  * return return the level with format
  */
 public static function set_level_format($level, $element = '', $current_user = '')
 {
     $return_level = '';
     // check if is base level
     if ($level != 0) {
         $return_level = ' (' . parent::$lang['bd_lvl'] . ' ' . $level . ')';
     }
     // check a commander plus
     switch ($element) {
         case 106:
             if (Officiers_Lib::is_officier_active($current_user['premium_officier_technocrat'])) {
                 $return_level .= Format_Lib::strong_text(Format_Lib::color_green(' +' . TECHNOCRATE_SPY . parent::$lang['bd_spy']));
             }
             break;
         case 108:
             if (Officiers_Lib::is_officier_active($current_user['premium_officier_admiral'])) {
                 $return_level .= Format_Lib::strong_text(Format_Lib::color_green(' +' . AMIRAL . parent::$lang['bd_commander']));
             }
             break;
     }
     return $return_level;
 }