Example #1
0
 /**
  * buildPages
  *
  * @return void
  */
 private function buildPage()
 {
     $parse = $this->langs;
     if ($_POST) {
         $login = parent::$db->queryFetch("SELECT `user_id`, `user_name`, `user_password`, `user_banned`\n                FROM " . USERS . "\n                WHERE `user_name` = '" . parent::$db->escapeValue($_POST['login']) . "'\n                AND `user_password` = '" . sha1($_POST['pass']) . "'\n                LIMIT 1");
         if ($login['user_banned'] <= time()) {
             $this->removeBan($login['user_name']);
         }
         if ($login) {
             // User login
             if (parent::$users->user_login($login['user_id'], $login['user_name'], $login['user_password'])) {
                 // Update current planet
                 parent::$db->query("UPDATE " . USERS . " SET\n                        `user_current_planet` = `user_home_planet_id`\n                        WHERE `user_id` ='" . $login['user_id'] . "'");
                 // Redirect to game
                 FunctionsLib::redirect('game.php?page=overview');
             }
         }
         // If login fails
         FunctionsLib::redirect('index.php');
     } else {
         $parse['year'] = date('Y');
         $parse['version'] = VERSION;
         $parse['servername'] = FunctionsLib::read_config('game_name');
         $parse['game_logo'] = FunctionsLib::read_config('game_logo');
         $parse['forum_url'] = FunctionsLib::read_config('forum_url');
         $parse['js_path'] = JS_PATH . 'home/';
         $parse['css_path'] = CSS_PATH . 'home/';
         $parse['img_path'] = IMG_PATH . 'home/';
         $parse['base_path'] = BASE_PATH;
         parent::$page->display(parent::$page->parse_template(parent::$page->get_template('home/index_body'), $parse), false, '', false);
     }
 }
Example #2
0
 /**
  * __construct()
  */
 public function __construct()
 {
     parent::__construct();
     // check if session is active
     parent::$users->check_session();
     // Check module access
     FunctionsLib::module_message(FunctionsLib::is_module_accesible(self::MODULE_ID));
     $this->_lang = parent::$lang;
     $this->_current_user = parent::$users->get_user_data();
     if (!OfficiersLib::isOfficierActive($this->_current_user['premium_officier_commander'])) {
         FunctionsLib::redirect('game.php?page=officier');
     } else {
         $this->build_page();
     }
 }
Example #3
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     if ($_POST) {
         if (!$this->run_validations()) {
             FunctionsLib::redirect('index.php');
         } else {
             $user_password = $_POST['password'];
             $user_name = $_POST['character'];
             $user_email = $_POST['email'];
             $hashed_password = sha1($user_password);
             parent::$db->query("INSERT INTO " . USERS . " SET\n\t\t\t\t\t\t\t\t\t\t`user_name` = '" . parent::$db->escapeValue(strip_tags($user_name)) . "',\n\t\t\t\t\t\t\t\t\t\t`user_email` = '" . parent::$db->escapeValue($user_email) . "',\n\t\t\t\t\t\t\t\t\t\t`user_email_permanent` = '" . parent::$db->escapeValue($user_email) . "',\n\t\t\t\t\t\t\t\t\t\t`user_ip_at_reg` = '" . $_SERVER['REMOTE_ADDR'] . "',\n\t\t\t\t\t\t\t\t\t\t`user_agent` = '" . $_SERVER['HTTP_USER_AGENT'] . "',\n\t\t\t\t\t\t\t\t\t\t`user_home_planet_id` = '0',\n\t\t\t\t\t\t\t\t\t\t`user_register_time` = '" . time() . "',\n\t\t\t\t\t\t\t\t\t\t`user_password`='" . $hashed_password . "';");
             $user_id = parent::$db->insertId();
             parent::$db->query("INSERT INTO " . RESEARCH . " SET\n\t\t\t\t\t\t\t\t\t\t`research_user_id` = '" . $user_id . "';");
             parent::$db->query("INSERT INTO " . USERS_STATISTICS . " SET\n\t\t\t\t\t\t\t\t\t\t`user_statistic_user_id` = '" . $user_id . "';");
             parent::$db->query("INSERT INTO " . PREMIUM . " SET\n\t\t\t\t\t\t\t\t\t\t`premium_user_id` = '" . $user_id . "';");
             parent::$db->query("INSERT INTO " . SETTINGS . " SET\n\t\t\t\t\t\t\t\t\t\t`setting_user_id` = '" . $user_id . "';");
             $last_galaxy = FunctionsLib::read_config('lastsettedgalaxypos');
             $last_system = FunctionsLib::read_config('lastsettedsystempos');
             $last_planet = FunctionsLib::read_config('lastsettedplanetpos');
             while (!isset($newpos_checked)) {
                 for ($galaxy = $last_galaxy; $galaxy <= MAX_GALAXY_IN_WORLD; $galaxy++) {
                     for ($system = $last_system; $system <= MAX_SYSTEM_IN_GALAXY; $system++) {
                         for ($pos = $last_planet; $pos <= 4; $pos++) {
                             $planet = round(mt_rand(4, 12));
                             switch ($last_planet) {
                                 case 1:
                                     $last_planet += 1;
                                     break;
                                 case 2:
                                     $last_planet += 1;
                                     break;
                                 case 3:
                                     if ($last_system == MAX_SYSTEM_IN_GALAXY) {
                                         $last_galaxy += 1;
                                         $last_system = 1;
                                         $last_planet = 1;
                                         break;
                                     } else {
                                         $last_planet = 1;
                                     }
                                     $last_system += 1;
                                     break;
                             }
                             break;
                         }
                         break;
                     }
                     break;
                 }
                 $planet_row = parent::$db->queryFetch("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . $galaxy . "' AND\n\t\t\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\t\t`planet_planet` = '" . $planet . "' LIMIT 1;");
                 if ($planet_row['id'] == '0') {
                     $newpos_checked = TRUE;
                 }
                 if (!$planet_row) {
                     $this->_creator->create_planet($galaxy, $system, $planet, $user_id, '', TRUE);
                     $newpos_checked = TRUE;
                 }
                 if ($newpos_checked) {
                     FunctionsLib::update_config('lastsettedgalaxypos', $last_galaxy);
                     FunctionsLib::update_config('lastsettedsystempos', $last_system);
                     FunctionsLib::update_config('lastsettedplanetpos', $last_planet);
                 }
             }
             parent::$db->query("UPDATE " . USERS . " SET\n\t\t\t\t\t\t\t\t\t\t`user_home_planet_id` = (SELECT `planet_id` FROM " . PLANETS . " WHERE `planet_user_id` = '" . $user_id . "' LIMIT 1),\n\t\t\t\t\t\t\t\t\t\t`user_current_planet` = (SELECT `planet_id` FROM " . PLANETS . " WHERE `planet_user_id` = '" . $user_id . "' LIMIT 1),\n\t\t\t\t\t\t\t\t\t\t`user_galaxy` = '" . $galaxy . "',\n\t\t\t\t\t\t\t\t\t\t`user_system` = '" . $system . "',\n\t\t\t\t\t\t\t\t\t\t`user_planet` = '" . $planet . "'\n\t\t\t\t\t\t\t\t\t\t WHERE `user_id` = '" . $user_id . "' LIMIT 1;");
             $from = $this->_lang['re_welcome_message_from'];
             $subject = $this->_lang['re_welcome_message_subject'];
             $message = str_replace('%s', $user_name, $this->_lang['re_welcome_message_content']);
             // Send Welcome Message to the user if the feature is enabled
             if (FunctionsLib::read_config('reg_welcome_message')) {
                 FunctionsLib::send_message($user_id, 0, '', 5, $from, $subject, $message);
             }
             // Send Welcome Email to the user if the feature is enabled
             if (FunctionsLib::read_config('reg_welcome_email')) {
                 $this->send_pass_email($user_email, $user_name, $user_password);
             }
             // User login
             if (parent::$users->user_login($user_id, $user_name, $hashed_password)) {
                 // Redirect to game
                 FunctionsLib::redirect('game.php?page=overview');
             }
         }
     }
     // If login fails
     FunctionsLib::redirect('index.php');
 }
Example #4
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     if (!array_key_exists($this->_element_id, $this->_resource)) {
         FunctionsLib::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) {
         $PageTPL = parent::$page->get_template('infos/info_buildings_table');
         $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) {
             FunctionsLib::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'] = FormatLib::pretty_number($this->_pricelist[$this->_element_id]['metal'] + $this->_pricelist[$this->_element_id]['crystal']);
         $parse['shield_pt'] = FormatLib::pretty_number($this->_combat_caps[$this->_element_id]['shield']);
         $parse['attack_pt'] = FormatLib::pretty_number($this->_combat_caps[$this->_element_id]['attack']);
         $parse['capacity_pt'] = FormatLib::pretty_number($this->_pricelist[$this->_element_id]['capacity']);
         $parse['base_speed'] = FormatLib::pretty_number($this->_pricelist[$this->_element_id]['speed']);
         $parse['base_conso'] = FormatLib::pretty_number($this->_pricelist[$this->_element_id]['consumption']);
         if ($this->_element_id == 202) {
             $parse['upd_speed'] = "<font color=\"yellow\">(" . FormatLib::pretty_number($this->_pricelist[$this->_element_id]['speed2']) . ")</font>";
             $parse['upd_conso'] = "<font color=\"yellow\">(" . FormatLib::pretty_number($this->_pricelist[$this->_element_id]['consumption2']) . ")</font>";
         } elseif ($this->_element_id == 211) {
             $parse['upd_speed'] = "<font color=\"yellow\">(" . FormatLib::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'] = FormatLib::pretty_number($this->_pricelist[$this->_element_id]['metal'] + $this->_pricelist[$this->_element_id]['crystal']);
         $parse['shield_pt'] = FormatLib::pretty_number($this->_combat_caps[$this->_element_id]['shield']);
         $parse['attack_pt'] = FormatLib::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);
         } elseif ($this->_element_id == 42) {
             $parse['table_data'] = $this->phalanxRange($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'] = FunctionsLib::chrono_applet("Gate", "1", $RestString['value'], TRUE);
                 $parse['gate_wait_time'] = "<div id=\"bxx" . "Gate" . "1" . "\"></div>";
                 $parse['gate_script_go'] = FunctionsLib::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 = DevelopmentsLib::development_price($this->_current_user, $this->_current_planet, $this->_element_id, TRUE, TRUE);
             $DestroyTime = DevelopmentsLib::development_time($this->_current_user, $this->_current_planet, $this->_element_id) / 2;
             $parse['destroyurl'] = "game.php?page=" . DevelopmentsLib::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'] = FormatLib::pretty_number($NeededRessources['metal']);
             $parse['crystal'] = FormatLib::pretty_number($NeededRessources['crystal']);
             $parse['deuterium'] = FormatLib::pretty_number($NeededRessources['deuterium']);
             $parse['destroytime'] = FormatLib::pretty_time($DestroyTime);
             $page .= parent::$page->parse_template($DestroyTPL, $parse);
         }
     }
     parent::$page->display($page);
 }
Example #5
0
 /**
  * method do_command
  * param
  * return void
  */
 private function do_command()
 {
     $cmd = isset($_GET['cmd']) ? $_GET['cmd'] : NULL;
     if (!is_null($cmd)) {
         $technology = (int) $_GET['tech'];
         if (in_array($technology, $this->_reslist['tech'])) {
             if (is_array($this->_is_working['working_on'])) {
                 $working_planet = $this->_is_working['working_on'];
             } else {
                 $working_planet = $this->_current_planet;
             }
             switch ($cmd) {
                 // cancel a research
                 case 'cancel':
                     if ($this->_is_working['working_on']['planet_b_tech_id'] == $technology) {
                         $costs = DevelopmentsLib::development_price($this->_current_user, $working_planet, $technology);
                         $working_planet['planet_metal'] += $costs['metal'];
                         $working_planet['planet_crystal'] += $costs['crystal'];
                         $working_planet['planet_deuterium'] += $costs['deuterium'];
                         $working_planet['planet_b_tech_id'] = 0;
                         $working_planet['planet_b_tech'] = 0;
                         $this->_current_user['research_current_research'] = 0;
                         $update_data = TRUE;
                         $this->_is_working['is_working'] = FALSE;
                     }
                     break;
                     // start a research
                 // start a research
                 case 'search':
                     if (DevelopmentsLib::is_development_allowed($this->_current_user, $working_planet, $technology) && DevelopmentsLib::is_development_payable($this->_current_user, $working_planet, $technology) && !parent::$users->is_on_vacations($this->_current_user)) {
                         $costs = DevelopmentsLib::development_price($this->_current_user, $working_planet, $technology);
                         $working_planet['planet_metal'] -= $costs['metal'];
                         $working_planet['planet_crystal'] -= $costs['crystal'];
                         $working_planet['planet_deuterium'] -= $costs['deuterium'];
                         $working_planet['planet_b_tech_id'] = $technology;
                         $working_planet['planet_b_tech'] = time() + DevelopmentsLib::development_time($this->_current_user, $working_planet, $technology, FALSE, $this->_lab_level);
                         $this->_current_user['research_current_research'] = $working_planet['id'];
                         $update_data = TRUE;
                         $this->_is_working['is_working'] = TRUE;
                     }
                     break;
             }
             if ($update_data == TRUE) {
                 parent::$db->query("UPDATE " . PLANETS . " AS p, " . RESEARCH . " AS r SET\n\t\t\t\t\t\t\t\t\t\t\tp.`planet_b_tech_id` = '" . $working_planet['planet_b_tech_id'] . "',\n\t\t\t\t\t\t\t\t\t\t\tp.`planet_b_tech` = '" . $working_planet['planet_b_tech'] . "',\n\t\t\t\t\t\t\t\t\t\t\tp.`planet_metal` = '" . $working_planet['planet_metal'] . "',\n\t\t\t\t\t\t\t\t\t\t\tp.`planet_crystal` = '" . $working_planet['planet_crystal'] . "',\n\t\t\t\t\t\t\t\t\t\t\tp.`planet_deuterium` = '" . $working_planet['planet_deuterium'] . "',\n\t\t\t\t\t\t\t\t\t\t\tr.`research_current_research` = '" . $this->_current_user['research_current_research'] . "'\n\t\t\t\t\t\t\t\t\t\t\tWHERE p.`planet_id` = '" . $working_planet['planet_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t\tAND r.`research_user_id` = '" . $this->_current_user['user_id'] . "';");
             }
             $this->_current_planet = $working_planet;
             if (is_array($this->_is_working['working_on'])) {
                 $this->_is_working['working_on'] = $working_planet;
             } else {
                 $this->_current_planet = $working_planet;
                 if ($cmd == 'search') {
                     $this->_is_working['working_on'] = $this->_current_planet;
                 }
             }
         }
         FunctionsLib::redirect('game.php?page=research');
     }
 }
Example #6
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $parse = $this->_lang;
     $load_template = parent::$page->get_template('adm/errors_row_view');
     $deleteall = isset($_GET['deleteall']) ? $_GET['deleteall'] : '';
     $file = XGP_ROOT . LOGS_PATH . 'ErrorLog.php';
     $errors_all = @file_get_contents($file);
     $i = 0;
     $parse['errors_list'] = '';
     if ($errors_all != "") {
         $errors_all = explode('||', $errors_all);
         foreach ($errors_all as $error) {
             $errors_row = explode('|', $error);
             if (isset($errors_row[3])) {
                 $i++;
                 $parse['errors_list'] .= parent::$page->parse_template($load_template, $errors_row);
             }
         }
     }
     $parse['errors_list_resume'] = $i . $this->_lang['er_errors'];
     if ($deleteall == 'yes') {
         $fh = fopen($file, 'w');
         fclose($fh);
         FunctionsLib::redirect('admin.php?page=errors');
     }
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('adm/errors_view'), $parse));
 }
 /**
  * method secure_connection
  * param
  * return stablish a secure connection and force it
  */
 public static function secure_connection()
 {
     if (FunctionsLib::read_config('ssl_enabled') == 1 && $_SERVER['SERVER_PORT'] !== 443 && (empty($_SERVER['HTTPS']) or $_SERVER['HTTPS'] === 'off')) {
         FunctionsLib::redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
     }
 }
Example #8
0
 * @version  3.0.0
 */
use application\libraries\FunctionsLib;
define('IN_GAME', true);
define('XGP_ROOT', './');
require XGP_ROOT . 'application/core/common.php';
$hooks->call_hook('before_page');
$page = isset($_GET['page']) ? $_GET['page'] : null;
// some replacements to adapt the pages
$page = strtr($page, array('resources' => 'buildings', 'resourceSettings' => 'resources', 'station' => 'buildings', 'federationlayer' => 'federation', 'shortcuts' => 'fleetshortcuts', 'forums' => 'forum'));
$file_name = XGP_ROOT . GAME_PATH . $page . '.php';
if (isset($page)) {
    // logout
    if ($page == 'logout') {
        $session->delete();
        FunctionsLib::redirect(XGP_ROOT);
    }
    // other pages
    if (file_exists($file_name)) {
        include $file_name;
        $class_name = 'application\\controllers\\game\\' . ucfirst($page);
        new $class_name();
    }
}
if ($page == null) {
    if (!$hooks->call_hook('new_page')) {
        FunctionsLib::redirect('game.php?page=overview');
    }
}
FunctionsLib::redirect('game.php?page=overview');
/* end of game.php */
Example #9
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $resource = parent::$objects->getObjects();
     $pricelist = parent::$objects->getPrice();
     $reslist = parent::$objects->getObjectsList();
     #####################################################################################################
     // SOME DEFAULT VALUES
     #####################################################################################################
     // QUERYS
     $getCurrentAcs = parent::$db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . ACS_FLEETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE acs_fleet_members = '" . $this->_current_user['user_id'] . "'");
     // ARRAYS
     $speed_values = array(10 => 100, 9 => 90, 8 => 80, 7 => 70, 6 => 60, 5 => 50, 4 => 40, 3 => 30, 2 => 20, 1 => 10);
     $planet_type = array('fl_planet', 'fl_debris', 'fl_moon');
     // LOAD TEMPLATES REQUIRED
     $inputs_template = parent::$page->get_template('fleet/fleet2_inputs');
     $options_template = parent::$page->get_template('fleet/fleet_options');
     $shortcut_template = parent::$page->get_template('fleet/fleet2_shortcuts');
     $shortcut_row_template = parent::$page->get_template('fleet/fleet2_shortcuts_row');
     $shortcut_noshortcuts = parent::$page->get_template('fleet/fleet2_shortcuts_noshortcuts_row');
     $shortcut_acs_row = parent::$page->get_template('fleet/fleet2_shortcut_acs_row');
     // LANGUAGE
     $this->_lang['js_path'] = XGP_ROOT . JS_PATH;
     $parse = $this->_lang;
     // COORDS
     $g = $_POST['galaxy'] == '' ? $this->_current_planet['planet_galaxy'] : $_POST['galaxy'];
     $s = $_POST['system'] == '' ? $this->_current_planet['planet_system'] : $_POST['system'];
     $p = $_POST['planet'] == '' ? $this->_current_planet['planet_planet'] : $_POST['planet'];
     $t = $_POST['planet_type'] == '' ? $this->_current_planet['planet_type'] : $_POST['planet_type'];
     // OTHER VALUES
     $value = 0;
     $FleetHiddenBlock = '';
     #####################################################################################################
     // END DEFAULT VALUES
     #####################################################################################################
     #####################################################################################################
     // LOAD SHIPS INPUTS
     #####################################################################################################
     $fleet['fleetlist'] = '';
     $fleet['amount'] = 0;
     $fleet['consumption'] = 0;
     foreach ($reslist['fleet'] as $n => $i) {
         if (isset($_POST["ship{$i}"]) && $i >= 201 && $i <= 215 && $_POST["ship{$i}"] > "0") {
             if ($_POST["ship{$i}"] > $this->_current_planet[$resource[$i]] or !ctype_digit($_POST["ship{$i}"])) {
                 FunctionsLib::redirect('game.php?page=fleet1');
             } else {
                 $fleet['fleetarray'][$i] = $_POST["ship{$i}"];
                 $fleet['fleetlist'] .= $i . "," . $_POST["ship{$i}"] . ";";
                 $fleet['amount'] += $_POST["ship{$i}"];
                 $fleet['i'] = $i;
                 $fleet['consumption'] += FleetsLib::ship_consumption($i, $this->_current_user);
                 $fleet['speed'] = FleetsLib::fleet_max_speed('', $i, $this->_current_user);
                 $fleet['capacity'] = $pricelist[$i]['capacity'];
                 $fleet['ship'] = $_POST["ship{$i}"];
                 $speedalls[$i] = FleetsLib::fleet_max_speed('', $i, $this->_current_user);
                 $FleetHiddenBlock .= parent::$page->parse_template($inputs_template, $fleet);
             }
         }
     }
     if (!$fleet['fleetlist']) {
         FunctionsLib::redirect('game.php?page=fleet1');
     } else {
         $speedallsmin = min($speedalls);
     }
     #####################################################################################################
     // LOAD PLANET TYPES OPTIONS
     #####################################################################################################
     $parse['options_planettype'] = '';
     foreach ($planet_type as $type) {
         $value++;
         $options['value'] = $value;
         if ($value == $t) {
             $options['selected'] = 'SELECTED';
         } else {
             $options['selected'] = '';
         }
         $options['title'] = $this->_lang[$type];
         $parse['options_planettype'] .= parent::$page->parse_template($options_template, $options);
     }
     #####################################################################################################
     // LOAD SPEED OPTIONS
     #####################################################################################################
     $parse['options'] = '';
     foreach ($speed_values as $value => $porcentage) {
         $speed_porcentage['value'] = $value;
         $speed_porcentage['selected'] = '';
         $speed_porcentage['title'] = $porcentage;
         $parse['options'] .= parent::$page->parse_template($options_template, $speed_porcentage);
     }
     #####################################################################################################
     // PARSE THE REST OF THE OPTIONS
     #####################################################################################################
     $parse['fleetblock'] = $FleetHiddenBlock;
     $parse['speedallsmin'] = $speedallsmin;
     $parse['fleetarray'] = str_rot13(base64_encode(serialize($fleet['fleetarray'])));
     $parse['galaxy'] = $this->_current_planet['planet_galaxy'];
     $parse['system'] = $this->_current_planet['planet_system'];
     $parse['planet'] = $this->_current_planet['planet_planet'];
     $parse['galaxy_post'] = (int) $_POST['galaxy'];
     $parse['system_post'] = (int) $_POST['system'];
     $parse['planet_post'] = (int) $_POST['planet'];
     $parse['speedfactor'] = FunctionsLib::fleet_speed_factor();
     $parse['planet_type'] = $this->_current_planet['planet_type'];
     $parse['metal'] = floor($this->_current_planet['planet_metal']);
     $parse['crystal'] = floor($this->_current_planet['planet_crystal']);
     $parse['deuterium'] = floor($this->_current_planet['planet_deuterium']);
     $parse['g'] = $g;
     $parse['s'] = $s;
     $parse['p'] = $p;
     #####################################################################################################
     // LOAD FLEET SHORTCUTS
     #####################################################################################################
     if (OfficiersLib::isOfficierActive($this->_current_user['premium_officier_commander'])) {
         if ($this->_current_user['user_fleet_shortcuts']) {
             $scarray = explode(";", $this->_current_user['user_fleet_shortcuts']);
             foreach ($scarray as $a => $b) {
                 if ($b != "") {
                     $c = explode(',', $b);
                     $shortcut['description'] = $c[0] . " " . $c[1] . ":" . $c[2] . ":" . $c[3] . " ";
                     switch ($c[4]) {
                         case 1:
                             $shortcut['description'] .= $this->_lang['fl_planet_shortcut'];
                             break;
                         case 2:
                             $shortcut['description'] .= $this->_lang['fl_debris_shortcut'];
                             break;
                         case 3:
                             $shortcut['description'] .= $this->_lang['fl_moon_shortcut'];
                             break;
                         default:
                             $shortcut['description'] .= '';
                             break;
                     }
                     $shortcut['select'] = 'shortcuts';
                     $shortcut['selected'] = '';
                     $shortcut['value'] = $c['1'] . ';' . $c['2'] . ';' . $c['3'] . ';' . $c['4'];
                     $shortcut['title'] = $shortcut['description'];
                     $shortcut['shortcut_options'] .= parent::$page->parse_template($options_template, $shortcut);
                 }
             }
             $parse['shortcuts_rows'] = parent::$page->parse_template($shortcut_row_template, $shortcut);
             $parse['shortcut'] = parent::$page->parse_template($shortcut_template, $parse);
         } else {
             $parse['fl_shorcut_message'] = $this->_lang['fl_no_shortcuts'];
             $parse['shortcuts_rows'] = parent::$page->parse_template($shortcut_noshortcuts, $parse);
             $parse['shortcut'] = parent::$page->parse_template($shortcut_template, $parse);
         }
     }
     #####################################################################################################
     // LOAD COLONY SHORTCUTS
     #####################################################################################################
     $colony['select'] = 'colonies';
     $colony['shortcut_options'] = FunctionsLib::build_planet_list($this->_current_user, $this->_current_planet['planet_id']);
     $parse['colonylist'] = parent::$page->parse_template($shortcut_row_template, $colony);
     if ($colony['shortcut_options'] === FALSE) {
         $parse['fl_shorcut_message'] = $this->_lang['fl_no_colony'];
         $parse['colonylist'] = parent::$page->parse_template($shortcut_noshortcuts, $parse);
     }
     #####################################################################################################
     // LOAD SAC SHORTCUTS
     #####################################################################################################
     $acs_fleets = '';
     while ($row = parent::$db->fetchArray($getCurrentAcs)) {
         $members = explode(",", $row['acs_fleet_invited']);
         foreach ($members as $a => $b) {
             if ($b == $this->_current_user['user_id']) {
                 $acs['galaxy'] = $row['acs_fleet_galaxy'];
                 $acs['system'] = $row['acs_fleet_system'];
                 $acs['planet'] = $row['acs_fleet_planet'];
                 $acs['planet_type'] = $row['acs_fleet_planet_type'];
                 $acs['id'] = $row['acs_fleet_id'];
                 $acs['name'] = $row['acs_fleet_name'];
                 $acs_fleets .= parent::$page->parse_template($shortcut_acs_row, $acs);
             }
         }
     }
     $parse['asc'] = $acs_fleets;
     $parse['maxepedition'] = $_POST['maxepedition'];
     $parse['curepedition'] = $_POST['curepedition'];
     $parse['target_mission'] = $_POST['target_mission'];
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('fleet/fleet2_table'), $parse));
 }
Example #10
0
 * PHP Version 5.5+
 *
 * @category Root File
 * @package  N/A
 * @author   XG Proyect Team
 * @license  http://www.xgproyect.org XG Proyect
 * @link     http://www.xgproyect.org
 * @version  3.0.0
 */
use application\libraries\adm\AdministrationLib;
use application\libraries\FunctionsLib;
define('IN_ADMIN', true);
define('XGP_ROOT', './');
require XGP_ROOT . 'application/core/common.php';
include_once XGP_ROOT . 'application/libraries/adm/AdministrationLib.php';
// check if SSL is setted
AdministrationLib::secure_connection();
$page = isset($_GET['page']) ? $_GET['page'] : 'home';
$file_name = XGP_ROOT . ADMIN_PATH . $page . '.php';
// logout
if ($page == 'logout') {
    FunctionsLib::redirect(XGP_ROOT . 'game.php?page=overview');
}
if (file_exists($file_name)) {
    include $file_name;
    $class_name = 'application\\controllers\\adm\\' . ucfirst($page);
    new $class_name();
} else {
    FunctionsLib::redirect(XGP_ROOT . 'admin.php');
}
/* end of admin.php */
Example #11
0
 /**
  * buildPage
  *
  * @return void
  */
 private function buildPage()
 {
     FunctionsLib::redirect(FunctionsLib::read_config('forum_url'));
 }
Example #12
0
 /**
  * method show_ban
  * param
  * return build the ban page
  */
 private function show_ban()
 {
     $parse = $this->_lang;
     $parse['js_path'] = XGP_ROOT . JS_PATH;
     $ban_name = isset($_GET['ban_name']) ? parent::$db->escapeValue($_GET['ban_name']) : NULL;
     if (isset($_GET['banuser']) && isset($_GET['ban_name'])) {
         $parse['name'] = $ban_name;
         $parse['banned_until'] = '';
         $parse['changedate'] = $this->_lang['bn_auto_lift_ban_message'];
         $parse['vacation'] = '';
         $banned_user = parent::$db->queryFetch("SELECT b.*, s.`setting_user_id`, s.`setting_vacations_status`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . BANNED . "` AS b\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN `" . SETTINGS . "` AS s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tON s.`setting_user_id` = (SELECT `user_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . USERS . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `user_name` = '" . $ban_name . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `banned_who` = '" . $ban_name . "'");
         if ($banned_user) {
             $parse['banned_until'] = $this->_lang['bn_banned_until'] . ' (' . date(FunctionsLib::read_config('date_format_extended'), $banned_user['banned_longer']) . ')';
             $parse['reason'] = $banned_user['banned_theme'];
             $parse['changedate'] = '<div style="float:left">' . $this->_lang['bn_change_date'] . '</div><div style="float:right">' . AdministrationLib::show_pop_up($this->_lang['bn_edit_ban_help']) . '</div>';
         }
         $parse['vacation'] = $banned_user['setting_vacations_status'] ? 'checked="checked"' : '';
         if (isset($_POST['bannow']) && $_POST['bannow']) {
             if (!is_numeric($_POST['days']) or !is_numeric($_POST['hour'])) {
                 $parse['alert'] = AdministrationLib::save_message('warning', $this->_lang['bn_all_fields_required']);
             } else {
                 $reas = (string) $_POST['why'];
                 $days = (int) $_POST['days'];
                 $hour = (int) $_POST['hour'];
                 $admin_name = $this->_current_user['user_name'];
                 $admin_mail = $this->_current_user['user_email'];
                 $current_time = time();
                 $ban_time = $days * 86400;
                 $ban_time += $hour * 3600;
                 if ($banned_user['banned_longer'] > time()) {
                     $ban_time += $banned_user['banned_longer'] - time();
                 }
                 if ($ban_time + $current_time < time()) {
                     $banned_until = $current_time;
                 } else {
                     $banned_until = $current_time + $ban_time;
                 }
                 if ($banned_user) {
                     parent::$db->query("UPDATE " . BANNED . "  SET\n\t\t\t\t\t\t\t\t\t\t\t`banned_who` = '" . $ban_name . "',\n\t\t\t\t\t\t\t\t\t\t\t`banned_theme` = '" . $reas . "',\n\t\t\t\t\t\t\t\t\t\t\t`banned_who2` = '" . $ban_name . "',\n\t\t\t\t\t\t\t\t\t\t\t`banned_time` = '" . $current_time . "',\n\t\t\t\t\t\t\t\t\t\t\t`banned_longer` = '" . $banned_until . "',\n\t\t\t\t\t\t\t\t\t\t\t`banned_author` = '" . $admin_name . "',\n\t\t\t\t\t\t\t\t\t\t\t`banned_email` = '" . $admin_mail . "'\n\t\t\t\t\t\t\t\t\t\t\tWHERE `banned_who2` = '" . $ban_name . "';");
                 } else {
                     parent::$db->query("INSERT INTO " . BANNED . " SET\n\t\t\t\t\t\t\t\t\t\t\t`banned_who` = '" . $ban_name . "',\n\t\t\t\t\t\t\t\t\t\t\t`banned_theme` = '" . $reas . "',\n\t\t\t\t\t\t\t\t\t\t\t`banned_who2` = '" . $ban_name . "',\n\t\t\t\t\t\t\t\t\t\t\t`banned_time` = '" . $current_time . "',\n\t\t\t\t\t\t\t\t\t\t\t`banned_longer` = '" . $banned_until . "',\n\t\t\t\t\t\t\t\t\t\t\t`banned_author` = '" . $admin_name . "',\n\t\t\t\t\t\t\t\t\t\t\t`banned_email` = '" . $admin_mail . "';");
                 }
                 $user_id = parent::$db->queryFetch("SELECT `user_id`\n\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\tWHERE `user_name` = '" . $ban_name . "' LIMIT 1");
                 parent::$db->query("UPDATE " . USERS . " AS u, " . SETTINGS . " AS s, " . PLANETS . " AS p SET\n\t\t\t\t\t\t\t\t\t\t\tu.`user_banned` = '" . $banned_until . "',\n\t\t\t\t\t\t\t\t\t\t\ts.`setting_vacations_status` = '" . (isset($_POST['vacat']) ? 1 : 0) . "',\n\t\t\t\t\t\t\t\t\t\t\tp.`planet_building_metal_mine_porcent` = '0',\n\t\t\t\t\t\t\t\t\t\t\tp.`planet_building_crystal_mine_porcent` = '0',\n\t\t\t\t\t\t\t\t\t\t\tp.`planet_building_deuterium_sintetizer_porcent` = '0'\n\t\t\t\t\t\t\t\t\t\t\tWHERE u.`user_id` = " . $user_id['user_id'] . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND s.`setting_user_id` = " . $user_id['user_id'] . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tAND p.`planet_user_id` = " . $user_id['user_id'] . ";");
                 $parse['alert'] = AdministrationLib::save_message('ok', str_replace('%s', $ban_name, $this->_lang['bn_ban_success']));
             }
         }
     } else {
         FunctionsLib::redirect('admin.php?page=ban');
     }
     return parent::$page->parse_template(parent::$page->get_template("adm/ban_result_view"), $parse);
 }
Example #13
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $parse = $this->_lang;
     /* range */
     $radar_limit_inf = $this->_current_planet['planet_system'] - $this->_formula->phalanx_range($this->_current_planet['building_phalanx']);
     $radar_limit_sup = $this->_current_planet['planet_system'] + $this->_formula->phalanx_range($this->_current_planet['building_phalanx']);
     $radar_limit_inf = max($radar_limit_inf, 1);
     $radar_limit_sup = min($radar_limit_sup, MAX_SYSTEM_IN_GALAXY);
     /* input validation */
     $Galaxy = (int) $_GET['galaxy'];
     $System = (int) $_GET['system'];
     $Planet = (int) $_GET['planet'];
     $PlType = (int) $_GET['planettype'];
     /* cheater detection */
     if ($System < $radar_limit_inf or $System > $radar_limit_sup or $Galaxy != $this->_current_planet['planet_galaxy'] or $PlType != 1 or $this->_current_planet['planet_type'] != 3) {
         FunctionsLib::redirect('game.php?page=galaxy');
     }
     /* main page */
     if ($this->_current_planet['planet_deuterium'] > 10000) {
         parent::$db->query("UPDATE " . PLANETS . " SET\n            \t\t\t\t\t\t`planet_deuterium` = `planet_deuterium` - '10000'\n            \t\t\t\t\t\tWHERE `planet_id` = '" . $this->_current_user['user_current_planet'] . "';");
         $TargetInfo = parent::$db->queryFetch("SELECT `planet_name`, `planet_user_id`\n            \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\tWHERE `planet_galaxy` = '" . $Galaxy . "' AND\n            \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`planet_planet` = '" . $Planet . "' AND\n            \t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = 1");
         $TargetID = $TargetInfo['planet_user_id'];
         $TargetName = $TargetInfo['planet_name'];
         $TargetInfo = parent::$db->queryFetch("SELECT `planet_destroyed`\n            \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\tWHERE `planet_galaxy` = '" . $Galaxy . "' AND\n            \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`planet_planet` = '" . $Planet . "' AND\n            \t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = 3 ");
         //if there isn't a moon,
         if ($TargetInfo === false) {
             $TargetMoonIsDestroyed = true;
         } else {
             $TargetMoonIsDestroyed = $TargetInfo['planet_destroyed'] !== 0;
         }
         $FleetToTarget = parent::$db->query("SELECT *\n            \t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n            \t\t\t\t\t\t\t\t\t\tWHERE ( ( `fleet_start_galaxy` = '" . $Galaxy . "' AND\n            \t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_start_system` = '" . $System . "' AND\n            \t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_start_planet` = '" . $Planet . "' ) OR\n            \t\t\t\t\t\t\t\t\t\t\t\t( `fleet_end_galaxy` = '" . $Galaxy . "' AND\n            \t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_end_system` = '" . $System . "' AND\n            \t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_end_planet` = '" . $Planet . "' )\n            \t\t\t\t\t\t\t\t\t\t\t   ) ;");
         $Record = 0;
         $fpage = array();
         while ($FleetRow = parent::$db->fetchArray($FleetToTarget)) {
             $Record++;
             $ArrivetoTargetTime = $FleetRow['fleet_start_time'];
             $EndStayTime = $FleetRow['fleet_end_stay'];
             $ReturnTime = $FleetRow['fleet_end_time'];
             $Mission = $FleetRow['fleet_mission'];
             $myFleet = $FleetRow['fleet_owner'] == $TargetID ? true : false;
             $FleetRow['fleet_resource_metal'] = 0;
             $FleetRow['fleet_resource_crystal'] = 0;
             $FleetRow['fleet_resource_deuterium'] = 0;
             $isStartedfromThis = $FleetRow['fleet_start_galaxy'] == $Galaxy && $FleetRow['fleet_start_system'] == $System && $FleetRow['fleet_start_planet'] == $Planet;
             $isTheTarget = $FleetRow['fleet_end_galaxy'] == $Galaxy && $FleetRow['fleet_end_system'] == $System && $FleetRow['fleet_end_planet'] == $Planet;
             /* 1)the arrive to target fleet table event
              * you can see start-fleet event only if this is a planet(or destroyed moon)
              * and if the fleet mission started from this planet is different from hold
              * or if it's a enemy mission.
              */
             if ($ArrivetoTargetTime > time()) {
                 //scannig of fleet started planet
                 if ($isStartedfromThis && ($FleetRow['fleet_start_type'] == 1 || $FleetRow['fleet_start_type'] == 3 && $TargetMoonIsDestroyed)) {
                     if ($Mission != 4) {
                         $Label = "fs";
                         $fpage[$ArrivetoTargetTime] .= "\n" . FleetsLib::flying_fleets_table($FleetRow, 0, $myFleet, $Label, $Record, $this->_current_user);
                     }
                 } elseif (!$isStartedfromThis && ($FleetRow['fleet_end_type'] == 1 || $FleetRow['fleet_end_type'] == 3 && $TargetMoonIsDestroyed)) {
                     $Label = "fs";
                     $fpage[$ArrivetoTargetTime] .= "\n" . FleetsLib::flying_fleets_table($FleetRow, 0, $myFleet, $Label, $Record, $this->_current_user);
                 }
             }
             /* 2)the stay fleet table event
              * you can see stay-fleet event only if the target is a planet(or destroyed moon) and is the targetPlanet
              */
             if ($EndStayTime > time() && $Mission == 5 && ($FleetRow['fleet_end_type'] == 1 || $FleetRow['fleet_end_type'] == 3 && $TargetMoonIsDestroyed) && $isTheTarget) {
                 $Label = "ft";
                 $fpage[$EndStayTime] .= "\n" . FleetsLib::flying_fleets_table($FleetRow, 1, $myFleet, $Label, $Record, $this->_current_user);
             }
             /* 3)the return fleet table event
              * you can see the return fleet if this is the started planet(or destroyed moon)
              * but no if it is a hold mission or mip
              */
             if ($ReturnTime > time() && $Mission != 4 && $Mission != 10 && $isStartedfromThis && ($FleetRow['fleet_start_type'] == 1 || $FleetRow['fleet_start_type'] == 3 && $TargetMoonIsDestroyed)) {
                 $Label = "fe";
                 $fpage[$ReturnTime] .= "\n" . FleetsLib::flying_fleets_table($FleetRow, 2, $myFleet, $Label, $Record, $this->_current_user);
             }
         }
         ksort($fpage);
         foreach ($fpage as $FleetTime => $FleetContent) {
             $Fleets .= $FleetContent . "\n";
         }
         $parse['phl_fleets_table'] = $Fleets;
         $parse['phl_er_deuter'] = "";
     } else {
         $parse['phl_er_deuter'] = $this->_lang['px_no_deuterium'];
     }
     $parse['phl_pl_galaxy'] = $Galaxy;
     $parse['phl_pl_system'] = $System;
     $parse['phl_pl_place'] = $Planet;
     $parse['phl_pl_name'] = $TargetName;
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('galaxy/phalanx_body'), $parse), FALSE, '', FALSE);
 }
Example #14
0
 /**
  * method build_page
  * param
  * return the statistics page
  */
 private function build_page()
 {
     $parse = $this->_lang;
     $parse['dpath'] = DPATH;
     $bloc = $this->_lang;
     $mode = isset($_GET['mode']) ? $_GET['mode'] : '';
     $time = isset($_GET['time']) ? $_GET['time'] : '';
     if ($mode == 2 && ($time == 'month' or $time == 'week')) {
         $Selected = $_GET['offi'];
         $time = 'darkmatter_' . $time;
         $set_time = $time == 'darkmatter_month' ? 3600 * 24 * 30 * 3 : 3600 * 24 * 7;
         if (in_array($Selected, $this->_reslist['officier'])) {
             $Result = $this->is_officier_accesible($Selected, $time);
             $Price = $this->get_officier_price($Selected, $time);
             if ($Result !== FALSE) {
                 $this->_current_user['premium_dark_matter'] -= $Price;
                 // IF THE OFFICIER IS ACTIVE
                 if (OfficiersLib::isOfficierActive($this->_current_user[$this->_resource[$Selected]])) {
                     $this->_current_user[$this->_resource[$Selected]] += $set_time;
                     // ADD TIME
                 } else {
                     $this->_current_user[$this->_resource[$Selected]] = time() + $set_time;
                     // SET TIME
                 }
                 parent::$db->query("UPDATE " . PREMIUM . " SET\n\t\t\t\t\t\t\t\t\t\t\t`premium_dark_matter` = '" . $this->_current_user['premium_dark_matter'] . "',\n\t\t\t\t\t\t\t\t\t\t\t`" . $this->_resource[$Selected] . "` = '" . $this->_current_user[$this->_resource[$Selected]] . "'\n\t\t\t\t\t\t\t\t\t\t\tWHERE `premium_user_id` = '" . $this->_current_user['user_id'] . "';");
             }
         }
         FunctionsLib::redirect('game.php?page=officier');
     } else {
         $OfficierRowTPL = parent::$page->get_template('officier/officier_row');
         $parse['disp_off_tbl'] = '';
         $parse['premium_pay_url'] = FunctionsLib::read_config('premium_url') != '' ? FunctionsLib::read_config('premium_url') : 'game.php?page=officier';
         foreach ($this->_lang['tech'] as $Element => $ElementName) {
             if ($Element >= 601 && $Element <= 605) {
                 $bloc['dpath'] = DPATH;
                 $bloc['off_id'] = $Element;
                 $bloc['off_status'] = OfficiersLib::isOfficierActive($this->_current_user[$this->_resource[$Element]]) ? '<font color=lime>' . $this->_lang['of_active'] . ' ' . date(FunctionsLib::read_config('date_format'), $this->_current_user[$this->_resource[$Element]]) . '</font>' : '<font color=red>' . $this->_lang['of_inactive'] . '</font>';
                 $bloc['off_name'] = $ElementName;
                 $bloc['off_desc'] = $this->_lang['res']['descriptions'][$Element];
                 $bloc['off_desc_short'] = $this->_lang['info'][$Element]['description'];
                 $bloc['month_price'] = FormatLib::pretty_number($this->get_officier_price($Element, 'darkmatter_month'));
                 $bloc['week_price'] = FormatLib::pretty_number($this->get_officier_price($Element, 'darkmatter_week'));
                 $bloc['img_big'] = $this->get_officier_image($Element, 'img_big');
                 $bloc['img_small'] = $this->get_officier_image($Element, 'img_small');
                 $bloc['off_link_month'] = "game.php?page=officier&mode=2&offi=" . $Element . "&time=month";
                 $bloc['off_link_week'] = "game.php?page=officier&mode=2&offi=" . $Element . "&time=week";
                 $parse['disp_off_tbl'] .= parent::$page->parse_template($OfficierRowTPL, $bloc);
             }
         }
     }
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('officier/officier_table'), $parse));
 }
Example #15
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\n\t\t\t\t\t\t\t\t\t\t`setting_vacations_status` = '0',\n\t\t\t\t\t\t\t\t\t\t`setting_vacations_until` = '0',\n\t\t\t\t\t\t\t\t\t\tplanet_building_metal_mine_porcent = '10',\n\t\t\t\t\t\t\t\t\t\tplanet_building_crystal_mine_porcent = '10',\n\t\t\t\t\t\t\t\t\t\tplanet_building_deuterium_sintetizer_porcent = '10',\n\t\t\t\t\t\t\t\t\t\tplanet_building_solar_plant_porcent = '10',\n\t\t\t\t\t\t\t\t\t\tplanet_building_fusion_reactor_porcent = '10',\n\t\t\t\t\t\t\t\t\t\tplanet_ship_solar_satellite_porcent = '10'\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']) . "'");
             FunctionsLib::redirect('game.php?page=options');
         } else {
             $urlaubs_modus = '1';
             FunctionsLib::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->escapeValue($_POST['db_character']);
         } else {
             $username = parent::$db->escapeValue($this->_current_user['user_name']);
         }
         // < ------------------------------------------------- DIRECCION DE EMAIL -------------------------------------------------- >
         if (isset($_POST['db_email']) && $_POST['db_email'] != '') {
             $db_email = parent::$db->escapeValue($_POST['db_email']);
         } else {
             $db_email = parent::$db->escapeValue($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()) {
                 FunctionsLib::message($this->_lang['op_cant_activate_vacation_mode'], "game.php?page=options", 2);
             }
             $urlaubs_modus = '1';
             $time = FunctionsLib::get_default_vacation_time();
             parent::$db->query("UPDATE " . SETTINGS . ", " . PLANETS . " SET\n\t\t\t\t\t\t\t\t\t\t`setting_vacations_status` = '{$urlaubs_modus}',\n\t\t\t\t\t\t\t\t\t\t`setting_vacations_until` = '{$time}',\n\t\t\t\t\t\t\t\t\t\tplanet_metal_perhour = '" . FunctionsLib::read_config('metal_basic_income') . "',\n\t\t\t\t\t\t\t\t\t\tplanet_crystal_perhour = '" . FunctionsLib::read_config('crystal_basic_income') . "',\n\t\t\t\t\t\t\t\t\t\tplanet_deuterium_perhour = '" . FunctionsLib::read_config('deuterium_basic_income') . "',\n\t\t\t\t\t\t\t\t\t\tplanet_energy_used = '0',\n\t\t\t\t\t\t\t\t\t\tplanet_energy_max = '0',\n\t\t\t\t\t\t\t\t\t\tplanet_building_metal_mine_porcent = '0',\n\t\t\t\t\t\t\t\t\t\tplanet_building_crystal_mine_porcent = '0',\n\t\t\t\t\t\t\t\t\t\tplanet_building_deuterium_sintetizer_porcent = '0',\n\t\t\t\t\t\t\t\t\t\tplanet_building_solar_plant_porcent = '0',\n\t\t\t\t\t\t\t\t\t\tplanet_building_fusion_reactor_porcent = '0',\n\t\t\t\t\t\t\t\t\t\tplanet_ship_solar_satellite_porcent = '0'\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->escapeValue($_POST['settings_sort']);
         $SetOrder = parent::$db->escapeValue($_POST['settings_order']);
         //// < -------------------------------------- ACTUALIZAR TODO LO SETEADO ANTES --------------------------------------------- >
         parent::$db->query("UPDATE " . USERS . " AS u, " . SETTINGS . " AS s SET\n\t\t\t\t\t\t\t\t\tu.`user_email` = '{$db_email}',\n\t\t\t\t\t\t\t\t\ts.`setting_no_ip_check` = '{$noipcheck}',\n\t\t\t\t\t\t\t\t\ts.`setting_planet_sort` = '{$SetSort}',\n\t\t\t\t\t\t\t\t\ts.`setting_planet_order` = '{$SetOrder}',\n\t\t\t\t\t\t\t\t\ts.`setting_probes_amount` = '{$spio_anz}',\n\t\t\t\t\t\t\t\t\ts.`setting_fleet_actions` = '{$settings_fleetactions}',\n\t\t\t\t\t\t\t\t\ts.`setting_galaxy_espionage` = '{$settings_esp}',\n\t\t\t\t\t\t\t\t\ts.`setting_galaxy_write` = '{$settings_wri}',\n\t\t\t\t\t\t\t\t\ts.`setting_galaxy_buddy` = '{$settings_bud}',\n\t\t\t\t\t\t\t\t\ts.`setting_galaxy_missile` = '{$settings_mis}',\n\t\t\t\t\t\t\t\t\ts.`setting_vacations_status` = '{$urlaubs_modus}',\n\t\t\t\t\t\t\t\t\ts.`setting_delete_account` = '{$db_deaktjava}'\n\t\t\t\t\t\t\t\t\tWHERE u.`user_id` = '" . $this->_current_user['user_id'] . "' AND\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\n\t\t\t\t\t\t\t\t\t\t\t\t`user_password` = '{$newpass}'\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `user_id` = '" . intval($this->_current_user['user_id']) . "' LIMIT 1");
                     FunctionsLib::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->queryFetch("SELECT `user_id`\n\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\tWHERE user_name = '" . parent::$db->escapeValue($_POST['db_character']) . "'");
             if (!$query) {
                 parent::$db->query("UPDATE `" . USERS . "` SET\n\t\t\t\t\t\t\t\t\t\t\t`user_name` = '" . parent::$db->escapeValue($username) . "'\n\t\t\t\t\t\t\t\t\t\t\tWHERE `user_id` = '" . $this->_current_user['user_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\tLIMIT 1");
                 FunctionsLib::message($this->_lang['op_username_changed'], "index.php", 1);
             }
         }
         FunctionsLib::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(FunctionsLib::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));
         }
     }
 }
Example #16
0
 /**
  * buildPage
  *
  * @return void
  */
 private function buildPage()
 {
     if (!isset($_POST) or empty($_POST)) {
         FunctionsLib::redirect('game.php?page=fleet1');
     }
     $pricelist = parent::$objects->getPrice();
     $reslist = parent::$objects->getObjectsList();
     $lang = $this->langs;
     #####################################################################################################
     // SOME DEFAULT VALUES
     #####################################################################################################
     // ARRAYS
     $exp_values = array(1, 2, 3, 4, 5);
     $hold_values = array(0, 1, 2, 4, 8, 16, 32);
     // LANG
     $this->langs['js_path'] = XGP_ROOT . JS_PATH;
     $parse = $this->langs;
     // LOAD TEMPLATES REQUIRED
     $mission_row_template = parent::$page->get_template('fleet/fleet3_mission_row');
     $input_template = parent::$page->get_template('fleet/fleet3_inputs');
     $stay_template = parent::$page->get_template('fleet/fleet3_stay_row');
     $options_template = parent::$page->get_template('fleet/fleet_options');
     // OTHER VALUES
     $galaxy = (int) $_POST['galaxy'];
     $system = (int) $_POST['system'];
     $planet = (int) $_POST['planet'];
     $planettype = (int) $_POST['planettype'];
     $fleet_acs = (int) $_POST['fleet_group'];
     $YourPlanet = false;
     $UsedPlanet = false;
     $MissionSelector = '';
     $available_ships = $this->getAvailableShips($_POST);
     // QUERYS
     $select = parent::$db->queryFetch("SELECT `planet_user_id`\n            FROM `" . PLANETS . "`\n            WHERE `planet_galaxy` = '" . $galaxy . "'\n            AND `planet_system` = '" . $system . "'\n            AND `planet_planet` = '" . $planet . "'\n            AND `planet_type` = '" . $planettype . "';");
     if ($select) {
         if ($select['planet_user_id'] == $this->current_user['user_id']) {
             $YourPlanet = true;
             $UsedPlanet = true;
         } else {
             $UsedPlanet = true;
         }
     }
     if ($planettype == 2) {
         if ($available_ships['ship209'] >= 1) {
             $missiontype[8] = $this->langs['type_mission'][8];
         } else {
             $missiontype = array();
         }
     } elseif ($planettype == 1 or $planettype == 3) {
         if ($available_ships['ship208'] >= 1 && !$UsedPlanet) {
             $missiontype[7] = $this->langs['type_mission'][7];
         } elseif ($available_ships['ship210'] >= 1 && !$YourPlanet) {
             $missiontype[6] = $this->langs['type_mission'][6];
         }
         if ($available_ships['ship202'] >= 1 or $available_ships['ship203'] >= 1 or $available_ships['ship204'] >= 1 or $available_ships['ship205'] >= 1 or $available_ships['ship206'] >= 1 or $available_ships['ship207'] >= 1 or $available_ships['ship210'] >= 1 or $available_ships['ship211'] >= 1 or $available_ships['ship213'] >= 1 or $available_ships['ship214'] >= 1 or $available_ships['ship215'] >= 1) {
             if (!$YourPlanet) {
                 $missiontype[1] = $this->langs['type_mission'][1];
             }
             $missiontype[3] = $this->langs['type_mission'][3];
             $missiontype[5] = $this->langs['type_mission'][5];
         }
     } elseif ($available_ships['ship209'] >= 1 or $available_ships['ship208']) {
         $missiontype[3] = $this->langs['type_mission'][3];
     }
     if ($YourPlanet) {
         $missiontype[4] = $this->langs['type_mission'][4];
     }
     if ($planettype == 3 || $planettype == 1 && $fleet_acs > 0 && $UsedPlanet) {
         if ($this->acsExists($fleet_acs, $galaxy, $system, $planet, $planettype)) {
             $missiontype[2] = $this->langs['type_mission'][2];
         }
     }
     if ($planettype == 3 && $available_ships['ship214'] >= 1 && !$YourPlanet && $UsedPlanet) {
         $missiontype[9] = $this->langs['type_mission'][9];
     }
     $fleetarray = unserialize(base64_decode(str_rot13($_POST['usedfleet'])));
     $mission = $_POST['target_mission'];
     $SpeedFactor = $_POST['speedfactor'];
     $AllFleetSpeed = FleetsLib::fleet_max_speed($fleetarray, 0, $this->current_user);
     $GenFleetSpeed = $_POST['speed'];
     $MaxFleetSpeed = min($AllFleetSpeed);
     $distance = FleetsLib::target_distance($_POST['thisgalaxy'], $galaxy, $_POST['thissystem'], $system, $_POST['thisplanet'], $planet);
     $duration = FleetsLib::mission_duration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor);
     $consumption = FleetsLib::fleet_consumption($fleetarray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $this->current_user);
     #####################################################################################################
     // INPUTS DATA
     #####################################################################################################
     $parse['metal'] = floor($this->current_planet['planet_metal']);
     $parse['crystal'] = floor($this->current_planet['planet_crystal']);
     $parse['deuterium'] = floor($this->current_planet['planet_deuterium']);
     $parse['consumption'] = $consumption;
     $parse['distance'] = $distance;
     $parse['speedfactor'] = $_POST['speedfactor'];
     $parse['thisgalaxy'] = $_POST['thisgalaxy'];
     $parse['thissystem'] = $_POST['thissystem'];
     $parse['thisplanet'] = $_POST['thisplanet'];
     $parse['galaxy'] = $galaxy;
     $parse['system'] = $system;
     $parse['planet'] = $planet;
     $parse['thisplanettype'] = $_POST['thisplanettype'];
     $parse['planettype'] = $planettype;
     $parse['speedallsmin'] = $_POST['speedallsmin'];
     $parse['speed'] = $_POST['speed'];
     $parse['speedfactor'] = $_POST['speedfactor'];
     $parse['usedfleet'] = $_POST['usedfleet'];
     $parse['maxepedition'] = $_POST['maxepedition'];
     $parse['curepedition'] = $_POST['curepedition'];
     $parse['fleet_group'] = $_POST['fleet_group'];
     $parse['acs_target_mr'] = $_POST['acs_target_mr'];
     #####################################################################################################
     // EXTRA INPUTS
     #####################################################################################################
     $input_extra = '';
     foreach ($fleetarray as $Ship => $Count) {
         $input_parse['ship'] = $Ship;
         $input_parse['amount'] = $Count;
         $input_parse['capacity'] = $pricelist[$Ship]['capacity'];
         $input_parse['consumption'] = FleetsLib::ship_consumption($Ship, $this->current_user);
         $input_parse['speed'] = FleetsLib::fleet_max_speed('', $Ship, $this->current_user);
         $input_extra .= parent::$page->parse_template($input_template, $input_parse);
     }
     #####################################################################################################
     // TOP TABLE TITLE
     #####################################################################################################
     $parse['title'] = $_POST['thisgalaxy'] . ':' . $_POST['thissystem'] . ':' . $_POST['thisplanet'] . ' - ';
     if ($_POST['thisplanettype'] == 1) {
         $parse['title'] .= $this->langs['fl_planet'];
     } elseif ($_POST['thisplanettype'] == 3) {
         $parse['title'] .= $this->langs['fl_moon'];
     }
     #####################################################################################################
     // MISSION TYPES
     #####################################################################################################
     if (count($missiontype) > 0) {
         if ($planet == 16) {
             $parse_mission['value'] = 15;
             $parse_mission['mission'] = $this->langs['type_mission'][15];
             $parse_mission['expedition_message'] = $this->langs['fl_expedition_alert_message'];
             $parse_mission['id'] = ' ';
             $parse_mission['checked'] = ' checked="checked"';
             $MissionSelector .= parent::$page->parse_template($mission_row_template, $parse_mission);
         } else {
             $i = 0;
             foreach ($missiontype as $a => $b) {
                 $parse_mission['value'] = $a;
                 $parse_mission['mission'] = $b;
                 $parse_mission['expedition_message'] = '';
                 $parse_mission['id'] = ' id="inpuT_' . $i . '" ';
                 $parse_mission['checked'] = $mission == $a ? ' checked="checked"' : '';
                 $i++;
                 $MissionSelector .= parent::$page->parse_template($mission_row_template, $parse_mission);
             }
         }
     } else {
         FunctionsLib::redirect('game.php?page=fleet1');
     }
     #####################################################################################################
     // STAY / EXPEDITION BLOCKS
     #####################################################################################################
     $stay_row['options'] = '';
     $StayBlock = '';
     if ($planet == 16) {
         $stay_row['stay_type'] = 'expeditiontime';
         foreach ($exp_values as $value) {
             $stay['value'] = $value;
             $stay['selected'] = '';
             $stay['title'] = $value;
             $stay_row['options'] .= parent::$page->parse_template($options_template, $stay);
         }
         $StayBlock = parent::$page->parse_template($stay_template, array_merge($stay_row, $this->langs));
     } elseif (isset($missiontype[5])) {
         $stay_row['stay_type'] = 'holdingtime';
         foreach ($hold_values as $value) {
             $stay['value'] = $value;
             $stay['selected'] = $value == 1 ? ' selected' : '';
             $stay['title'] = $value;
             $stay_row['options'] .= parent::$page->parse_template($options_template, $stay);
         }
         $StayBlock = parent::$page->parse_template($stay_template, array_merge($stay_row, $this->langs));
     }
     $parse['input_extra'] = $input_extra;
     $parse['missionselector'] = $MissionSelector;
     $parse['stayblock'] = $StayBlock;
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('fleet/fleet3_table'), $parse));
 }
Example #17
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     // some values by default
     $parse = $this->_lang;
     $parse['js_path'] = XGP_ROOT . JS_PATH;
     // display an specific category of items
     if (isset($_GET['dsp']) && $_GET['dsp'] == 1 && $this->_have_premium) {
         $mode = '';
         $get_messages = '';
         foreach ($_GET as $field => $value) {
             if (FunctionsLib::in_multiarray($field, $this->_message_type)) {
                 $type_id = FunctionsLib::recursive_array_search($field, $this->_message_type);
                 $get_messages .= $type_id . ',';
                 $active[$type_id] = 1;
             }
         }
         // get list of messages
         $message_list = parent::$db->query("SELECT *\n                                                                                                            FROM `" . MESSAGES . "`\n                                                                                                            WHERE `message_receiver` = " . $this->_current_user['user_id'] . "\n                                                                                                                    AND `message_type` IN (" . rtrim($get_messages, ',') . ");");
         // set messages as read
         parent::$db->query("UPDATE `" . MESSAGES . "`\n                                                                    SET `message_read` = '1'\n                                                                    WHERE `message_receiver` = " . $this->_current_user['user_id'] . "\n                                                                            AND `message_type` IN (" . rtrim($get_messages, ',') . ");");
     } else {
         $mode = isset($_GET['mode']) ? $_GET['mode'] : NULL;
     }
     // to delete something
     $to_delete = isset($_POST['deletemessages']) ? $_POST['deletemessages'] : NULL;
     if (isset($to_delete)) {
         $mode = "delete";
     }
     $write_to = isset($_GET['id']) ? (int) $_GET['id'] : NULL;
     switch ($mode) {
         case 'write':
             $text = '';
             $error_page = '';
             if (!is_numeric($write_to)) {
                 FunctionsLib::redirect('game.php?page=messages');
             } else {
                 $OwnerHome = parent::$db->queryFetch("SELECT u.`user_name`, p.`planet_galaxy`, p.`planet_system`, p.`planet_planet`\n                                                                                                                                            FROM " . PLANETS . " AS p\n                                                                                                                                            INNER JOIN " . USERS . " as u ON p.planet_user_id = u.user_id\n                                                                                                                                            WHERE p.`planet_user_id` = '" . (int) $write_to . "';");
                 if (!$OwnerHome) {
                     FunctionsLib::redirect('game.php?page=messages');
                 }
             }
             if ($_POST) {
                 $error = 0;
                 if (!$_POST['subject']) {
                     $error++;
                     $parse['error_text'] = $this->_lang['mg_no_subject'];
                     $parse['error_color'] = '#FF0000';
                     $error_page = parent::$page->parse_template(parent::$page->get_template('messages/messages_error_table'), $parse);
                 }
                 if (!$_POST['text']) {
                     $error++;
                     $parse['error_text'] = $this->_lang['mg_no_text'];
                     $parse['error_color'] = '#FF0000';
                     $error_page = parent::$page->parse_template(parent::$page->get_template('messages/messages_error_table'), $parse);
                 }
                 if ($error == 0) {
                     $parse['error_text'] = $this->_lang['mg_msg_sended'];
                     $parse['error_color'] = '#00FF00';
                     $error_page = parent::$page->parse_template(parent::$page->get_template('messages/messages_error_table'), $parse);
                     $Owner = $write_to;
                     $Sender = $this->_current_user['user_id'];
                     $From = $this->_current_user['user_name'] . ' [' . $this->_current_user['user_galaxy'] . ':' . $this->_current_user['user_system'] . ':' . $this->_current_user['user_planet'] . ']';
                     $Subject = $_POST['subject'];
                     $Message = FunctionsLib::format_text($_POST['text']);
                     FunctionsLib::send_message($Owner, $Sender, '', 4, $From, $Subject, $Message);
                     $subject = '';
                     $text = '';
                 }
             }
             $parse['id'] = $write_to;
             $parse['to'] = $OwnerHome['user_name'] . ' [' . $OwnerHome['planet_galaxy'] . ':' . $OwnerHome['planet_system'] . ':' . $OwnerHome['planet_planet'] . ']';
             $parse['subject'] = !isset($subject) ? $this->_lang['mg_no_subject'] : $subject;
             $parse['text'] = $text;
             $parse['status_message'] = $error_page;
             parent::$page->display(parent::$page->parse_template(parent::$page->get_template('messages/messages_pm_form_view'), $parse));
             break;
         case 'delete':
             if ($to_delete == 'deleteall') {
                 parent::$db->query("DELETE FROM " . MESSAGES . "\n                                                                            WHERE `message_receiver` = '" . $this->_current_user['user_id'] . "';");
             } elseif ($to_delete == 'deletemarked') {
                 foreach ($_POST as $Message => $Answer) {
                     if (preg_match("/delmes/i", $Message) && $Answer == 'on') {
                         $MessId = str_replace("delmes", "", $Message);
                         $MessHere = parent::$db->queryFetch("SELECT *\n                                                                                                                                    FROM " . MESSAGES . "\n                                                                                                                                    WHERE `message_id` = '" . (int) $MessId . "' AND\n                                                                                                                                                    `message_receiver` = '" . $this->_current_user['user_id'] . "';");
                         if ($MessHere) {
                             parent::$db->query("DELETE FROM " . MESSAGES . "\n                                                                                                            WHERE `message_id` = '" . (int) $MessId . "';");
                         }
                     }
                 }
             } elseif ($to_delete == 'deleteunmarked') {
                 foreach ($_POST as $Message => $Answer) {
                     $CurMess = preg_match("/showmes/i", $Message);
                     $MessId = str_replace("showmes", "", $Message);
                     $Selected = "delmes" . $MessId;
                     $IsSelected = $_POST[$Selected];
                     if (preg_match("/showmes/i", $Message) && !isset($IsSelected)) {
                         $MessHere = parent::$db->queryFetch("SELECT *\n                                                                                                                                    FROM " . MESSAGES . "\n                                                                                                                                    WHERE `message_id` = '" . (int) $MessId . "' AND\n                                                                                                                                                    `message_receiver` = '" . $this->_current_user['user_id'] . "';");
                         if ($MessHere) {
                             parent::$db->queryFetch("DELETE FROM " . MESSAGES . "\n                                                                                                                    WHERE `message_id` = '" . (int) $MessId . "';");
                         }
                     }
                 }
             }
             FunctionsLib::redirect('game.php?page=messages');
             break;
         default:
             if ($this->_have_premium) {
                 $type_row_template = parent::$page->get_template('messages/messages_body_premium_row_view');
                 $rows = '';
                 $this->make_counts();
                 while ($messages_list = parent::$db->fetchAssoc($this->_messages_count)) {
                     $this->_message_type[$messages_list['message_type']]['count'] = $messages_list['message_type_count'];
                     $this->_message_type[$messages_list['message_type']]['unread'] = $messages_list['unread_count'];
                 }
                 foreach ($this->_message_type as $id => $data) {
                     $parse['message_type'] = $data['type_name'];
                     $parse['message_type_name'] = $this->_lang['mg_type'][$id];
                     $parse['message_amount'] = isset($data['count']) ? $data['count'] : 0;
                     $parse['message_unread'] = isset($data['unread']) ? $data['unread'] : 0;
                     $parse['checked'] = isset($active[$id]) ? 'checked' : '';
                     $parse['checked_status'] = isset($active[$id]) ? 1 : 0;
                     $rows .= parent::$page->parse_template($type_row_template, $parse);
                 }
                 $parse['message_type_rows'] = $rows;
                 $parse['buddys_count'] = $this->_extra_count['buddys_count'];
                 $parse['alliance_count'] = $this->_extra_count['alliance_count'];
                 $parse['operators_count'] = $this->_extra_count['operators_count'];
                 $parse['notes_count'] = $this->_extra_count['notes_count'];
                 $parse['message_list'] = isset($message_list) ? $this->load_messages($message_list) : '';
                 $parse['delete_options'] = isset($_GET['dsp']) ? $this->load_delete_box() : '';
             } else {
                 // get list of messages
                 $message_list = parent::$db->query("SELECT *\n                                        FROM `" . MESSAGES . "`\n                                        WHERE `message_receiver` = " . $this->_current_user['user_id'] . " \n                                        ORDER BY `message_time` DESC;");
                 // set messages as read
                 parent::$db->query("UPDATE `" . MESSAGES . "`\n                                                                                    SET `message_read` = '1'\n                                                                                    WHERE `message_receiver` = " . $this->_current_user['user_id'] . ";");
                 $single_message_template = parent::$page->get_template('messages/messages_list_row_view');
                 $list_of_messages = '';
                 while ($message = parent::$db->fetchArray($message_list)) {
                     $message['message_text'] = nl2br($message['message_text']);
                     $message['message_time'] = date('m-d h:i:s', $message['message_time']);
                     $list_of_messages .= parent::$page->parse_template($single_message_template, $message);
                 }
                 $parse['message_list'] = $list_of_messages;
             }
             parent::$page->display(parent::$page->parse_template($this->set_default_template(), $parse));
             break;
     }
 }
Example #18
0
 /**
  * method have_access
  * param $alliance_owner
  * param $permission
  * return checks if the user is allowed to access a section
  */
 private function have_access($alliance_owner, $permission)
 {
     if ($alliance_owner != $this->_current_user['user_id'] && !$permission) {
         FunctionsLib::redirect('game.php?page=alliance');
     } else {
         return TRUE;
     }
 }
Example #19
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $parse = $this->_lang;
     $game_metal_basic_income = FunctionsLib::read_config('metal_basic_income');
     $game_crystal_basic_income = FunctionsLib::read_config('crystal_basic_income');
     $game_deuterium_basic_income = FunctionsLib::read_config('deuterium_basic_income');
     $game_energy_basic_income = FunctionsLib::read_config('energy_basic_income');
     $game_resource_multiplier = FunctionsLib::read_config('resource_multiplier');
     if ($this->_current_planet['planet_type'] == 3) {
         $game_metal_basic_income = 0;
         $game_crystal_basic_income = 0;
         $game_deuterium_basic_income = 0;
     }
     $this->_current_planet['planet_metal_max'] = ProductionLib::maxStorable($this->_current_planet[$this->_resource[22]]);
     $this->_current_planet['planet_crystal_max'] = ProductionLib::maxStorable($this->_current_planet[$this->_resource[23]]);
     $this->_current_planet['planet_deuterium_max'] = ProductionLib::maxStorable($this->_current_planet[$this->_resource[24]]);
     $parse['production_level'] = 100;
     $post_porcent = ProductionLib::maxProduction($this->_current_planet['planet_energy_max'], $this->_current_planet['planet_energy_used']);
     $parse['resource_row'] = '';
     $this->_current_planet['planet_metal_perhour'] = 0;
     $this->_current_planet['planet_crystal_perhour'] = 0;
     $this->_current_planet['planet_deuterium_perhour'] = 0;
     $this->_current_planet['planet_energy_max'] = 0;
     $this->_current_planet['planet_energy_used'] = 0;
     $BuildTemp = $this->_current_planet['planet_temp_max'];
     $ResourcesRowTPL = parent::$page->get_template('resources/resources_row');
     foreach ($this->_reslist['prod'] as $ProdID) {
         if ($this->_current_planet[$this->_resource[$ProdID]] > 0 && isset($this->_prod_grid[$ProdID])) {
             $BuildLevelFactor = $this->_current_planet['planet_' . $this->_resource[$ProdID] . '_porcent'];
             $BuildLevel = $this->_current_planet[$this->_resource[$ProdID]];
             $BuildEnergy = $this->_current_user['research_energy_technology'];
             // BOOST
             $geologe_boost = 1 + 1 * (OfficiersLib::isOfficierActive($this->_current_user['premium_officier_geologist']) ? GEOLOGUE : 0);
             $engineer_boost = 1 + 1 * (OfficiersLib::isOfficierActive($this->_current_user['premium_officier_engineer']) ? ENGINEER_ENERGY : 0);
             // PRODUCTION FORMULAS
             $metal_prod = eval($this->_prod_grid[$ProdID]['formule']['metal']);
             $crystal_prod = eval($this->_prod_grid[$ProdID]['formule']['crystal']);
             $deuterium_prod = eval($this->_prod_grid[$ProdID]['formule']['deuterium']);
             $energy_prod = eval($this->_prod_grid[$ProdID]['formule']['energy']);
             // PRODUCTION
             $metal = ProductionLib::productionAmount($metal_prod, $geologe_boost);
             $crystal = ProductionLib::productionAmount($crystal_prod, $geologe_boost);
             $deuterium = ProductionLib::productionAmount($deuterium_prod, $geologe_boost);
             if ($ProdID >= 4) {
                 $energy = ProductionLib::productionAmount($energy_prod, $engineer_boost, TRUE);
             } else {
                 $energy = ProductionLib::productionAmount($energy_prod, 1, TRUE);
             }
             if ($energy > 0) {
                 $this->_current_planet['planet_energy_max'] += $energy;
             } else {
                 $this->_current_planet['planet_energy_used'] += $energy;
             }
             $this->_current_planet['planet_metal_perhour'] += $metal;
             $this->_current_planet['planet_crystal_perhour'] += $crystal;
             $this->_current_planet['planet_deuterium_perhour'] += $deuterium;
             $metal = ProductionLib::currentProduction($metal, $post_porcent);
             $crystal = ProductionLib::currentProduction($crystal, $post_porcent);
             $deuterium = ProductionLib::currentProduction($deuterium, $post_porcent);
             $energy = ProductionLib::currentProduction($energy, $post_porcent);
             $Field = 'planet_' . $this->_resource[$ProdID] . '_porcent';
             $CurrRow = array();
             $CurrRow['name'] = $this->_resource[$ProdID];
             $CurrRow['porcent'] = $this->_current_planet[$Field];
             $CurrRow['option'] = $this->build_options($CurrRow['porcent']);
             $CurrRow['type'] = $this->_lang['tech'][$ProdID];
             $CurrRow['level'] = $ProdID > 200 ? $this->_lang['rs_amount'] : $this->_lang['rs_lvl'];
             $CurrRow['level_type'] = $this->_current_planet[$this->_resource[$ProdID]];
             $CurrRow['metal_type'] = FormatLib::pretty_number($metal);
             $CurrRow['crystal_type'] = FormatLib::pretty_number($crystal);
             $CurrRow['deuterium_type'] = FormatLib::pretty_number($deuterium);
             $CurrRow['energy_type'] = FormatLib::pretty_number($energy);
             $CurrRow['metal_type'] = FormatLib::color_number($CurrRow['metal_type']);
             $CurrRow['crystal_type'] = FormatLib::color_number($CurrRow['crystal_type']);
             $CurrRow['deuterium_type'] = FormatLib::color_number($CurrRow['deuterium_type']);
             $CurrRow['energy_type'] = FormatLib::color_number($CurrRow['energy_type']);
             $parse['resource_row'] .= parent::$page->parse_template($ResourcesRowTPL, $CurrRow);
         }
     }
     $parse['Production_of_resources_in_the_planet'] = str_replace('%s', $this->_current_planet['planet_name'], $this->_lang['rs_production_on_planet']);
     $parse['production_level'] = $this->prod_level($this->_current_planet['planet_energy_used'], $this->_current_planet['planet_energy_max']);
     $parse['metal_basic_income'] = $game_metal_basic_income;
     $parse['crystal_basic_income'] = $game_crystal_basic_income;
     $parse['deuterium_basic_income'] = $game_deuterium_basic_income;
     $parse['energy_basic_income'] = $game_energy_basic_income;
     $parse['planet_metal_max'] = $this->resource_color($this->_current_planet['planet_metal'], $this->_current_planet['planet_metal_max']);
     $parse['planet_crystal_max'] = $this->resource_color($this->_current_planet['planet_crystal'], $this->_current_planet['planet_crystal_max']);
     $parse['planet_deuterium_max'] = $this->resource_color($this->_current_planet['planet_deuterium'], $this->_current_planet['planet_deuterium_max']);
     $parse['metal_total'] = FormatLib::color_number(FormatLib::pretty_number(floor($this->_current_planet['planet_metal_perhour'] * 0.01 * $parse['production_level'] + $parse['metal_basic_income'])));
     $parse['crystal_total'] = FormatLib::color_number(FormatLib::pretty_number(floor($this->_current_planet['planet_crystal_perhour'] * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'])));
     $parse['deuterium_total'] = FormatLib::color_number(FormatLib::pretty_number(floor($this->_current_planet['planet_deuterium_perhour'] * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'])));
     $parse['energy_total'] = FormatLib::color_number(FormatLib::pretty_number(floor($this->_current_planet['planet_energy_max'] + $parse['energy_basic_income'] + $this->_current_planet['planet_energy_used'])));
     $parse['daily_metal'] = $this->calculate_daily($this->_current_planet['planet_metal_perhour'], $parse['production_level'], $parse['metal_basic_income']);
     $parse['weekly_metal'] = $this->calculate_weekly($this->_current_planet['planet_metal_perhour'], $parse['production_level'], $parse['metal_basic_income']);
     $parse['daily_crystal'] = $this->calculate_daily($this->_current_planet['planet_crystal_perhour'], $parse['production_level'], $parse['crystal_basic_income']);
     $parse['weekly_crystal'] = $this->calculate_weekly($this->_current_planet['planet_crystal_perhour'], $parse['production_level'], $parse['crystal_basic_income']);
     $parse['daily_deuterium'] = $this->calculate_daily($this->_current_planet['planet_deuterium_perhour'], $parse['production_level'], $parse['deuterium_basic_income']);
     $parse['weekly_deuterium'] = $this->calculate_weekly($this->_current_planet['planet_deuterium_perhour'], $parse['production_level'], $parse['deuterium_basic_income']);
     $parse['daily_metal'] = FormatLib::color_number(FormatLib::pretty_number($parse['daily_metal']));
     $parse['weekly_metal'] = FormatLib::color_number(FormatLib::pretty_number($parse['weekly_metal']));
     $parse['daily_crystal'] = FormatLib::color_number(FormatLib::pretty_number($parse['daily_crystal']));
     $parse['weekly_crystal'] = FormatLib::color_number(FormatLib::pretty_number($parse['weekly_crystal']));
     $parse['daily_deuterium'] = FormatLib::color_number(FormatLib::pretty_number($parse['daily_deuterium']));
     $parse['weekly_deuterium'] = FormatLib::color_number(FormatLib::pretty_number($parse['weekly_deuterium']));
     $ValidList['percent'] = array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100);
     $SubQry = '';
     if ($_POST && !parent::$users->is_on_vacations($this->_current_user)) {
         foreach ($_POST as $Field => $Value) {
             $FieldName = 'planet_' . $Field . '_porcent';
             if (isset($this->_current_planet[$FieldName])) {
                 if (!in_array($Value, $ValidList['percent'])) {
                     FunctionsLib::redirect('game.php?page=resourceSettings');
                 }
                 $Value = $Value / 10;
                 $this->_current_planet[$FieldName] = $Value;
                 $SubQry .= ", `" . $FieldName . "` = '" . $Value . "'";
             }
         }
         parent::$db->query("UPDATE " . PLANETS . " SET\n\t\t\t\t\t\t\t\t\t`planet_id` = '" . $this->_current_planet['planet_id'] . "'\n\t\t\t\t\t\t\t\t\t{$SubQry}\n\t\t\t\t\t\t\t\t\tWHERE `planet_id` = '" . $this->_current_planet['planet_id'] . "';");
         FunctionsLib::redirect('game.php?page=resourceSettings');
     }
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('resources/resources'), $parse));
 }
Example #20
0
    ini_set('display_errors', 1);
    error_reporting(E_ALL);
} else {
    // Only for Betas, it's going to be changed
    ini_set('display_errors', 1);
    error_reporting(E_ALL);
}
$debug = FunctionsLib::load_library('DebugLib');
$db = new Database();
$installed = FunctionsLib::read_config('game_installed');
$game_version = FunctionsLib::read_config('version');
$game_lang = FunctionsLib::read_config('lang');
$current_page = isset($_GET['page']) ? $_GET['page'] : '';
// check if is installed
if ($installed == 0 && !defined('IN_INSTALL')) {
    FunctionsLib::redirect(XGP_ROOT . 'install/');
}
// define game version
if ($installed != 0) {
    define('VERSION', $game_version == '' ? '' : 'v' . $game_version);
}
// define game language
define('DEFAULT_LANG', $game_lang == '' ? 'spanish' : $game_lang);
if (!defined('IN_INSTALL')) {
    require_once XGP_ROOT . CORE_PATH . 'Sessions.php';
    require_once XGP_ROOT . CORE_PATH . 'Hooks.php';
    require_once XGP_ROOT . LIB_PATH . 'StatisticsLib.php';
    require_once XGP_ROOT . LIB_PATH . 'UpdateResourcesLib.php';
    require_once XGP_ROOT . LIB_PATH . 'UpdateLib.php';
    // Sessions
    $session = new Sessions();
Example #21
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->queryFetch("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']) {
                             FunctionsLib::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']) {
                             FunctionsLib::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']) {
                             FunctionsLib::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']) {
                             FunctionsLib::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'] . "') ");
                     FunctionsLib::redirect('game.php?page=buddy');
                     break;
                     // ACCEPT
                 // ACCEPT
                 case 2:
                     $senderID = parent::$db->queryFetch("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) . "'");
                     FunctionsLib::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'] . "'");
                     FunctionsLib::redirect('game.php?page=buddy');
                     break;
                     // SEND REQUEST
                 // SEND REQUEST
                 case 3:
                     $query = parent::$db->queryFetch("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->escapeValue(strip_tags($_POST['text']));
                         FunctionsLib::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 . "'");
                         FunctionsLib::redirect('game.php?page=buddy');
                     } else {
                         FunctionsLib::message($this->_lang['bu_request_exists'], 'game.php?page=buddy', 2, FALSE, FALSE, FALSE);
                     }
                     break;
                     // ANY OTHER OPTION EXIT
                 // ANY OTHER OPTION EXIT
                 default:
                     FunctionsLib::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']) {
                 FunctionsLib::message($this->_lang['bu_cannot_request_yourself'], 'game.php?page=buddy', 2, FALSE, FALSE, FALSE);
             } else {
                 // SEARCH THE PLAYER
                 $player = parent::$db->queryFetch("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 {
                     FunctionsLib::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->fetchAssoc($getBuddys)) {
                 if ($buddy['buddy_status'] == 0) {
                     if ($buddy['buddy_sender'] == $this->_current_user['user_id']) {
                         $buddy_receiver = parent::$db->queryFetch("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->queryFetch("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->queryFetch("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->queryFetch("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;
     }
 }
Example #22
0
 public function build_page()
 {
     $parse = $this->_lang;
     if (isset($_POST['fmenge'])) {
         $AddedInQueue = FALSE;
         $totalCount = 0;
         foreach ($_POST['fmenge'] as $Element => $Count) {
             if ($Element < 200 or $Element > 300) {
                 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 (DevelopmentsLib::is_development_allowed($this->_current_user, $this->_current_planet, $Element)) {
                     $MaxElements = $this->GetMaxConstructibleElements($Element, $this->_current_planet);
                     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\n                                                                            p.`planet_b_hangar_id` = '" . $this->_current_planet['planet_b_hangar_id'] . "',\n                                                                            p.`planet_metal` = '" . $this->_current_planet['planet_metal'] . "',\n                                                                            p.`planet_crystal` = '" . $this->_current_planet['planet_crystal'] . "',\n                                                                            p.`planet_deuterium` = '" . $this->_current_planet['planet_deuterium'] . "'\n                                                                            WHERE p.`planet_id` = '" . $this->_current_planet['planet_id'] . "';");
         }
         FunctionsLib::redirect('game.php?page=shipyard');
     }
     if ($this->_current_planet[$this->_resource[21]] == 0) {
         FunctionsLib::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 > 201 && $Element <= 399) {
             if (DevelopmentsLib::is_development_allowed($this->_current_user, $this->_current_planet, $Element)) {
                 $CanBuildOne = DevelopmentsLib::is_development_payable($this->_current_user, $this->_current_planet, $Element, FALSE);
                 $BuildOneElementTime = DevelopmentsLib::development_time($this->_current_user, $this->_current_planet, $Element);
                 $ElementCount = $this->_current_planet[$this->_resource[$Element]];
                 $ElementNbre = $ElementCount == 0 ? "" : " (" . $this->_lang['bd_available'] . FormatLib::pretty_number($ElementCount) . ")";
                 $parse['dpath'] = DPATH;
                 $parse['add_element'] = '';
                 $parse['element'] = $Element;
                 $parse['element_name'] = $ElementName;
                 $parse['element_description'] = $this->_lang['res']['descriptions'][$Element];
                 $parse['element_price'] = DevelopmentsLib::formated_development_price($this->_current_user, $this->_current_planet, $Element, FALSE);
                 $parse['building_time'] = DevelopmentsLib::formated_development_time($BuildOneElementTime);
                 $parse['element_nbre'] = $ElementNbre;
                 if ($CanBuildOne && $NotBuilding && !parent::$users->is_on_vacations($this->_current_user)) {
                     $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_fleet'] = '<tr><td class="c" colspan="2" align="center"><input type="submit" value="' . $this->_lang['bd_build_ships'] . '"></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('shipyard');
     }
     $parse['buildlist'] = $PageTable;
     $parse['buildinglist'] = $BuildQueue;
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('buildings/buildings_fleet'), $parse));
 }
Example #23
0
 /**
  * method refresh_page
  * param
  * return refresh the page
  */
 private function refresh_page()
 {
     // SET PARAMS
     $page = isset($_GET['page']) ? '?page=' . $_GET['page'] : '';
     $type = isset($_GET['type']) ? '&type=' . $_GET['type'] : '';
     $user = isset($_GET['user']) ? '&user='******'user'] : '';
     // REDIRECTION
     FunctionsLib::redirect("admin.php{$page}{$type}{$user}");
 }
Example #24
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     #####################################################################################################
     // SOME DEFAULT VALUES
     #####################################################################################################
     // LOAD TEMPLATES REQUIRED
     $options_template = parent::$page->get_template('fleet/fleet_options');
     // LANGUAGE
     $parse = $this->_lang;
     // OTHER VALUES
     $this->_fleet_id = isset($_GET['fleet']) ? (int) $_GET['fleet'] : NULL;
     $union = isset($_GET['union']) ? (int) $_GET['union'] : NULL;
     $acs_user_message = '';
     if (!is_numeric($this->_fleet_id) or empty($this->_fleet_id) or !is_numeric($union) or empty($union)) {
         FunctionsLib::redirect('game.php?page=fleet1');
     }
     // QUERY
     $fleet = parent::$db->queryFetch("SELECT `fleet_id`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_start_time`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_end_time`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_mess`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_group`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_end_galaxy`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_end_system`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_end_planet`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`fleet_end_type`\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_id = '" . intval($this->_fleet_id) . "'");
     $query_buddies = parent::$db->query("SELECT `user_id`, `user_name`\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . BUDDY . " AS b\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN " . USERS . " AS u ON ((u.user_id = b.buddy_sender) OR (u.user_id = b.buddy_receiver))\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE (`buddy_sender` = '" . $this->_current_user['user_id'] . "' OR\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`buddy_receiver` = '" . $this->_current_user['user_id'] . "') AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`buddy_status` = '1';");
     if ($fleet['fleet_id'] == '') {
         FunctionsLib::redirect('game.php?page=fleet1');
     }
     // ACTIONS
     if ($_POST['save_acs']) {
         $this->set_name($_POST['name_acs']);
     }
     // REMOVE A MEMBER
     if ($_POST['remove']) {
         $this->remove_user($_POST['members_list']);
     }
     // ADD A MEMBER
     if ($_POST['search_user'] or $_POST['add']) {
         $user_to_add = $_POST['search_user'] ? '' : $_POST['add'] ? $_POST['friends_list'] : '';
         if ($this->add_user($user_to_add)) {
             $acs_user_message = "<font color=\"lime\">" . $this->_lang['fl_player'] . " " . $_POST['addtogroup'] . " " . $this->_lang['fl_add_to_attack'] . "</font>";
         } else {
             $acs_user_message = "<font color=\"red\">" . $this->_lang['fl_player'] . " " . $_POST['addtogroup'] . " " . $this->_lang['fl_dont_exist'] . "</font>";
         }
     }
     if ($fleet['fleet_start_time'] <= time() or $fleet['fleet_end_time'] < time() or $fleet['fleet_mess'] == 1) {
         FunctionsLib::redirect('game.php?page=fleet1');
     }
     if (empty($fleet['fleet_group'])) {
         $rand = mt_rand(100000, 999999999);
         $acs_code = "AG" . $rand;
         $federation_invited = intval($this->_current_user['user_id']);
         parent::$db->query("INSERT INTO " . ACS_FLEETS . " SET\n\t\t\t\t\t\t\t\t\t`acs_fleet_name` = '" . $acs_code . "',\n\t\t\t\t\t\t\t\t\t`acs_fleet_members` = '" . $this->_current_user['user_id'] . "',\n\t\t\t\t\t\t\t\t\t`acs_fleet_fleets` = '" . $this->_fleet_id . "',\n\t\t\t\t\t\t\t\t\t`acs_fleet_galaxy` = '" . $fleet['fleet_end_galaxy'] . "',\n\t\t\t\t\t\t\t\t\t`acs_fleet_system` = '" . $fleet['fleet_end_system'] . "',\n\t\t\t\t\t\t\t\t\t`acs_fleet_planet` = '" . $fleet['fleet_end_planet'] . "',\n\t\t\t\t\t\t\t\t\t`acs_fleet_planet_type` = '" . $fleet['fleet_end_type'] . "',\n\t\t\t\t\t\t\t\t\t`acs_fleet_invited` = '" . $federation_invited . "'");
         $acs_id = parent::$db->insertId();
         $acs_madnessred = parent::$db->query("SELECT `acs_fleet_invited`, `acs_fleet_name`\n\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\tWHERE `acs_fleet_name` = '" . $acs_code . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`acs_fleet_members` = '" . $this->_current_user['user_id'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`acs_fleet_fleets` = '" . $this->_fleet_id . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`acs_fleet_galaxy` = '" . $fleet['fleet_end_galaxy'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`acs_fleet_system` = '" . $fleet['fleet_end_system'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`acs_fleet_planet` = '" . $fleet['fleet_end_planet'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`acs_fleet_invited` = '" . $this->_current_user['user_id'] . "'");
         parent::$db->query("UPDATE " . FLEETS . "\n\t\t\t\t\t\t\t\t\tSET fleet_group = '" . $acs_id . "'\n\t\t\t\t\t\t\t\t\tWHERE fleet_id = '" . intval($this->_fleet_id) . "'");
     } else {
         $acs_madnessred = parent::$db->query("SELECT `acs_fleet_invited`, `acs_fleet_name`\n\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\tWHERE acs_fleet_id = '" . intval($fleet['fleet_group']) . "'");
     }
     $row = parent::$db->fetchArray($acs_madnessred);
     $federation_invited = $row['acs_fleet_invited'];
     $parse['acs_code'] = $row['acs_fleet_name'];
     $members = explode(",", $federation_invited);
     $members_count = 0;
     foreach ($members as $a => $b) {
         if ($b != '') {
             $member_qry = parent::$db->query("SELECT `user_name`\n\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\tWHERE `user_id` ='" . intval($b) . "' ;");
             while ($row = parent::$db->fetchArray($member_qry)) {
                 $members_option['value'] = $row['user_name'];
                 $members_option['selected'] = '';
                 $members_option['title'] = $row['user_name'];
                 $members_row .= parent::$page->parse_template($options_template, $members_option);
             }
         }
         $members_count++;
     }
     while ($buddies = parent::$db->fetchArray($query_buddies)) {
         if ($buddies['user_id'] != $this->_current_user['user_id']) {
             $members_option['value'] = $buddies['user_name'];
             $members_option['selected'] = '';
             $members_option['title'] = $buddies['user_name'];
             $friends_row .= parent::$page->parse_template($options_template, $members_option);
         }
     }
     $parse['friends'] = $friends_row;
     $parse['invited_count'] = $members_count;
     $parse['invited_members'] = $members_row;
     $parse['fleetid'] = $_GET['fleetid'];
     $parse['federation_invited'] = $federation_invited;
     $parse['add_user_message'] = $acs_user_message;
     parent::$page->display(parent::$page->parse_template(parent::$page->get_template('fleet/fleet_federation'), $parse), FALSE, '', FALSE);
 }
 /**
  * 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(FunctionsLib::message($this->langs['ins_already_installed'], '', '', false, false));
     }
     if (!$this->checkXmlFile()) {
         die(FunctionsLib::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) {
                 FunctionsLib::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) {
                 FunctionsLib::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) {
                 FunctionsLib::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':
             FunctionsLib::redirect('?page=install&mode=step5');
             break;
         case 'step5':
             $create_account_status = $this->createAccount();
             if ($create_account_status < 0) {
                 // Failure
                 if ($create_account_status == -1) {
                     $error_message = $this->langs['ins_adm_empty_fields_error'];
                 } else {
                     $error_message = $this->langs['ins_adm_invalid_email_address'];
                 }
                 $parse['alert'] = $this->saveMessage($error_message, 'warning');
                 $current_page = parent::$page->parse_template(parent::$page->get_template('install/in_create_admin_view'), $parse);
                 $continue = false;
             }
             if ($continue) {
                 FunctionsLib::update_config('stat_last_update', time());
                 FunctionsLib::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);
 }
Example #26
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $resource = parent::$objects->getObjects();
     $pricelist = parent::$objects->getPrice();
     $reslist = parent::$objects->getObjectsList();
     $parse = $this->_lang;
     if (parent::$users->is_on_vacations($this->_current_user)) {
         exit(FunctionsLib::message($this->_lang['fl_vacation_mode_active'], "game.php?page=overview", 2));
     }
     $fleet_group_mr = 0;
     if ($_POST['fleet_group'] > 0) {
         if ($_POST['mission'] == 2) {
             $target = 'g' . (int) $_POST['galaxy'] . 's' . (int) $_POST['system'] . 'p' . (int) $_POST['planet'] . 't' . (int) $_POST['planettype'];
             if ($_POST['acs_target_mr'] == $target) {
                 $aks_count_mr = parent::$db->query("SELECT COUNT(`acs_fleet_id`)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . ACS_FLEETS . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `acs_fleet_id` = '" . (int) $_POST['fleet_group'] . "'");
                 if ($aks_count_mr > 0) {
                     $fleet_group_mr = $_POST['fleet_group'];
                 }
             }
         }
     }
     if ($_POST['fleet_group'] == 0 && $_POST['mission'] == 2) {
         $_POST['mission'] = 1;
     }
     $TargetPlanet = parent::$db->queryFetch("SELECT `planet_user_id`,`planet_destroyed`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . PLANETS . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t WHERE `planet_galaxy` = '" . (int) $_POST['galaxy'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t`planet_system` = '" . (int) $_POST['system'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t`planet_planet` = '" . (int) $_POST['planet'] . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t`planet_type` = '" . (int) $_POST['planettype'] . "';");
     $MyDBRec = parent::$db->queryFetch("SELECT u.`user_id`, u.`user_onlinetime`, u.`user_ally_id`, s.`setting_vacations_status`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . " AS u, " . SETTINGS . " AS s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE u.`user_id` = '" . $this->_current_user['user_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND s.`setting_user_id` = '" . $this->_current_user['user_id'] . "';");
     $fleetarray = unserialize(base64_decode(str_rot13($_POST['usedfleet'])));
     if ($TargetPlanet['planet_destroyed'] != 0) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if (!is_array($fleetarray)) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     foreach ($fleetarray as $Ship => $Count) {
         $Count = intval($Count);
         if ($Count > $this->_current_planet[$resource[$Ship]]) {
             FunctionsLib::redirect('game.php?page=movement');
         }
     }
     $error = 0;
     $galaxy = (int) $_POST['galaxy'];
     $system = (int) $_POST['system'];
     $planet = (int) $_POST['planet'];
     $planettype = (int) $_POST['planettype'];
     $fleetmission = (int) $_POST['mission'];
     //fix by jstar
     if ($fleetmission == 7 && !isset($fleetarray[208])) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if ($planettype != 1 && $planettype != 2 && $planettype != 3) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     //fix invisible debris like ogame by jstar
     if ($fleetmission == 8) {
         $YourPlanet = FALSE;
         $UsedPlanet = FALSE;
         $select = parent::$db->queryFetch("SELECT COUNT(*) AS count, p.*\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . PLANETS . "` AS p\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . $galaxy . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . $system . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . $planet . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = 1;");
         if ($select['planet_debris_metal'] == 0 && $select['planet_debris_crystal'] == 0 && time() > $select['planet_invisible_start_time'] + DEBRIS_LIFE_TIME) {
             FunctionsLib::redirect('game.php?page=movement');
         }
     } else {
         $YourPlanet = FALSE;
         $UsedPlanet = FALSE;
         $select = parent::$db->queryFetch("SELECT COUNT(*) AS count, p.`planet_user_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . PLANETS . "` AS p\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `planet_galaxy` = '" . $galaxy . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_system` = '" . $system . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_planet` = '" . $planet . "' AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`planet_type` = '" . $planettype . "'");
     }
     if ($this->_current_planet['planet_galaxy'] == $galaxy && $this->_current_planet['planet_system'] == $system && $this->_current_planet['planet_planet'] == $planet && $this->_current_planet['planet_type'] == $planettype) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if ($_POST['mission'] != 15) {
         if ($select['count'] < 1 && $fleetmission != 7) {
             FunctionsLib::redirect('game.php?page=movement');
         } elseif ($fleetmission == 9 && $select['count'] < 1) {
             FunctionsLib::redirect('game.php?page=movement');
         }
     } else {
         $MaxExpedition = $this->_current_user[$resource[124]];
         if ($MaxExpedition >= 1) {
             $maxexpde = parent::$db->queryFetch("SELECT COUNT(fleet_owner) AS `expedi`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_owner` = '" . $this->_current_user['user_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `fleet_mission` = '15';");
             $ExpeditionEnCours = $maxexpde['expedi'];
             $EnvoiMaxExpedition = FleetsLib::get_max_expeditions($MaxExpedition);
         } else {
             $ExpeditionEnCours = 0;
             $EnvoiMaxExpedition = 0;
         }
         if ($EnvoiMaxExpedition == 0) {
             FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_expedition_tech_required'] . "</b></font>", "game.php?page=movement", 2);
         } elseif ($ExpeditionEnCours >= $EnvoiMaxExpedition) {
             FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_expedition_fleets_limit'] . "</b></font>", "game.php?page=movement", 2);
         }
     }
     if ($select['planet_user_id'] == $this->_current_user['user_id']) {
         $YourPlanet = TRUE;
         $UsedPlanet = TRUE;
     } elseif (!empty($select['planet_user_id'])) {
         $YourPlanet = FALSE;
         $UsedPlanet = TRUE;
     } else {
         $YourPlanet = FALSE;
         $UsedPlanet = FALSE;
     }
     //fix by jstar
     if ($fleetmission == 9) {
         $countfleettype = count($fleetarray);
         if ($YourPlanet or !$UsedPlanet or $planettype != 3) {
             FunctionsLib::redirect('game.php?page=movement');
         } elseif ($countfleettype == 1 && !isset($fleetarray[214])) {
             FunctionsLib::redirect('game.php?page=movement');
         } elseif ($countfleettype == 2 && !isset($fleetarray[214])) {
             FunctionsLib::redirect('game.php?page=movement');
         } elseif ($countfleettype > 2) {
             FunctionsLib::redirect('game.php?page=movement');
         }
     }
     if (empty($fleetmission)) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if ($TargetPlanet['planet_user_id'] == '') {
         $HeDBRec = $MyDBRec;
     } elseif ($TargetPlanet['planet_user_id'] != '') {
         $HeDBRec = parent::$db->queryFetch("SELECT u.`user_id`, u.`user_onlinetime`, u.`user_ally_id`, s.`setting_vacations_status`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . USERS . " AS u, " . SETTINGS . " AS s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE u.`user_id` = '" . $TargetPlanet['planet_user_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND s.`setting_user_id` ='" . $TargetPlanet['planet_user_id'] . "';");
     }
     $user_points = $this->_noob->return_points($MyDBRec['user_id'], $HeDBRec['user_id']);
     $MyGameLevel = $user_points['user_points'];
     $HeGameLevel = $user_points['target_points'];
     if ($HeDBRec['user_onlinetime'] >= time() - 60 * 60 * 24 * 7) {
         if ($this->_noob->is_weak($MyGameLevel, $HeGameLevel) && $TargetPlanet['planet_user_id'] != '' && ($_POST['mission'] == 1 or $_POST['mission'] == 6 or $_POST['mission'] == 9)) {
             FunctionsLib::message("<font color=\"lime\"><b>" . $this->_lang['fl_week_player'] . "</b></font>", "game.php?page=movement", 2);
         }
         if ($this->_noob->is_strong($MyGameLevel, $HeGameLevel) && $TargetPlanet['planet_user_id'] != '' && ($_POST['mission'] == 1 or $_POST['mission'] == 5 or $_POST['mission'] == 6 or $_POST['mission'] == 9)) {
             FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_strong_player'] . "</b></font>", "game.php?page=movement", 2);
         }
     }
     if ($HeDBRec['setting_vacations_status'] && $_POST['mission'] != 8) {
         FunctionsLib::message("<font color=\"lime\"><b>" . $this->_lang['fl_in_vacation_player'] . "</b></font>", "game.php?page=movement", 2);
     }
     $FlyingFleets = parent::$db->queryFetch("SELECT COUNT(fleet_id) as Number\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_owner`='" . $this->_current_user['user_id'] . "'");
     $ActualFleets = $FlyingFleets['Number'];
     if (FleetsLib::get_max_fleets($this->_current_user[$resource[108]], $this->_current_user['premium_officier_admiral']) <= $ActualFleets) {
         FunctionsLib::message($this->_lang['fl_no_slots'], "game.php?page=movement", 1);
     }
     if ($_POST['resource1'] + $_POST['resource2'] + $_POST['resource3'] < 1 && $_POST['mission'] == 3) {
         FunctionsLib::message("<font color=\"lime\"><b>" . $this->_lang['fl_empty_transport'] . "</b></font>", "game.php?page=movement", 1);
     }
     if ($_POST['mission'] != 15) {
         if ($TargetPlanet['planet_user_id'] == '' && $_POST['mission'] < 7) {
             FunctionsLib::redirect('game.php?page=movement');
         }
         if ($TargetPlanet['planet_user_id'] != '' && $_POST['mission'] == 7) {
             FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_planet_populed'] . "</b></font>", "game.php?page=movement", 2);
         }
         if ($HeDBRec['user_ally_id'] != $MyDBRec['user_ally_id'] && $_POST['mission'] == 4) {
             FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_stay_not_on_enemy'] . "</b></font>", "game.php?page=movement", 2);
         }
         if ($TargetPlanet['planet_user_id'] == $this->_current_planet['planet_user_id'] && ($_POST['mission'] == 1 or $_POST['mission'] == 6)) {
             FunctionsLib::redirect('game.php?page=movement');
         }
         if ($TargetPlanet['planet_user_id'] != $this->_current_planet['planet_user_id'] && $_POST['mission'] == 4) {
             FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_deploy_only_your_planets'] . "</b></font>", "game.php?page=movement", 2);
         }
         if ($_POST['mission'] == 5) {
             $buddy = parent::$db->queryFetch("SELECT COUNT( * ) AS buddys\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM  `" . BUDDY . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbuddy_sender ='" . intval($this->_current_planet['planet_user_id']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND buddy_receiver ='" . intval($TargetPlanet['planet_user_id']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tOR (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbuddy_sender ='" . intval($TargetPlanet['planet_user_id']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND buddy_receiver ='" . intval($this->_current_planet['planet_user_id']) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND buddy_status =1");
             if ($HeDBRec['user_ally_id'] != $MyDBRec['user_ally_id'] && $buddy['buddys'] < 1) {
                 FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_stay_not_on_enemy'] . "</b></font>", "game.php?page=movement", 2);
             }
         }
     }
     $missiontype = FleetsLib::get_missions();
     $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
     $AllFleetSpeed = FleetsLib::fleet_max_speed($fleetarray, 0, $this->_current_user);
     $GenFleetSpeed = $_POST['speed'];
     $SpeedFactor = FunctionsLib::fleet_speed_factor();
     $MaxFleetSpeed = min($AllFleetSpeed);
     if (!in_array($GenFleetSpeed, $speed_possible)) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if ($MaxFleetSpeed != $_POST['speedallsmin']) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if (!$_POST['planettype']) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if (!$_POST['galaxy'] || !is_numeric($_POST['galaxy']) || $_POST['galaxy'] > MAX_GALAXY_IN_WORLD || $_POST['galaxy'] < 1) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if (!$_POST['system'] || !is_numeric($_POST['system']) || $_POST['system'] > MAX_SYSTEM_IN_GALAXY || $_POST['system'] < 1) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if (!$_POST['planet'] || !is_numeric($_POST['planet']) || $_POST['planet'] > MAX_PLANET_IN_SYSTEM + 1 || $_POST['planet'] < 1) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if ($_POST['thisgalaxy'] != $this->_current_planet['planet_galaxy'] | $_POST['thissystem'] != $this->_current_planet['planet_system'] | $_POST['thisplanet'] != $this->_current_planet['planet_planet'] | $_POST['thisplanettype'] != $this->_current_planet['planet_type']) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     if (!isset($fleetarray)) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     $distance = FleetsLib::target_distance($_POST['thisgalaxy'], $_POST['galaxy'], $_POST['thissystem'], $_POST['system'], $_POST['thisplanet'], $_POST['planet']);
     $duration = FleetsLib::mission_duration($GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor);
     $consumption = FleetsLib::fleet_consumption($fleetarray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $this->_current_user);
     $fleet['start_time'] = $duration + time();
     // START CODE BY JSTAR
     if ($_POST['mission'] == 15) {
         $StayDuration = floor($_POST['expeditiontime']);
         if ($StayDuration > 0) {
             $StayDuration = $StayDuration * 3600;
             $StayTime = $fleet['start_time'] + $StayDuration;
         } else {
             FunctionsLib::redirect('game.php?page=movement');
         }
     } elseif ($_POST['mission'] == 5) {
         $StayDuration = $_POST['holdingtime'] * 3600;
         $StayTime = $fleet['start_time'] + $_POST['holdingtime'] * 3600;
     } else {
         $StayDuration = 0;
         $StayTime = 0;
     }
     $fleet['end_time'] = $StayDuration + 2 * $duration + time();
     $FleetStorage = 0;
     $FleetShipCount = 0;
     $fleet_array = "";
     $FleetSubQRY = "";
     //fix by jstar
     $haveSpyProbos = FALSE;
     foreach ($fleetarray as $Ship => $Count) {
         $Count = intval($Count);
         if ($Ship == 210) {
             $haveSpyProbos = TRUE;
         }
         $FleetStorage += $pricelist[$Ship]['capacity'] * $Count;
         $FleetShipCount += $Count;
         $fleet_array .= $Ship . "," . $Count . ";";
         $FleetSubQRY .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` - " . $Count . ", ";
     }
     if (!$haveSpyProbos && $_POST['mission'] == 6) {
         FunctionsLib::redirect('game.php?page=movement');
     }
     $FleetStorage -= $consumption;
     $StorageNeeded = 0;
     $_POST['resource1'] = max(0, (int) trim($_POST['resource1']));
     $_POST['resource2'] = max(0, (int) trim($_POST['resource2']));
     $_POST['resource3'] = max(0, (int) trim($_POST['resource3']));
     if ($_POST['resource1'] < 1) {
         $TransMetal = 0;
     } else {
         $TransMetal = $_POST['resource1'];
         $StorageNeeded += $TransMetal;
     }
     if ($_POST['resource2'] < 1) {
         $TransCrystal = 0;
     } else {
         $TransCrystal = $_POST['resource2'];
         $StorageNeeded += $TransCrystal;
     }
     if ($_POST['resource3'] < 1) {
         $TransDeuterium = 0;
     } else {
         $TransDeuterium = $_POST['resource3'];
         $StorageNeeded += $TransDeuterium;
     }
     $StockMetal = $this->_current_planet['planet_metal'];
     $StockCrystal = $this->_current_planet['planet_crystal'];
     $StockDeuterium = $this->_current_planet['planet_deuterium'];
     $StockDeuterium -= $consumption;
     $StockOk = FALSE;
     if ($StockMetal >= $TransMetal) {
         if ($StockCrystal >= $TransCrystal) {
             if ($StockDeuterium >= $TransDeuterium) {
                 $StockOk = TRUE;
             }
         }
     }
     if (!$StockOk) {
         FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_no_enought_deuterium'] . FormatLib::pretty_number($consumption) . "</b></font>", "game.php?page=movement", 2);
     }
     if ($StorageNeeded > $FleetStorage) {
         FunctionsLib::message("<font color=\"red\"><b>" . $this->_lang['fl_no_enought_cargo_capacity'] . FormatLib::pretty_number($StorageNeeded - $FleetStorage) . "</b></font>", "game.php?page=movement", 2);
     }
     if (FunctionsLib::read_config('adm_attack') != 0) {
         FunctionsLib::message($this->_lang['fl_admins_cannot_be_attacked'], "game.php?page=movement", 2);
     }
     if ($fleet_group_mr != 0) {
         $AksStartTime = parent::$db->queryFetch("SELECT MAX(`fleet_start_time`) AS Start\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . FLEETS . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `fleet_group` = '" . $fleet_group_mr . "';");
         if ($AksStartTime['Start'] >= $fleet['start_time']) {
             $fleet['end_time'] += $AksStartTime['Start'] - $fleet['start_time'];
             $fleet['start_time'] = $AksStartTime['Start'];
         } else {
             parent::$db->query("UPDATE " . FLEETS . " SET\n\t\t\t\t\t\t\t\t\t\t`fleet_start_time` = '" . $fleet['start_time'] . "',\n\t\t\t\t\t\t\t\t\t\t`fleet_end_time` = fleet_end_time + '" . ($fleet['start_time'] - $AksStartTime['Start']) . "'\n\t\t\t\t\t\t\t\t\t\tWHERE `fleet_group` = '" . $fleet_group_mr . "';");
             $fleet['end_time'] += $fleet['start_time'] - $AksStartTime['Start'];
         }
     }
     parent::$db->query("INSERT INTO " . FLEETS . " SET\n\t\t\t\t\t\t\t`fleet_owner` = '" . $this->_current_user['user_id'] . "',\n\t\t\t\t\t\t\t`fleet_mission` = '" . (int) $_POST['mission'] . "',\n\t\t\t\t\t\t\t`fleet_amount` = '" . (int) $FleetShipCount . "',\n\t\t\t\t\t\t\t`fleet_array` = '" . $fleet_array . "',\n\t\t\t\t\t\t\t`fleet_start_time` = '" . $fleet['start_time'] . "',\n\t\t\t\t\t\t\t`fleet_start_galaxy` = '" . (int) $_POST['thisgalaxy'] . "',\n\t\t\t\t\t\t\t`fleet_start_system` = '" . (int) $_POST['thissystem'] . "',\n\t\t\t\t\t\t\t`fleet_start_planet` = '" . (int) $_POST['thisplanet'] . "',\n\t\t\t\t\t\t\t`fleet_start_type` = '" . (int) $_POST['thisplanettype'] . "',\n\t\t\t\t\t\t\t`fleet_end_time` = '" . (int) $fleet['end_time'] . "',\n\t\t\t\t\t\t\t`fleet_end_stay` = '" . (int) $StayTime . "',\n\t\t\t\t\t\t\t`fleet_end_galaxy` = '" . (int) $_POST['galaxy'] . "',\n\t\t\t\t\t\t\t`fleet_end_system` = '" . (int) $_POST['system'] . "',\n\t\t\t\t\t\t\t`fleet_end_planet` = '" . (int) $_POST['planet'] . "',\n\t\t\t\t\t\t\t`fleet_end_type` = '" . (int) $_POST['planettype'] . "',\n\t\t\t\t\t\t\t`fleet_resource_metal` = '" . $TransMetal . "',\n\t\t\t\t\t\t\t`fleet_resource_crystal` = '" . $TransCrystal . "',\n\t\t\t\t\t\t\t`fleet_resource_deuterium` = '" . $TransDeuterium . "',\n\t\t\t\t\t\t\t`fleet_target_owner` = '" . (int) $TargetPlanet['planet_user_id'] . "',\n\t\t\t\t\t\t\t`fleet_group` = '" . (int) $fleet_group_mr . "',\n\t\t\t\t\t\t\t`fleet_creation` = '" . time() . "';");
     parent::$db->query("UPDATE `" . PLANETS . "` AS p\n\t\t\t\t\t\t\t\tINNER JOIN " . SHIPS . " AS s ON s.ship_planet_id = p.`planet_id` SET\n\t\t\t\t\t\t\t\t{$FleetSubQRY}\n\t\t\t\t\t\t\t\t`planet_metal` = `planet_metal` - " . $TransMetal . ",\n\t\t\t\t\t\t\t\t`planet_crystal` = `planet_crystal` - " . $TransCrystal . ",\n\t\t\t\t\t\t\t\t`planet_deuterium` = `planet_deuterium` - " . ($TransDeuterium + $consumption) . "\n\t\t\t\t\t\t\t\tWHERE `planet_id` = " . $this->_current_planet['planet_id'] . ";");
     FunctionsLib::redirect('game.php?page=movement');
 }
Example #27
0
 /**
  * method add_to_queue
  * param $building
  * param $AddMode
  * return (int) the queue ID
  */
 private function add_to_queue($building, $AddMode = TRUE)
 {
     $resource = $this->_objects->getObjects();
     $CurrentQueue = $this->_current_planet['planet_b_building_id'];
     $queue = $this->show_queue();
     $max_fields = DevelopmentsLib::max_fields($this->_current_planet);
     if ($this->_current_planet['planet_field_current'] >= $max_fields - $queue['lenght']) {
         FunctionsLib::redirect('game.php?page=' . $this->_current_page);
     }
     if ($CurrentQueue != 0) {
         $QueueArray = explode(";", $CurrentQueue);
         $ActualCount = count($QueueArray);
     } else {
         $QueueArray = "";
         $ActualCount = 0;
     }
     if ($AddMode == TRUE) {
         $BuildMode = 'build';
     } else {
         $BuildMode = 'destroy';
     }
     if ($ActualCount < MAX_BUILDING_QUEUE_SIZE) {
         $QueueID = $ActualCount + 1;
     } else {
         $QueueID = FALSE;
     }
     $continue = FALSE;
     if ($QueueID != FALSE && DevelopmentsLib::is_development_allowed($this->_current_user, $this->_current_planet, $building)) {
         if ($QueueID <= 1) {
             if (DevelopmentsLib::is_development_payable($this->_current_user, $this->_current_planet, $building, TRUE, FALSE) && !parent::$users->is_on_vacations($this->_current_user)) {
                 $continue = TRUE;
             }
         } else {
             $continue = TRUE;
         }
         if ($continue) {
             if ($QueueID > 1) {
                 $InArray = 0;
                 for ($QueueElement = 0; $QueueElement < $ActualCount; $QueueElement++) {
                     $QueueSubArray = explode(",", $QueueArray[$QueueElement]);
                     if ($QueueSubArray[0] == $building) {
                         $InArray++;
                     }
                 }
             } else {
                 $InArray = 0;
             }
             if ($InArray != 0) {
                 $ActualLevel = $this->_current_planet[$resource[$building]];
                 if ($AddMode == TRUE) {
                     $BuildLevel = $ActualLevel + 1 + $InArray;
                     $this->_current_planet[$resource[$building]] += $InArray;
                     $BuildTime = DevelopmentsLib::development_time($this->_current_user, $this->_current_planet, $building);
                     $this->_current_planet[$resource[$building]] -= $InArray;
                 } else {
                     $BuildLevel = $ActualLevel - 1 - $InArray;
                     $this->_current_planet[$resource[$building]] -= $InArray;
                     $BuildTime = DevelopmentsLib::development_time($this->_current_user, $this->_current_planet, $building) / 2;
                     $this->_current_planet[$resource[$building]] += $InArray;
                 }
             } else {
                 $ActualLevel = $this->_current_planet[$resource[$building]];
                 if ($AddMode == TRUE) {
                     $BuildLevel = $ActualLevel + 1;
                     $BuildTime = DevelopmentsLib::development_time($this->_current_user, $this->_current_planet, $building);
                 } else {
                     $BuildLevel = $ActualLevel - 1;
                     $BuildTime = DevelopmentsLib::development_time($this->_current_user, $this->_current_planet, $building) / 2;
                 }
             }
             if ($QueueID == 1) {
                 $BuildEndTime = time() + $BuildTime;
             } else {
                 $PrevBuild = explode(",", $QueueArray[$ActualCount - 1]);
                 $BuildEndTime = $PrevBuild[3] + $BuildTime;
             }
             $QueueArray[$ActualCount] = $building . "," . $BuildLevel . "," . $BuildTime . "," . $BuildEndTime . "," . $BuildMode;
             $NewQueue = implode(";", $QueueArray);
             $this->_current_planet['planet_b_building_id'] = $NewQueue;
         }
     }
     return $QueueID;
 }
Example #28
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $this->_lang['js_path'] = XGP_ROOT . JS_PATH;
     $parse = $this->_lang;
     $a = isset($_GET['a']) ? intval($_GET['a']) : NULL;
     $n = isset($_GET['n']) ? intval($_GET['n']) : NULL;
     $s = isset($_POST['s']) ? intval($_POST['s']) : NULL;
     if ($s == 1 or $s == 2) {
         $time = time();
         $priority = intval($_POST['u']);
         $title = $_POST['title'] ? parent::$db->escapeValue(strip_tags($_POST['title'])) : "Sin t&iacute;tulo";
         $text = $_POST['text'] ? FunctionsLib::format_text($_POST['text']) : $this->_lang['nt_no_text'];
         if ($s == 1) {
             parent::$db->query("INSERT INTO " . NOTES . " SET\n\t\t\t\t\t\t\t\t\t\tnote_owner=" . intval($this->_current_user['user_id']) . ",\n\t\t\t\t\t\t\t\t\t\tnote_time={$time},\n\t\t\t\t\t\t\t\t\t\tnote_priority={$priority},\n\t\t\t\t\t\t\t\t\t\tnote_title='{$title}',\n\t\t\t\t\t\t\t\t\t\tnote_text='{$text}'");
             FunctionsLib::redirect('game.php?page=notes');
         } elseif ($s == 2) {
             $id = intval($_POST['n']);
             $note_query = parent::$db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . NOTES . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE note_id=" . intval($id) . " AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnote_owner=" . intval($this->_current_user['user_id']) . "");
             if (!$note_query) {
                 FunctionsLib::redirect('game.php?page=notes');
             }
             parent::$db->query("UPDATE `" . NOTES . "` SET\n\t\t\t\t\t\t\t\t\t\tnote_time={$time},\n\t\t\t\t\t\t\t\t\t\tnote_priority={$priority},\n\t\t\t\t\t\t\t\t\t\tnote_title='{$title}',\n\t\t\t\t\t\t\t\t\t\tnote_text='{$text}'\n\t\t\t\t\t\t\t\t\t\tWHERE note_id=" . intval($id) . "");
             FunctionsLib::redirect('game.php?page=notes');
         }
     } elseif ($_POST) {
         foreach ($_POST as $a => $b) {
             if (preg_match("/delmes/i", $a) && $b == "y") {
                 $id = str_replace("delmes", "", $a);
                 $note_query = parent::$db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . NOTES . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `note_id` = " . (int) $id . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `note_owner` = " . $this->_current_user['user_id'] . "");
                 if ($note_query) {
                     parent::$db->query("DELETE FROM `" . NOTES . "`\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `note_id` = " . (int) $id . ";");
                 }
             }
         }
         FunctionsLib::redirect('game.php?page=notes');
     } else {
         if ($a == 1) {
             $parse['c_Options'] = "<option value=2 selected=selected>" . $this->_lang['nt_important'] . "</option>\n\t\t\t\t<option value=1>" . $this->_lang['nt_normal'] . "</option>\n\t\t\t\t<option value=0>" . $this->_lang['nt_unimportant'] . "</option>";
             $parse['TITLE'] = $this->_lang['nt_create_note'];
             $parse['inputs'] = "<input type=hidden name=s value=1>";
             parent::$page->display(parent::$page->parse_template(parent::$page->get_template('notes/notes_form'), $parse), FALSE, '', FALSE);
         } elseif ($a == 2) {
             $SELECTED['0'] = '';
             $SELECTED['1'] = '';
             $SELECTED['2'] = '';
             $note = parent::$db->queryFetch("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . NOTES . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `note_owner` = " . $this->_current_user['user_id'] . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND `note_id` = " . (int) $n . ";");
             if (!$note) {
                 FunctionsLib::redirect('game.php?page=notes');
             }
             $SELECTED[$note['note_priority']] = ' selected="selected"';
             $parse['c_Options'] = "<option value=2{$SELECTED['2']}>" . $this->_lang['nt_important'] . "</option>\n\t\t\t\t<option value=1{$SELECTED['1']}>" . $this->_lang['nt_normal'] . "</option>\n\t\t\t\t<option value=0{$SELECTED['0']}>" . $this->_lang['nt_unimportant'] . "</option>";
             $parse['TITLE'] = $this->_lang['nt_edit_note'];
             $parse['inputs'] = '<input type="hidden" name="s" value="2"><input type="hidden" name="n" value=' . $note['note_id'] . '>';
             $parse['asunto'] = $note['note_title'];
             $parse['texto'] = $note['note_text'];
             parent::$page->display(parent::$page->parse_template(parent::$page->get_template('notes/notes_form'), $parse), FALSE, '', FALSE);
         } else {
             $notes_query = parent::$db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . NOTES . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `note_owner` = " . $this->_current_user['user_id'] . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY `note_time` DESC");
             $count = 0;
             $NotesBodyEntryTPL = parent::$page->get_template('notes/notes_body_entry');
             $list = '';
             while ($note = parent::$db->fetchArray($notes_query)) {
                 $count++;
                 $parse['NOTE_COLOR'] = $this->return_priority($note['note_priority']);
                 $parse['NOTE_ID'] = $note['note_id'];
                 $parse['NOTE_TIME'] = date(FunctionsLib::read_config('date_format_extended'), $note['note_time']);
                 $parse['NOTE_TITLE'] = $note['note_title'];
                 $parse['NOTE_TEXT'] = strlen($note['note_text']);
                 $list .= parent::$page->parse_template($NotesBodyEntryTPL, $parse);
             }
             if ($count == 0) {
                 $list .= "<tr><th colspan=4>" . $this->_lang['nt_you_dont_have_notes'] . "</th>\n";
             }
             $parse['BODY_LIST'] = $list;
             parent::$page->display(parent::$page->parse_template(parent::$page->get_template('notes/notes_body'), $parse), FALSE, '', FALSE);
         }
     }
 }
Example #29
0
 private function deleteFleetShortcuts($id)
 {
     $scarray = explode(";", $this->_current_user['user_fleet_shortcuts']);
     unset($scarray[$id]);
     $this->_current_user['user_fleet_shortcuts'] = implode(";", $scarray);
     parent::$db->query("UPDATE " . USERS . " SET\n\t\t\t\t\t\t\tuser_fleet_shortcuts='" . $this->_current_user['user_fleet_shortcuts'] . "'\n\t\t\t\t\t\t\tWHERE user_id=" . $this->_current_user['user_id']);
     FunctionsLib::redirect('game.php?page=shortcuts');
 }
Example #30
0
 /**
  * method check_session
  * param
  * return (void)
  */
 public function check_session()
 {
     if (!$this->is_session_set()) {
         FunctionsLib::redirect(XGP_ROOT);
     }
 }