Exemplo n.º 1
0
 /**
  * method build_page
  * param
  * return main method, loads everything
  */
 private function build_page()
 {
     $mode = isset($_GET['mode']) ? $_GET['mode'] : NULL;
     if ($_POST && $mode == 'exit') {
         if (isset($_POST['exit_modus']) && $_POST['exit_modus'] == 'on' and $this->_current_user['setting_vacations_until'] <= time()) {
             $urlaubs_modus = '0';
             parent::$db->query("UPDATE " . SETTINGS . ", " . PLANETS . " SET\r\n\t\t\t\t\t\t\t\t\t\t`setting_vacations_status` = '0',\r\n\t\t\t\t\t\t\t\t\t\t`setting_vacations_until` = '0',\r\n\t\t\t\t\t\t\t\t\t\tplanet_building_metal_mine_porcent = '10',\r\n\t\t\t\t\t\t\t\t\t\tplanet_building_crystal_mine_porcent = '10',\r\n\t\t\t\t\t\t\t\t\t\tplanet_building_deuterium_sintetizer_porcent = '10',\r\n\t\t\t\t\t\t\t\t\t\tplanet_building_solar_plant_porcent = '10',\r\n\t\t\t\t\t\t\t\t\t\tplanet_building_fusion_reactor_porcent = '10',\r\n\t\t\t\t\t\t\t\t\t\tplanet_ship_solar_satellite_porcent = '10'\r\n\t\t\t\t\t\t\t\t\t\tWHERE `setting_user_id` = '" . intval($this->_current_user['user_id']) . "' AND planet_user_id = '" . intval($this->_current_user['user_id']) . "'");
             Functions_Lib::redirect('game.php?page=options');
         } else {
             $urlaubs_modus = '1';
             Functions_Lib::redirect('game.php?page=options');
         }
     }
     if ($_POST && $mode == "change") {
         // < ------------------------------------------------- COMPROBACION DE IP -------------------------------------------------- >
         if (isset($_POST['noipcheck']) && $_POST['noipcheck'] == 'on') {
             $noipcheck = '1';
         } else {
             $noipcheck = '0';
         }
         // < ------------------------------------------------- NOMBRE DE USUARIO --------------------------------------------------- >
         if (isset($_POST['db_character']) && $_POST['db_character'] != '') {
             $username = parent::$db->escape_value($_POST['db_character']);
         } else {
             $username = parent::$db->escape_value($this->_current_user['user_name']);
         }
         // < ------------------------------------------------- DIRECCION DE EMAIL -------------------------------------------------- >
         if (isset($_POST['db_email']) && $_POST['db_email'] != '') {
             $db_email = parent::$db->escape_value($_POST['db_email']);
         } else {
             $db_email = parent::$db->escape_value($this->_current_user['user_email']);
         }
         // < ------------------------------------------------- CANTIDAD DE SONDAS -------------------------------------------------- >
         if (isset($_POST['spio_anz']) && is_numeric($_POST['spio_anz'])) {
             $spio_anz = intval($_POST['spio_anz']);
         } else {
             $spio_anz = '1';
         }
         // < ------------------------------------------------- MENSAJES DE FLOTAS -------------------------------------------------- >
         if (isset($_POST['settings_fleetactions']) && is_numeric($_POST['settings_fleetactions'])) {
             $settings_fleetactions = intval($_POST['settings_fleetactions']);
         } else {
             $settings_fleetactions = '1';
         }
         // < ------------------------------------------------- SONDAS DE ESPIONAJE ------------------------------------------------- >
         if (isset($_POST['settings_esp']) && $_POST['settings_esp'] == 'on') {
             $settings_esp = '1';
         } else {
             $settings_esp = '0';
         }
         // < ------------------------------------------------- ESCRIBIR MENSAJE ---------------------------------------------------- >
         if (isset($_POST['settings_wri']) && $_POST['settings_wri'] == 'on') {
             $settings_wri = '1';
         } else {
             $settings_wri = '0';
         }
         // < --------------------------------------------- AÑADIR A LISTA DE AMIGOS ------------------------------------------------ >
         if (isset($_POST['settings_bud']) && $_POST['settings_bud'] == 'on') {
             $settings_bud = '1';
         } else {
             $settings_bud = '0';
         }
         // < ------------------------------------------------- ATAQUE CON MISILES -------------------------------------------------- >
         if (isset($_POST['settings_mis']) && $_POST['settings_mis'] == 'on') {
             $settings_mis = '1';
         } else {
             $settings_mis = '0';
         }
         // < ------------------------------------------------- VER REPORTE --------------------------------------------------------- >
         if (isset($_POST['settings_rep']) && $_POST['settings_rep'] == 'on') {
             $settings_rep = '1';
         } else {
             $settings_rep = '0';
         }
         // < ------------------------------------------------- MODO VACACIONES ----------------------------------------------------- >
         if (isset($_POST['urlaubs_modus']) && $_POST['urlaubs_modus'] == 'on') {
             if ($this->CheckIfIsBuilding()) {
                 Functions_Lib::message($this->_lang['op_cant_activate_vacation_mode'], "game.php?page=options", 2);
             }
             $urlaubs_modus = '1';
             $time = Functions_Lib::get_default_vacation_time();
             parent::$db->query("UPDATE " . SETTINGS . ", " . PLANETS . " SET\r\n\t\t\t\t\t\t\t\t\t\t`setting_vacations_status` = '{$urlaubs_modus}',\r\n\t\t\t\t\t\t\t\t\t\t`setting_vacations_until` = '{$time}',\r\n\t\t\t\t\t\t\t\t\t\tplanet_metal_perhour = '" . Functions_Lib::read_config('metal_basic_income') . "',\r\n\t\t\t\t\t\t\t\t\t\tplanet_crystal_perhour = '" . Functions_Lib::read_config('crystal_basic_income') . "',\r\n\t\t\t\t\t\t\t\t\t\tplanet_deuterium_perhour = '" . Functions_Lib::read_config('deuterium_basic_income') . "',\r\n\t\t\t\t\t\t\t\t\t\tplanet_energy_used = '0',\r\n\t\t\t\t\t\t\t\t\t\tplanet_energy_max = '0',\r\n\t\t\t\t\t\t\t\t\t\tplanet_building_metal_mine_porcent = '0',\r\n\t\t\t\t\t\t\t\t\t\tplanet_building_crystal_mine_porcent = '0',\r\n\t\t\t\t\t\t\t\t\t\tplanet_building_deuterium_sintetizer_porcent = '0',\r\n\t\t\t\t\t\t\t\t\t\tplanet_building_solar_plant_porcent = '0',\r\n\t\t\t\t\t\t\t\t\t\tplanet_building_fusion_reactor_porcent = '0',\r\n\t\t\t\t\t\t\t\t\t\tplanet_ship_solar_satellite_porcent = '0'\r\n\t\t\t\t\t\t\t\t\t\tWHERE `setting_user_id` = '" . intval($this->_current_user['user_id']) . "' AND planet_user_id = '" . intval($this->_current_user['user_id']) . "'");
         } else {
             $urlaubs_modus = '0';
         }
         // < ------------------------------------------------- BORRAR CUENTA ------------------------------------------------------- >
         if (isset($_POST['db_deaktjava']) && $_POST['db_deaktjava'] == 'on') {
             $db_deaktjava = time();
         } else {
             $db_deaktjava = '0';
         }
         $SetSort = parent::$db->escape_value($_POST['settings_sort']);
         $SetOrder = parent::$db->escape_value($_POST['settings_order']);
         //// < -------------------------------------- ACTUALIZAR TODO LO SETEADO ANTES --------------------------------------------- >
         parent::$db->query("UPDATE " . USERS . " AS u, " . SETTINGS . " AS s SET\r\n\t\t\t\t\t\t\t\t\tu.`user_email` = '{$db_email}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_no_ip_check` = '{$noipcheck}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_planet_sort` = '{$SetSort}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_planet_order` = '{$SetOrder}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_probes_amount` = '{$spio_anz}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_fleet_actions` = '{$settings_fleetactions}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_galaxy_espionage` = '{$settings_esp}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_galaxy_write` = '{$settings_wri}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_galaxy_buddy` = '{$settings_bud}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_galaxy_missile` = '{$settings_mis}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_vacations_status` = '{$urlaubs_modus}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_delete_account` = '{$db_deaktjava}'\r\n\t\t\t\t\t\t\t\t\tWHERE u.`user_id` = '" . $this->_current_user['user_id'] . "' AND\r\n\t\t\t\t\t\t\t\t\t\t\ts.`setting_user_id` = '" . $this->_current_user['user_id'] . "'");
         // < ------------------------------------------------- CAMBIO DE CLAVE ----------------------------------------------------- >
         if (isset($_POST['db_password']) && sha1($_POST['db_password']) == $this->_current_user['user_password']) {
             if ($_POST['newpass1'] == $_POST['newpass2']) {
                 if ($_POST['newpass1'] != '') {
                     $newpass = sha1($_POST['newpass1']);
                     parent::$db->query("UPDATE " . USERS . " SET\r\n\t\t\t\t\t\t\t\t\t\t\t\t`user_password` = '{$newpass}'\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `user_id` = '" . intval($this->_current_user['user_id']) . "' LIMIT 1");
                     Functions_Lib::message($this->_lang['op_password_changed'], "index.php", 1);
                 }
             }
         }
         // < --------------------------------------------- CAMBIO DE NOMBRE DE USUARIO --------------------------------------------- >
         if ($this->_current_user['user_name'] != $_POST['db_character']) {
             $query = parent::$db->query_fetch("SELECT `user_id`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . USERS . "`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE user_name = '" . parent::$db->escape_value($_POST['db_character']) . "'");
             if (!$query) {
                 parent::$db->query("UPDATE `" . USERS . "` SET\r\n\t\t\t\t\t\t\t\t\t\t\t`user_name` = '" . parent::$db->escape_value($username) . "'\r\n\t\t\t\t\t\t\t\t\t\t\tWHERE `user_id` = '" . $this->_current_user['user_id'] . "'\r\n\t\t\t\t\t\t\t\t\t\t\tLIMIT 1");
                 Functions_Lib::message($this->_lang['op_username_changed'], "index.php", 1);
             }
         }
         Functions_Lib::message($this->_lang['op_options_changed'], "game.php?page=options", 1);
     } else {
         $parse = $this->_lang;
         $parse['dpath'] = DPATH;
         if ($this->_current_user['setting_vacations_status']) {
             $parse['opt_modev_data'] = $this->_current_user['setting_vacations_status'] == 1 ? " checked='checked'/" : '';
             $parse['opt_modev_exit'] = $this->_current_user['setting_vacations_status'] == 0 ? " checked='1'/" : '';
             $parse['vacation_until'] = date(Functions_Lib::read_config('date_format_extended'), $this->_current_user['setting_vacations_until']);
             parent::$page->display(parent::$page->parse_template(parent::$page->get_template('options/options_body_vmode'), $parse));
         } else {
             $parse['opt_lst_ord_data'] = "<option value =\"0\"" . ($this->_current_user['setting_planet_sort'] == 0 ? " selected" : "") . ">" . $this->_lang['op_sort_colonization'] . "</option>";
             $parse['opt_lst_ord_data'] .= "<option value =\"1\"" . ($this->_current_user['setting_planet_sort'] == 1 ? " selected" : "") . ">" . $this->_lang['op_sort_coords'] . "</option>";
             $parse['opt_lst_ord_data'] .= "<option value =\"2\"" . ($this->_current_user['setting_planet_sort'] == 2 ? " selected" : "") . ">" . $this->_lang['op_sort_alpha'] . "</option>";
             $parse['opt_lst_cla_data'] = "<option value =\"0\"" . ($this->_current_user['setting_planet_order'] == 0 ? " selected" : "") . ">" . $this->_lang['op_sort_asc'] . "</option>";
             $parse['opt_lst_cla_data'] .= "<option value =\"1\"" . ($this->_current_user['setting_planet_order'] == 1 ? " selected" : "") . ">" . $this->_lang['op_sort_desc'] . "</option>";
             $parse['opt_usern_data'] = $this->_current_user['user_name'];
             $parse['opt_mail1_data'] = $this->_current_user['user_email'];
             $parse['opt_mail2_data'] = $this->_current_user['user_email_permanent'];
             $parse['opt_probe_data'] = $this->_current_user['setting_probes_amount'];
             $parse['opt_fleet_data'] = $this->_current_user['setting_fleet_actions'];
             $parse['opt_noipc_data'] = $this->_current_user['setting_no_ip_check'] == 1 ? " checked='checked'" : '';
             $parse['opt_delac_data'] = $this->_current_user['setting_delete_account'] == 1 ? " checked='checked'" : '';
             $parse['user_settings_esp'] = $this->_current_user['setting_galaxy_espionage'] == 1 ? " checked='checked'" : '';
             $parse['user_settings_wri'] = $this->_current_user['setting_galaxy_write'] == 1 ? " checked='checked'" : '';
             $parse['user_settings_mis'] = $this->_current_user['setting_galaxy_missile'] == 1 ? " checked='checked'" : '';
             $parse['user_settings_bud'] = $this->_current_user['setting_galaxy_buddy'] == 1 ? " checked='checked'" : '';
             $parse['db_deaktjava'] = $this->_current_user['setting_delete_account'] > 0 ? " checked='checked'" : '';
             parent::$page->display(parent::$page->parse_template(parent::$page->get_template('options/options_body'), $parse));
         }
     }
 }
Exemplo n.º 2
0
 /**
  * method save_settings
  * param
  * return save settings for the current user
  */
 private function save_settings()
 {
     $vacation_time = Functions_Lib::get_default_vacation_time();
     // DEFAULT VACATION TIME BEFORE A USER CAN REMOVE IT
     $setting_planet_sort = isset($_POST['setting_planet_sort']) ? (int) $_POST['setting_planet_sort'] : 0;
     $setting_planet_order = isset($_POST['setting_planet_order']) ? (int) $_POST['setting_planet_order'] : 0;
     $setting_no_ip_check = isset($_POST['setting_no_ip_check']) && $_POST['setting_no_ip_check'] == 'on' ? 1 : 0;
     $setting_probes_amount = isset($_POST['setting_probes_amount']) ? (int) $_POST['setting_probes_amount'] : 0;
     $setting_fleet_actions = isset($_POST['setting_fleet_actions']) ? (int) $_POST['setting_fleet_actions'] : 0;
     $setting_galaxy_espionage = isset($_POST['setting_galaxy_espionage']) && $_POST['setting_galaxy_espionage'] == 'on' ? 1 : 0;
     $setting_galaxy_write = isset($_POST['setting_galaxy_write']) && $_POST['setting_galaxy_write'] == 'on' ? 1 : 0;
     $setting_galaxy_buddy = isset($_POST['setting_galaxy_buddy']) && $_POST['setting_galaxy_buddy'] == 'on' ? 1 : 0;
     $setting_galaxy_missile = isset($_POST['setting_galaxy_missile']) && $_POST['setting_galaxy_missile'] == 'on' ? 1 : 0;
     $setting_vacations_status = isset($_POST['setting_vacations_status']) && $_POST['setting_vacations_status'] == 'on' ? 1 : 0;
     $setting_vacations_until = isset($_POST['setting_vacations_status']) && $_POST['setting_vacations_status'] == 'on' ? $vacation_time : 0;
     $setting_delete_account = isset($_POST['setting_delete_account']) && $_POST['setting_delete_account'] == 'on' ? time() : 0;
     // BUILD THE SPECIFIC QUERY
     if ($this->_user_query['setting_vacations_status'] == 1 && $setting_vacations_status == 0) {
         // WE HAVE TO REMOVE HIM FROM VACATION AND SET PLANET PRODUCTION
         $vacation_head = " , " . PLANETS . " AS p";
         $vacation_condition = " AND p.`planet_user_id` = '" . (int) $this->_id . "'";
         $vacation_query = "\r\n\t\t\ts.`setting_vacations_status` = '{$setting_vacations_status}',\r\n\t\t\ts.`setting_vacations_until` = '{$setting_vacations_until}',\r\n\t\t\tp.`planet_building_metal_mine_porcent` = '10',\r\n\t\t\tp.`planet_building_crystal_mine_porcent` = '10',\r\n\t\t\tp.`planet_building_deuterium_sintetizer_porcent` = '10',\r\n\t\t\tp.`planet_building_solar_plant_porcent` = '10',\r\n\t\t\tp.`planet_building_fusion_reactor_porcent` = '10',\r\n\t\t\tp.`planet_ship_solar_satellite_porcent` = '10',";
     } elseif ($this->_user_query['setting_vacations_status'] == 0 && $setting_vacations_status == 1) {
         // WE HAVE TO ADD HIM TO VACATION AND REMOVE PLANET PRODUCTION
         $vacation_head = " , " . PLANETS . " AS p";
         $vacation_condition = " AND p.`planet_user_id` = '" . (int) $this->_id . "'";
         $vacation_query = "\r\n\t\t\ts.`setting_vacations_status` = '{$setting_vacations_status}',\r\n\t\t\ts.`setting_vacations_until` = '{$setting_vacations_until}',\r\n\t\t\tp.`planet_metal_perhour` = '" . Functions_Lib::read_config('metal_basic_income') . "',\r\n\t\t\tp.`planet_crystal_perhour` = '" . Functions_Lib::read_config('crystal_basic_income') . "',\r\n\t\t\tp.`planet_deuterium_perhour` = '" . Functions_Lib::read_config('deuterium_basic_income') . "',\r\n\t\t\tp.`planet_energy_used` = '0',\r\n\t\t\tp.`planet_energy_max` = '0',\r\n\t\t\tp.`planet_building_metal_mine_porcent` = '0',\r\n\t\t\tp.`planet_building_crystal_mine_porcent` = '0',\r\n\t\t\tp.`planet_building_deuterium_sintetizer_porcent` = '0',\r\n\t\t\tp.`planet_building_solar_plant_porcent` = '0',\r\n\t\t\tp.`planet_building_fusion_reactor_porcent` = '0',\r\n\t\t\tp.`planet_ship_solar_satellite_porcent` = '0',";
     } else {
         $vacation_head = '';
         $vacation_condition = '';
         $vacation_query = '';
     }
     parent::$db->query("UPDATE " . SETTINGS . " AS s{$vacation_head} SET\r\n\t\t\t\t\t\t\t\t\t{$vacation_query}\r\n\t\t\t\t\t\t\t\t\ts.`setting_no_ip_check` = '{$setting_no_ip_check}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_planet_sort` = '{$setting_planet_sort}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_planet_order` = '{$setting_planet_order}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_probes_amount` = '{$setting_probes_amount}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_fleet_actions` = '{$setting_fleet_actions}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_galaxy_espionage` = '{$setting_galaxy_espionage}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_galaxy_write` = '{$setting_galaxy_write}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_galaxy_buddy` = '{$setting_galaxy_buddy}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_galaxy_missile` = '{$setting_galaxy_missile}',\r\n\t\t\t\t\t\t\t\t\ts.`setting_delete_account` = '{$setting_delete_account}'\r\n\t\t\t\t\t\t\t\t\tWHERE s.`setting_user_id` = '{$this->_id}'{$vacation_condition}");
     $this->_alert_info = $this->_lang['us_all_ok_message'];
     $this->_alert_type = 'ok';
 }