Beispiel #1
0
 /**
  * __construct()
  */
 public function __construct()
 {
     parent::__construct();
     $this->_lang = parent::$lang;
     if ($this->server_requirementes()) {
         $this->build_page();
     } else {
         die(Functions_Lib::message($this->_lang['ins_no_server_requirements']));
     }
 }
 /**
  * process_request()
  * param $mail
  * return process the user request for a new password
  **/
 private function process_request($mail)
 {
     $lang = parent::$lang;
     $ExistMail = parent::$db->query_fetch("SELECT `user_name`\r\n\t\t\t\t\t\t\t\t\t\t \t\t\tFROM " . USERS . "\r\n\t\t\t\t\t\t\t\t\t\t \t\t\tWHERE `user_email` = '" . parent::$db->escape_value($mail) . "' LIMIT 1;");
     if (empty($ExistMail['user_name'])) {
         Functions_Lib::message($lang['mail_not_exist'], "index.php?page=recoverpassword", 2, FALSE, FALSE);
     } else {
         $new_password = $this->send_pass_email($mail, $ExistMail['user_name']);
         parent::$db->query("UPDATE " . USERS . " SET\r\n\t\t\t\t\t\t\t\t\t`user_password` ='" . sha1($new_password) . "'\r\n\t\t\t\t\t\t\t\t\tWHERE `user_email`='" . parent::$db->escape_value($mail) . "' LIMIT 1;");
     }
 }
Beispiel #3
0
 /**
  * __construct()
  */
 public function __construct()
 {
     parent::__construct();
     $this->_lang = parent::$lang;
     if (Functions_Lib::read_config('reg_enable') == 1) {
         $this->_creator = Functions_Lib::load_library('Creator_Lib');
         $this->build_page();
     } else {
         die(Functions_Lib::message($this->_lang['re_disabled'], 'index.php', '5', FALSE, FALSE));
     }
 }
Beispiel #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 (!Administration_Lib::have_access($this->_current_user['user_authlevel'])) {
         die(Functions_Lib::message($this->_lang['ge_no_permissions']));
     } else {
         $this->build_page();
     }
 }
 /**
  * __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 (Administration_Lib::have_access($this->_current_user['user_authlevel']) && Administration_Lib::authorization($this->_current_user['user_authlevel'], 'config_game') == 1) {
         $this->_game_config = Functions_Lib::read_config('', TRUE);
         $this->build_page();
     } else {
         die(Functions_Lib::message($this->_lang['ge_no_permissions']));
     }
 }
Beispiel #6
0
 /**
  * __construct()
  */
 public function __construct()
 {
     parent::__construct();
     // check if session is active
     parent::$users->check_session();
     $this->_lang = parent::$lang;
     $this->_creator = Functions_Lib::load_library('Creator_Lib');
     $this->_current_user = parent::$users->get_user_data();
     // Check if the user is allowed to access
     if (Administration_Lib::have_access($this->_current_user['user_authlevel']) && Administration_Lib::authorization($this->_current_user['user_authlevel'], 'edit_users') == 1) {
         $this->build_page();
     } else {
         die(Functions_Lib::message($this->_lang['ge_no_permissions']));
     }
 }
Beispiel #7
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 (Administration_Lib::have_access($this->_current_user['user_authlevel']) && $this->_current_user['user_authlevel'] == 3) {
         include_once XGP_ROOT . 'application/libraries/Creator_Lib.php';
         $this->_creator = new Creator_Lib();
         $this->build_page();
     } else {
         die(Functions_Lib::message($this->_lang['ge_no_permissions']));
     }
 }
Beispiel #8
0
 /**
  * __construct()
  */
 public function __construct()
 {
     parent::__construct();
     // check if session is active
     parent::$users->check_session();
     // Check module access
     Functions_Lib::module_message(Functions_Lib::is_module_accesible(self::MODULE_ID));
     $this->_current_user = parent::$users->get_user_data();
     $this->_current_planet = parent::$users->get_planet_data();
     $this->_lang = parent::$lang;
     $this->_resource = parent::$objects->get_objects();
     $this->_reslist = parent::$objects->get_objects_list();
     if ($this->_current_planet[$this->_resource[31]] == 0) {
         Functions_Lib::message($this->_lang['bd_lab_required'], '', '', TRUE);
     } else {
         $this->handle_technologie_build();
         $this->build_page();
     }
 }
Beispiel #9
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     if (!array_key_exists($this->_element_id, $this->_resource)) {
         Functions_Lib::redirect('game.php?page=techtree');
     }
     $GateTPL = '';
     $DestroyTPL = '';
     $TableHeadTPL = '';
     $TableFooterTPL = '';
     $parse = $this->_lang;
     $parse['dpath'] = DPATH;
     $parse['name'] = $this->_lang['info'][$this->_element_id]['name'];
     $parse['image'] = $this->_element_id;
     $parse['description'] = $this->_lang['info'][$this->_element_id]['description'];
     if ($this->_element_id < 13 or $this->_element_id == 43 && $this->_current_planet[$this->_resource[43]] > 0) {
         $PageTPL = parent::$page->get_template('infos/info_buildings_table');
     } elseif ($this->_element_id < 200) {
         $PageTPL = parent::$page->get_template('infos/info_buildings_general');
     } elseif ($this->_element_id < 400) {
         $PageTPL = parent::$page->get_template('infos/info_buildings_fleet');
     } elseif ($this->_element_id < 600) {
         $PageTPL = parent::$page->get_template('infos/info_buildings_defense');
     } else {
         $PageTPL = parent::$page->get_template('infos/info_officiers_general');
     }
     //S�lo hay destroy en <200
     if ($this->_element_id < 200 && $this->_element_id != 33 && $this->_element_id != 41) {
         $DestroyTPL = parent::$page->get_template('infos/info_buildings_destroy');
     }
     if ($this->_element_id >= 1 && $this->_element_id <= 3) {
         $PageTPL = parent::$page->get_template('infos/info_buildings_table');
         $TableHeadTPL = parent::$page->get_template('infos/info_production_header');
         $TableTPL = parent::$page->get_template('infos/info_production_body');
     } elseif ($this->_element_id == 4) {
         $PageTPL = parent::$page->get_template('infos/info_buildings_table');
         $TableHeadTPL = parent::$page->get_template('infos/info_production_simple_header');
         $TableTPL = parent::$page->get_template('infos/info_production_simple_body');
     } elseif ($this->_element_id >= 22 && $this->_element_id <= 24) {
         $PageTPL = parent::$page->get_template('infos/info_buildings_table');
         $DestroyTPL = parent::$page->get_template('infos/info_buildings_destroy');
         $TableHeadTPL = parent::$page->get_template('infos/info_storage_header');
         $TableTPL = parent::$page->get_template('infos/info_storage_table');
     } elseif ($this->_element_id == 12) {
         $TableHeadTPL = parent::$page->get_template('infos/info_energy_header');
         $TableTPL = parent::$page->get_template('infos/info_energy_body');
     } elseif ($this->_element_id == 42) {
         $TableHeadTPL = parent::$page->get_template('infos/info_range_header');
         $TableTPL = parent::$page->get_template('infos/info_range_body');
     } elseif ($this->_element_id == 43) {
         $GateTPL = parent::$page->get_template('infos/info_gate_table');
         if ($_POST) {
             Functions_Lib::message($this->DoFleetJump(), "game.php?page=infos&gid=43", 2);
         }
     } elseif ($this->_element_id == 124) {
         $PageTPL = parent::$page->get_template('infos/info_buildings_table');
         $DestroyTPL = parent::$page->get_template('infos/info_buildings_destroy');
         $TableHeadTPL = parent::$page->get_template('infos/info_astrophysics_header');
         $TableTPL = parent::$page->get_template('infos/info_astrophysics_table');
         $TableFooterTPL = parent::$page->get_template('infos/info_astrophysics_footer');
     } elseif ($this->_element_id >= 202 && $this->_element_id <= 250) {
         $PageTPL = parent::$page->get_template('infos/info_buildings_fleet');
         $parse['element_typ'] = $this->_lang['tech'][200];
         $parse['rf_info_to'] = $this->ShowRapidFireTo();
         $parse['rf_info_fr'] = $this->ShowRapidFireFrom();
         $parse['hull_pt'] = Format_Lib::pretty_number($this->_pricelist[$this->_element_id]['metal'] + $this->_pricelist[$this->_element_id]['crystal']);
         $parse['shield_pt'] = Format_Lib::pretty_number($this->_combat_caps[$this->_element_id]['shield']);
         $parse['attack_pt'] = Format_Lib::pretty_number($this->_combat_caps[$this->_element_id]['attack']);
         $parse['capacity_pt'] = Format_Lib::pretty_number($this->_pricelist[$this->_element_id]['capacity']);
         $parse['base_speed'] = Format_Lib::pretty_number($this->_pricelist[$this->_element_id]['speed']);
         $parse['base_conso'] = Format_Lib::pretty_number($this->_pricelist[$this->_element_id]['consumption']);
         if ($this->_element_id == 202) {
             $parse['upd_speed'] = "<font color=\"yellow\">(" . Format_Lib::pretty_number($this->_pricelist[$this->_element_id]['speed2']) . ")</font>";
             $parse['upd_conso'] = "<font color=\"yellow\">(" . Format_Lib::pretty_number($this->_pricelist[$this->_element_id]['consumption2']) . ")</font>";
         } elseif ($this->_element_id == 211) {
             $parse['upd_speed'] = "<font color=\"yellow\">(" . Format_Lib::pretty_number($this->_pricelist[$this->_element_id]['speed2']) . ")</font>";
         }
     } elseif ($this->_element_id >= 401 && $this->_element_id <= 550) {
         $PageTPL = parent::$page->get_template('infos/info_buildings_defense');
         $parse['element_typ'] = $this->_lang['tech'][400];
         if ($this->_element_id < 500) {
             $parse['rf_info_to'] = $this->ShowRapidFireTo();
             $parse['rf_info_fr'] = $this->ShowRapidFireFrom();
         }
         $parse['hull_pt'] = Format_Lib::pretty_number($this->_pricelist[$this->_element_id]['metal'] + $this->_pricelist[$this->_element_id]['crystal']);
         $parse['shield_pt'] = Format_Lib::pretty_number($this->_combat_caps[$this->_element_id]['shield']);
         $parse['attack_pt'] = Format_Lib::pretty_number($this->_combat_caps[$this->_element_id]['attack']);
     }
     if ($TableHeadTPL != '') {
         $parse['table_head'] = parent::$page->parse_template($TableHeadTPL, $this->_lang);
         if ($this->_element_id >= 22 && $this->_element_id <= 24) {
             $parse['table_data'] = $this->storage_table($TableTPL);
         } elseif ($this->_element_id == 124) {
             $parse['table_data'] = $this->astrophysics_table($TableTPL);
         } else {
             $parse['table_data'] = $this->ShowProductionTable($TableTPL);
         }
     }
     if ($TableFooterTPL != '') {
         $parse['table_footer'] = parent::$page->parse_template($TableFooterTPL, $this->_lang);
     }
     $page = parent::$page->parse_template($PageTPL, $parse);
     if ($GateTPL != '') {
         if ($this->_current_planet[$this->_resource[$this->_element_id]] > 0) {
             $RestString = $this->GetNextJumpWaitTime($this->_current_planet);
             $parse['gate_start_link'] = $this->planet_link($this->_current_planet);
             if ($RestString['value'] != 0) {
                 $parse['gate_time_script'] = Functions_Lib::chrono_applet("Gate", "1", $RestString['value'], TRUE);
                 $parse['gate_wait_time'] = "<div id=\"bxx" . "Gate" . "1" . "\"></div>";
                 $parse['gate_script_go'] = Functions_Lib::chrono_applet("Gate", "1", $RestString['value'], FALSE);
             } else {
                 $parse['gate_time_script'] = "";
                 $parse['gate_wait_time'] = "";
                 $parse['gate_script_go'] = "";
             }
             $parse['gate_dest_moons'] = $this->BuildJumpableMoonCombo($this->_current_user, $this->_current_planet);
             $parse['gate_fleet_rows'] = $this->BuildFleetListRows($this->_current_planet);
             $page .= parent::$page->parse_template($GateTPL, $parse);
         }
     }
     if ($DestroyTPL != '') {
         if (isset($this->_current_planet[$this->_resource[$this->_element_id]]) && $this->_current_planet[$this->_resource[$this->_element_id]] > 0) {
             $NeededRessources = Developments_Lib::development_price($this->_current_user, $this->_current_planet, $this->_element_id, TRUE, TRUE);
             $DestroyTime = Developments_Lib::development_time($this->_current_user, $this->_current_planet, $this->_element_id) / 2;
             $parse['destroyurl'] = "game.php?page=" . Developments_Lib::set_building_page($this->_element_id) . "&cmd=destroy&building=" . $this->_element_id;
             $parse['levelvalue'] = $this->_current_planet[$this->_resource[$this->_element_id]];
             $parse['nfo_metal'] = $this->_lang['Metal'];
             $parse['nfo_crysta'] = $this->_lang['Crystal'];
             $parse['nfo_deuter'] = $this->_lang['Deuterium'];
             $parse['metal'] = Format_Lib::pretty_number($NeededRessources['metal']);
             $parse['crystal'] = Format_Lib::pretty_number($NeededRessources['crystal']);
             $parse['deuterium'] = Format_Lib::pretty_number($NeededRessources['deuterium']);
             $parse['destroytime'] = Format_Lib::pretty_time($DestroyTime);
             $page .= parent::$page->parse_template($DestroyTPL, $parse);
         }
     }
     parent::$page->display($page);
 }
 /**
  * method set_user_data
  * param
  * return (void)
  */
 private function set_user_data()
 {
     $user_row = array();
     $this->_user_data = parent::$db->query("SELECT u.*,\n\t            \t\t\t\t\t\t\t\t\t\t\tpre.*,\n\t            \t\t\t\t\t\t\t\t\t\t\tse.*,\n\t            \t\t\t\t\t\t\t\t\t\t\tusul.user_statistic_total_rank,\n\t            \t\t\t\t\t\t\t\t\t\t\tusul.user_statistic_total_points,\n\t            \t\t\t\t\t\t\t\t\t\t\tr.*,\n\t            \t\t\t\t\t\t\t\t\t\t\ta.alliance_name,\n\t            \t\t\t\t\t\t\t\t\t\t\t(SELECT COUNT(`message_id`) AS `new_message` FROM `" . MESSAGES . "` WHERE `message_receiver` = u.`user_id` AND `message_read` = 0) AS `new_message`\n\t            \t\t\t\t\t\t\t\t\tFROM " . USERS . " AS u\n\t            \t\t\t\t\t\t\t\t\tINNER JOIN " . SETTINGS . " AS se ON se.setting_user_id = u.user_id\n\t                                    \t\t\tINNER JOIN " . USERS_STATISTICS . " AS usul ON usul.user_statistic_user_id = u.user_id\n\t                                    \t\t\tINNER JOIN " . PREMIUM . " AS pre ON pre.premium_user_id = u.user_id\n\t                                    \t\t\tINNER JOIN " . RESEARCH . " AS r ON r.research_user_id = u.user_id\n\t                                    \t\t\tLEFT JOIN " . ALLIANCE . " AS a ON a.alliance_id = u.user_ally_id\n\t            \t\t\t\t\t\t\t\t\tWHERE (u.user_name = '" . parent::$db->escape_value($_SESSION['user_name']) . "')\n\t            \t\t\t\t\t\t\t\t\tLIMIT 1;");
     if (parent::$db->num_rows($this->_user_data) != 1) {
         Functions_Lib::message($this->_lang['ccs_multiple_users'], XGP_ROOT, 3, FALSE, FALSE);
     }
     $user_row = parent::$db->fetch_array($this->_user_data);
     if ($user_row['user_id'] != $_SESSION['user_id']) {
         Functions_Lib::message($this->_lang['ccs_other_user'], XGP_ROOT, 3, FALSE, FALSE);
     }
     if (sha1($user_row['user_password'] . "-" . SECRETWORD) != $_SESSION['user_password']) {
         Functions_Lib::message($this->_lang['css_different_password'], XGP_ROOT, 5, FALSE, FALSE);
     }
     if ($user_row['user_banned'] > 0) {
         $parse = $this->_lang;
         $parse['banned_until'] = date(Functions_Lib::read_config('date_format_extended'), $user_row['user_banned']);
         die(parent::$page->parse_template(parent::$page->get_template('home/banned_message'), $parse));
     }
     parent::$db->query("UPDATE " . USERS . " SET\n            \t\t\t\t\t`user_onlinetime` = '" . time() . "',\n            \t\t\t\t\t`user_current_page` = '" . parent::$db->escape_value($_SERVER['REQUEST_URI']) . "',\n            \t\t\t\t\t`user_lastip` = '" . parent::$db->escape_value($_SERVER['REMOTE_ADDR']) . "',\n            \t\t\t\t\t`user_agent` = '" . parent::$db->escape_value($_SERVER['HTTP_USER_AGENT']) . "'\n            \t\t\t\t\tWHERE `user_id` = '" . parent::$db->escape_value($_SESSION['user_id']) . "'\n            \t\t\t\t\tLIMIT 1;");
     // pass the data
     $this->_user_data = $user_row;
     // unset the old data
     unset($user_row);
 }
Beispiel #11
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $mode = isset($_GET['mode']) ? intval($_GET['mode']) : NULL;
     $bid = isset($_GET['bid']) ? intval($_GET['bid']) : NULL;
     $sm = isset($_GET['sm']) ? intval($_GET['sm']) : NULL;
     $user = isset($_GET['u']) ? intval($_GET['u']) : NULL;
     $this->_lang['js_path'] = XGP_ROOT . JS_PATH;
     $parse = $this->_lang;
     $requestsSended = '';
     $requestsReceived = '';
     $budys = '';
     switch ($mode) {
         case 1:
             switch ($sm) {
                 // REJECT / CANCEL
                 case 1:
                     $senderID = parent::$db->query_fetch("SELECT *\n\t\t\t\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\t\t\tWHERE `buddy_id`='" . intval($bid) . "'");
                     if ($senderID['buddy_status'] == 0) {
                         if ($senderID['buddy_sender'] != $this->_current_user['user_id']) {
                             Functions_Lib::send_message($senderID['buddy_sender'], $this->_current_user['user_id'], '', 5, $this->_current_user['user_name'], $this->_lang['bu_rejected_title'], str_replace('%u', $this->_current_user['user_name'], $this->_lang['bu_rejected_text']));
                         } elseif ($senderID['buddy_sender'] == $this->_current_user['user_id']) {
                             Functions_Lib::send_message($senderID['buddy_receiver'], $this->_current_user['user_id'], '', 5, $this->_current_user['user_name'], $this->_lang['bu_rejected_title'], str_replace('%u', $this->_current_user['user_name'], $this->_lang['bu_rejected_title']));
                         }
                     } else {
                         if ($senderID['buddy_sender'] != $this->_current_user['user_id']) {
                             Functions_Lib::send_message($senderID['buddy_sender'], $this->_current_user['user_id'], '', 5, $this->_current_user['user_name'], $this->_lang['bu_deleted_title'], str_replace('%u', $this->_current_user['user_name'], $this->_lang['bu_deleted_text']));
                         } elseif ($senderID['buddy_sender'] == $this->_current_user['user_id']) {
                             Functions_Lib::send_message($senderID['buddy_receiver'], $this->_current_user['user_id'], '', 5, $this->_current_user['user_name'], $this->_lang['bu_deleted_title'], str_replace('%u', $this->_current_user['user_name'], $this->_lang['bu_deleted_text']));
                         }
                     }
                     parent::$db->query("DELETE FROM " . BUDDY . "\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `buddy_id`='" . intval($bid) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(`buddy_receiver`='" . $this->_current_user['user_id'] . "' OR `buddy_sender`='" . $this->_current_user['user_id'] . "') ");
                     Functions_Lib::redirect('game.php?page=buddy');
                     break;
                     // ACCEPT
                 // ACCEPT
                 case 2:
                     $senderID = parent::$db->query_fetch("SELECT *\n\t\t\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\t\tWHERE `buddy_id`='" . intval($bid) . "'");
                     Functions_Lib::send_message($senderID['buddy_sender'], $this->_current_user['user_id'], '', 5, $this->_current_user['user_name'], $this->_lang['bu_accepted_title'], str_replace('%u', $this->_current_user['user_name'], $this->_lang['bu_accepted_text']));
                     parent::$db->query("UPDATE " . BUDDY . "\n\t\t\t\t\t\t\t\t\t\t\t\tSET `buddy_status` = '1'\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `buddy_id` ='" . intval($bid) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`buddy_receiver`='" . $this->_current_user['user_id'] . "'");
                     Functions_Lib::redirect('game.php?page=buddy');
                     break;
                     // SEND REQUEST
                 // SEND REQUEST
                 case 3:
                     $query = parent::$db->query_fetch("SELECT `buddy_id`\n\t\t\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\t\tWHERE (`buddy_receiver`='" . intval($this->_current_user['user_id']) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`buddy_sender`='" . intval($_POST['user']) . "') OR\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(`buddy_receiver`='" . intval($_POST['user']) . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`buddy_sender`='" . intval($this->_current_user['user_id']) . "')");
                     if (!$query) {
                         $text = parent::$db->escape_value(strip_tags($_POST['text']));
                         Functions_Lib::send_message(intval($_POST['user']), $this->_current_user['user_id'], '', 5, $this->_current_user['user_name'], $this->_lang['bu_to_accept_title'], str_replace('%u', $this->_current_user['user_name'], $this->_lang['bu_to_accept_text']));
                         parent::$db->query("INSERT INTO " . BUDDY . " SET\n\t\t\t\t\t\t\t\t\t\t\t\t\t`buddy_sender`='" . intval($this->_current_user['user_id']) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t`buddy_receiver`='" . intval($_POST['user']) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t`buddy_status`='0',\n\t\t\t\t\t\t\t\t\t\t\t\t\t`buddy_request_text`='" . $text . "'");
                         Functions_Lib::redirect('game.php?page=buddy');
                     } else {
                         Functions_Lib::message($this->_lang['bu_request_exists'], 'game.php?page=buddy', 2, FALSE, FALSE, FALSE);
                     }
                     break;
                     // ANY OTHER OPTION EXIT
                 // ANY OTHER OPTION EXIT
                 default:
                     Functions_Lib::redirect('game.php?page=buddy');
                     break;
             }
             break;
             // FRIENDSHIP REQUEST
         // FRIENDSHIP REQUEST
         case 2:
             // IF USER = REQUESTED USER, SHOW ERROR.
             if ($user == $this->_current_user['user_id']) {
                 Functions_Lib::message($this->_lang['bu_cannot_request_yourself'], 'game.php?page=buddy', 2, FALSE, FALSE, FALSE);
             } else {
                 // SEARCH THE PLAYER
                 $player = parent::$db->query_fetch("SELECT `user_name`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `user_id`='" . intval($user) . "'");
                 // IF PLAYER EXISTS, PROCEED
                 if ($player) {
                     $parse['user'] = $user;
                     $parse['player'] = $player['user_name'];
                     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('buddy/buddy_request'), $parse), FALSE, '', FALSE);
                 } else {
                     Functions_Lib::redirect('game.php?page=buddy');
                 }
             }
             break;
             // NOTHING SELECTED
         // NOTHING SELECTED
         default:
             $getBuddys = parent::$db->query("SELECT *\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\tWHERE `buddy_sender`='" . intval($this->_current_user['user_id']) . "' OR\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`buddy_receiver`='" . intval($this->_current_user['user_id']) . "'");
             $subTemplate = parent::$page->get_template('buddy/buddy_row');
             while ($buddy = parent::$db->fetch_assoc($getBuddys)) {
                 if ($buddy['buddy_status'] == 0) {
                     if ($buddy['buddy_sender'] == $this->_current_user['user_id']) {
                         $buddy_receiver = parent::$db->query_fetch("SELECT u.`user_id`, u.`user_name`, u.`user_galaxy`, u.`user_system`, u.`user_planet`, u.`user_ally_id`, a.`alliance_name`\n\t\t\t\t\t\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\t\t\t\t\t\tLEFT JOIN `" . ALLIANCE . "` AS a ON a.`alliance_id` = u.`user_ally_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE u.`user_id`='" . intval($buddy['buddy_receiver']) . "'");
                         $parse['id'] = $buddy_receiver['user_id'];
                         $parse['username'] = $buddy_receiver['user_name'];
                         $parse['ally_id'] = $buddy_receiver['user_ally_id'];
                         $parse['alliance_name'] = $buddy_receiver['alliance_name'];
                         $parse['galaxy'] = $buddy_receiver['user_galaxy'];
                         $parse['system'] = $buddy_receiver['user_system'];
                         $parse['planet'] = $buddy_receiver['user_planet'];
                         $parse['text'] = $buddy['buddy_request_text'];
                         $parse['action'] = '<a href="game.php?page=buddy&mode=1&sm=1&bid=' . $buddy['buddy_id'] . '">' . $this->_lang['bu_cancel_request'] . '</a>';
                         $requestsSended .= parent::$page->parse_template($subTemplate, $parse);
                     } else {
                         $buddy_sender = parent::$db->query_fetch("SELECT `user_id`, `user_name`, `user_galaxy`, `user_system`, `user_planet`,`user_ally_id`, `alliance_name`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `user_id`='" . intval($buddy['buddy_sender']) . "'");
                         $parse['id'] = $buddy_sender['user_id'];
                         $parse['username'] = $buddy_sender['user_name'];
                         $parse['ally_id'] = $buddy_sender['user_ally_id'];
                         $parse['alliance_name'] = $buddy_sender['alliance_name'];
                         $parse['galaxy'] = $buddy_sender['user_galaxy'];
                         $parse['system'] = $buddy_sender['user_system'];
                         $parse['planet'] = $buddy_sender['user_planet'];
                         $parse['text'] = $buddy['buddy_request_text'];
                         $parse['action'] = '<a href="game.php?page=buddy&mode=1&sm=2&bid=' . $buddy['buddy_id'] . '">' . $this->_lang['bu_accept'] . '</a><br /><a href="game.php?page=buddy&mode=1&sm=1&bid=' . $buddy['buddy_id'] . '">' . $this->_lang['bu_decline'] . '</a>';
                         $requestsReceived .= parent::$page->parse_template($subTemplate, $parse);
                     }
                 } else {
                     if ($buddy['buddy_sender'] == $this->_current_user['user_id']) {
                         $buddy_receiver = parent::$db->query_fetch("SELECT `user_id`, `user_name`, `user_onlinetime`, `user_galaxy`, `user_system`, `user_planet`,`user_ally_id`, `alliance_name`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `user_id`='" . intval($buddy['buddy_receiver']) . "'");
                     } else {
                         $buddy_receiver = parent::$db->query_fetch("SELECT `user_id`, `user_name`, `user_onlinetime`, `user_galaxy`, `user_system`, `user_planet`,`user_ally_id`, `alliance_name`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `user_id`='" . intval($buddy['buddy_sender']) . "'");
                     }
                     $parse['id'] = $buddy_receiver['user_id'];
                     $parse['username'] = $buddy_receiver['user_name'];
                     $parse['ally_id'] = $buddy_receiver['user_ally_id'];
                     $parse['alliance_name'] = $buddy_receiver['alliance_name'];
                     $parse['galaxy'] = $buddy_receiver['user_galaxy'];
                     $parse['system'] = $buddy_receiver['user_system'];
                     $parse['planet'] = $buddy_receiver['user_planet'];
                     $parse['text'] = '<font color="' . ($buddy_receiver['user_onlinetime'] + 60 * 10 >= time() ? 'lime">' . $this->_lang['bu_connected'] . '' : ($buddy_receiver['user_onlinetime'] + 60 * 15 >= time() ? 'yellow">' . $this->_lang['bu_fifteen_minutes'] : 'red">' . $this->_lang['bu_disconnected'])) . '</font>';
                     $parse['action'] = '<a href="game.php?page=buddy&mode=1&sm=1&bid=' . $buddy['buddy_id'] . '">' . $this->_lang['bu_delete'] . '</a>';
                     $budys .= parent::$page->parse_template($subTemplate, $parse);
                 }
             }
             $parse['request_received'] = $requestsSended;
             $parse['request_sended'] = $requestsReceived;
             $parse['buddys'] = $budys;
             parent::$page->display(parent::$page->parse_template(parent::$page->get_template('buddy/buddy_body'), $parse), FALSE, '', FALSE);
             break;
     }
 }
Beispiel #12
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $resource = parent::$objects->get_objects();
     $pricelist = parent::$objects->get_price();
     $reslist = parent::$objects->get_objects_list();
     $parse = $this->_lang;
     if (parent::$users->is_on_vacations($this->_current_user)) {
         exit(Functions_Lib::message($this->_lang['fl_vacation_mode_active'], "game.php?page=overview", 2));
     }
     $fleet_group_mr = 0;
     if ($_POST['fleet_group'] > 0) {
         if ($_POST['mission'] == 2) {
             $target = 'g' . (int) $_POST['galaxy'] . 's' . (int) $_POST['system'] . 'p' . (int) $_POST['planet'] . 't' . (int) $_POST['planettype'];
             if ($_POST['acs_target_mr'] == $target) {
                 $aks_count_mr = parent::$db->query("SELECT COUNT(`acs_fleet_id`)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . ACS_FLEETS . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `acs_fleet_id` = '" . (int) $_POST['fleet_group'] . "'");
                 if ($aks_count_mr > 0) {
                     $fleet_group_mr = $_POST['fleet_group'];
                 }
             }
         }
     }
     if ($_POST['fleet_group'] == 0 && $_POST['mission'] == 2) {
         $_POST['mission'] = 1;
     }
     $TargetPlanet = parent::$db->query_fetch("SELECT `planet_user_id`,`planet_destroyed`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . PLANETS . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE `planet_galaxy` = '" . (int) $_POST['galaxy'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t`planet_system` = '" . (int) $_POST['system'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t`planet_planet` = '" . (int) $_POST['planet'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t`planet_type` = '" . (int) $_POST['planettype'] . "';");
     $MyDBRec = parent::$db->query_fetch("SELECT u.`user_id`, u.`user_onlinetime`, u.`user_ally_id`, s.`setting_vacations_status`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . " AS u, " . SETTINGS . " AS s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE u.`user_id` = '" . $this->_current_user['user_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND s.`setting_user_id` = '" . $this->_current_user['user_id'] . "';");
     $fleetarray = unserialize(base64_decode(str_rot13($_POST['usedfleet'])));
     if ($TargetPlanet['planet_destroyed'] != 0) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     if (!is_array($fleetarray)) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     foreach ($fleetarray as $Ship => $Count) {
         $Count = intval($Count);
         if ($Count > $this->_current_planet[$resource[$Ship]]) {
             Functions_Lib::redirect('game.php?page=movement');
         }
     }
     $error = 0;
     $galaxy = (int) $_POST['galaxy'];
     $system = (int) $_POST['system'];
     $planet = (int) $_POST['planet'];
     $planettype = (int) $_POST['planettype'];
     $fleetmission = (int) $_POST['mission'];
     //fix by jstar
     if ($fleetmission == 7 && !isset($fleetarray[208])) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     if ($planettype != 1 && $planettype != 2 && $planettype != 3) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     //fix invisible debris like ogame by jstar
     if ($fleetmission == 8) {
         $YourPlanet = FALSE;
         $UsedPlanet = FALSE;
         $select = parent::$db->query_fetch("SELECT COUNT(*) AS count, p.*\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . PLANETS . "` AS p\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . $galaxy . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . $system . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . $planet . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = 1;");
         if ($select['planet_debris_metal'] == 0 && $select['planet_debris_crystal'] == 0 && time() > $select['planet_invisible_start_time'] + DEBRIS_LIFE_TIME) {
             Functions_Lib::redirect('game.php?page=movement');
         }
     } else {
         $YourPlanet = FALSE;
         $UsedPlanet = FALSE;
         $select = parent::$db->query_fetch("SELECT COUNT(*) AS count, p.`planet_user_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . PLANETS . "` AS p\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . $galaxy . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . $system . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . $planet . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = '" . $planettype . "'");
     }
     if ($this->_current_planet['planet_galaxy'] == $galaxy && $this->_current_planet['planet_system'] == $system && $this->_current_planet['planet_planet'] == $planet && $this->_current_planet['planet_type'] == $planettype) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     if ($_POST['mission'] != 15) {
         if ($select['count'] < 1 && $fleetmission != 7) {
             Functions_Lib::redirect('game.php?page=movement');
         } elseif ($fleetmission == 9 && $select['count'] < 1) {
             Functions_Lib::redirect('game.php?page=movement');
         }
     } else {
         $MaxExpedition = $this->_current_user[$resource[124]];
         if ($MaxExpedition >= 1) {
             $maxexpde = parent::$db->query_fetch("SELECT COUNT(fleet_owner) AS `expedi`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_owner` = '" . $this->_current_user['user_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `fleet_mission` = '15';");
             $ExpeditionEnCours = $maxexpde['expedi'];
             $EnvoiMaxExpedition = Fleets_Lib::get_max_expeditions($MaxExpedition);
         } else {
             $ExpeditionEnCours = 0;
             $EnvoiMaxExpedition = 0;
         }
         if ($EnvoiMaxExpedition == 0) {
             Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_expedition_tech_required'] . "</b></font>", "game.php?page=movement", 2);
         } elseif ($ExpeditionEnCours >= $EnvoiMaxExpedition) {
             Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_expedition_fleets_limit'] . "</b></font>", "game.php?page=movement", 2);
         }
     }
     if ($select['planet_user_id'] == $this->_current_user['user_id']) {
         $YourPlanet = TRUE;
         $UsedPlanet = TRUE;
     } elseif (!empty($select['planet_user_id'])) {
         $YourPlanet = FALSE;
         $UsedPlanet = TRUE;
     } else {
         $YourPlanet = FALSE;
         $UsedPlanet = FALSE;
     }
     //fix by jstar
     if ($fleetmission == 9) {
         $countfleettype = count($fleetarray);
         if ($YourPlanet or !$UsedPlanet or $planettype != 3) {
             Functions_Lib::redirect('game.php?page=movement');
         } elseif ($countfleettype == 1 && !isset($fleetarray[214])) {
             Functions_Lib::redirect('game.php?page=movement');
         } elseif ($countfleettype == 2 && !isset($fleetarray[214])) {
             Functions_Lib::redirect('game.php?page=movement');
         } elseif ($countfleettype > 2) {
             Functions_Lib::redirect('game.php?page=movement');
         }
     }
     if (empty($fleetmission)) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     if ($TargetPlanet['planet_user_id'] == '') {
         $HeDBRec = $MyDBRec;
     } elseif ($TargetPlanet['planet_user_id'] != '') {
         $HeDBRec = parent::$db->query_fetch("SELECT u.`user_id`, u.`user_onlinetime`, u.`user_ally_id`, s.`setting_vacations_status`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . " AS u, " . SETTINGS . " AS s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE u.`user_id` = '" . $TargetPlanet['planet_user_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND s.`setting_user_id` ='" . $TargetPlanet['planet_user_id'] . "';");
     }
     $user_points = $this->_noob->return_points($MyDBRec['user_id'], $HeDBRec['user_id']);
     $MyGameLevel = $user_points['user_points'];
     $HeGameLevel = $user_points['target_points'];
     if ($HeDBRec['user_onlinetime'] >= time() - 60 * 60 * 24 * 7) {
         if ($this->_noob->is_weak($MyGameLevel, $HeGameLevel) && $TargetPlanet['planet_user_id'] != '' && ($_POST['mission'] == 1 or $_POST['mission'] == 6 or $_POST['mission'] == 9)) {
             Functions_Lib::message("<font color=\"lime\"><b>" . $this->_lang['fl_week_player'] . "</b></font>", "game.php?page=movement", 2);
         }
         if ($this->_noob->is_strong($MyGameLevel, $HeGameLevel) && $TargetPlanet['planet_user_id'] != '' && ($_POST['mission'] == 1 or $_POST['mission'] == 5 or $_POST['mission'] == 6 or $_POST['mission'] == 9)) {
             Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_strong_player'] . "</b></font>", "game.php?page=movement", 2);
         }
     }
     if ($HeDBRec['setting_vacations_status'] && $_POST['mission'] != 8) {
         Functions_Lib::message("<font color=\"lime\"><b>" . $this->_lang['fl_in_vacation_player'] . "</b></font>", "game.php?page=movement", 2);
     }
     $FlyingFleets = parent::$db->query_fetch("SELECT COUNT(fleet_id) as Number\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_owner`='" . $this->_current_user['user_id'] . "'");
     $ActualFleets = $FlyingFleets['Number'];
     if (Fleets_Lib::get_max_fleets($this->_current_user[$resource[108]], $this->_current_user['premium_officier_admiral']) <= $ActualFleets) {
         Functions_Lib::message($this->_lang['fl_no_slots'], "game.php?page=movement", 1);
     }
     if ($_POST['resource1'] + $_POST['resource2'] + $_POST['resource3'] < 1 && $_POST['mission'] == 3) {
         Functions_Lib::message("<font color=\"lime\"><b>" . $this->_lang['fl_empty_transport'] . "</b></font>", "game.php?page=movement", 1);
     }
     if ($_POST['mission'] != 15) {
         if ($TargetPlanet['planet_user_id'] == '' && $_POST['mission'] < 7) {
             Functions_Lib::redirect('game.php?page=movement');
         }
         if ($TargetPlanet['planet_user_id'] != '' && $_POST['mission'] == 7) {
             Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_planet_populed'] . "</b></font>", "game.php?page=movement", 2);
         }
         if ($HeDBRec['user_ally_id'] != $MyDBRec['user_ally_id'] && $_POST['mission'] == 4) {
             Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_stay_not_on_enemy'] . "</b></font>", "game.php?page=movement", 2);
         }
         if ($TargetPlanet['planet_user_id'] == $this->_current_planet['planet_user_id'] && ($_POST['mission'] == 1 or $_POST['mission'] == 6)) {
             Functions_Lib::redirect('game.php?page=movement');
         }
         if ($TargetPlanet['planet_user_id'] != $this->_current_planet['planet_user_id'] && $_POST['mission'] == 4) {
             Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_deploy_only_your_planets'] . "</b></font>", "game.php?page=movement", 2);
         }
         if ($_POST['mission'] == 5) {
             $buddy = parent::$db->query_fetch("SELECT COUNT( * ) AS buddys\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM  `" . BUDDY . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbuddy_sender ='" . intval($this->_current_planet['planet_user_id']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND buddy_receiver ='" . intval($TargetPlanet['planet_user_id']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tOR (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbuddy_sender ='" . intval($TargetPlanet['planet_user_id']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND buddy_receiver ='" . intval($this->_current_planet['planet_user_id']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND buddy_status =1");
             if ($HeDBRec['user_ally_id'] != $MyDBRec['user_ally_id'] && $buddy['buddys'] < 1) {
                 Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_stay_not_on_enemy'] . "</b></font>", "game.php?page=movement", 2);
             }
         }
     }
     $missiontype = Fleets_Lib::get_missions();
     $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
     $AllFleetSpeed = Fleets_Lib::fleet_max_speed($fleetarray, 0, $this->_current_user);
     $GenFleetSpeed = $_POST['speed'];
     $SpeedFactor = Functions_Lib::fleet_speed_factor();
     $MaxFleetSpeed = min($AllFleetSpeed);
     if (!in_array($GenFleetSpeed, $speed_possible)) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     if ($MaxFleetSpeed != $_POST['speedallsmin']) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     if (!$_POST['planettype']) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     if (!$_POST['galaxy'] || !is_numeric($_POST['galaxy']) || $_POST['galaxy'] > MAX_GALAXY_IN_WORLD || $_POST['galaxy'] < 1) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     if (!$_POST['system'] || !is_numeric($_POST['system']) || $_POST['system'] > MAX_SYSTEM_IN_GALAXY || $_POST['system'] < 1) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     if (!$_POST['planet'] || !is_numeric($_POST['planet']) || $_POST['planet'] > MAX_PLANET_IN_SYSTEM + 1 || $_POST['planet'] < 1) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     if ($_POST['thisgalaxy'] != $this->_current_planet['planet_galaxy'] | $_POST['thissystem'] != $this->_current_planet['planet_system'] | $_POST['thisplanet'] != $this->_current_planet['planet_planet'] | $_POST['thisplanettype'] != $this->_current_planet['planet_type']) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     if (!isset($fleetarray)) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     $distance = Fleets_Lib::target_distance($_POST['thisgalaxy'], $_POST['galaxy'], $_POST['thissystem'], $_POST['system'], $_POST['thisplanet'], $_POST['planet']);
     $duration = Fleets_Lib::mission_duration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor);
     $consumption = Fleets_Lib::fleet_consumption($fleetarray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $this->_current_user);
     $fleet['start_time'] = $duration + time();
     // START CODE BY JSTAR
     if ($_POST['mission'] == 15) {
         $StayDuration = floor($_POST['expeditiontime']);
         if ($StayDuration > 0) {
             $StayDuration = $StayDuration * 3600;
             $StayTime = $fleet['start_time'] + $StayDuration;
         } else {
             Functions_Lib::redirect('game.php?page=movement');
         }
     } elseif ($_POST['mission'] == 5) {
         $StayDuration = $_POST['holdingtime'] * 3600;
         $StayTime = $fleet['start_time'] + $_POST['holdingtime'] * 3600;
     } else {
         $StayDuration = 0;
         $StayTime = 0;
     }
     $fleet['end_time'] = $StayDuration + 2 * $duration + time();
     $FleetStorage = 0;
     $FleetShipCount = 0;
     $fleet_array = "";
     $FleetSubQRY = "";
     //fix by jstar
     $haveSpyProbos = FALSE;
     foreach ($fleetarray as $Ship => $Count) {
         $Count = intval($Count);
         if ($Ship == 210) {
             $haveSpyProbos = TRUE;
         }
         $FleetStorage += $pricelist[$Ship]['capacity'] * $Count;
         $FleetShipCount += $Count;
         $fleet_array .= $Ship . "," . $Count . ";";
         $FleetSubQRY .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` - " . $Count . ", ";
     }
     if (!$haveSpyProbos && $_POST['mission'] == 6) {
         Functions_Lib::redirect('game.php?page=movement');
     }
     $FleetStorage -= $consumption;
     $StorageNeeded = 0;
     $_POST['resource1'] = max(0, (int) trim($_POST['resource1']));
     $_POST['resource2'] = max(0, (int) trim($_POST['resource2']));
     $_POST['resource3'] = max(0, (int) trim($_POST['resource3']));
     if ($_POST['resource1'] < 1) {
         $TransMetal = 0;
     } else {
         $TransMetal = $_POST['resource1'];
         $StorageNeeded += $TransMetal;
     }
     if ($_POST['resource2'] < 1) {
         $TransCrystal = 0;
     } else {
         $TransCrystal = $_POST['resource2'];
         $StorageNeeded += $TransCrystal;
     }
     if ($_POST['resource3'] < 1) {
         $TransDeuterium = 0;
     } else {
         $TransDeuterium = $_POST['resource3'];
         $StorageNeeded += $TransDeuterium;
     }
     $StockMetal = $this->_current_planet['planet_metal'];
     $StockCrystal = $this->_current_planet['planet_crystal'];
     $StockDeuterium = $this->_current_planet['planet_deuterium'];
     $StockDeuterium -= $consumption;
     $StockOk = FALSE;
     if ($StockMetal >= $TransMetal) {
         if ($StockCrystal >= $TransCrystal) {
             if ($StockDeuterium >= $TransDeuterium) {
                 $StockOk = TRUE;
             }
         }
     }
     if (!$StockOk) {
         Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_no_enought_deuterium'] . Format_Lib::pretty_number($consumption) . "</b></font>", "game.php?page=movement", 2);
     }
     if ($StorageNeeded > $FleetStorage) {
         Functions_Lib::message("<font color=\"red\"><b>" . $this->_lang['fl_no_enought_cargo_capacity'] . Format_Lib::pretty_number($StorageNeeded - $FleetStorage) . "</b></font>", "game.php?page=movement", 2);
     }
     if (Functions_Lib::read_config('adm_attack') != 0) {
         Functions_Lib::message($this->_lang['fl_admins_cannot_be_attacked'], "game.php?page=movement", 2);
     }
     if ($fleet_group_mr != 0) {
         $AksStartTime = parent::$db->query_fetch("SELECT MAX(`fleet_start_time`) AS Start\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_group` = '" . $fleet_group_mr . "';");
         if ($AksStartTime['Start'] >= $fleet['start_time']) {
             $fleet['end_time'] += $AksStartTime['Start'] - $fleet['start_time'];
             $fleet['start_time'] = $AksStartTime['Start'];
         } else {
             parent::$db->query("UPDATE " . FLEETS . " SET\n\t\t\t\t\t\t\t\t\t\t`fleet_start_time` = '" . $fleet['start_time'] . "',\n\t\t\t\t\t\t\t\t\t\t`fleet_end_time` = fleet_end_time + '" . ($fleet['start_time'] - $AksStartTime['Start']) . "'\n\t\t\t\t\t\t\t\t\t\tWHERE `fleet_group` = '" . $fleet_group_mr . "';");
             $fleet['end_time'] += $fleet['start_time'] - $AksStartTime['Start'];
         }
     }
     parent::$db->query("INSERT INTO " . FLEETS . " SET\n\t\t\t\t\t\t\t`fleet_owner` = '" . $this->_current_user['user_id'] . "',\n\t\t\t\t\t\t\t`fleet_mission` = '" . (int) $_POST['mission'] . "',\n\t\t\t\t\t\t\t`fleet_amount` = '" . (int) $FleetShipCount . "',\n\t\t\t\t\t\t\t`fleet_array` = '" . $fleet_array . "',\n\t\t\t\t\t\t\t`fleet_start_time` = '" . $fleet['start_time'] . "',\n\t\t\t\t\t\t\t`fleet_start_galaxy` = '" . (int) $_POST['thisgalaxy'] . "',\n\t\t\t\t\t\t\t`fleet_start_system` = '" . (int) $_POST['thissystem'] . "',\n\t\t\t\t\t\t\t`fleet_start_planet` = '" . (int) $_POST['thisplanet'] . "',\n\t\t\t\t\t\t\t`fleet_start_type` = '" . (int) $_POST['thisplanettype'] . "',\n\t\t\t\t\t\t\t`fleet_end_time` = '" . (int) $fleet['end_time'] . "',\n\t\t\t\t\t\t\t`fleet_end_stay` = '" . (int) $StayTime . "',\n\t\t\t\t\t\t\t`fleet_end_galaxy` = '" . (int) $_POST['galaxy'] . "',\n\t\t\t\t\t\t\t`fleet_end_system` = '" . (int) $_POST['system'] . "',\n\t\t\t\t\t\t\t`fleet_end_planet` = '" . (int) $_POST['planet'] . "',\n\t\t\t\t\t\t\t`fleet_end_type` = '" . (int) $_POST['planettype'] . "',\n\t\t\t\t\t\t\t`fleet_resource_metal` = '" . $TransMetal . "',\n\t\t\t\t\t\t\t`fleet_resource_crystal` = '" . $TransCrystal . "',\n\t\t\t\t\t\t\t`fleet_resource_deuterium` = '" . $TransDeuterium . "',\n\t\t\t\t\t\t\t`fleet_target_owner` = '" . (int) $TargetPlanet['planet_user_id'] . "',\n\t\t\t\t\t\t\t`fleet_group` = '" . (int) $fleet_group_mr . "',\n\t\t\t\t\t\t\t`fleet_creation` = '" . time() . "';");
     parent::$db->query("UPDATE `" . PLANETS . "` AS p\n\t\t\t\t\t\t\t\tINNER JOIN " . SHIPS . " AS s ON s.ship_planet_id = p.`planet_id` SET\n\t\t\t\t\t\t\t\t{$FleetSubQRY}\n\t\t\t\t\t\t\t\t`planet_metal` = `planet_metal` - " . $TransMetal . ",\n\t\t\t\t\t\t\t\t`planet_crystal` = `planet_crystal` - " . $TransCrystal . ",\n\t\t\t\t\t\t\t\t`planet_deuterium` = `planet_deuterium` - " . ($TransDeuterium + $consumption) . "\n\t\t\t\t\t\t\t\tWHERE `planet_id` = " . $this->_current_planet['planet_id'] . ";");
     Functions_Lib::redirect('game.php?page=movement');
 }
Beispiel #13
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $mode = isset($_GET['mode']) ? $_GET['mode'] : NULL;
     if ($_POST && $mode == 'exit') {
         if (isset($_POST['exit_modus']) && $_POST['exit_modus'] == 'on' and $this->_current_user['setting_vacations_until'] <= time()) {
             $urlaubs_modus = '0';
             parent::$db->query("UPDATE " . SETTINGS . ", " . PLANETS . " SET\r\n\t\t\t\t\t\t\t\t\t\t`setting_vacations_status` = '0',\r\n\t\t\t\t\t\t\t\t\t\t`setting_vacations_until` = '0',\r\n\t\t\t\t\t\t\t\t\t\tplanet_building_metal_mine_porcent = '10',\r\n\t\t\t\t\t\t\t\t\t\tplanet_building_crystal_mine_porcent = '10',\r\n\t\t\t\t\t\t\t\t\t\tplanet_building_deuterium_sintetizer_porcent = '10',\r\n\t\t\t\t\t\t\t\t\t\tplanet_building_solar_plant_porcent = '10',\r\n\t\t\t\t\t\t\t\t\t\tplanet_building_fusion_reactor_porcent = '10',\r\n\t\t\t\t\t\t\t\t\t\tplanet_ship_solar_satellite_porcent = '10'\r\n\t\t\t\t\t\t\t\t\t\tWHERE `setting_user_id` = '" . intval($this->_current_user['user_id']) . "' AND planet_user_id = '" . intval($this->_current_user['user_id']) . "'");
             Functions_Lib::redirect('game.php?page=options');
         } else {
             $urlaubs_modus = '1';
             Functions_Lib::redirect('game.php?page=options');
         }
     }
     if ($_POST && $mode == "change") {
         // < ------------------------------------------------- COMPROBACION DE IP -------------------------------------------------- >
         if (isset($_POST['noipcheck']) && $_POST['noipcheck'] == 'on') {
             $noipcheck = '1';
         } else {
             $noipcheck = '0';
         }
         // < ------------------------------------------------- NOMBRE DE USUARIO --------------------------------------------------- >
         if (isset($_POST['db_character']) && $_POST['db_character'] != '') {
             $username = parent::$db->escape_value($_POST['db_character']);
         } else {
             $username = parent::$db->escape_value($this->_current_user['user_name']);
         }
         // < ------------------------------------------------- DIRECCION DE EMAIL -------------------------------------------------- >
         if (isset($_POST['db_email']) && $_POST['db_email'] != '') {
             $db_email = parent::$db->escape_value($_POST['db_email']);
         } else {
             $db_email = parent::$db->escape_value($this->_current_user['user_email']);
         }
         // < ------------------------------------------------- CANTIDAD DE SONDAS -------------------------------------------------- >
         if (isset($_POST['spio_anz']) && is_numeric($_POST['spio_anz'])) {
             $spio_anz = intval($_POST['spio_anz']);
         } else {
             $spio_anz = '1';
         }
         // < ------------------------------------------------- MENSAJES DE FLOTAS -------------------------------------------------- >
         if (isset($_POST['settings_fleetactions']) && is_numeric($_POST['settings_fleetactions'])) {
             $settings_fleetactions = intval($_POST['settings_fleetactions']);
         } else {
             $settings_fleetactions = '1';
         }
         // < ------------------------------------------------- SONDAS DE ESPIONAJE ------------------------------------------------- >
         if (isset($_POST['settings_esp']) && $_POST['settings_esp'] == 'on') {
             $settings_esp = '1';
         } else {
             $settings_esp = '0';
         }
         // < ------------------------------------------------- ESCRIBIR MENSAJE ---------------------------------------------------- >
         if (isset($_POST['settings_wri']) && $_POST['settings_wri'] == 'on') {
             $settings_wri = '1';
         } else {
             $settings_wri = '0';
         }
         // < --------------------------------------------- AÑADIR A LISTA DE AMIGOS ------------------------------------------------ >
         if (isset($_POST['settings_bud']) && $_POST['settings_bud'] == 'on') {
             $settings_bud = '1';
         } else {
             $settings_bud = '0';
         }
         // < ------------------------------------------------- ATAQUE CON MISILES -------------------------------------------------- >
         if (isset($_POST['settings_mis']) && $_POST['settings_mis'] == 'on') {
             $settings_mis = '1';
         } else {
             $settings_mis = '0';
         }
         // < ------------------------------------------------- VER REPORTE --------------------------------------------------------- >
         if (isset($_POST['settings_rep']) && $_POST['settings_rep'] == 'on') {
             $settings_rep = '1';
         } else {
             $settings_rep = '0';
         }
         // < ------------------------------------------------- MODO VACACIONES ----------------------------------------------------- >
         if (isset($_POST['urlaubs_modus']) && $_POST['urlaubs_modus'] == 'on') {
             if ($this->CheckIfIsBuilding()) {
                 Functions_Lib::message($this->_lang['op_cant_activate_vacation_mode'], "game.php?page=options", 2);
             }
             $urlaubs_modus = '1';
             $time = Functions_Lib::get_default_vacation_time();
             parent::$db->query("UPDATE " . SETTINGS . ", " . PLANETS . " SET\r\n\t\t\t\t\t\t\t\t\t\t`setting_vacations_status` = '{$urlaubs_modus}',\r\n\t\t\t\t\t\t\t\t\t\t`setting_vacations_until` = '{$time}',\r\n\t\t\t\t\t\t\t\t\t\tplanet_metal_perhour = '" . Functions_Lib::read_config('metal_basic_income') . "',\r\n\t\t\t\t\t\t\t\t\t\tplanet_crystal_perhour = '" . Functions_Lib::read_config('crystal_basic_income') . "',\r\n\t\t\t\t\t\t\t\t\t\tplanet_deuterium_perhour = '" . Functions_Lib::read_config('deuterium_basic_income') . "',\r\n\t\t\t\t\t\t\t\t\t\tplanet_energy_used = '0',\r\n\t\t\t\t\t\t\t\t\t\tplanet_energy_max = '0',\r\n\t\t\t\t\t\t\t\t\t\tplanet_building_metal_mine_porcent = '0',\r\n\t\t\t\t\t\t\t\t\t\tplanet_building_crystal_mine_porcent = '0',\r\n\t\t\t\t\t\t\t\t\t\tplanet_building_deuterium_sintetizer_porcent = '0',\r\n\t\t\t\t\t\t\t\t\t\tplanet_building_solar_plant_porcent = '0',\r\n\t\t\t\t\t\t\t\t\t\tplanet_building_fusion_reactor_porcent = '0',\r\n\t\t\t\t\t\t\t\t\t\tplanet_ship_solar_satellite_porcent = '0'\r\n\t\t\t\t\t\t\t\t\t\tWHERE `setting_user_id` = '" . intval($this->_current_user['user_id']) . "' AND planet_user_id = '" . intval($this->_current_user['user_id']) . "'");
         } else {
             $urlaubs_modus = '0';
         }
         // < ------------------------------------------------- BORRAR CUENTA ------------------------------------------------------- >
         if (isset($_POST['db_deaktjava']) && $_POST['db_deaktjava'] == 'on') {
             $db_deaktjava = time();
         } else {
             $db_deaktjava = '0';
         }
         $SetSort = parent::$db->escape_value($_POST['settings_sort']);
         $SetOrder = parent::$db->escape_value($_POST['settings_order']);
         //// < -------------------------------------- ACTUALIZAR TODO LO SETEADO ANTES --------------------------------------------- >
         parent::$db->query("UPDATE " . USERS . " AS u, " . SETTINGS . " AS s SET\r\n\t\t\t\t\t\t\t\t\tu.`user_email` = '{$db_email}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_no_ip_check` = '{$noipcheck}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_planet_sort` = '{$SetSort}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_planet_order` = '{$SetOrder}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_probes_amount` = '{$spio_anz}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_fleet_actions` = '{$settings_fleetactions}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_galaxy_espionage` = '{$settings_esp}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_galaxy_write` = '{$settings_wri}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_galaxy_buddy` = '{$settings_bud}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_galaxy_missile` = '{$settings_mis}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_vacations_status` = '{$urlaubs_modus}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_delete_account` = '{$db_deaktjava}'\r\n\t\t\t\t\t\t\t\t\tWHERE u.`user_id` = '" . $this->_current_user['user_id'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\ts.`setting_user_id` = '" . $this->_current_user['user_id'] . "'");
         // < ------------------------------------------------- CAMBIO DE CLAVE ----------------------------------------------------- >
         if (isset($_POST['db_password']) && sha1($_POST['db_password']) == $this->_current_user['user_password']) {
             if ($_POST['newpass1'] == $_POST['newpass2']) {
                 if ($_POST['newpass1'] != '') {
                     $newpass = sha1($_POST['newpass1']);
                     parent::$db->query("UPDATE " . USERS . " SET\r\n\t\t\t\t\t\t\t\t\t\t\t\t`user_password` = '{$newpass}'\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `user_id` = '" . intval($this->_current_user['user_id']) . "' LIMIT 1");
                     Functions_Lib::message($this->_lang['op_password_changed'], "index.php", 1);
                 }
             }
         }
         // < --------------------------------------------- CAMBIO DE NOMBRE DE USUARIO --------------------------------------------- >
         if ($this->_current_user['user_name'] != $_POST['db_character']) {
             $query = parent::$db->query_fetch("SELECT `user_id`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . USERS . "`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE user_name = '" . parent::$db->escape_value($_POST['db_character']) . "'");
             if (!$query) {
                 parent::$db->query("UPDATE `" . USERS . "` SET\r\n\t\t\t\t\t\t\t\t\t\t\t`user_name` = '" . parent::$db->escape_value($username) . "'\r\n\t\t\t\t\t\t\t\t\t\t\tWHERE `user_id` = '" . $this->_current_user['user_id'] . "'\r\n\t\t\t\t\t\t\t\t\t\t\tLIMIT 1");
                 Functions_Lib::message($this->_lang['op_username_changed'], "index.php", 1);
             }
         }
         Functions_Lib::message($this->_lang['op_options_changed'], "game.php?page=options", 1);
     } else {
         $parse = $this->_lang;
         $parse['dpath'] = DPATH;
         if ($this->_current_user['setting_vacations_status']) {
             $parse['opt_modev_data'] = $this->_current_user['setting_vacations_status'] == 1 ? " checked='checked'/" : '';
             $parse['opt_modev_exit'] = $this->_current_user['setting_vacations_status'] == 0 ? " checked='1'/" : '';
             $parse['vacation_until'] = date(Functions_Lib::read_config('date_format_extended'), $this->_current_user['setting_vacations_until']);
             parent::$page->display(parent::$page->parse_template(parent::$page->get_template('options/options_body_vmode'), $parse));
         } else {
             $parse['opt_lst_ord_data'] = "<option value =\"0\"" . ($this->_current_user['setting_planet_sort'] == 0 ? " selected" : "") . ">" . $this->_lang['op_sort_colonization'] . "</option>";
             $parse['opt_lst_ord_data'] .= "<option value =\"1\"" . ($this->_current_user['setting_planet_sort'] == 1 ? " selected" : "") . ">" . $this->_lang['op_sort_coords'] . "</option>";
             $parse['opt_lst_ord_data'] .= "<option value =\"2\"" . ($this->_current_user['setting_planet_sort'] == 2 ? " selected" : "") . ">" . $this->_lang['op_sort_alpha'] . "</option>";
             $parse['opt_lst_cla_data'] = "<option value =\"0\"" . ($this->_current_user['setting_planet_order'] == 0 ? " selected" : "") . ">" . $this->_lang['op_sort_asc'] . "</option>";
             $parse['opt_lst_cla_data'] .= "<option value =\"1\"" . ($this->_current_user['setting_planet_order'] == 1 ? " selected" : "") . ">" . $this->_lang['op_sort_desc'] . "</option>";
             $parse['opt_usern_data'] = $this->_current_user['user_name'];
             $parse['opt_mail1_data'] = $this->_current_user['user_email'];
             $parse['opt_mail2_data'] = $this->_current_user['user_email_permanent'];
             $parse['opt_probe_data'] = $this->_current_user['setting_probes_amount'];
             $parse['opt_fleet_data'] = $this->_current_user['setting_fleet_actions'];
             $parse['opt_noipc_data'] = $this->_current_user['setting_no_ip_check'] == 1 ? " checked='checked'" : '';
             $parse['opt_delac_data'] = $this->_current_user['setting_delete_account'] == 1 ? " checked='checked'" : '';
             $parse['user_settings_esp'] = $this->_current_user['setting_galaxy_espionage'] == 1 ? " checked='checked'" : '';
             $parse['user_settings_wri'] = $this->_current_user['setting_galaxy_write'] == 1 ? " checked='checked'" : '';
             $parse['user_settings_mis'] = $this->_current_user['setting_galaxy_missile'] == 1 ? " checked='checked'" : '';
             $parse['user_settings_bud'] = $this->_current_user['setting_galaxy_buddy'] == 1 ? " checked='checked'" : '';
             $parse['db_deaktjava'] = $this->_current_user['setting_delete_account'] > 0 ? " checked='checked'" : '';
             parent::$page->display(parent::$page->parse_template(parent::$page->get_template('options/options_body'), $parse));
         }
     }
 }
Beispiel #14
0
 public function build_page()
 {
     $parse = $this->_lang;
     if (isset($_POST['fmenge'])) {
         $Missiles[502] = $this->_current_planet[$this->_resource[502]];
         $Missiles[503] = $this->_current_planet[$this->_resource[503]];
         $SiloSize = $this->_current_planet[$this->_resource[44]];
         $MaxMissiles = $SiloSize * 10;
         $BuildQueue = $this->_current_planet['planet_b_hangar_id'];
         $BuildArray = explode(";", $BuildQueue);
         $totalCount = 0;
         for ($QElement = 0; $QElement < count($BuildArray); $QElement++) {
             $ElmentArray = explode(",", $BuildArray[$QElement]);
             if ($ElmentArray[0] == 502) {
                 $Missiles[502] += $ElmentArray[1];
             } elseif ($ElmentArray[0] == 503) {
                 $Missiles[503] += $ElmentArray[1];
             }
         }
         foreach ($_POST['fmenge'] as $Element => $Count) {
             if ($Element < 300 or $Element > 550) {
                 continue;
             }
             $Element = (int) $Element;
             $Count = (int) $Count;
             $totalCount += $Count;
             if ($Count > MAX_FLEET_OR_DEFS_PER_ROW) {
                 $Count = MAX_FLEET_OR_DEFS_PER_ROW;
             }
             if ($Count != 0) {
                 if ($Element == 407 or $Element == 408) {
                     if (!$this->is_shield_in_queue($BuildQueue, $Element)) {
                         $Count = 1;
                     } else {
                         $Count = 0;
                     }
                 }
                 if (Developments_Lib::is_development_allowed($this->_current_user, $this->_current_planet, $Element)) {
                     $MaxElements = $this->GetMaxConstructibleElements($Element, $this->_current_planet);
                     if ($Element == 502 || $Element == 503) {
                         $ActuMissiles = $Missiles[502] + 2 * $Missiles[503];
                         $MissilesSpace = $MaxMissiles - $ActuMissiles;
                         if ($Element == 502) {
                             if ($Count > $MissilesSpace) {
                                 $Count = $MissilesSpace;
                             }
                         } else {
                             if ($Count > floor($MissilesSpace / 2)) {
                                 $Count = floor($MissilesSpace / 2);
                             }
                         }
                         if ($Count > $MaxElements) {
                             $Count = $MaxElements;
                         }
                         $Missiles[$Element] += $Count;
                     } else {
                         if ($Count > $MaxElements) {
                             $Count = $MaxElements;
                         }
                     }
                     $Ressource = $this->GetElementRessources($Element, $Count);
                     if ($Count >= 1) {
                         $this->_current_planet['planet_metal'] -= $Ressource['metal'];
                         $this->_current_planet['planet_crystal'] -= $Ressource['crystal'];
                         $this->_current_planet['planet_deuterium'] -= $Ressource['deuterium'];
                         $this->_current_planet['planet_b_hangar_id'] .= '' . $Element . ',' . $Count . ';';
                     }
                 }
             }
         }
         if ($totalCount > 0) {
             parent::$db->query("UPDATE " . PLANETS . " AS p SET\r\n\t\t\t\t\t\t\t\t\t\tp.`planet_b_hangar_id` = '" . $this->_current_planet['planet_b_hangar_id'] . "',\r\n\t\t\t\t\t\t\t\t\t\tp.`planet_metal` = '" . $this->_current_planet['planet_metal'] . "',\r\n\t\t\t\t\t\t\t\t\t\tp.`planet_crystal` = '" . $this->_current_planet['planet_crystal'] . "',\r\n\t\t\t\t\t\t\t\t\t\tp.`planet_deuterium` = '" . $this->_current_planet['planet_deuterium'] . "'\r\n\t\t\t\t\t\t\t\t\t\tWHERE p.`planet_id` = '" . $this->_current_planet['planet_id'] . "';");
         }
         Functions_Lib::redirect('game.php?page=defense');
     }
     if ($this->_current_planet[$this->_resource[21]] == 0) {
         Functions_Lib::message($this->_lang['bd_shipyard_required'], '', '', TRUE);
     }
     $NotBuilding = TRUE;
     if ($this->_current_planet['planet_b_building_id'] != 0) {
         $CurrentQueue = $this->_current_planet['planet_b_building_id'];
         if (strpos($CurrentQueue, ";")) {
             // FIX BY LUCKY - IF THE SHIPYARD IS IN QUEUE THE USER CANT RESEARCH ANYTHING...
             $QueueArray = explode(";", $CurrentQueue);
             for ($i = 0; $i < MAX_BUILDING_QUEUE_SIZE; $i++) {
                 $ListIDArray = explode(",", $QueueArray[$i]);
                 $Element = $ListIDArray[0];
                 if ($Element == 21 or $Element == 14 or $Element == 15) {
                     break;
                 }
             }
             // END - FIX
         } else {
             $CurrentBuilding = $CurrentQueue;
         }
         if ($CurrentBuilding == 21 or $CurrentBuilding == 14 or $CurrentBuilding == 15 or ($Element == 21 or $Element == 14 or $Element == 15)) {
             $parse['message'] = "<font color=\"red\">" . $this->_lang['bd_building_shipyard'] . "</font>";
             $NotBuilding = FALSE;
         }
     }
     $TabIndex = 0;
     $PageTable = "";
     $BuildQueue = '';
     foreach ($this->_lang['tech'] as $Element => $ElementName) {
         if ($Element > 400 && $Element <= 599) {
             if (Developments_Lib::is_development_allowed($this->_current_user, $this->_current_planet, $Element)) {
                 $CanBuildOne = Developments_Lib::is_development_payable($this->_current_user, $this->_current_planet, $Element, FALSE);
                 $BuildOneElementTime = Developments_Lib::development_time($this->_current_user, $this->_current_planet, $Element);
                 $ElementCount = $this->_current_planet[$this->_resource[$Element]];
                 $ElementNbre = $ElementCount == 0 ? "" : " (" . $this->_lang['bd_available'] . Format_Lib::pretty_number($ElementCount) . ")";
                 $parse['add_element'] = '';
                 $parse['dpath'] = DPATH;
                 $parse['element'] = $Element;
                 $parse['element_name'] = $ElementName;
                 $parse['element_description'] = $this->_lang['res']['descriptions'][$Element];
                 $parse['element_price'] = Developments_Lib::formated_development_price($this->_current_user, $this->_current_planet, $Element, FALSE);
                 $parse['building_time'] = Developments_Lib::formated_development_time($BuildOneElementTime);
                 $parse['element_nbre'] = $ElementNbre;
                 if ($CanBuildOne && !parent::$users->is_on_vacations($this->_current_user)) {
                     $InQueue = strpos($this->_current_planet['planet_b_hangar_id'], $Element . ",");
                     $IsBuildp = $this->_current_planet[$this->_resource[407]] >= 1 ? TRUE : FALSE;
                     $IsBuildg = $this->_current_planet[$this->_resource[408]] >= 1 ? TRUE : FALSE;
                     $BuildIt = TRUE;
                     if ($Element == 407 || $Element == 408) {
                         $BuildIt = FALSE;
                         if ($Element == 407 && !$IsBuildp && $InQueue === FALSE) {
                             $BuildIt = TRUE;
                         }
                         if ($Element == 408 && !$IsBuildg && $InQueue === FALSE) {
                             $BuildIt = TRUE;
                         }
                     }
                     if (!$BuildIt) {
                         $parse['add_element'] = '<font color="red">' . $this->_lang['bd_protection_shield_only_one'] . '</font>';
                     } elseif ($NotBuilding) {
                         $TabIndex++;
                         $parse['add_element'] = '<input type=text name=fmenge[' . $Element . '] alt="' . $this->_lang['tech'][$Element] . '" size=6 maxlength=6 value=0 tabindex=' . $TabIndex . '>';
                     }
                     if ($NotBuilding) {
                         $parse['build_defenses'] = '<tr><td class="c" colspan="2" align="center"><input type="submit" value="' . $this->_lang['bd_build_defenses'] . '"></td></tr>';
                     }
                 }
                 $PageTable .= parent::$page->parse_template(parent::$page->get_template('buildings/buildings_fleet_row'), $parse);
             }
         }
     }
     if ($this->_current_planet['planet_b_hangar_id'] != '') {
         $BuildQueue .= $this->ElementBuildListBox('defenses');
     }
     $parse['buildlist'] = $PageTable;
     $parse['buildinglist'] = $BuildQueue;
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('buildings/buildings_defense'), $parse));
 }
Beispiel #15
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $parse = $this->_lang;
     if ($this->_current_user['premium_dark_matter'] < $this->_tr_dark_matter) {
         Functions_Lib::message(str_replace('%s', $this->_tr_dark_matter, $this->_lang['tr_darkmatter_needed']), '', '', TRUE);
         die;
     }
     if (isset($_POST['ress']) && $_POST['ress'] != '') {
         switch ($_POST['ress']) {
             case 'metal':
                 if ($_POST['cristal'] < 0 or $_POST['deut'] < 0) {
                     Functions_Lib::message($this->_lang['tr_only_positive_numbers'], "game.php?page=trader", 1);
                 } else {
                     $necessaire = $_POST['cristal'] * 2 + $_POST['deut'] * 4;
                     $amout = array('metal' => 0, 'crystal' => $_POST['cristal'], 'deuterium' => $_POST['deut']);
                     $storage = $this->check_storage($amout);
                     if (is_string($storage)) {
                         die(Functions_Lib::message($storage, 'game.php?page=trader', '2'));
                     }
                     if ($this->_current_planet['planet_metal'] > $necessaire) {
                         parent::$db->query("UPDATE " . PLANETS . " SET\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_metal` = `planet_metal` - " . round($necessaire) . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_crystal` = `planet_crystal` + " . round($_POST['cristal']) . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_deuterium` = `planet_deuterium` + " . round($_POST['deut']) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_id` = '" . $this->_current_planet['planet_id'] . "';");
                         $this->_current_planet['planet_metal'] -= $necessaire;
                         $this->_current_planet['planet_crystal'] += isset($_POST['cristal']) ? $_POST['cristal'] : 0;
                         $this->_current_planet['planet_deuterium'] += isset($_POST['deut']) ? $_POST['deut'] : 0;
                         $this->discount_dark_matter();
                         // REDUCE DARKMATTER
                     } else {
                         Functions_Lib::message($this->_lang['tr_not_enought_metal'], "game.php?page=trader", 1);
                     }
                 }
                 break;
             case 'cristal':
                 if ($_POST['metal'] < 0 or $_POST['deut'] < 0) {
                     Functions_Lib::message($this->_lang['tr_only_positive_numbers'], "game.php?page=trader", 1);
                 } else {
                     $necessaire = abs($_POST['metal']) * 0.5 + abs($_POST['deut']) * 2;
                     $amout = array('metal' => $_POST['metal'], 'crystal' => 0, 'deuterium' => $_POST['deut']);
                     $storage = $this->check_storage($amout);
                     if (is_string($storage)) {
                         die(Functions_Lib::message($storage, 'game.php?page=trader', '2'));
                     }
                     if ($this->_current_planet['planet_crystal'] > $necessaire) {
                         parent::$db->query("UPDATE " . PLANETS . " SET\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_metal` = `planet_metal` + " . round($_POST['metal']) . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_crystal` = `planet_crystal` - " . round($necessaire) . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_deuterium` = `planet_deuterium` + " . round($_POST['deut']) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_id` = '" . $this->_current_planet['planet_id'] . "';");
                         $this->_current_planet['planet_metal'] += isset($_POST['metal']) ? $_POST['metal'] : 0;
                         $this->_current_planet['planet_crystal'] -= $necessaire;
                         $this->_current_planet['planet_deuterium'] += isset($_POST['deut']) ? $_POST['deut'] : 0;
                         $this->discount_dark_matter($this->_current_user);
                         // REDUCE DARKMATTER
                     } else {
                         Functions_Lib::message($this->_lang['tr_not_enought_crystal'], "game.php?page=trader", 1);
                     }
                 }
                 break;
             case 'deuterium':
                 if ($_POST['cristal'] < 0 or $_POST['metal'] < 0) {
                     Functions_Lib::message($this->_lang['tr_only_positive_numbers'], "game.php?page=trader", 1);
                 } else {
                     $necessaire = abs($_POST['metal']) * 0.25 + abs($_POST['cristal']) * 0.5;
                     $amout = array('metal' => $_POST['metal'], 'crystal' => $_POST['cristal'], 'deuterium' => 0);
                     $storage = $this->check_storage($amout);
                     if (is_string($storage)) {
                         die(message($storage, 'game.php?page=trader', '2'));
                     }
                     if ($this->_current_planet['planet_deuterium'] > $necessaire) {
                         parent::$db->query("UPDATE " . PLANETS . " SET\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_metal` = `planet_metal` + " . round($_POST['metal']) . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_crystal` = `planet_crystal` + " . round($_POST['cristal']) . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_deuterium` = `planet_deuterium` - " . round($necessaire) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_id` = '" . $this->_current_planet['planet_id'] . "';");
                         $this->_current_planet['planet_metal'] += isset($_POST['metal']) ? $_POST['metal'] : 0;
                         $this->_current_planet['planet_crystal'] += isset($_POST['cristal']) ? $_POST['cristal'] : 0;
                         $this->_current_planet['planet_deuterium'] -= $necessaire;
                         $this->discount_dark_matter($this->_current_user);
                         // REDUCE DARKMATTER
                     } else {
                         Functions_Lib::message($this->_lang['tr_not_enought_deuterium'], "game.php?page=trader", 1);
                     }
                 }
                 break;
         }
         Functions_Lib::message($this->_lang['tr_exchange_done'], "game.php?page=trader", 1);
     } else {
         $template = parent::$page->get_template('trader/trader_main');
         if (isset($_POST['action'])) {
             $parse['mod_ma_res'] = '1';
             switch (isset($_POST['choix']) ? $_POST['choix'] : NULL) {
                 case 'metal':
                     $template = parent::$page->get_template('trader/trader_metal');
                     $parse['mod_ma_res_a'] = '2';
                     $parse['mod_ma_res_b'] = '4';
                     break;
                 case 'cristal':
                     $template = parent::$page->get_template('trader/trader_cristal');
                     $parse['mod_ma_res_a'] = '0.5';
                     $parse['mod_ma_res_b'] = '2';
                     break;
                 case 'deut':
                     $template = parent::$page->get_template('trader/trader_deuterium');
                     $parse['mod_ma_res_a'] = '0.25';
                     $parse['mod_ma_res_b'] = '0.5';
                     break;
             }
         }
     }
     parent::$page->display(parent::$page->parse_template($template, $parse));
 }
Beispiel #16
0
 /**
  * method delete_planet
  * param
  * return deletes the planet
  */
 private function delete_planet()
 {
     $own_fleet = 0;
     $enemy_fleet = 0;
     $fleets_incoming = parent::$db->query("SELECT *\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE ( fleet_owner = '" . intval($this->_current_user['user_id']) . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfleet_start_galaxy='" . intval($this->_current_planet['planet_galaxy']) . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfleet_start_system='" . intval($this->_current_planet['planet_system']) . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfleet_start_planet='" . intval($this->_current_planet['planet_planet']) . "') OR\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t  ( fleet_target_owner = '" . intval($this->_current_user['user_id']) . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfleet_end_galaxy='" . intval($this->_current_planet['planet_galaxy']) . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfleet_end_system='" . intval($this->_current_planet['planet_system']) . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfleet_end_planet='" . intval($this->_current_planet['planet_planet']) . "')");
     while ($fleet = parent::$db->fetch_array($fleets_incoming)) {
         $own_fleet = $fleet['fleet_owner'];
         $enemy_fleet = $fleet['fleet_target_owner'];
         if ($fleet['fleet_target_owner'] == $this->_current_user['user_id']) {
             $end_type = $fleet['fleet_end_type'];
         }
         $mess = $fleet['fleet_mess'];
     }
     if ($own_fleet > 0) {
         Functions_Lib::message($this->_lang['ov_abandon_planet_not_possible'], 'game.php?page=renameplanet');
     } elseif ($enemy_fleet > 0 && $mess < 1 && $end_type != 2) {
         Functions_Lib::message($this->_lang['ov_abandon_planet_not_possible'], 'game.php?page=renameplanet');
     } else {
         if (sha1($_POST['pw']) == $this->_current_user['password'] && $this->_current_user['user_home_planet_id'] != $this->_current_user['user_current_planet']) {
             if ($this->_current_planet['moon_id'] != 0) {
                 parent::$db->query("UPDATE " . PLANETS . " AS p, " . PLANETS . " AS m, " . USERS . " AS u SET\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tp.`planet_destroyed` = '" . (time() + PLANETS_LIFE_TIME * 3600) . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tm.`planet_destroyed` = '" . (time() + PLANETS_LIFE_TIME * 3600) . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tu.`user_current_planet` = u.`user_home_planet_id`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE p.`planet_id` = '" . $this->_current_user['user_current_planet'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tm.`planet_galaxy` = '" . $this->_current_planet['planet_galaxy'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tm.`planet_system` = '" . $this->_current_planet['planet_system'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tm.`planet_planet` = '" . $this->_current_planet['planet_planet'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tm.`planet_type` = '3' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tu.`user_id` = '" . $this->_current_user['user_id'] . "';");
             } else {
                 parent::$db->query("UPDATE " . PLANETS . " AS p, " . USERS . " AS u SET\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tp.`planet_destroyed` = '" . (time() + PLANETS_LIFE_TIME * 3600) . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tu.`user_current_planet` = u.`user_home_planet_id`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE p.`planet_id` = '" . $this->_current_user['user_current_planet'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tu.`user_id` = '" . $this->_current_user['user_id'] . "';");
             }
             Functions_Lib::message($this->_lang['ov_planet_abandoned'], 'game.php?page=overview');
         } elseif ($this->_current_user['user_home_planet_id'] == $this->_current_user['user_current_planet']) {
             Functions_Lib::message($this->_lang['ov_principal_planet_cant_abanone'], 'game.php?page=renameplanet');
         } else {
             Functions_Lib::message($this->_lang['ov_wrong_pass'], 'game.php?page=renameplanet');
         }
     }
 }
Beispiel #17
0
 /**
  * method check_name
  * param $alliance_name
  * return the validated the ally name
  */
 private function check_name($alliance_name)
 {
     $alliance_name = trim($alliance_name);
     $alliance_name = htmlspecialchars_decode($alliance_name, ENT_QUOTES);
     if ($alliance_name == '' or is_null($alliance_name) or strlen($alliance_name) < 3 or strlen($alliance_name) > 30) {
         Functions_Lib::message(parent::$this->_lang['al_name_required'], "game.php?page=alliance&mode=make", 2);
         exit;
     }
     $alliance_name = parent::$db->escape_value($alliance_name);
     $check_name = parent::$db->query_fetch("SELECT `alliance_name`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . ALLIANCE . "`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `alliance_name` = '" . $alliance_name . "'");
     if ($check_name) {
         Functions_Lib::message(str_replace('%s', $alliance_name, parent::$this->_lang['al_name_already_exists']), "game.php?page=alliance&mode=make", 2);
         exit;
     }
     return $alliance_name;
 }
Beispiel #18
0
 /**
  * method send_missiles
  * param
  * return send missiles routine
  */
 private function send_missiles()
 {
     $g = intval($_GET['galaxy']);
     $s = intval($_GET['system']);
     $i = intval($_GET['planet']);
     $anz = $_POST['SendMI'] < 0 ? 0 : intval($_POST['SendMI']);
     $target = $_POST['Target'];
     $missiles = $this->_current_planet['defense_interplanetary_missile'];
     $tempvar1 = abs($s - $this->_current_planet['planet_system']);
     $tempvar2 = $this->_formula->missile_range($this->_current_user['research_impulse_drive']);
     $tempvar3 = parent::$db->query_fetch("SELECT u.`user_id`,u.`user_onlinetime`,s.`setting_vacations_status`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . " AS u\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . SETTINGS . " AS s ON s.setting_user_id = u.user_id\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE u.user_id = (SELECT `planet_user_id`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . "\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE planet_galaxy = " . $g . "  AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tplanet_system = " . $s . " AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tplanet_planet = " . $i . " AND\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tplanet_type = 1 LIMIT 1) LIMIT 1");
     $user_points = $this->_noob->return_points($this->_current_user['user_id'], $tempvar3['id']);
     $MyGameLevel = $user_points['user_points'];
     $HeGameLevel = $user_points['target_points'];
     $error = '';
     if ($this->_current_planet['building_missile_silo'] < 4) {
         $error .= $this->_lang['ma_silo_level'] . '<br>';
         $errors++;
     }
     if ($this->_current_user['research_impulse_drive'] == 0) {
         $error .= $this->_lang['ma_impulse_drive_required'] . '<br>';
         $errors++;
     }
     if ($tempvar1 >= $tempvar2 || $g != $this->_current_planet['planet_galaxy']) {
         $error .= $this->_lang['ma_not_send_other_galaxy'] . '<br>';
         $errors++;
     }
     if (!$tempvar3) {
         $error .= $this->_lang['ma_planet_doesnt_exists'] . '<br>';
         $errors++;
     }
     if ($anz > $missiles) {
         $error .= $this->_lang['ma_cant_send'] . $anz . $this->_lang['ma_missile'] . $missiles . '<br>';
         $errors++;
     }
     if (!is_numeric($target) && $target != "all" or ($target < 0 or $target > 8)) {
         $error .= $this->_lang['ma_wrong_target'] . '<br>';
         $errors++;
     }
     if ($missiles == 0) {
         $error .= $this->_lang['ma_no_missiles'] . '<br>';
         $errors++;
     }
     if ($anz == 0) {
         $error .= $this->_lang['ma_add_missile_number'] . '<br>';
         $errors++;
     }
     if ($tempvar3['user_onlinetime'] >= time() - 60 * 60 * 24 * 7) {
         if ($this->_noob->is_weak($MyGameLevel, $HeGameLevel)) {
             $error .= $this->_lang['fl_week_player'] . '<br>';
             $errors++;
         } elseif ($this->_noob->is_strong($MyGameLevel, $HeGameLevel)) {
             $error .= $this->_lang['fl_strong_player'] . '<br>';
             $errors++;
         }
     }
     if ($tempvar3['setting_vacations_status'] == 1) {
         $error .= $this->_lang['fl_in_vacation_player'] . '<br>';
         $errors++;
     }
     if ($errors != 0) {
         Functions_Lib::message($error, "game.php?page=galaxy&mode=0&galaxy=" . $g . "&system=" . $s, 3);
     }
     $ziel_id = $tempvar3['id'];
     $flugzeit = round((30 + 60 * $tempvar1) * 2500 / Functions_Lib::read_config('fleet_speed'));
     $DefenseLabel = array(0 => $this->_lang['tech'][401], 1 => $this->_lang['tech'][402], 2 => $this->_lang['tech'][403], 3 => $this->_lang['tech'][404], 4 => $this->_lang['tech'][405], 5 => $this->_lang['tech'][406], 6 => $this->_lang['tech'][407], 7 => $this->_lang['tech'][408], 'all' => $this->_lang['ma_all']);
     parent::$db->query("INSERT INTO " . FLEETS . " SET\r\n\t\t\t\t\t\t\t\tfleet_owner = " . $this->_current_user['user_id'] . ",\r\n\t\t\t\t\t\t\t\tfleet_mission = 10,\r\n\t\t\t\t\t\t\t\tfleet_amount = " . $anz . ",\r\n\t\t\t\t\t\t\t\tfleet_array = '503," . $anz . "',\r\n\t\t\t\t\t\t\t\tfleet_start_time = '" . (time() + $flugzeit) . "',\r\n\t\t\t\t\t\t\t\tfleet_start_galaxy = '" . $this->_current_planet['planet_galaxy'] . "',\r\n\t\t\t\t\t\t\t\tfleet_start_system = '" . $this->_current_planet['planet_system'] . "',\r\n\t\t\t\t\t\t\t\tfleet_start_planet ='" . $this->_current_planet['planet_planet'] . "',\r\n\t\t\t\t\t\t\t\tfleet_start_type = 1,\r\n\t\t\t\t\t\t\t\tfleet_end_time = '" . (time() + $flugzeit + 1) . "',\r\n\t\t\t\t\t\t\t\tfleet_end_stay = 0,\r\n\t\t\t\t\t\t\t\tfleet_end_galaxy = '" . $g . "',\r\n\t\t\t\t\t\t\t\tfleet_end_system = '" . $s . "',\r\n\t\t\t\t\t\t\t\tfleet_end_planet = '" . $i . "',\r\n\t\t\t\t\t\t\t\tfleet_end_type = 1,\r\n\t\t\t\t\t\t\t\tfleet_target_obj = '" . $target . "',\r\n\t\t\t\t\t\t\t\tfleet_resource_metal = 0,\r\n\t\t\t\t\t\t\t\tfleet_resource_crystal = 0,\r\n\t\t\t\t\t\t\t\tfleet_resource_deuterium = 0,\r\n\t\t\t\t\t\t\t\tfleet_target_owner = '" . $ziel_id . "',\r\n\t\t\t\t\t\t\t\tfleet_group = 0,\r\n\t\t\t\t\t\t\t\tfleet_mess = 0,\r\n\t\t\t\t\t\t\t\tfleet_creation = " . time() . ";");
     parent::$db->query("UPDATE " . DEFENSES . " SET\r\n\t\t\t\t\t\t\t\tdefense_interplanetary_missile = defense_interplanetary_missile - " . $anz . "\r\n\t\t\t\t\t\t\t\tWHERE defense_planet_id =  '" . $this->_current_user['user_current_planet'] . "'");
     Functions_Lib::message("<b>" . $anz . "</b>" . $this->_lang['ma_missiles_sended'] . $DefenseLabel[$target], "game.php?page=overview", 3);
 }
 /**
  * method buildPage
  * param
  * return main method, loads everything
  */
 private function buildPage()
 {
     $parse = $this->langs;
     $continue = true;
     // VERIFICATION - WE DON'T WANT ANOTHER INSTALLATION
     if ($this->isInstalled()) {
         die(Functions_Lib::message($this->langs['ins_already_installed'], '', '', false, false));
     }
     if (!$this->checkXmlFile()) {
         die(Functions_Lib::message($this->langs['ins_missing_xml_file'], '', '', false, false));
     }
     // ACTION FOR THE CURRENT PAGE
     switch (isset($_POST['page']) ? $_POST['page'] : '') {
         case 'step1':
             $this->host = $_POST['host'];
             $this->name = $_POST['db'];
             $this->user = $_POST['user'];
             $this->password = $_POST['password'];
             $this->prefix = $_POST['prefix'];
             if (!$this->validateDbData()) {
                 $alerts = $this->langs['ins_empty_fields_error'];
                 $continue = false;
             }
             if (!$this->writeConfigFile()) {
                 $alerts = $this->langs['ins_write_config_error'];
                 $continue = false;
             }
             if ($continue) {
                 Functions_Lib::redirect('?page=install&mode=step2');
             }
             $parse['alert'] = $this->saveMessage($alerts, 'warning');
             $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_database_view'), $parse);
             break;
         case 'step2':
             if (!$this->tryConnection()) {
                 $alerts = $this->langs['ins_not_connected_error'];
                 $continue = false;
             }
             if ($continue) {
                 Functions_Lib::redirect('?page=install&mode=step3');
             }
             $parse['alert'] = $this->saveMessage($alerts, 'warning');
             $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_database_view'), $parse);
             break;
         case 'step3':
             if (!$this->insertDbData()) {
                 $alerts = $this->langs['ins_insert_tables_error'];
                 $continue = false;
             }
             if ($continue) {
                 Functions_Lib::redirect('?page=install&mode=step4');
             }
             $parse['alert'] = $this->saveMessage($alerts, 'warning');
             $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_database_view'), $parse);
             break;
         case 'step4':
             Functions_Lib::redirect('?page=install&mode=step5');
             break;
         case 'step5':
             if (!$this->createAccount()) {
                 $parse['alert'] = $this->saveMessage($this->langs['ins_adm_empty_fields_eror'], 'warning');
                 $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_create_admin_view'), $parse);
                 $continue = false;
             }
             if ($continue) {
                 Functions_Lib::update_config('stat_last_update', time());
                 Functions_Lib::update_config('game_installed', '1');
                 $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_create_admin_done_view'), $this->langs);
                 // This will continue on false meaning "This is the end of the installation, no else where to go"
                 $continue = false;
             }
             break;
         case '':
         default:
             break;
     }
     if ($continue) {
         switch (isset($_GET['mode']) ? $_GET['mode'] : '') {
             case 'step1':
                 $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_database_view'), $this->langs);
                 break;
             case 'step2':
                 $parse['step'] = 'step2';
                 $parse['done_config'] = $this->langs['ins_done_config'];
                 $parse['done_connected'] = '';
                 $parse['done_insert'] = '';
                 $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_done_actions_view'), $parse);
                 break;
             case 'step3':
                 $parse['step'] = 'step3';
                 $parse['done_config'] = '';
                 $parse['done_connected'] = $this->langs['ins_done_connected'];
                 $parse['done_insert'] = '';
                 $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_done_actions_view'), $parse);
                 break;
             case 'step4':
                 $parse['step'] = 'step4';
                 $parse['done_config'] = '';
                 $parse['done_connected'] = '';
                 $parse['done_insert'] = $this->langs['ins_done_insert'];
                 $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_done_actions_view'), $parse);
                 break;
             case 'step5':
                 $parse['step'] = 'step5';
                 $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_create_admin_view'), $parse);
                 break;
             case 'license':
                 $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_license_view'), $this->langs);
                 break;
             case '':
             case 'overview':
             default:
                 $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_welcome_view'), $this->langs);
                 break;
         }
     }
     parent::$page->display($current_page);
 }
Beispiel #20
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $parse = $this->_lang;
     $continue = TRUE;
     // VERIFICATION - WE DON'T WANT ANOTHER INSTALLATION
     if ($this->is_installed()) {
         die(Functions_Lib::message($this->_lang['ins_already_installed'], '', '', FALSE, FALSE));
     }
     if (!$this->check_xml_file()) {
         die(Functions_Lib::message($this->_lang['ins_missing_xml_file'], '', '', FALSE, FALSE));
     }
     // ACTION FOR THE CURRENT PAGE
     switch (isset($_POST['page']) ? $_POST['page'] : '') {
         case 'step1':
             $this->_host = $_POST['host'];
             $this->_db = $_POST['db'];
             $this->_user = $_POST['user'];
             $this->_password = $_POST['password'];
             $this->_prefix = $_POST['prefix'];
             if (!$this->validate_db_data()) {
                 $alerts = $this->_lang['ins_empty_fields_error'];
                 $continue = FALSE;
             }
             if (!$this->write_config_file()) {
                 $alerts = $this->_lang['ins_write_config_error'];
                 $continue = FALSE;
             }
             if ($continue) {
                 Functions_Lib::redirect('?page=install&mode=step2');
             }
             $parse['alert'] = $this->save_message('warning', $alerts);
             $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_database_view'), $parse);
             break;
         case 'step2':
             if (!$this->try_connection()) {
                 $alerts = $this->_lang['ins_not_connected_error'];
                 $continue = FALSE;
             }
             if ($continue) {
                 Functions_Lib::redirect('?page=install&mode=step3');
             }
             $parse['alert'] = $this->save_message('warning', $alerts);
             $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_database_view'), $parse);
             break;
         case 'step3':
             if (!$this->insert_db_data()) {
                 $alerts = $this->_lang['ins_insert_tables_error'];
                 $continue = FALSE;
             }
             if ($continue) {
                 Functions_Lib::redirect('?page=install&mode=step4');
             }
             $parse['alert'] = $this->save_message('warning', $alerts);
             $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_database_view'), $parse);
             break;
         case 'step4':
             Functions_Lib::redirect('?page=install&mode=step5');
             break;
         case 'step5':
             if (!$this->create_account()) {
                 $parse['alert'] = $this->save_message('warning', $this->_lang['ins_adm_empty_fields_eror']);
                 $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_create_admin_view'), $parse);
                 $continue = FALSE;
             }
             if ($continue) {
                 Functions_Lib::update_config('stat_last_update', time());
                 Functions_Lib::update_config('game_installed', '1');
                 $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_create_admin_done_view'), $this->_lang);
                 $continue = FALSE;
                 // THIS CONTINUE ON FALSE MEANS "THIS IS THE END OF THE INSTALLATION, NO WHERE ELSE TO GO"
             }
             break;
         case '':
         default:
             break;
     }
     if ($continue) {
         switch (isset($_GET['mode']) ? $_GET['mode'] : '') {
             case 'step1':
                 $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_database_view'), $this->_lang);
                 break;
             case 'step2':
                 $parse['step'] = 'step2';
                 $parse['done_config'] = $this->_lang['ins_done_config'];
                 $parse['done_connected'] = '';
                 $parse['done_insert'] = '';
                 $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_done_actions_view'), $parse);
                 break;
             case 'step3':
                 $parse['step'] = 'step3';
                 $parse['done_config'] = '';
                 $parse['done_connected'] = $this->_lang['ins_done_connected'];
                 $parse['done_insert'] = '';
                 $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_done_actions_view'), $parse);
                 break;
             case 'step4':
                 $parse['step'] = 'step4';
                 $parse['done_config'] = '';
                 $parse['done_connected'] = '';
                 $parse['done_insert'] = $this->_lang['ins_done_insert'];
                 $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_done_actions_view'), $parse);
                 break;
             case 'step5':
                 $parse['step'] = 'step5';
                 $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_create_admin_view'), $parse);
                 break;
             case 'license':
                 $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_license_view'), $this->_lang);
                 break;
             case '':
             case 'overview':
             default:
                 $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_welcome_view'), $this->_lang);
                 break;
         }
     }
     parent::$page->display($current_page);
 }