Example #1
0
 /**
  * buildPages
  *
  * @return void
  */
 private function buildPage()
 {
     $parse = $this->langs;
     if ($_POST) {
         $login = parent::$db->queryFetch("SELECT `user_id`, `user_name`, `user_password`, `user_banned`\n                FROM " . USERS . "\n                WHERE `user_name` = '" . parent::$db->escapeValue($_POST['login']) . "'\n                AND `user_password` = '" . sha1($_POST['pass']) . "'\n                LIMIT 1");
         if ($login['user_banned'] <= time()) {
             $this->removeBan($login['user_name']);
         }
         if ($login) {
             // User login
             if (parent::$users->user_login($login['user_id'], $login['user_name'], $login['user_password'])) {
                 // Update current planet
                 parent::$db->query("UPDATE " . USERS . " SET\n                        `user_current_planet` = `user_home_planet_id`\n                        WHERE `user_id` ='" . $login['user_id'] . "'");
                 // Redirect to game
                 FunctionsLib::redirect('game.php?page=overview');
             }
         }
         // If login fails
         FunctionsLib::redirect('index.php');
     } else {
         $parse['year'] = date('Y');
         $parse['version'] = VERSION;
         $parse['servername'] = FunctionsLib::read_config('game_name');
         $parse['game_logo'] = FunctionsLib::read_config('game_logo');
         $parse['forum_url'] = FunctionsLib::read_config('forum_url');
         $parse['js_path'] = JS_PATH . 'home/';
         $parse['css_path'] = CSS_PATH . 'home/';
         $parse['img_path'] = IMG_PATH . 'home/';
         $parse['base_path'] = BASE_PATH;
         parent::$page->display(parent::$page->parse_template(parent::$page->get_template('home/index_body'), $parse), false, '', false);
     }
 }
Example #2
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $parse = $this->_lang;
     $modules_array = '';
     $modules_count = count(explode(';', FunctionsLib::read_config('modules')));
     $row_template = parent::$page->get_template('adm/modules_row_view');
     $module_rows = '';
     $parse['alert'] = '';
     // SAVE PAGE
     if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['save']) {
         for ($i = 0; $i <= $modules_count - 2; $i++) {
             $modules_array .= (isset($_POST["status{$i}"]) ? 1 : 0) . ';';
         }
         FunctionsLib::update_config('modules', $modules_array);
         $parse['alert'] = AdministrationLib::save_message('ok', $this->_lang['se_all_ok_message']);
     }
     // SHOW PAGE
     $modules_array = explode(';', FunctionsLib::read_config('modules'));
     foreach ($modules_array as $module => $status) {
         if ($status != NULL) {
             $parse['module'] = $module;
             $parse['module_name'] = $this->_lang['module'][$module];
             $parse['module_value'] = $status == 1 ? 'checked' : '';
             $parse['color'] = $status == 1 ? 'text-success' : 'text-error';
             $module_rows .= parent::$page->parse_template($row_template, $parse);
         }
     }
     $parse['module_rows'] = $module_rows;
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template("adm/modules_view"), $parse));
 }
Example #3
0
 /**
  * __construct()
  */
 public function __construct()
 {
     parent::__construct();
     // check if session is active
     parent::$users->check_session();
     // Check module access
     FunctionsLib::module_message(FunctionsLib::is_module_accesible(self::MODULE_ID));
     $this->_lang = parent::$lang;
     $this->_resource = parent::$objects->getObjects();
     $this->_tr_dark_matter = FunctionsLib::read_config('trader_darkmatter');
     $this->_current_user = parent::$users->get_user_data();
     $this->_current_planet = parent::$users->get_planet_data();
     $this->build_page();
 }
Example #4
0
 /**
  * __construct()
  */
 public function __construct()
 {
     parent::__construct();
     // check if session is active
     parent::$users->check_session();
     $this->_lang = parent::$lang;
     $this->_current_user = parent::$users->get_user_data();
     // Check if the user is allowed to access
     if (AdministrationLib::have_access($this->_current_user['user_authlevel']) && AdministrationLib::authorization($this->_current_user['user_authlevel'], 'config_game') == 1) {
         $this->_game_config = FunctionsLib::read_config('', TRUE);
         $this->build_page();
     } else {
         die(FunctionsLib::message($this->_lang['ge_no_permissions']));
     }
 }
Example #5
0
 /**
  * method calculate_points
  * param $element
  * param $level
  * return the points for the current element and level
  */
 public static function calculate_points($element, $level, $type = '')
 {
     switch ($type) {
         case 'tech':
             $current_level = $level;
             break;
         case '':
         default:
             $current_level = $level - 1 < 0 ? 0 : $level - 1;
             break;
     }
     $element = parent::$objects->getPrice($element);
     $resources_total = $element['metal'] + $element['crystal'] + $element['deuterium'];
     $level_mult = pow($element['factor'], $current_level);
     $points = $resources_total * $level_mult / FunctionsLib::read_config('stat_settings');
     return $points;
 }
Example #6
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $resource = parent::$objects->getObjects();
     $reslist = parent::$objects->getObjectsList();
     $planetsrow = parent::$db->query("SELECT `planet_id`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_name`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_galaxy`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_image`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_field_current`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_field_max`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_metal`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_metal_perhour`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_crystal`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_crystal_perhour`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_deuterium`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_deuterium_perhour`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_energy_used`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_energy_max`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_metal_mine`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_crystal_mine`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_deuterium_sintetizer`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_solar_plant`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_fusion_reactor`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_robot_factory`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_nano_factory`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_hangar`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_metal_store`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_crystal_store`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_deuterium_tank`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_laboratory`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_terraformer`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_ally_deposit`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_missile_silo`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_mondbasis`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_phalanx`,\n\t\t\t\t\t\t\t\t\t\t\t\t\tb.`building_jump_gate`,\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_rocket_launcher`,\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_light_laser`,\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_heavy_laser`,\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_gauss_cannon`,\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_ion_cannon`,\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_plasma_turret`,\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_small_shield_dome`,\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_large_shield_dome`,\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_anti-ballistic_missile`,\n\t\t\t\t\t\t\t\t\t\t\t\t\td.`defense_interplanetary_missile`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_small_cargo_ship`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_big_cargo_ship`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_light_fighter`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_heavy_fighter`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_cruiser`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_battleship`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_colony_ship`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_recycler`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_espionage_probe`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_bomber`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_solar_satellite`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_destroyer`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_deathstar`,\n\t\t\t\t\t\t\t\t\t\t\t\t\ts.`ship_battlecruiser`\n\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\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\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\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\tWHERE `planet_user_id` = '" . (int) $this->_current_user['user_id'] . "'\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->fetchArray($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'] . '">' . FormatLib::pretty_number($p['planet_metal']) . '</a> / ' . FormatLib::pretty_number($p['planet_metal_perhour'] + FunctionsLib::read_config('metal_basic_income')), '<a href="game.php?page=resources&cp=' . $p['planet_id'] . '&amp;re=0&amp;planettype=' . $p['planet_type'] . '">' . FormatLib::pretty_number($p['planet_crystal']) . '</a> / ' . FormatLib::pretty_number($p['planet_crystal_perhour'] + FunctionsLib::read_config('crystal_basic_income')), '<a href="game.php?page=resources&cp=' . $p['planet_id'] . '&amp;re=0&amp;planettype=' . $p['planet_type'] . '">' . FormatLib::pretty_number($p['planet_deuterium']) . '</a> / ' . FormatLib::pretty_number($p['planet_deuterium_perhour'] + FunctionsLib::read_config('deuterium_basic_income')), FormatLib::pretty_number($p['planet_energy_max'] - $p['planet_energy_used']) . ' / ' . FormatLib::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=" . DevelopmentsLib::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);
 }
Example #7
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $game_stat = FunctionsLib::read_config('stat');
     $game_stat_level = FunctionsLib::read_config('stat_level');
     $game_stat_settings = FunctionsLib::read_config('stat_settings');
     $game_stat_update_time = FunctionsLib::read_config('stat_update_time');
     $this->_lang['alert'] = '';
     if (isset($_POST['save']) && $_POST['save'] == $this->_lang['cs_save_changes']) {
         if (isset($_POST['stat']) && $_POST['stat'] != $game_stat) {
             FunctionsLib::update_config('stat', $_POST['stat']);
             $game_stat = $_POST['stat'];
             $ASD3 = $_POST['stat'];
         }
         if (isset($_POST['stat_level']) && is_numeric($_POST['stat_level']) && $_POST['stat_level'] != $game_stat_level) {
             FunctionsLib::update_config('stat_level', $_POST['stat_level']);
             $game_stat_level = $_POST['stat_level'];
             $ASD1 = $_POST['stat_level'];
         }
         if (isset($_POST['stat_settings']) && is_numeric($_POST['stat_settings']) && $_POST['stat_settings'] != $game_stat_settings) {
             FunctionsLib::update_config('stat_settings', $_POST['stat_settings']);
             $game_stat_settings = $_POST['stat_settings'];
         }
         if (isset($_POST['stat_update_time']) && is_numeric($_POST['stat_update_time']) && $_POST['stat_update_time'] != $game_stat_update_time) {
             FunctionsLib::update_config('stat_update_time', $_POST['stat_update_time']);
             $game_stat_update_time = $_POST['stat_update_time'];
         }
         $this->_lang['alert'] = AdministrationLib::save_message('ok', $this->_lang['cs_all_ok_message']);
     }
     $selected = "selected=\"selected\"";
     $stat = $game_stat == 1 ? 'sel_sta1' : 'sel_sta0';
     $this->_lang[$stat] = $selected;
     $this->_lang['stat_level'] = $game_stat_level;
     $this->_lang['stat_settings'] = $game_stat_settings;
     $this->_lang['stat_update_time'] = $game_stat_update_time;
     $this->_lang['yes'] = $this->_lang['cs_yes'][1];
     $this->_lang['no'] = $this->_lang['cs_no'][0];
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('adm/statistics_view'), $this->_lang));
 }
Example #8
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $parse = $this->_lang;
     // ON POST
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         // SAVE DATA
         if (isset($_POST['save']) && $_POST['save']) {
             FunctionsLib::update_config('auto_backup', isset($_POST['auto_backup']) && $_POST['auto_backup'] == 'on' ? 1 : 0);
         }
         // BACKUP DATABASE RIGHT NOW
         if (isset($_POST['backup']) && $_POST['backup']) {
             $result = parent::$db->backupDb();
             if ($result != FALSE) {
                 $parse['alert'] = AdministrationLib::save_message('ok', str_replace('%s', round($result / 1024, 2), $this->_lang['bku_backup_done']));
             }
         }
     }
     // PARSE DATA
     $auto_backup_status = FunctionsLib::read_config('auto_backup');
     $parse['color'] = $auto_backup_status == 1 ? 'text-success' : 'text-error';
     $parse['checked'] = $auto_backup_status == 1 ? 'checked' : '';
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template("adm/backup_view"), $parse));
 }
Example #9
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $parse = $this->_lang;
     $query = parent::$db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\tFROM " . BANNED . "\n\t\t\t\t\t\t\t\t\t\t\tORDER BY `banned_id`;");
     $i = 0;
     $sub_template = parent::$page->get_template('banned/banned_row');
     $body = '';
     while ($u = parent::$db->fetchArray($query)) {
         $parse['player'] = $u[1];
         $parse['reason'] = $u[2];
         $parse['since'] = date(FunctionsLib::read_config('date_format_extended'), $u[4]);
         $parse['until'] = date(FunctionsLib::read_config('date_format_extended'), $u[5]);
         $parse['by'] = $u[6];
         $i++;
         $body .= parent::$page->parse_template($sub_template, $parse);
     }
     if ($i == 0) {
         $parse['banned_msg'] = $this->_lang['bn_no_players_banned'];
     } else {
         $parse['banned_msg'] = $this->_lang['bn_exists'] . $i . $this->_lang['bn_players_banned'];
     }
     $parse['banned_players'] = $body;
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('banned/banned_body'), $parse));
 }
Example #10
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $parse = $this->_lang;
     $parse['alert'] = '';
     $error = '';
     if (isset($_POST['save'])) {
         if (isset($_POST['premium_url']) && !empty($_POST['premium_url'])) {
             FunctionsLib::update_config('premium_url', FunctionsLib::prep_url($_POST['premium_url']));
         } else {
             $error .= $this->_lang['pr_error_url'];
         }
         if (isset($_POST['trader_darkmatter']) && $_POST['trader_darkmatter'] > 0) {
             FunctionsLib::update_config('trader_darkmatter', $_POST['trader_darkmatter']);
         } else {
             $error .= $this->_lang['pr_error_trader'];
         }
         if ($error != '') {
             $parse['alert'] = AdministrationLib::save_message('warning', $error);
         } else {
             $parse['alert'] = AdministrationLib::save_message('ok', $this->_lang['pr_all_ok_message']);
         }
     }
     $parse['premium_url'] = FunctionsLib::read_config('premium_url');
     $parse['trader_darkmatter'] = FunctionsLib::read_config('trader_darkmatter');
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('adm/premium_view'), $parse));
 }
Example #11
0
 /**
  * method send_fleet
  * param
  * return send fleet routine
  */
 private function send_fleet()
 {
     $max_spy_probes = $this->_current_user['setting_probes_amount'];
     $UserSpyProbes = $this->_current_planet['ship_espionage_probe'];
     $UserRecycles = $this->_current_planet['ship_recycler'];
     $UserDeuterium = $this->_current_planet['planet_deuterium'];
     $UserMissiles = $this->_current_planet['defense_interplanetary_missile'];
     $fleet = array();
     $speedalls = array();
     $PartialFleet = FALSE;
     $PartialCount = 0;
     $order = isset($_POST['order']) ? $_POST['order'] : NULL;
     $ResultMessage = '';
     $fleet['fleetlist'] = '';
     $fleet['amount'] = '';
     switch ($order) {
         case 6:
             $_POST['ship210'] = $_POST['shipcount'];
             break;
         case 7:
             $_POST['ship208'] = $_POST['shipcount'];
             break;
         case 8:
             $_POST['ship209'] = $_POST['shipcount'];
             break;
     }
     foreach ($this->_reslist['fleet'] as $Node => $ShipID) {
         $TName = "ship" . $ShipID;
         if (isset($_POST[$TName]) && $ShipID > 200 && $ShipID < 300 && $_POST[$TName] > 0) {
             if ($_POST[$TName] > $this->_current_planet[$this->_resource[$ShipID]]) {
                 $fleet['fleetarray'][$ShipID] = $this->_current_planet[$this->_resource[$ShipID]];
                 $fleet['fleetlist'] .= $ShipID . "," . $this->_current_planet[$this->_resource[$ShipID]] . ";";
                 $fleet['amount'] += $this->_current_planet[$this->_resource[$ShipID]];
                 $PartialCount += $this->_current_planet[$this->_resource[$ShipID]];
                 $PartialFleet = TRUE;
             } else {
                 $fleet['fleetarray'][$ShipID] = $_POST[$TName];
                 $fleet['fleetlist'] .= $ShipID . "," . $_POST[$TName] . ";";
                 $fleet['amount'] += $_POST[$TName];
                 $speedalls[$ShipID] = $_POST[$TName];
             }
         }
     }
     $errors_types = array(600 => $this->_lang['gl_success'], 601 => $this->_lang['gl_error'], 602 => $this->_lang['gl_no_moon'], 603 => $this->_lang['gl_noob_protection'], 604 => $this->_lang['gl_too_strong'], 605 => $this->_lang['gl_vacation_mode'], 610 => $this->_lang['gl_only_amount_ships'], 611 => $this->_lang['gl_no_ships'], 612 => $this->_lang['gl_no_slots'], 613 => $this->_lang['gl_no_deuterium'], 614 => $this->_lang['gl_no_planet'], 615 => $this->_lang['gl_not_enough_storage'], 616 => $this->_lang['gl_multi_alarm']);
     if ($PartialFleet == TRUE) {
         if ($PartialCount < 1) {
             die("611 ");
         }
     }
     $galaxy = isset($_POST['galaxy']) ? (int) $_POST['galaxy'] : 0;
     $system = isset($_POST['system']) ? (int) $_POST['system'] : 0;
     $planet = isset($_POST['planet']) ? (int) $_POST['planet'] : 0;
     $FleetArray = isset($fleet['fleetarray']) ? $fleet['fleetarray'] : NULL;
     if ($galaxy > MAX_GALAXY_IN_WORLD or $galaxy < 1 or ($system > MAX_SYSTEM_IN_GALAXY or $system < 1) or ($planet > MAX_PLANET_IN_SYSTEM or $planet < 1) or is_null($FleetArray)) {
         die("614 ");
     }
     $CurrentFlyingFleets = parent::$db->queryFetch("SELECT COUNT(fleet_id) AS `Nbre`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_owner` = '" . $this->_current_user['user_id'] . "';");
     $CurrentFlyingFleets = $CurrentFlyingFleets['Nbre'];
     $TargetRow = parent::$db->queryFetch("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . parent::$db->escapeValue($_POST['galaxy']) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . parent::$db->escapeValue($_POST['system']) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . parent::$db->escapeValue($_POST['planet']) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = '" . parent::$db->escapeValue($_POST['planettype']) . "';");
     if ($TargetRow['planet_user_id'] == '') {
         $TargetUser = $this->_current_user;
     } elseif ($TargetRow['planet_user_id'] != '') {
         $TargetUser = parent::$db->queryFetch("SELECT u.`user_id`, u.`user_onlinetime`, u.`user_authlevel`, s.`setting_vacations_status`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . " AS u\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . SETTINGS . " AS s ON s.setting_user_id = u.user_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `user_id` = '" . $TargetRow['planet_user_id'] . "';");
     }
     // invisible debris by jstar
     if ($order == 8) {
         $TargetGPlanet = parent::$db->queryFetch("SELECT planet_invisible_start_time, planet_debris_metal, planet_debris_crystal\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE planet_galaxy = '" . parent::$db->escapeValue($_POST['galaxy']) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tplanet_system = '" . parent::$db->escapeValue($_POST['system']) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tplanet_planet = '" . parent::$db->escapeValue($_POST['planet']) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tplanet_type = 1;");
         if ($TargetGPlanet['planet_debris_metal'] == 0 && $TargetGPlanet['planet_debris_crystal'] == 0 && time() > $TargetGPlanet['planet_invisible_start_time'] + DEBRIS_LIFE_TIME) {
             die;
         }
     }
     $user_points = $this->_noob->return_points($this->_current_user['user_id'], $TargetUser['user_id']);
     $CurrentPoints = $user_points['user_points'];
     $TargetPoints = $user_points['target_points'];
     $TargetVacat = $TargetUser['setting_vacations_status'];
     if (FleetsLib::get_max_fleets($this->_current_user[$this->_resource[108]], $this->_current_user['premium_officier_admiral']) <= $CurrentFlyingFleets) {
         die("612 ");
     }
     if (!is_array($FleetArray)) {
         die("611 ");
     }
     if (!($order == 6 or $order == 8)) {
         die("601 ");
     }
     if ($TargetVacat && $order != 8 or $this->_current_user['setting_vacations_status']) {
         die("605 ");
     }
     if ($TargetUser['user_onlinetime'] >= time() - 60 * 60 * 24 * 7) {
         if ($this->_noob->is_weak($CurrentPoints, $TargetPoints) && $TargetRow['planet_user_id'] != '' && $order == 6) {
             die("603 ");
         }
         if ($this->_noob->is_strong($CurrentPoints, $TargetPoints) && $TargetRow['planet_user_id'] != '' && $order == 6) {
             die("604 ");
         }
     }
     if ($TargetRow['planet_user_id'] == '' && $order != 8) {
         die("601 ");
     }
     if ($TargetRow['planet_user_id'] == $this->_current_planet['planet_user_id'] && $order == 6) {
         die("601 ");
     }
     $Distance = FleetsLib::target_distance($this->_current_planet['planet_galaxy'], $_POST['galaxy'], $this->_current_planet['planet_system'], $_POST['system'], $this->_current_planet['planet_planet'], $_POST['planet']);
     $speedall = FleetsLib::fleet_max_speed($FleetArray, 0, $this->_current_user);
     $SpeedAllMin = min($speedall);
     $Duration = FleetsLib::mission_duration(10, $SpeedAllMin, $Distance, FunctionsLib::fleet_speed_factor());
     $fleet['fly_time'] = $Duration;
     $fleet['start_time'] = $Duration + time();
     $fleet['end_time'] = $Duration * 2 + time();
     $FleetShipCount = 0;
     $FleetDBArray = "";
     $FleetSubQRY = "";
     $consumption = 0;
     $SpeedFactor = FunctionsLib::fleet_speed_factor();
     foreach ($FleetArray as $Ship => $Count) {
         if ($Ship != '') {
             $ShipSpeed = $this->_pricelist[$Ship]['speed'];
             $spd = 35000 / ($Duration * $SpeedFactor - 10) * sqrt($Distance * 10 / $ShipSpeed);
             $basicConsumption = $this->_pricelist[$Ship]['consumption'] * $Count;
             $consumption += $basicConsumption * $Distance / 35000 * ($spd / 10 + 1) * ($spd / 10 + 1);
             $FleetShipCount += $Count;
             $FleetDBArray .= $Ship . "," . $Count . ";";
             $FleetSubQRY .= "`" . $this->_resource[$Ship] . "` = `" . $this->_resource[$Ship] . "` - " . $Count . " , ";
         }
     }
     $consumption = round($consumption) + 1;
     if ($UserDeuterium < $consumption) {
         die("613 ");
     }
     if (FunctionsLib::read_config('adm_attack') == 1 && $TargetUser['user_authlevel'] > 0) {
         die("601 ");
     }
     parent::$db->query("INSERT INTO " . FLEETS . " SET\n\t\t\t\t\t\t\t\t`fleet_owner` = '" . $this->_current_user['user_id'] . "',\n\t\t\t\t\t\t\t\t`fleet_mission` = '" . intval($order) . "',\n\t\t\t\t\t\t\t\t`fleet_amount` = '" . $FleetShipCount . "',\n\t\t\t\t\t\t\t\t`fleet_array` = '" . $FleetDBArray . "',\n\t\t\t\t\t\t\t\t`fleet_start_time` = '" . $fleet['start_time'] . "',\n\t\t\t\t\t\t\t\t`fleet_start_galaxy` = '" . $this->_current_planet['planet_galaxy'] . "',\n\t\t\t\t\t\t\t\t`fleet_start_system` = '" . $this->_current_planet['planet_system'] . "',\n\t\t\t\t\t\t\t\t`fleet_start_planet` = '" . $this->_current_planet['planet_planet'] . "',\n\t\t\t\t\t\t\t\t`fleet_start_type` = '" . $this->_current_planet['planet_type'] . "',\n\t\t\t\t\t\t\t\t`fleet_end_time` = '" . $fleet['end_time'] . "',\n\t\t\t\t\t\t\t\t`fleet_end_galaxy` = '" . intval($_POST['galaxy']) . "',\n\t\t\t\t\t\t\t\t`fleet_end_system` = '" . intval($_POST['system']) . "',\n\t\t\t\t\t\t\t\t`fleet_end_planet` = '" . intval($_POST['planet']) . "',\n\t\t\t\t\t\t\t\t`fleet_end_type` = '" . intval($_POST['planettype']) . "',\n\t\t\t\t\t\t\t\t`fleet_target_owner` = '" . $TargetRow['planet_user_id'] . "',\n\t\t\t\t\t\t\t\t`fleet_creation` = '" . time() . "';");
     $UserDeuterium -= $consumption;
     parent::$db->query("UPDATE " . PLANETS . " AS p\n\t\t\t\t\t\t\t\tINNER JOIN " . SHIPS . " AS s ON s.ship_planet_id = p.`planet_id` SET\n\t\t\t\t\t\t\t\t{$FleetSubQRY}\n\t\t\t\t\t\t\t\tp.`planet_deuterium` = '" . ($UserDeuterium < 1 ? 0 : $UserDeuterium) . "'\n\t\t\t\t\t\t\t\tWHERE p.`planet_id` = '" . $this->_current_planet['planet_id'] . "';");
     $CurrentFlyingFleets++;
     foreach ($FleetArray as $Ships => $Count) {
         if ($max_spy_probes > $this->_current_planet[$this->_resource[$Ships]]) {
             $ResultMessage = "610 " . $FleetShipCount;
         }
     }
     if ($ResultMessage == '') {
         $ResultMessage = "600 " . $Ships;
     }
     die($ResultMessage);
 }
Example #12
0
define('DPATH', DEFAULT_SKINPATH);
// For debugging
if (FunctionsLib::read_config('debug') == 1) {
    // Show all errors
    ini_set('display_errors', 1);
    error_reporting(E_ALL);
} else {
    // Only for Betas, it's going to be changed
    ini_set('display_errors', 1);
    error_reporting(E_ALL);
}
$debug = FunctionsLib::load_library('DebugLib');
$db = new Database();
$installed = FunctionsLib::read_config('game_installed');
$game_version = FunctionsLib::read_config('version');
$game_lang = FunctionsLib::read_config('lang');
$current_page = isset($_GET['page']) ? $_GET['page'] : '';
// check if is installed
if ($installed == 0 && !defined('IN_INSTALL')) {
    FunctionsLib::redirect(XGP_ROOT . 'install/');
}
// define game version
if ($installed != 0) {
    define('VERSION', $game_version == '' ? '' : 'v' . $game_version);
}
// define game language
define('DEFAULT_LANG', $game_lang == '' ? 'spanish' : $game_lang);
if (!defined('IN_INSTALL')) {
    require_once XGP_ROOT . CORE_PATH . 'Sessions.php';
    require_once XGP_ROOT . CORE_PATH . 'Hooks.php';
    require_once XGP_ROOT . LIB_PATH . 'StatisticsLib.php';
 /**
  * method isInstalled
  * param
  * return true if the game is already installed, false if not
  */
 private function isInstalled()
 {
     return FunctionsLib::read_config('game_installed') == 1;
 }
Example #14
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $this->_lang['js_path'] = XGP_ROOT . JS_PATH;
     $parse = $this->_lang;
     $a = isset($_GET['a']) ? intval($_GET['a']) : NULL;
     $n = isset($_GET['n']) ? intval($_GET['n']) : NULL;
     $s = isset($_POST['s']) ? intval($_POST['s']) : NULL;
     if ($s == 1 or $s == 2) {
         $time = time();
         $priority = intval($_POST['u']);
         $title = $_POST['title'] ? parent::$db->escapeValue(strip_tags($_POST['title'])) : "Sin t&iacute;tulo";
         $text = $_POST['text'] ? FunctionsLib::format_text($_POST['text']) : $this->_lang['nt_no_text'];
         if ($s == 1) {
             parent::$db->query("INSERT INTO " . NOTES . " SET\n\t\t\t\t\t\t\t\t\t\tnote_owner=" . intval($this->_current_user['user_id']) . ",\n\t\t\t\t\t\t\t\t\t\tnote_time={$time},\n\t\t\t\t\t\t\t\t\t\tnote_priority={$priority},\n\t\t\t\t\t\t\t\t\t\tnote_title='{$title}',\n\t\t\t\t\t\t\t\t\t\tnote_text='{$text}'");
             FunctionsLib::redirect('game.php?page=notes');
         } elseif ($s == 2) {
             $id = intval($_POST['n']);
             $note_query = parent::$db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . NOTES . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE note_id=" . intval($id) . " AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnote_owner=" . intval($this->_current_user['user_id']) . "");
             if (!$note_query) {
                 FunctionsLib::redirect('game.php?page=notes');
             }
             parent::$db->query("UPDATE `" . NOTES . "` SET\n\t\t\t\t\t\t\t\t\t\tnote_time={$time},\n\t\t\t\t\t\t\t\t\t\tnote_priority={$priority},\n\t\t\t\t\t\t\t\t\t\tnote_title='{$title}',\n\t\t\t\t\t\t\t\t\t\tnote_text='{$text}'\n\t\t\t\t\t\t\t\t\t\tWHERE note_id=" . intval($id) . "");
             FunctionsLib::redirect('game.php?page=notes');
         }
     } elseif ($_POST) {
         foreach ($_POST as $a => $b) {
             if (preg_match("/delmes/i", $a) && $b == "y") {
                 $id = str_replace("delmes", "", $a);
                 $note_query = parent::$db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . NOTES . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `note_id` = " . (int) $id . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `note_owner` = " . $this->_current_user['user_id'] . "");
                 if ($note_query) {
                     parent::$db->query("DELETE FROM `" . NOTES . "`\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `note_id` = " . (int) $id . ";");
                 }
             }
         }
         FunctionsLib::redirect('game.php?page=notes');
     } else {
         if ($a == 1) {
             $parse['c_Options'] = "<option value=2 selected=selected>" . $this->_lang['nt_important'] . "</option>\n\t\t\t\t<option value=1>" . $this->_lang['nt_normal'] . "</option>\n\t\t\t\t<option value=0>" . $this->_lang['nt_unimportant'] . "</option>";
             $parse['TITLE'] = $this->_lang['nt_create_note'];
             $parse['inputs'] = "<input type=hidden name=s value=1>";
             parent::$page->display(parent::$page->parse_template(parent::$page->get_template('notes/notes_form'), $parse), FALSE, '', FALSE);
         } elseif ($a == 2) {
             $SELECTED['0'] = '';
             $SELECTED['1'] = '';
             $SELECTED['2'] = '';
             $note = parent::$db->queryFetch("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . NOTES . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `note_owner` = " . $this->_current_user['user_id'] . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `note_id` = " . (int) $n . ";");
             if (!$note) {
                 FunctionsLib::redirect('game.php?page=notes');
             }
             $SELECTED[$note['note_priority']] = ' selected="selected"';
             $parse['c_Options'] = "<option value=2{$SELECTED['2']}>" . $this->_lang['nt_important'] . "</option>\n\t\t\t\t<option value=1{$SELECTED['1']}>" . $this->_lang['nt_normal'] . "</option>\n\t\t\t\t<option value=0{$SELECTED['0']}>" . $this->_lang['nt_unimportant'] . "</option>";
             $parse['TITLE'] = $this->_lang['nt_edit_note'];
             $parse['inputs'] = '<input type="hidden" name="s" value="2"><input type="hidden" name="n" value=' . $note['note_id'] . '>';
             $parse['asunto'] = $note['note_title'];
             $parse['texto'] = $note['note_text'];
             parent::$page->display(parent::$page->parse_template(parent::$page->get_template('notes/notes_form'), $parse), FALSE, '', FALSE);
         } else {
             $notes_query = parent::$db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . NOTES . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `note_owner` = " . $this->_current_user['user_id'] . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY `note_time` DESC");
             $count = 0;
             $NotesBodyEntryTPL = parent::$page->get_template('notes/notes_body_entry');
             $list = '';
             while ($note = parent::$db->fetchArray($notes_query)) {
                 $count++;
                 $parse['NOTE_COLOR'] = $this->return_priority($note['note_priority']);
                 $parse['NOTE_ID'] = $note['note_id'];
                 $parse['NOTE_TIME'] = date(FunctionsLib::read_config('date_format_extended'), $note['note_time']);
                 $parse['NOTE_TITLE'] = $note['note_title'];
                 $parse['NOTE_TEXT'] = strlen($note['note_text']);
                 $list .= parent::$page->parse_template($NotesBodyEntryTPL, $parse);
             }
             if ($count == 0) {
                 $list .= "<tr><th colspan=4>" . $this->_lang['nt_you_dont_have_notes'] . "</th>\n";
             }
             $parse['BODY_LIST'] = $list;
             parent::$page->display(parent::$page->parse_template(parent::$page->get_template('notes/notes_body'), $parse), FALSE, '', FALSE);
         }
     }
 }
Example #15
0
 /**
  * method check_updates
  * param
  * return check for updates and returns true or false
  */
 private function check_updates()
 {
     if (function_exists('file_get_contents')) {
         $last_v = @file_get_contents('http://xgproyect.xgproyect.org/current.php');
         $system_v = FunctionsLib::read_config('version');
         return version_compare($system_v, $last_v, '<');
     }
 }
Example #16
0
 /**
  * buildPage
  *
  * @return void
  */
 private function buildPage()
 {
     FunctionsLib::redirect(FunctionsLib::read_config('forum_url'));
 }
Example #17
0
 /**
  * method time_zone_picker
  * param
  * return return the select options
  */
 private function time_zone_picker()
 {
     $utc = new DateTimeZone('UTC');
     $dt = new DateTime('now', $utc);
     $time_zones = '';
     $current_time_zone = FunctionsLib::read_config('date_time_zone');
     // Get the data
     foreach (DateTimeZone::listIdentifiers() as $tz) {
         $current_tz = new DateTimeZone($tz);
         $offset = $current_tz->getOffset($dt);
         $transition = $current_tz->getTransitions($dt->getTimestamp(), $dt->getTimestamp());
         foreach ($transition as $element => $data) {
             $time_zones_data[$data['offset']][] = $tz;
         }
     }
     // Sort by key
     ksort($time_zones_data);
     // Build the combo
     foreach ($time_zones_data as $offset => $tz) {
         $time_zones .= '<optgroup label="GMT' . $this->format_offset($offset) . '">';
         foreach ($tz as $key => $zone) {
             $time_zones .= '<option value="' . $zone . '" ' . ($current_time_zone == $zone ? ' selected' : '') . ' >' . $zone . '</option>';
         }
         $time_zones .= '</optgroup>';
     }
     // Return data
     return $time_zones;
 }
Example #18
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $parse = $this->_lang;
     $parse['alert'] = '';
     if (isset($_POST['mode']) && $_POST['mode']) {
         $view_m = isset($_POST['view_m']) ? $this->set_rank($_POST['view_m']) : '';
         $edit_m = isset($_POST['edit_m']) ? $this->set_rank($_POST['edit_m']) : '';
         $config_m = isset($_POST['config_m']) ? $this->set_rank($_POST['config_m']) : '';
         $tools_m = isset($_POST['tools_m']) ? $this->set_rank($_POST['tools_m']) : '';
         $log_m = isset($_POST['log_m']) ? $this->set_rank($_POST['log_m']) : '';
         $maintenance_m = isset($_POST['maintenance_m']) ? $this->set_rank($_POST['maintenance_m']) : '';
         $view_o = isset($_POST['view_o']) ? $this->set_rank($_POST['view_o']) : '';
         $edit_o = isset($_POST['edit_o']) ? $this->set_rank($_POST['edit_o']) : '';
         $config_o = isset($_POST['config_o']) ? $this->set_rank($_POST['config_o']) : '';
         $tools_o = isset($_POST['tools_o']) ? $this->set_rank($_POST['tools_o']) : '';
         $log_o = isset($_POST['log_o']) ? $this->set_rank($_POST['log_o']) : '';
         $maintenance_o = isset($_POST['maintenance_o']) ? $this->set_rank($_POST['maintenance_o']) : '';
         $log_a = isset($_POST['log_a']) ? $this->set_rank($_POST['log_a']) : '';
         $QueryEdit = $view_m . "," . $edit_m . "," . $config_m . "," . $tools_m . "," . $log_m . "," . $maintenance_m . ";" . $view_o . "," . $edit_o . "," . $config_o . "," . $tools_o . "," . $log_o . "," . $maintenance_o . ";" . $log_a . ";";
         FunctionsLib::update_config('moderation', $QueryEdit);
         $parse['alert'] = AdministrationLib::save_message('ok', $this->_lang['mod_all_ok_message']);
     }
     $QueryModeration = FunctionsLib::read_config('moderation');
     $QueryModerationEx = explode(";", $QueryModeration);
     $Moderator = explode(",", $QueryModerationEx[0]);
     $Operator = explode(",", $QueryModerationEx[1]);
     $Administrator = explode(",", $QueryModerationEx[2]);
     // MODERADORES
     if ($Moderator[0] == 1) {
         $parse['view_m'] = 'checked = "checked"';
     }
     if ($Moderator[1] == 1) {
         $parse['edit_m'] = 'checked = "checked"';
     }
     if ($Moderator[2] == 1) {
         $parse['config_m'] = 'checked = "checked"';
     }
     if ($Moderator[3] == 1) {
         $parse['tools_m'] = 'checked = "checked"';
     }
     if ($Moderator[4] == 1) {
         $parse['log_m'] = 'checked = "checked"';
     }
     if ($Moderator[5] == 1) {
         $parse['maintenance_m'] = 'checked = "checked"';
     }
     // OPERADORES
     if ($Operator[0] == 1) {
         $parse['view_o'] = 'checked = "checked"';
     }
     if ($Operator[1] == 1) {
         $parse['edit_o'] = 'checked = "checked"';
     }
     if ($Operator[2] == 1) {
         $parse['config_o'] = 'checked = "checked"';
     }
     if ($Operator[3] == 1) {
         $parse['tools_o'] = 'checked = "checked"';
     }
     if ($Operator[4] == 1) {
         $parse['log_o'] = 'checked = "checked"';
     }
     if ($Operator[5] == 1) {
         $parse['maintenance_o'] = 'checked = "checked"';
     }
     // ADMINISTRADOR (SOLO PARA EL HISTORIAL)
     if ($Administrator[0] == 1) {
         $parse['log_a'] = 'checked = "checked"';
     }
     $parse['mods'] = $this->_lang['user_level'][1];
     $parse['oper'] = $this->_lang['user_level'][2];
     $parse['adm'] = $this->_lang['user_level'][3];
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('adm/moderation_view'), $parse));
 }
 /**
  * __construct()
  */
 public function __construct()
 {
     $this->_protection = FunctionsLib::read_config('noobprotection');
     $this->_protectiontime = FunctionsLib::read_config('noobprotectiontime');
     $this->_protectionmulti = FunctionsLib::read_config('noobprotectionmulti');
 }
Example #20
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->escapeValue(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\n                                                                                            `alliance_ranks`='" . $ranks . "'\n                                                                                            WHERE `alliance_id` = " . (int) $this->_ally['alliance_id']);
                     $goto = $_SERVER['PHP_SELF'] . "?" . str_replace('&amp;', '&', $_SERVER['QUERY_STRING']);
                     FunctionsLib::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\n                                                                                            `alliance_ranks`='" . $ranks . "'\n                                                                                            WHERE `alliance_id`= " . $this->_ally['alliance_id']);
                     $goto = $_SERVER['PHP_SELF'] . "?" . str_replace('&amp;', '&', $_SERVER['QUERY_STRING']);
                     FunctionsLib::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\n                                                                                            `alliance_ranks`='" . $this->_ally['ally_rank'] . "'\n                                                                                            WHERE `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']) ? FunctionsLib::format_text($_POST['text']) : '';
                 }
                 if (isset($_POST['options'])) {
                     $this->_ally['alliance_owner_range'] = parent::$db->escapeValue(htmlspecialchars(strip_tags($_POST['owner_range'])));
                     $this->_ally['alliance_web'] = parent::$db->escapeValue(htmlspecialchars(strip_tags($_POST['web'])));
                     $this->_ally['alliance_image'] = parent::$db->escapeValue(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) {
                         FunctionsLib::redirect('game.php?page=alliance?mode=admin&edit=ally');
                     }
                     parent::$db->query("UPDATE " . ALLIANCE . " SET\n                                                                                            `alliance_owner_range`='" . $this->_ally['alliance_owner_range'] . "',\n                                                                                            `alliance_image`='" . $this->_ally['alliance_image'] . "',\n                                                                                            `alliance_web`='" . $this->_ally['alliance_web'] . "',\n                                                                                            `alliance_request_notallow`='" . $this->_ally['alliance_request_notallow'] . "'\n                                                                                            WHERE `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\n                                                                                                    `alliance_request`='" . $this->_ally['alliance_request'] . "'\n                                                                                                    WHERE `alliance_id` = '" . $this->_ally['alliance_id'] . "'");
                         FunctionsLib::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\n                                                                                                    `alliance_text`='" . $this->_ally['alliance_text'] . "'\n                                                                                                    WHERE `alliance_id` = '" . $this->_ally['alliance_id'] . "'");
                         FunctionsLib::redirect('game.php?page=alliance&mode=admin&edit=ally&t=2');
                     } else {
                         $this->_ally['alliance_description'] = $_POST['text'];
                         parent::$db->query("UPDATE " . ALLIANCE . " SET\n                                                                                                    `alliance_description`='" . $this->_ally['alliance_description'] . "'\n                                                                                                    WHERE `alliance_id` = '" . $this->_ally['alliance_id'] . "'");
                         FunctionsLib::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->queryFetch("SELECT `user_ally_id`, `user_id`\n                                                                                                                    FROM `" . USERS . "`\n                                                                                                                    WHERE `user_id` = '" . (int) $kick . "'\n                                                                                                                    LIMIT 1");
                     if ($u['user_ally_id'] == $this->_ally['alliance_id'] && $u['user_id'] != $this->_ally['alliance_owner']) {
                         parent::$db->query("UPDATE " . USERS . " SET\n                                                                                                    `user_ally_id`='0',\n                                                                                                    `user_ally_rank_id` = 0\n                                                                                                    WHERE `user_id`='" . (int) $u['id'] . "' LIMIT 1;");
                     }
                 } elseif (isset($_POST['newrang'])) {
                     $u = isset($id) ? $id : '';
                     $q = parent::$db->queryFetch("SELECT `user_id`\n                                                                                                                    FROM " . USERS . "\n                                                                                                                    WHERE `user_id` = '" . (int) $u . "'\n                                                                                                                    LIMIT 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\n                                                                                                    `user_ally_rank_id` = '" . parent::$db->escapeValue($_POST['newrang']) . "'\n                                                                                                    WHERE `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\n                                                                                                            FROM `" . USERS . "` AS u\n                                                                                                            INNER JOIN `" . USERS_STATISTICS . "`AS s ON u.user_id = s.user_statistic_user_id\n                                                                                                            WHERE u.user_ally_id='" . $this->_current_user['user_ally_id'] . "'" . $sort);
                 $i = 0;
                 $r = $this->_lang;
                 $s = $this->_lang;
                 $this->_lang['i'] = parent::$db->numRows($listuser);
                 $page_list = '';
                 $r['options'] = '';
                 while ($u = parent::$db->fetchArray($listuser)) {
                     $u['i'] = ++$i;
                     $u['points'] = FormatLib::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(FunctionsLib::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\n                                                                                            user_ally_request_text = '',\n                                                                                            user_ally_request = '0',\n                                                                                            user_ally_id = '" . $this->_ally['alliance_id'] . "'\n                                                                                            WHERE user_id = '" . $show . "'");
                     FunctionsLib::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']);
                     FunctionsLib::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\n                                                                                            user_ally_request_text='',\n                                                                                            user_ally_request='0',\n                                                                                            user_ally_id='0'\n                                                                                            WHERE user_id = '" . (int) $show . "'");
                     FunctionsLib::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']);
                     FunctionsLib::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\n                                                                                                            FROM " . USERS . "\n                                                                                                            WHERE user_ally_request = '" . $this->_ally['alliance_id'] . "'");
                 /***start fix by jstar***/
                 $s = array();
                 $parse['list'] = '';
                 while ($r = parent::$db->fetchArray($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(FunctionsLib::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\n                                                                                            a.`alliance_name` = '" . $alliance_name . "',\n                                                                                            WHERE 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\n                                                                                            `alliance_tag` = '" . $alliance_tag . "'\n                                                                                            WHERE `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\n                                                                                    `user_ally_id` = '0'\n                                                                                    WHERE `user_ally_id` = '" . $this->_ally['alliance_id'] . "'");
                 parent::$db->query("DELETE FROM " . ALLIANCE . "\n                                                                                    WHERE `alliance_id` = '" . $this->_ally['alliance_id'] . "'\n                                                                                    LIMIT 1");
                 FunctionsLib::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\n                                                                                            u1.`user_ally_rank_id` = '0',\n                                                                                            a.`alliance_owner` = '" . parent::$db->escapeValue(strip_tags($_POST['newleader'])) . "',\n                                                                                            u2.`user_ally_rank_id` = '0'\n                                                                                            WHERE u1.`user_id`=" . $this->_current_user['user_id'] . " AND\n                                                                                                            a.`alliance_id`=" . $this->_current_user['user_ally_id'] . " AND\n                                                                                                            u2.user_id`='" . parent::$db->escapeValue(strip_tags($_POST['newleader'])) . "'");
                     FunctionsLib::redirect('game.php?page=alliance');
                 }
                 $page_list = '';
                 if ($this->_ally['alliance_owner'] != $this->_current_user['user_id']) {
                     FunctionsLib::redirect('game.php?page=alliance');
                 } else {
                     $listuser = parent::$db->query("SELECT *\n                                                                                                                                    FROM " . USERS . "\n                                                                                                                                    WHERE user_ally_id = '" . $this->_current_user['user_ally_id'] . "'");
                     $righthand = $this->_lang;
                     while ($u = parent::$db->fetchArray($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;
         }
     }
 }
Example #21
0
 /**
  * method create_planet
  * param $Galaxy
  * param $System
  * param $Position
  * param $PlanetOwnerID
  * param $PlanetName
  * param $HomeWorld
  * return creates a planet into the data base.
  */
 public function create_planet($galaxy, $system, $position, $planet_owner_id, $planet_name = '', $home_world = FALSE)
 {
     $planet_exist = parent::$db->queryFetch("SELECT `planet_id`\n\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\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` = '" . $position . "';");
     if (!$planet_exist) {
         $planet = $this->return_size($position, $home_world);
         $planet['planet_diameter'] = ($planet['planet_field_max'] ^ 14 / 1.5) * 75;
         $planet['metal'] = BUILD_METAL;
         $planet['crystal'] = BUILD_CRISTAL;
         $planet['deuterium'] = BUILD_DEUTERIUM;
         $planet['planet_metal_perhour'] = FunctionsLib::read_config('metal_basic_income');
         $planet['planet_crystal_perhour'] = FunctionsLib::read_config('crystal_basic_income');
         $planet['planet_deuterium_perhour'] = FunctionsLib::read_config('deuterium_basic_income');
         $planet['galaxy'] = $galaxy;
         $planet['system'] = $system;
         $planet['planet'] = $position;
         if ($position == 1 || $position == 2 || $position == 3) {
             $PlanetType = array('trocken');
             $PlanetClass = array('planet');
             $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10');
             $planet['planet_temp_min'] = mt_rand(0, 100);
             $planet['planet_temp_max'] = $planet['planet_temp_min'] + 40;
         } elseif ($position == 4 || $position == 5 || $position == 6) {
             $PlanetType = array('dschjungel');
             $PlanetClass = array('planet');
             $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10');
             $planet['planet_temp_min'] = mt_rand(-25, 75);
             $planet['planet_temp_max'] = $planet['planet_temp_min'] + 40;
         } elseif ($position == 7 || $position == 8 || $position == 9) {
             $PlanetType = array('normaltemp');
             $PlanetClass = array('planet');
             $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07');
             $planet['planet_temp_min'] = mt_rand(-50, 50);
             $planet['planet_temp_max'] = $planet['planet_temp_min'] + 40;
         } elseif ($position == 10 || $position == 11 || $position == 12) {
             $PlanetType = array('wasser');
             $PlanetClass = array('planet');
             $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09');
             $planet['planet_temp_min'] = mt_rand(-75, 25);
             $planet['planet_temp_max'] = $planet['planet_temp_min'] + 40;
         } elseif ($position == 13 || $position == 14 || $position == 15) {
             $PlanetType = array('eis');
             $PlanetClass = array('planet');
             $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10');
             $planet['planet_temp_min'] = mt_rand(-100, 10);
             $planet['planet_temp_max'] = $planet['planet_temp_min'] + 40;
         } else {
             $PlanetType = array('dschjungel', 'gas', 'normaltemp', 'trocken', 'wasser', 'wuesten', 'eis');
             $PlanetClass = array('planet');
             $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '00');
             $planet['planet_temp_min'] = mt_rand(-120, 10);
             $planet['planet_temp_max'] = $planet['planet_temp_min'] + 40;
         }
         $planet['image'] = $PlanetType[mt_rand(0, count($PlanetType) - 1)];
         $planet['image'] .= $PlanetClass[mt_rand(0, count($PlanetClass) - 1)];
         $planet['image'] .= $PlanetDesign[mt_rand(0, count($PlanetDesign) - 1)];
         $planet['planet_type'] = 1;
         $planet['planet_user_id'] = $planet_owner_id;
         $planet['planet_last_update'] = time();
         $planet['planet_name'] = $planet_name == '' ? $this->_lang['ge_colony'] : $planet_name;
         parent::$db->query("INSERT INTO " . PLANETS . " SET\n\t\t\t\t\t\t\t\t\t" . ($home_world == FALSE ? "`planet_name` = '{$planet['planet_name']}'," : "`planet_name` = '{$this->_lang['ge_home_planet']}',") . "\n\t\t\t\t\t\t\t\t\t`planet_user_id` = '" . $planet['planet_user_id'] . "',\n\t\t\t\t\t\t\t\t\t`planet_galaxy` = '" . $planet['galaxy'] . "',\n\t\t\t\t\t\t\t\t\t`planet_system` = '" . $planet['system'] . "',\n\t\t\t\t\t\t\t\t\t`planet_planet` = '" . $planet['planet'] . "',\n\t\t\t\t\t\t\t\t\t`planet_last_update` = '" . $planet['planet_last_update'] . "',\n\t\t\t\t\t\t\t\t\t`planet_type` = '" . $planet['planet_type'] . "',\n\t\t\t\t\t\t\t\t\t`planet_image` = '" . $planet['image'] . "',\n\t\t\t\t\t\t\t\t\t`planet_diameter` = '" . $planet['planet_diameter'] . "',\n\t\t\t\t\t\t\t\t\t`planet_field_max` = '" . $planet['planet_field_max'] . "',\n\t\t\t\t\t\t\t\t\t`planet_temp_min` = '" . $planet['planet_temp_min'] . "',\n\t\t\t\t\t\t\t\t\t`planet_temp_max` = '" . $planet['planet_temp_max'] . "',\n\t\t\t\t\t\t\t\t\t`planet_metal` = '" . $planet['metal'] . "',\n\t\t\t\t\t\t\t\t\t`planet_metal_perhour` = '" . $planet['planet_metal_perhour'] . "',\n\t\t\t\t\t\t\t\t\t`planet_crystal` = '" . $planet['crystal'] . "',\n\t\t\t\t\t\t\t\t\t`planet_crystal_perhour` = '" . $planet['planet_crystal_perhour'] . "',\n\t\t\t\t\t\t\t\t\t`planet_deuterium` = '" . $planet['deuterium'] . "',\n\t\t\t\t\t\t\t\t\t`planet_deuterium_perhour` = '" . $planet['planet_deuterium_perhour'] . "';");
         $last_id = parent::$db->insertId();
         parent::$db->query("INSERT INTO " . BUILDINGS . " SET\n\t\t\t\t\t\t\t\t\t`building_planet_id` = '" . $last_id . "';");
         parent::$db->query("INSERT INTO " . DEFENSES . " SET\n\t\t\t\t\t\t\t\t\t`defense_planet_id` = '" . $last_id . "';");
         parent::$db->query("INSERT INTO " . SHIPS . " SET\n\t\t\t\t\t\t\t\t\t`ship_planet_id` = '" . $last_id . "';");
         $RetValue = TRUE;
     } else {
         $RetValue = FALSE;
     }
     return $RetValue;
 }
Example #22
0
 /**
  * method vacation_set
  * param
  * return format vacation end date
  */
 private function vacation_set()
 {
     return $this->_lang['us_user_setting_vacations_until'] . date(FunctionsLib::read_config('date_format_extended'), $this->_user_query['setting_vacations_until']);
 }
Example #23
0
 /**
  * method show_queue
  * param $Sprice
  * return (array) the queue to build data
  */
 private function show_queue(&$Sprice = FALSE)
 {
     $lang = $this->_lang;
     $CurrentQueue = $this->_current_planet['planet_b_building_id'];
     $QueueID = 0;
     $to_destroy = 0;
     $BuildMode = '';
     if ($CurrentQueue != 0) {
         $QueueArray = explode(";", $CurrentQueue);
         $ActualCount = count($QueueArray);
     } else {
         $QueueArray = '0';
         $ActualCount = 0;
     }
     $ListIDRow = '';
     if ($ActualCount != 0) {
         $PlanetID = $this->_current_planet['planet_id'];
         for ($QueueID = 0; $QueueID < $ActualCount; $QueueID++) {
             $BuildArray = explode(",", $QueueArray[$QueueID]);
             $BuildEndTime = floor($BuildArray[3]);
             $CurrentTime = floor(time());
             if ($BuildMode == 'destroy') {
                 $to_destroy++;
             }
             if ($BuildEndTime >= $CurrentTime) {
                 $ListID = $QueueID + 1;
                 $building = $BuildArray[0];
                 $BuildLevel = $BuildArray[1];
                 $BuildMode = $BuildArray[4];
                 $BuildTime = $BuildEndTime - time();
                 $ElementTitle = $this->_lang['tech'][$building];
                 if (isset($Sprice[$building]) && $Sprice !== FALSE && $BuildLevel > $Sprice[$building]) {
                     $Sprice[$building] = $BuildLevel;
                 }
                 if ($ListID > 0) {
                     $ListIDRow .= "<tr>";
                     if ($BuildMode == 'build') {
                         $ListIDRow .= "\t<td class=\"l\" colspan=\"2\">" . $ListID . ".: " . $ElementTitle . " " . $BuildLevel . "</td>";
                     } else {
                         $ListIDRow .= "\t<td class=\"l\" colspan=\"2\">" . $ListID . ".: " . $ElementTitle . " " . $BuildLevel . " " . $this->_lang['bd_dismantle'] . "</td>";
                     }
                     $ListIDRow .= "\t<td class=\"k\">";
                     if ($ListID == 1) {
                         $ListIDRow .= "\t\t<div id=\"blc\" class=\"z\">" . $BuildTime . "<br>";
                         $ListIDRow .= "\t\t<a href=\"game.php?page=" . $this->_current_page . "&listid=" . $ListID . "&amp;cmd=cancel&amp;planet=" . $PlanetID . "\">" . $this->_lang['bd_interrupt'] . "</a></div>";
                         $ListIDRow .= "\t\t<script language=\"JavaScript\">";
                         $ListIDRow .= "\t\t\tpp = \"" . $BuildTime . "\";\n";
                         $ListIDRow .= "\t\t\tpk = \"" . $ListID . "\";\n";
                         $ListIDRow .= "\t\t\tpm = \"cancel\";\n";
                         $ListIDRow .= "\t\t\tpl = \"" . $PlanetID . "\";\n";
                         $ListIDRow .= "\t\t\tt();\n";
                         $ListIDRow .= "\t\t</script>";
                         $ListIDRow .= "\t\t<strong color=\"lime\"><br><font color=\"lime\">" . date(FunctionsLib::read_config('date_format_extended'), $BuildEndTime) . "</font></strong>";
                     } else {
                         $ListIDRow .= "\t\t<font color=\"red\">";
                         $ListIDRow .= "\t\t<a href=\"game.php?page=" . $this->_current_page . "&listid=" . $ListID . "&amp;cmd=remove&amp;planet=" . $PlanetID . "\">" . $this->_lang['bd_cancel'] . "</a></font>";
                     }
                     $ListIDRow .= "\t</td>";
                     $ListIDRow .= "</tr>";
                 }
             }
         }
     }
     $RetValue['to_destoy'] = $to_destroy;
     $RetValue['lenght'] = $ActualCount;
     $RetValue['buildlist'] = $ListIDRow;
     return $RetValue;
 }
 /**
  * send_mail()
  * param1 $to
  * param2 $title
  * param3 $body
  * param4 $from
  * return send the email to destiny
  **/
 private function send_mail($to, $title, $body, $from = '')
 {
     $from = trim($from);
     if (!$from) {
         $from = FunctionsLib::read_config('admin_email');
     }
     $rp = FunctionsLib::read_config('admin_email');
     $head = '';
     $head .= "Content-Type: text/html \r\n";
     $head .= "charset: UTF-8 \r\n";
     $head .= "Date: " . date('r') . " \r\n";
     $head .= "Return-Path: {$rp} \r\n";
     $head .= "From: {$from} \r\n";
     $head .= "Sender: {$from} \r\n";
     $head .= "Reply-To: {$from} \r\n";
     $head .= "Organization: {$org} \r\n";
     $head .= "X-Sender: {$from} \r\n";
     $head .= "X-Priority: 3 \r\n";
     $body = str_replace("\r\n", "\n", $body);
     $body = str_replace("\n", "\r\n", $body);
     return @mail($to, $title, $body, $head);
 }
Example #25
0
 /**
  * method get_research_info
  * param
  * return the research page for the current user
  */
 private function get_data_members()
 {
     $parse = $this->_lang;
     $parse['al_alliance_members'] = str_replace('%s', $this->_alliance_query['alliance_name'], $this->_lang['al_alliance_members']);
     $all_members = $this->get_members();
     $alliance_ranks = unserialize($this->_alliance_query['alliance_ranks']);
     $template = parent::$page->get_template('adm/alliances_members_row_view');
     $members = '';
     if (!empty($all_members)) {
         while ($member = parent::$db->fetchAssoc($all_members)) {
             $member['alliance_request'] = $member['alliance_request'] ? $this->_lang['al_request_yes'] : $this->_lang['al_request_no'];
             $member['ally_request_text'] = $member['ally_request_text'] ? $this->_lang['ally_request_text'] : '-';
             $member['alliance_register_time'] = date(FunctionsLib::read_config('date_format_extended'), $member['alliance_register_time']);
             if ($member['user_id'] == $member['alliance_owner']) {
                 $member['ally_rank'] = $member['alliance_owner_range'];
             } else {
                 if (isset($member['ally_rank'])) {
                     $member['ally_rank'] = $alliance_ranks[$member['ally_rank']]['name'];
                 } else {
                     $member['ally_rank'] = $this->_lang['al_rank_not_defined'];
                 }
             }
             $members .= parent::$page->parse_template($template, $member);
         }
     }
     $parse['members_table'] = empty($members) ? '<tr><td colspan="6" class="align_center text-error">' . $this->_lang['al_no_ranks'] . '</td></tr>' : $members;
     $parse['alert_info'] = $this->_alert_type != '' ? AdministrationLib::save_message($this->_alert_type, $this->_alert_info) : '';
     return parent::$page->parse_template(parent::$page->get_template("adm/alliances_members_view"), $parse);
 }
Example #26
0
 /**
  * method flying_fleets_table
  * param
  * return the fleets table
  */
 private function flying_fleets_table()
 {
     $table = '';
     $i = 0;
     while ($fleet = parent::$db->fetchArray($this->_flying_fleets)) {
         $block['num'] = ++$i;
         $block['mission'] = $this->resources_pop_up($this->_lang['ff_type_mission'][$fleet['fleet_mission']] . ' ' . (FleetsLib::is_fleet_returning($fleet) ? $this->_lang['ff_r'] : $this->_lang['ff_a']), $fleet);
         $block['amount'] = $this->ships_pop_up($this->_lang['ff_ships'], $fleet);
         $block['beginning'] = FormatLib::pretty_coords($fleet['fleet_start_galaxy'], $fleet['fleet_start_system'], $fleet['fleet_start_planet']);
         $block['departure'] = date(FunctionsLib::read_config('date_format_extended'), $fleet['fleet_creation']);
         $block['objective'] = FormatLib::pretty_coords($fleet['fleet_end_galaxy'], $fleet['fleet_end_system'], $fleet['fleet_end_planet']);
         $block['arrival'] = date(FunctionsLib::read_config('date_format_extended'), $fleet['fleet_start_time']);
         $block['return'] = date(FunctionsLib::read_config('date_format_extended'), $fleet['fleet_end_time']);
         $table .= parent::$page->parse_template(parent::$page->get_template('adm/fleet_rows_view'), $block);
     }
     return $table;
 }
 /**
  * method secure_connection
  * param
  * return stablish a secure connection and force it
  */
 public static function secure_connection()
 {
     if (FunctionsLib::read_config('ssl_enabled') == 1 && $_SERVER['SERVER_PORT'] !== 443 && (empty($_SERVER['HTTPS']) or $_SERVER['HTTPS'] === 'off')) {
         FunctionsLib::redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
     }
 }
Example #28
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $resource = parent::$objects->getObjects();
     $pricelist = parent::$objects->getPrice();
     $reslist = parent::$objects->getObjectsList();
     $parse = $this->_lang;
     if (parent::$users->is_on_vacations($this->_current_user)) {
         exit(FunctionsLib::message($this->_lang['fl_vacation_mode_active'], "game.php?page=overview", 2));
     }
     $fleet_group_mr = 0;
     if ($_POST['fleet_group'] > 0) {
         if ($_POST['mission'] == 2) {
             $target = 'g' . (int) $_POST['galaxy'] . 's' . (int) $_POST['system'] . 'p' . (int) $_POST['planet'] . 't' . (int) $_POST['planettype'];
             if ($_POST['acs_target_mr'] == $target) {
                 $aks_count_mr = parent::$db->query("SELECT COUNT(`acs_fleet_id`)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . ACS_FLEETS . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `acs_fleet_id` = '" . (int) $_POST['fleet_group'] . "'");
                 if ($aks_count_mr > 0) {
                     $fleet_group_mr = $_POST['fleet_group'];
                 }
             }
         }
     }
     if ($_POST['fleet_group'] == 0 && $_POST['mission'] == 2) {
         $_POST['mission'] = 1;
     }
     $TargetPlanet = parent::$db->queryFetch("SELECT `planet_user_id`,`planet_destroyed`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . PLANETS . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE `planet_galaxy` = '" . (int) $_POST['galaxy'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t`planet_system` = '" . (int) $_POST['system'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t`planet_planet` = '" . (int) $_POST['planet'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t`planet_type` = '" . (int) $_POST['planettype'] . "';");
     $MyDBRec = parent::$db->queryFetch("SELECT u.`user_id`, u.`user_onlinetime`, u.`user_ally_id`, s.`setting_vacations_status`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . " AS u, " . SETTINGS . " AS s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE u.`user_id` = '" . $this->_current_user['user_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND s.`setting_user_id` = '" . $this->_current_user['user_id'] . "';");
     $fleetarray = unserialize(base64_decode(str_rot13($_POST['usedfleet'])));
     if ($TargetPlanet['planet_destroyed'] != 0) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if (!is_array($fleetarray)) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     foreach ($fleetarray as $Ship => $Count) {
         $Count = intval($Count);
         if ($Count > $this->_current_planet[$resource[$Ship]]) {
             FunctionsLib::redirect('game.php?page=movement');
         }
     }
     $error = 0;
     $galaxy = (int) $_POST['galaxy'];
     $system = (int) $_POST['system'];
     $planet = (int) $_POST['planet'];
     $planettype = (int) $_POST['planettype'];
     $fleetmission = (int) $_POST['mission'];
     //fix by jstar
     if ($fleetmission == 7 && !isset($fleetarray[208])) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if ($planettype != 1 && $planettype != 2 && $planettype != 3) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     //fix invisible debris like ogame by jstar
     if ($fleetmission == 8) {
         $YourPlanet = FALSE;
         $UsedPlanet = FALSE;
         $select = parent::$db->queryFetch("SELECT COUNT(*) AS count, p.*\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . PLANETS . "` AS p\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . $galaxy . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . $system . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . $planet . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = 1;");
         if ($select['planet_debris_metal'] == 0 && $select['planet_debris_crystal'] == 0 && time() > $select['planet_invisible_start_time'] + DEBRIS_LIFE_TIME) {
             FunctionsLib::redirect('game.php?page=movement');
         }
     } else {
         $YourPlanet = FALSE;
         $UsedPlanet = FALSE;
         $select = parent::$db->queryFetch("SELECT COUNT(*) AS count, p.`planet_user_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . PLANETS . "` AS p\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . $galaxy . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . $system . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . $planet . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = '" . $planettype . "'");
     }
     if ($this->_current_planet['planet_galaxy'] == $galaxy && $this->_current_planet['planet_system'] == $system && $this->_current_planet['planet_planet'] == $planet && $this->_current_planet['planet_type'] == $planettype) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if ($_POST['mission'] != 15) {
         if ($select['count'] < 1 && $fleetmission != 7) {
             FunctionsLib::redirect('game.php?page=movement');
         } elseif ($fleetmission == 9 && $select['count'] < 1) {
             FunctionsLib::redirect('game.php?page=movement');
         }
     } else {
         $MaxExpedition = $this->_current_user[$resource[124]];
         if ($MaxExpedition >= 1) {
             $maxexpde = parent::$db->queryFetch("SELECT COUNT(fleet_owner) AS `expedi`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_owner` = '" . $this->_current_user['user_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `fleet_mission` = '15';");
             $ExpeditionEnCours = $maxexpde['expedi'];
             $EnvoiMaxExpedition = FleetsLib::get_max_expeditions($MaxExpedition);
         } else {
             $ExpeditionEnCours = 0;
             $EnvoiMaxExpedition = 0;
         }
         if ($EnvoiMaxExpedition == 0) {
             FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_expedition_tech_required'] . "</b></font>", "game.php?page=movement", 2);
         } elseif ($ExpeditionEnCours >= $EnvoiMaxExpedition) {
             FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_expedition_fleets_limit'] . "</b></font>", "game.php?page=movement", 2);
         }
     }
     if ($select['planet_user_id'] == $this->_current_user['user_id']) {
         $YourPlanet = TRUE;
         $UsedPlanet = TRUE;
     } elseif (!empty($select['planet_user_id'])) {
         $YourPlanet = FALSE;
         $UsedPlanet = TRUE;
     } else {
         $YourPlanet = FALSE;
         $UsedPlanet = FALSE;
     }
     //fix by jstar
     if ($fleetmission == 9) {
         $countfleettype = count($fleetarray);
         if ($YourPlanet or !$UsedPlanet or $planettype != 3) {
             FunctionsLib::redirect('game.php?page=movement');
         } elseif ($countfleettype == 1 && !isset($fleetarray[214])) {
             FunctionsLib::redirect('game.php?page=movement');
         } elseif ($countfleettype == 2 && !isset($fleetarray[214])) {
             FunctionsLib::redirect('game.php?page=movement');
         } elseif ($countfleettype > 2) {
             FunctionsLib::redirect('game.php?page=movement');
         }
     }
     if (empty($fleetmission)) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if ($TargetPlanet['planet_user_id'] == '') {
         $HeDBRec = $MyDBRec;
     } elseif ($TargetPlanet['planet_user_id'] != '') {
         $HeDBRec = parent::$db->queryFetch("SELECT u.`user_id`, u.`user_onlinetime`, u.`user_ally_id`, s.`setting_vacations_status`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . " AS u, " . SETTINGS . " AS s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE u.`user_id` = '" . $TargetPlanet['planet_user_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND s.`setting_user_id` ='" . $TargetPlanet['planet_user_id'] . "';");
     }
     $user_points = $this->_noob->return_points($MyDBRec['user_id'], $HeDBRec['user_id']);
     $MyGameLevel = $user_points['user_points'];
     $HeGameLevel = $user_points['target_points'];
     if ($HeDBRec['user_onlinetime'] >= time() - 60 * 60 * 24 * 7) {
         if ($this->_noob->is_weak($MyGameLevel, $HeGameLevel) && $TargetPlanet['planet_user_id'] != '' && ($_POST['mission'] == 1 or $_POST['mission'] == 6 or $_POST['mission'] == 9)) {
             FunctionsLib::message("<font color=\"lime\"><b>" . $this->_lang['fl_week_player'] . "</b></font>", "game.php?page=movement", 2);
         }
         if ($this->_noob->is_strong($MyGameLevel, $HeGameLevel) && $TargetPlanet['planet_user_id'] != '' && ($_POST['mission'] == 1 or $_POST['mission'] == 5 or $_POST['mission'] == 6 or $_POST['mission'] == 9)) {
             FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_strong_player'] . "</b></font>", "game.php?page=movement", 2);
         }
     }
     if ($HeDBRec['setting_vacations_status'] && $_POST['mission'] != 8) {
         FunctionsLib::message("<font color=\"lime\"><b>" . $this->_lang['fl_in_vacation_player'] . "</b></font>", "game.php?page=movement", 2);
     }
     $FlyingFleets = parent::$db->queryFetch("SELECT COUNT(fleet_id) as Number\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_owner`='" . $this->_current_user['user_id'] . "'");
     $ActualFleets = $FlyingFleets['Number'];
     if (FleetsLib::get_max_fleets($this->_current_user[$resource[108]], $this->_current_user['premium_officier_admiral']) <= $ActualFleets) {
         FunctionsLib::message($this->_lang['fl_no_slots'], "game.php?page=movement", 1);
     }
     if ($_POST['resource1'] + $_POST['resource2'] + $_POST['resource3'] < 1 && $_POST['mission'] == 3) {
         FunctionsLib::message("<font color=\"lime\"><b>" . $this->_lang['fl_empty_transport'] . "</b></font>", "game.php?page=movement", 1);
     }
     if ($_POST['mission'] != 15) {
         if ($TargetPlanet['planet_user_id'] == '' && $_POST['mission'] < 7) {
             FunctionsLib::redirect('game.php?page=movement');
         }
         if ($TargetPlanet['planet_user_id'] != '' && $_POST['mission'] == 7) {
             FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_planet_populed'] . "</b></font>", "game.php?page=movement", 2);
         }
         if ($HeDBRec['user_ally_id'] != $MyDBRec['user_ally_id'] && $_POST['mission'] == 4) {
             FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_stay_not_on_enemy'] . "</b></font>", "game.php?page=movement", 2);
         }
         if ($TargetPlanet['planet_user_id'] == $this->_current_planet['planet_user_id'] && ($_POST['mission'] == 1 or $_POST['mission'] == 6)) {
             FunctionsLib::redirect('game.php?page=movement');
         }
         if ($TargetPlanet['planet_user_id'] != $this->_current_planet['planet_user_id'] && $_POST['mission'] == 4) {
             FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_deploy_only_your_planets'] . "</b></font>", "game.php?page=movement", 2);
         }
         if ($_POST['mission'] == 5) {
             $buddy = parent::$db->queryFetch("SELECT COUNT( * ) AS buddys\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM  `" . BUDDY . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbuddy_sender ='" . intval($this->_current_planet['planet_user_id']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND buddy_receiver ='" . intval($TargetPlanet['planet_user_id']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tOR (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbuddy_sender ='" . intval($TargetPlanet['planet_user_id']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND buddy_receiver ='" . intval($this->_current_planet['planet_user_id']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND buddy_status =1");
             if ($HeDBRec['user_ally_id'] != $MyDBRec['user_ally_id'] && $buddy['buddys'] < 1) {
                 FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_stay_not_on_enemy'] . "</b></font>", "game.php?page=movement", 2);
             }
         }
     }
     $missiontype = FleetsLib::get_missions();
     $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
     $AllFleetSpeed = FleetsLib::fleet_max_speed($fleetarray, 0, $this->_current_user);
     $GenFleetSpeed = $_POST['speed'];
     $SpeedFactor = FunctionsLib::fleet_speed_factor();
     $MaxFleetSpeed = min($AllFleetSpeed);
     if (!in_array($GenFleetSpeed, $speed_possible)) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if ($MaxFleetSpeed != $_POST['speedallsmin']) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if (!$_POST['planettype']) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if (!$_POST['galaxy'] || !is_numeric($_POST['galaxy']) || $_POST['galaxy'] > MAX_GALAXY_IN_WORLD || $_POST['galaxy'] < 1) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if (!$_POST['system'] || !is_numeric($_POST['system']) || $_POST['system'] > MAX_SYSTEM_IN_GALAXY || $_POST['system'] < 1) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if (!$_POST['planet'] || !is_numeric($_POST['planet']) || $_POST['planet'] > MAX_PLANET_IN_SYSTEM + 1 || $_POST['planet'] < 1) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if ($_POST['thisgalaxy'] != $this->_current_planet['planet_galaxy'] | $_POST['thissystem'] != $this->_current_planet['planet_system'] | $_POST['thisplanet'] != $this->_current_planet['planet_planet'] | $_POST['thisplanettype'] != $this->_current_planet['planet_type']) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if (!isset($fleetarray)) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     $distance = FleetsLib::target_distance($_POST['thisgalaxy'], $_POST['galaxy'], $_POST['thissystem'], $_POST['system'], $_POST['thisplanet'], $_POST['planet']);
     $duration = FleetsLib::mission_duration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor);
     $consumption = FleetsLib::fleet_consumption($fleetarray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $this->_current_user);
     $fleet['start_time'] = $duration + time();
     // START CODE BY JSTAR
     if ($_POST['mission'] == 15) {
         $StayDuration = floor($_POST['expeditiontime']);
         if ($StayDuration > 0) {
             $StayDuration = $StayDuration * 3600;
             $StayTime = $fleet['start_time'] + $StayDuration;
         } else {
             FunctionsLib::redirect('game.php?page=movement');
         }
     } elseif ($_POST['mission'] == 5) {
         $StayDuration = $_POST['holdingtime'] * 3600;
         $StayTime = $fleet['start_time'] + $_POST['holdingtime'] * 3600;
     } else {
         $StayDuration = 0;
         $StayTime = 0;
     }
     $fleet['end_time'] = $StayDuration + 2 * $duration + time();
     $FleetStorage = 0;
     $FleetShipCount = 0;
     $fleet_array = "";
     $FleetSubQRY = "";
     //fix by jstar
     $haveSpyProbos = FALSE;
     foreach ($fleetarray as $Ship => $Count) {
         $Count = intval($Count);
         if ($Ship == 210) {
             $haveSpyProbos = TRUE;
         }
         $FleetStorage += $pricelist[$Ship]['capacity'] * $Count;
         $FleetShipCount += $Count;
         $fleet_array .= $Ship . "," . $Count . ";";
         $FleetSubQRY .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` - " . $Count . ", ";
     }
     if (!$haveSpyProbos && $_POST['mission'] == 6) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     $FleetStorage -= $consumption;
     $StorageNeeded = 0;
     $_POST['resource1'] = max(0, (int) trim($_POST['resource1']));
     $_POST['resource2'] = max(0, (int) trim($_POST['resource2']));
     $_POST['resource3'] = max(0, (int) trim($_POST['resource3']));
     if ($_POST['resource1'] < 1) {
         $TransMetal = 0;
     } else {
         $TransMetal = $_POST['resource1'];
         $StorageNeeded += $TransMetal;
     }
     if ($_POST['resource2'] < 1) {
         $TransCrystal = 0;
     } else {
         $TransCrystal = $_POST['resource2'];
         $StorageNeeded += $TransCrystal;
     }
     if ($_POST['resource3'] < 1) {
         $TransDeuterium = 0;
     } else {
         $TransDeuterium = $_POST['resource3'];
         $StorageNeeded += $TransDeuterium;
     }
     $StockMetal = $this->_current_planet['planet_metal'];
     $StockCrystal = $this->_current_planet['planet_crystal'];
     $StockDeuterium = $this->_current_planet['planet_deuterium'];
     $StockDeuterium -= $consumption;
     $StockOk = FALSE;
     if ($StockMetal >= $TransMetal) {
         if ($StockCrystal >= $TransCrystal) {
             if ($StockDeuterium >= $TransDeuterium) {
                 $StockOk = TRUE;
             }
         }
     }
     if (!$StockOk) {
         FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_no_enought_deuterium'] . FormatLib::pretty_number($consumption) . "</b></font>", "game.php?page=movement", 2);
     }
     if ($StorageNeeded > $FleetStorage) {
         FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_no_enought_cargo_capacity'] . FormatLib::pretty_number($StorageNeeded - $FleetStorage) . "</b></font>", "game.php?page=movement", 2);
     }
     if (FunctionsLib::read_config('adm_attack') != 0) {
         FunctionsLib::message($this->_lang['fl_admins_cannot_be_attacked'], "game.php?page=movement", 2);
     }
     if ($fleet_group_mr != 0) {
         $AksStartTime = parent::$db->queryFetch("SELECT MAX(`fleet_start_time`) AS Start\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_group` = '" . $fleet_group_mr . "';");
         if ($AksStartTime['Start'] >= $fleet['start_time']) {
             $fleet['end_time'] += $AksStartTime['Start'] - $fleet['start_time'];
             $fleet['start_time'] = $AksStartTime['Start'];
         } else {
             parent::$db->query("UPDATE " . FLEETS . " SET\n\t\t\t\t\t\t\t\t\t\t`fleet_start_time` = '" . $fleet['start_time'] . "',\n\t\t\t\t\t\t\t\t\t\t`fleet_end_time` = fleet_end_time + '" . ($fleet['start_time'] - $AksStartTime['Start']) . "'\n\t\t\t\t\t\t\t\t\t\tWHERE `fleet_group` = '" . $fleet_group_mr . "';");
             $fleet['end_time'] += $fleet['start_time'] - $AksStartTime['Start'];
         }
     }
     parent::$db->query("INSERT INTO " . FLEETS . " SET\n\t\t\t\t\t\t\t`fleet_owner` = '" . $this->_current_user['user_id'] . "',\n\t\t\t\t\t\t\t`fleet_mission` = '" . (int) $_POST['mission'] . "',\n\t\t\t\t\t\t\t`fleet_amount` = '" . (int) $FleetShipCount . "',\n\t\t\t\t\t\t\t`fleet_array` = '" . $fleet_array . "',\n\t\t\t\t\t\t\t`fleet_start_time` = '" . $fleet['start_time'] . "',\n\t\t\t\t\t\t\t`fleet_start_galaxy` = '" . (int) $_POST['thisgalaxy'] . "',\n\t\t\t\t\t\t\t`fleet_start_system` = '" . (int) $_POST['thissystem'] . "',\n\t\t\t\t\t\t\t`fleet_start_planet` = '" . (int) $_POST['thisplanet'] . "',\n\t\t\t\t\t\t\t`fleet_start_type` = '" . (int) $_POST['thisplanettype'] . "',\n\t\t\t\t\t\t\t`fleet_end_time` = '" . (int) $fleet['end_time'] . "',\n\t\t\t\t\t\t\t`fleet_end_stay` = '" . (int) $StayTime . "',\n\t\t\t\t\t\t\t`fleet_end_galaxy` = '" . (int) $_POST['galaxy'] . "',\n\t\t\t\t\t\t\t`fleet_end_system` = '" . (int) $_POST['system'] . "',\n\t\t\t\t\t\t\t`fleet_end_planet` = '" . (int) $_POST['planet'] . "',\n\t\t\t\t\t\t\t`fleet_end_type` = '" . (int) $_POST['planettype'] . "',\n\t\t\t\t\t\t\t`fleet_resource_metal` = '" . $TransMetal . "',\n\t\t\t\t\t\t\t`fleet_resource_crystal` = '" . $TransCrystal . "',\n\t\t\t\t\t\t\t`fleet_resource_deuterium` = '" . $TransDeuterium . "',\n\t\t\t\t\t\t\t`fleet_target_owner` = '" . (int) $TargetPlanet['planet_user_id'] . "',\n\t\t\t\t\t\t\t`fleet_group` = '" . (int) $fleet_group_mr . "',\n\t\t\t\t\t\t\t`fleet_creation` = '" . time() . "';");
     parent::$db->query("UPDATE `" . PLANETS . "` AS p\n\t\t\t\t\t\t\t\tINNER JOIN " . SHIPS . " AS s ON s.ship_planet_id = p.`planet_id` SET\n\t\t\t\t\t\t\t\t{$FleetSubQRY}\n\t\t\t\t\t\t\t\t`planet_metal` = `planet_metal` - " . $TransMetal . ",\n\t\t\t\t\t\t\t\t`planet_crystal` = `planet_crystal` - " . $TransCrystal . ",\n\t\t\t\t\t\t\t\t`planet_deuterium` = `planet_deuterium` - " . ($TransDeuterium + $consumption) . "\n\t\t\t\t\t\t\t\tWHERE `planet_id` = " . $this->_current_planet['planet_id'] . ";");
     FunctionsLib::redirect('game.php?page=movement');
 }
Example #29
0
 /**
  * updateStatistics
  *
  * @return void
  */
 private function updateStatistics()
 {
     // LAST UPDATE AND UPDATE INTERVAL, EX: 15 MINUTES
     $stat_last_update = FunctionsLib::read_config('stat_last_update');
     $update_interval = FunctionsLib::read_config('stat_update_time');
     if (time() >= $stat_last_update + 60 * $update_interval) {
         $result = StatisticsLib::make_stats();
         FunctionsLib::update_config('stat_last_update', $result['stats_time']);
     }
 }
Example #30
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $parse = $this->_lang;
     $game_metal_basic_income = FunctionsLib::read_config('metal_basic_income');
     $game_crystal_basic_income = FunctionsLib::read_config('crystal_basic_income');
     $game_deuterium_basic_income = FunctionsLib::read_config('deuterium_basic_income');
     $game_energy_basic_income = FunctionsLib::read_config('energy_basic_income');
     $game_resource_multiplier = FunctionsLib::read_config('resource_multiplier');
     if ($this->_current_planet['planet_type'] == 3) {
         $game_metal_basic_income = 0;
         $game_crystal_basic_income = 0;
         $game_deuterium_basic_income = 0;
     }
     $this->_current_planet['planet_metal_max'] = ProductionLib::maxStorable($this->_current_planet[$this->_resource[22]]);
     $this->_current_planet['planet_crystal_max'] = ProductionLib::maxStorable($this->_current_planet[$this->_resource[23]]);
     $this->_current_planet['planet_deuterium_max'] = ProductionLib::maxStorable($this->_current_planet[$this->_resource[24]]);
     $parse['production_level'] = 100;
     $post_porcent = ProductionLib::maxProduction($this->_current_planet['planet_energy_max'], $this->_current_planet['planet_energy_used']);
     $parse['resource_row'] = '';
     $this->_current_planet['planet_metal_perhour'] = 0;
     $this->_current_planet['planet_crystal_perhour'] = 0;
     $this->_current_planet['planet_deuterium_perhour'] = 0;
     $this->_current_planet['planet_energy_max'] = 0;
     $this->_current_planet['planet_energy_used'] = 0;
     $BuildTemp = $this->_current_planet['planet_temp_max'];
     $ResourcesRowTPL = parent::$page->get_template('resources/resources_row');
     foreach ($this->_reslist['prod'] as $ProdID) {
         if ($this->_current_planet[$this->_resource[$ProdID]] > 0 && isset($this->_prod_grid[$ProdID])) {
             $BuildLevelFactor = $this->_current_planet['planet_' . $this->_resource[$ProdID] . '_porcent'];
             $BuildLevel = $this->_current_planet[$this->_resource[$ProdID]];
             $BuildEnergy = $this->_current_user['research_energy_technology'];
             // BOOST
             $geologe_boost = 1 + 1 * (OfficiersLib::isOfficierActive($this->_current_user['premium_officier_geologist']) ? GEOLOGUE : 0);
             $engineer_boost = 1 + 1 * (OfficiersLib::isOfficierActive($this->_current_user['premium_officier_engineer']) ? ENGINEER_ENERGY : 0);
             // PRODUCTION FORMULAS
             $metal_prod = eval($this->_prod_grid[$ProdID]['formule']['metal']);
             $crystal_prod = eval($this->_prod_grid[$ProdID]['formule']['crystal']);
             $deuterium_prod = eval($this->_prod_grid[$ProdID]['formule']['deuterium']);
             $energy_prod = eval($this->_prod_grid[$ProdID]['formule']['energy']);
             // PRODUCTION
             $metal = ProductionLib::productionAmount($metal_prod, $geologe_boost);
             $crystal = ProductionLib::productionAmount($crystal_prod, $geologe_boost);
             $deuterium = ProductionLib::productionAmount($deuterium_prod, $geologe_boost);
             if ($ProdID >= 4) {
                 $energy = ProductionLib::productionAmount($energy_prod, $engineer_boost, TRUE);
             } else {
                 $energy = ProductionLib::productionAmount($energy_prod, 1, TRUE);
             }
             if ($energy > 0) {
                 $this->_current_planet['planet_energy_max'] += $energy;
             } else {
                 $this->_current_planet['planet_energy_used'] += $energy;
             }
             $this->_current_planet['planet_metal_perhour'] += $metal;
             $this->_current_planet['planet_crystal_perhour'] += $crystal;
             $this->_current_planet['planet_deuterium_perhour'] += $deuterium;
             $metal = ProductionLib::currentProduction($metal, $post_porcent);
             $crystal = ProductionLib::currentProduction($crystal, $post_porcent);
             $deuterium = ProductionLib::currentProduction($deuterium, $post_porcent);
             $energy = ProductionLib::currentProduction($energy, $post_porcent);
             $Field = 'planet_' . $this->_resource[$ProdID] . '_porcent';
             $CurrRow = array();
             $CurrRow['name'] = $this->_resource[$ProdID];
             $CurrRow['porcent'] = $this->_current_planet[$Field];
             $CurrRow['option'] = $this->build_options($CurrRow['porcent']);
             $CurrRow['type'] = $this->_lang['tech'][$ProdID];
             $CurrRow['level'] = $ProdID > 200 ? $this->_lang['rs_amount'] : $this->_lang['rs_lvl'];
             $CurrRow['level_type'] = $this->_current_planet[$this->_resource[$ProdID]];
             $CurrRow['metal_type'] = FormatLib::pretty_number($metal);
             $CurrRow['crystal_type'] = FormatLib::pretty_number($crystal);
             $CurrRow['deuterium_type'] = FormatLib::pretty_number($deuterium);
             $CurrRow['energy_type'] = FormatLib::pretty_number($energy);
             $CurrRow['metal_type'] = FormatLib::color_number($CurrRow['metal_type']);
             $CurrRow['crystal_type'] = FormatLib::color_number($CurrRow['crystal_type']);
             $CurrRow['deuterium_type'] = FormatLib::color_number($CurrRow['deuterium_type']);
             $CurrRow['energy_type'] = FormatLib::color_number($CurrRow['energy_type']);
             $parse['resource_row'] .= parent::$page->parse_template($ResourcesRowTPL, $CurrRow);
         }
     }
     $parse['Production_of_resources_in_the_planet'] = str_replace('%s', $this->_current_planet['planet_name'], $this->_lang['rs_production_on_planet']);
     $parse['production_level'] = $this->prod_level($this->_current_planet['planet_energy_used'], $this->_current_planet['planet_energy_max']);
     $parse['metal_basic_income'] = $game_metal_basic_income;
     $parse['crystal_basic_income'] = $game_crystal_basic_income;
     $parse['deuterium_basic_income'] = $game_deuterium_basic_income;
     $parse['energy_basic_income'] = $game_energy_basic_income;
     $parse['planet_metal_max'] = $this->resource_color($this->_current_planet['planet_metal'], $this->_current_planet['planet_metal_max']);
     $parse['planet_crystal_max'] = $this->resource_color($this->_current_planet['planet_crystal'], $this->_current_planet['planet_crystal_max']);
     $parse['planet_deuterium_max'] = $this->resource_color($this->_current_planet['planet_deuterium'], $this->_current_planet['planet_deuterium_max']);
     $parse['metal_total'] = FormatLib::color_number(FormatLib::pretty_number(floor($this->_current_planet['planet_metal_perhour'] * 0.01 * $parse['production_level'] + $parse['metal_basic_income'])));
     $parse['crystal_total'] = FormatLib::color_number(FormatLib::pretty_number(floor($this->_current_planet['planet_crystal_perhour'] * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'])));
     $parse['deuterium_total'] = FormatLib::color_number(FormatLib::pretty_number(floor($this->_current_planet['planet_deuterium_perhour'] * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'])));
     $parse['energy_total'] = FormatLib::color_number(FormatLib::pretty_number(floor($this->_current_planet['planet_energy_max'] + $parse['energy_basic_income'] + $this->_current_planet['planet_energy_used'])));
     $parse['daily_metal'] = $this->calculate_daily($this->_current_planet['planet_metal_perhour'], $parse['production_level'], $parse['metal_basic_income']);
     $parse['weekly_metal'] = $this->calculate_weekly($this->_current_planet['planet_metal_perhour'], $parse['production_level'], $parse['metal_basic_income']);
     $parse['daily_crystal'] = $this->calculate_daily($this->_current_planet['planet_crystal_perhour'], $parse['production_level'], $parse['crystal_basic_income']);
     $parse['weekly_crystal'] = $this->calculate_weekly($this->_current_planet['planet_crystal_perhour'], $parse['production_level'], $parse['crystal_basic_income']);
     $parse['daily_deuterium'] = $this->calculate_daily($this->_current_planet['planet_deuterium_perhour'], $parse['production_level'], $parse['deuterium_basic_income']);
     $parse['weekly_deuterium'] = $this->calculate_weekly($this->_current_planet['planet_deuterium_perhour'], $parse['production_level'], $parse['deuterium_basic_income']);
     $parse['daily_metal'] = FormatLib::color_number(FormatLib::pretty_number($parse['daily_metal']));
     $parse['weekly_metal'] = FormatLib::color_number(FormatLib::pretty_number($parse['weekly_metal']));
     $parse['daily_crystal'] = FormatLib::color_number(FormatLib::pretty_number($parse['daily_crystal']));
     $parse['weekly_crystal'] = FormatLib::color_number(FormatLib::pretty_number($parse['weekly_crystal']));
     $parse['daily_deuterium'] = FormatLib::color_number(FormatLib::pretty_number($parse['daily_deuterium']));
     $parse['weekly_deuterium'] = FormatLib::color_number(FormatLib::pretty_number($parse['weekly_deuterium']));
     $ValidList['percent'] = array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100);
     $SubQry = '';
     if ($_POST && !parent::$users->is_on_vacations($this->_current_user)) {
         foreach ($_POST as $Field => $Value) {
             $FieldName = 'planet_' . $Field . '_porcent';
             if (isset($this->_current_planet[$FieldName])) {
                 if (!in_array($Value, $ValidList['percent'])) {
                     FunctionsLib::redirect('game.php?page=resourceSettings');
                 }
                 $Value = $Value / 10;
                 $this->_current_planet[$FieldName] = $Value;
                 $SubQry .= ", `" . $FieldName . "` = '" . $Value . "'";
             }
         }
         parent::$db->query("UPDATE " . PLANETS . " SET\n\t\t\t\t\t\t\t\t\t`planet_id` = '" . $this->_current_planet['planet_id'] . "'\n\t\t\t\t\t\t\t\t\t{$SubQry}\n\t\t\t\t\t\t\t\t\tWHERE `planet_id` = '" . $this->_current_planet['planet_id'] . "';");
         FunctionsLib::redirect('game.php?page=resourceSettings');
     }
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('resources/resources'), $parse));
 }