示例#1
0
 /**
  * method save_settings
  * param
  * return save settings for the current user
  */
 private function save_settings()
 {
     $vacation_time = FunctionsLib::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 = "\n\t\t\ts.`setting_vacations_status` = '{$setting_vacations_status}',\n\t\t\ts.`setting_vacations_until` = '{$setting_vacations_until}',\n\t\t\tp.`planet_building_metal_mine_porcent` = '10',\n\t\t\tp.`planet_building_crystal_mine_porcent` = '10',\n\t\t\tp.`planet_building_deuterium_sintetizer_porcent` = '10',\n\t\t\tp.`planet_building_solar_plant_porcent` = '10',\n\t\t\tp.`planet_building_fusion_reactor_porcent` = '10',\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 = "\n\t\t\ts.`setting_vacations_status` = '{$setting_vacations_status}',\n\t\t\ts.`setting_vacations_until` = '{$setting_vacations_until}',\n\t\t\tp.`planet_metal_perhour` = '" . FunctionsLib::read_config('metal_basic_income') . "',\n\t\t\tp.`planet_crystal_perhour` = '" . FunctionsLib::read_config('crystal_basic_income') . "',\n\t\t\tp.`planet_deuterium_perhour` = '" . FunctionsLib::read_config('deuterium_basic_income') . "',\n\t\t\tp.`planet_energy_used` = '0',\n\t\t\tp.`planet_energy_max` = '0',\n\t\t\tp.`planet_building_metal_mine_porcent` = '0',\n\t\t\tp.`planet_building_crystal_mine_porcent` = '0',\n\t\t\tp.`planet_building_deuterium_sintetizer_porcent` = '0',\n\t\t\tp.`planet_building_solar_plant_porcent` = '0',\n\t\t\tp.`planet_building_fusion_reactor_porcent` = '0',\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\n\t\t\t\t\t\t\t\t\t{$vacation_query}\n\t\t\t\t\t\t\t\t\ts.`setting_no_ip_check` = '{$setting_no_ip_check}',\n\t\t\t\t\t\t\t\t\ts.`setting_planet_sort` = '{$setting_planet_sort}',\n\t\t\t\t\t\t\t\t\ts.`setting_planet_order` = '{$setting_planet_order}',\n\t\t\t\t\t\t\t\t\ts.`setting_probes_amount` = '{$setting_probes_amount}',\n\t\t\t\t\t\t\t\t\ts.`setting_fleet_actions` = '{$setting_fleet_actions}',\n\t\t\t\t\t\t\t\t\ts.`setting_galaxy_espionage` = '{$setting_galaxy_espionage}',\n\t\t\t\t\t\t\t\t\ts.`setting_galaxy_write` = '{$setting_galaxy_write}',\n\t\t\t\t\t\t\t\t\ts.`setting_galaxy_buddy` = '{$setting_galaxy_buddy}',\n\t\t\t\t\t\t\t\t\ts.`setting_galaxy_missile` = '{$setting_galaxy_missile}',\n\t\t\t\t\t\t\t\t\ts.`setting_delete_account` = '{$setting_delete_account}'\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';
 }
示例#2
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));
         }
     }
 }