PageRenderTime 32ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/includes/pages/class.ShowOptionsPage.php

https://github.com/jstar88/LibreTitan
PHP | 346 lines | 299 code | 25 blank | 22 comment | 94 complexity | 3ad1f81d13a9cc552bc4a37c899d9851 MD5 | raw file
  1. <?php
  2. /**
  3. * @project XG Proyect
  4. * @version 2.10.x build 0000
  5. * @copyright Copyright (C) 2008 - 2012
  6. */
  7. class ShowOptionsPage
  8. {
  9. private function CheckIfIsBuilding($CurrentUser)
  10. {
  11. $activity = doquery ( "SELECT (
  12. (
  13. SELECT COUNT( fleet_id ) AS quantity
  14. FROM {{table}}fleets
  15. WHERE fleet_owner = '" . intval ( $CurrentUser['id'] ) . "'
  16. )
  17. +
  18. (
  19. SELECT COUNT(id) AS quantity
  20. FROM {{table}}planets
  21. WHERE id_owner = '" . intval ( $CurrentUser['id'] ) . "' AND
  22. (b_building <> 0 OR b_tech <> 0 OR b_hangar <> 0)
  23. )
  24. ) as total" , '' , TRUE );
  25. if ( $activity['total'] > 0 )
  26. {
  27. return TRUE;
  28. }
  29. else
  30. {
  31. return FALSE;
  32. }
  33. }
  34. public function __construct($CurrentUser)
  35. {
  36. global $lang;
  37. $mode = isset ( $_GET['mode'] ) ? $_GET['mode'] : NULL;
  38. if ($_POST && $mode == "exit")
  39. {
  40. if (isset($_POST["exit_modus"]) && $_POST["exit_modus"] == 'on' and $CurrentUser['urlaubs_until'] <= time())
  41. {
  42. $urlaubs_modus = "0";
  43. doquery("UPDATE {{table}} SET
  44. `urlaubs_modus` = '0',
  45. `urlaubs_until` = '0'
  46. WHERE `id` = '".intval($CurrentUser['id'])."' LIMIT 1", "users");
  47. die(header("location:game.php?page=options"));
  48. }
  49. else
  50. {
  51. $urlaubs_modus = "1";
  52. die(header("location:game.php?page=options"));
  53. }
  54. }
  55. if ($_POST && $mode == "change")
  56. {
  57. if ($CurrentUser['authlevel'] > 0)
  58. {
  59. if ($_POST['adm_pl_prot'] == 'on')
  60. doquery ("UPDATE {{table}} SET `id_level` = '".intval($CurrentUser['authlevel'])."' WHERE `id_owner` = '".intval($CurrentUser['id'])."';", 'planets');
  61. else
  62. doquery ("UPDATE {{table}} SET `id_level` = '0' WHERE `id_owner` = '".intval($CurrentUser['id'])."';", 'planets');
  63. }
  64. // < ------------------------------------------------------- EL SKIN ------------------------------------------------------- >
  65. if (isset($_POST["design"]) && $_POST["design"] == 'on')
  66. {
  67. $design = "1";
  68. }
  69. else
  70. {
  71. $design = "0";
  72. }
  73. // < ------------------------------------------------- COMPROBACION DE IP -------------------------------------------------- >
  74. if (isset($_POST["noipcheck"]) && $_POST["noipcheck"] == 'on')
  75. {
  76. $noipcheck = "1";
  77. }
  78. else
  79. {
  80. $noipcheck = "0";
  81. }
  82. // < ------------------------------------------------- NOMBRE DE USUARIO --------------------------------------------------- >
  83. if (isset($_POST["db_character"]) && $_POST["db_character"] != '')
  84. {
  85. $username = ( $_POST['db_character'] );
  86. }
  87. else
  88. {
  89. $username = ( $CurrentUser['username'] );
  90. }
  91. // < ------------------------------------------------- DIRECCION DE EMAIL -------------------------------------------------- >
  92. if (isset($_POST["db_email"]) && $_POST["db_email"] != '')
  93. {
  94. $db_email = ( $_POST['db_email'] );
  95. }
  96. else
  97. {
  98. $db_email = ( $CurrentUser['email'] );
  99. }
  100. // < ------------------------------------------------- CANTIDAD DE SONDAS -------------------------------------------------- >
  101. if (isset($_POST["spio_anz"]) && is_numeric($_POST["spio_anz"]))
  102. {
  103. $spio_anz = intval($_POST["spio_anz"]);
  104. }
  105. else
  106. {
  107. $spio_anz = "1";
  108. }
  109. // < ------------------------------------------------- TIEMPO TOOLTIP ------------------------------------------------------ >
  110. if (isset($_POST["settings_tooltiptime"]) && is_numeric($_POST["settings_tooltiptime"]))
  111. {
  112. $settings_tooltiptime = intval($_POST["settings_tooltiptime"]);
  113. }
  114. else
  115. {
  116. $settings_tooltiptime = "1";
  117. }
  118. // < ------------------------------------------------- MENSAJES DE FLOTAS -------------------------------------------------- >
  119. if (isset($_POST["settings_fleetactions"]) && is_numeric($_POST["settings_fleetactions"]))
  120. {
  121. $settings_fleetactions = intval($_POST["settings_fleetactions"]);
  122. }
  123. else
  124. {
  125. $settings_fleetactions = "1";
  126. }
  127. // < ------------------------------------------------- SONDAS DE ESPIONAJE ------------------------------------------------- >
  128. if (isset($_POST["settings_esp"]) && $_POST["settings_esp"] == 'on')
  129. {
  130. $settings_esp = "1";
  131. }
  132. else
  133. {
  134. $settings_esp = "0";
  135. }
  136. // < ------------------------------------------------- ESCRIBIR MENSAJE ---------------------------------------------------- >
  137. if (isset($_POST["settings_wri"]) && $_POST["settings_wri"] == 'on')
  138. {
  139. $settings_wri = "1";
  140. }
  141. else
  142. {
  143. $settings_wri = "0";
  144. }
  145. // < --------------------------------------------- AÑADIR A LISTA DE AMIGOS ------------------------------------------------ >
  146. if (isset($_POST["settings_bud"]) && $_POST["settings_bud"] == 'on')
  147. {
  148. $settings_bud = "1";
  149. }
  150. else
  151. {
  152. $settings_bud = "0";
  153. }
  154. // < ------------------------------------------------- ATAQUE CON MISILES -------------------------------------------------- >
  155. if (isset($_POST["settings_mis"]) && $_POST["settings_mis"] == 'on')
  156. {
  157. $settings_mis = "1";
  158. }
  159. else
  160. {
  161. $settings_mis = "0";
  162. }
  163. // < ------------------------------------------------- VER REPORTE --------------------------------------------------------- >
  164. if (isset($_POST["settings_rep"]) && $_POST["settings_rep"] == 'on')
  165. {
  166. $settings_rep = "1";
  167. }
  168. else
  169. {
  170. $settings_rep = "0";
  171. }
  172. // < ------------------------------------------------- MODO VACACIONES ----------------------------------------------------- >
  173. if (isset($_POST["urlaubs_modus"]) && $_POST["urlaubs_modus"] == 'on')
  174. {
  175. if($this->CheckIfIsBuilding($CurrentUser))
  176. {
  177. message($lang['op_cant_activate_vacation_mode'], "game.php?page=options",2);
  178. }
  179. $urlaubs_modus = "1";
  180. $time = time() + 86400;
  181. doquery("UPDATE {{table}} SET
  182. `urlaubs_modus` = '$urlaubs_modus',
  183. `urlaubs_until` = '$time'
  184. WHERE `id` = '".intval($CurrentUser["id"])."' LIMIT 1", "users");
  185. $query = doquery("SELECT * FROM {{table}} WHERE id_owner = '".intval($CurrentUser['id'])."'", 'planets');
  186. while($id = mysql_fetch_array($query))
  187. {
  188. doquery("UPDATE {{table}} SET
  189. metal_perhour = '".read_config ( 'metal_basic_income' )."',
  190. crystal_perhour = '".read_config ( 'crystal_basic_income' )."',
  191. deuterium_perhour = '".read_config ( 'deuterium_basic_income' )."',
  192. energy_used = '0',
  193. energy_max = '0',
  194. metal_mine_porcent = '0',
  195. crystal_mine_porcent = '0',
  196. deuterium_sintetizer_porcent = '0',
  197. solar_plant_porcent = '0',
  198. fusion_plant_porcent = '0',
  199. solar_satelit_porcent = '0'
  200. WHERE id = '{$id['id']}' AND `planet_type` = 1 ", 'planets');
  201. }
  202. }
  203. else
  204. $urlaubs_modus = "0";
  205. // < ------------------------------------------------- BORRAR CUENTA ------------------------------------------------------- >
  206. if (isset($_POST["db_deaktjava"]) && $_POST["db_deaktjava"] == 'on')
  207. {
  208. $db_deaktjava = time();
  209. }
  210. else
  211. {
  212. $db_deaktjava = "0";
  213. }
  214. $SetSort = ($_POST['settings_sort']);
  215. $SetOrder = ($_POST['settings_order']);
  216. //// < -------------------------------------- ACTUALIZAR TODO LO SETEADO ANTES --------------------------------------------- >
  217. doquery("UPDATE {{table}} SET
  218. `email` = '$db_email',
  219. `dpath` = '$_POST[dpath]',
  220. `design` = '$design',
  221. `noipcheck` = '$noipcheck',
  222. `planet_sort` = '$SetSort',
  223. `planet_sort_order` = '$SetOrder',
  224. `spio_anz` = '$spio_anz',
  225. `settings_tooltiptime` = '$settings_tooltiptime',
  226. `settings_fleetactions` = '$settings_fleetactions',
  227. `settings_allylogo` = '$settings_allylogo',
  228. `settings_esp` = '$settings_esp',
  229. `settings_wri` = '$settings_wri',
  230. `settings_bud` = '$settings_bud',
  231. `settings_mis` = '$settings_mis',
  232. `settings_rep` = '$settings_rep',
  233. `urlaubs_modus` = '$urlaubs_modus',
  234. `db_deaktjava` = '$db_deaktjava'
  235. WHERE `id` = '".$CurrentUser["id"]."' LIMIT 1", "users");
  236. // < ------------------------------------------------- CAMBIO DE CLAVE ----------------------------------------------------- >
  237. if (isset($_POST["db_password"]) && md5($_POST["db_password"]) == $CurrentUser["password"])
  238. {
  239. if ($_POST["newpass1"] == $_POST["newpass2"])
  240. {
  241. if ($_POST["newpass1"] != "")
  242. {
  243. $newpass = md5($_POST["newpass1"]);
  244. doquery("UPDATE {{table}} SET `password` = '{$newpass}' WHERE `id` = '".intval($CurrentUser['id'])."' LIMIT 1", "users");
  245. setcookie(COOKIE_NAME, "", time()-100000, "/", "", 0);
  246. message($lang['op_password_changed'],"index.php",1);
  247. }
  248. }
  249. }
  250. // < --------------------------------------------- CAMBIO DE NOMBRE DE USUARIO --------------------------------------------- >
  251. if ($CurrentUser['username'] != $_POST["db_character"])
  252. {
  253. $query = doquery("SELECT id FROM {{table}} WHERE username='". ($_POST["db_character"])."'", 'users', TRUE);
  254. if (!$query)
  255. {
  256. doquery("UPDATE {{table}} SET username='". ($username)."' WHERE id='".intval($CurrentUser['id'])."' LIMIT 1", "users");
  257. setcookie(COOKIE_NAME, "", time()-100000, "/", "", 0);
  258. message($lang['op_username_changed'], "index.php", 1);
  259. }
  260. }
  261. message($lang['op_options_changed'], "game.php?page=options", 1);
  262. }
  263. else
  264. {
  265. $parse = $lang;
  266. $parse['dpath'] = DPATH;
  267. if($CurrentUser['urlaubs_modus'])
  268. {
  269. $parse['opt_modev_data'] = ($CurrentUser['urlaubs_modus'] == 1)?" checked='checked'/":'';
  270. $parse['opt_modev_exit'] = ($CurrentUser['urlaubs_modus'] == 0)?" checked='1'/":'';
  271. $parse['vacation_until'] = date("d.m.Y G:i:s",$CurrentUser['urlaubs_until']);
  272. display(parsetemplate(gettemplate('options/options_body_vmode'), $parse), FALSE);
  273. }
  274. else
  275. {
  276. $parse['opt_lst_ord_data'] = "<option value =\"0\"". (($CurrentUser['planet_sort'] == 0) ? " selected": "") .">" . $lang['op_sort_colonization'] . "</option>";
  277. $parse['opt_lst_ord_data'] .= "<option value =\"1\"". (($CurrentUser['planet_sort'] == 1) ? " selected": "") .">" . $lang['op_sort_coords'] . "</option>";
  278. $parse['opt_lst_ord_data'] .= "<option value =\"2\"". (($CurrentUser['planet_sort'] == 2) ? " selected": "") .">" . $lang['op_sort_alpha'] . "</option>";
  279. $parse['opt_lst_cla_data'] = "<option value =\"0\"". (($CurrentUser['planet_sort_order'] == 0) ? " selected": "") .">" . $lang['op_sort_asc'] . "</option>";
  280. $parse['opt_lst_cla_data'] .= "<option value =\"1\"". (($CurrentUser['planet_sort_order'] == 1) ? " selected": "") .">" . $lang['op_sort_desc'] . "</option>";
  281. $SkinsFolder = opendir(XGP_ROOT . 'styles/skins');
  282. $parse['opt_skin_data'] = '';
  283. while (($SkinsSubFolder = readdir($SkinsFolder)) !== FALSE)
  284. {
  285. if($SkinsSubFolder != '.' && $SkinsSubFolder != '..' && $SkinsSubFolder != '.htaccess' && $SkinsSubFolder != '.svn' && $SkinsSubFolder != 'index.html')
  286. {
  287. $parse['opt_skin_data'] .= "<option ";
  288. if($CurrentUser['dpath'] == $SkinsSubFolder)
  289. $parse['opt_skin_data'] .= "selected = selected";
  290. $parse['opt_skin_data'] .= " value=\"".$SkinsSubFolder."\">".$SkinsSubFolder."</option>";
  291. }
  292. }
  293. if ($CurrentUser['authlevel'] > 0)
  294. {
  295. $IsProtOn = doquery ("SELECT `id_level` FROM {{table}} WHERE `id_owner` = '".intval($CurrentUser['id'])."' LIMIT 1;", 'planets', TRUE);
  296. $parse['adm_pl_prot_data'] = ($IsProtOn['id_level'] > 0) ? " checked='checked'":'';
  297. $parse['opt_adm_frame'] = parsetemplate(gettemplate('options/options_admadd'), $parse);
  298. }
  299. $parse['opt_usern_data'] = $CurrentUser['username'];
  300. $parse['opt_mail1_data'] = $CurrentUser['email'];
  301. $parse['opt_mail2_data'] = $CurrentUser['email_2'];
  302. $parse['opt_dpath_data'] = $CurrentUser['dpath'];
  303. $parse['opt_probe_data'] = $CurrentUser['spio_anz'];
  304. $parse['opt_toolt_data'] = $CurrentUser['settings_tooltiptime'];
  305. $parse['opt_fleet_data'] = $CurrentUser['settings_fleetactions'];
  306. $parse['opt_sskin_data'] = ($CurrentUser['design'] == 1) ? " checked='checked'":'';
  307. $parse['opt_noipc_data'] = ($CurrentUser['noipcheck'] == 1) ? " checked='checked'":'';
  308. $parse['opt_allyl_data'] = ($CurrentUser['settings_allylogo'] == 1) ? " checked='checked'":'';
  309. $parse['opt_delac_data'] = ($CurrentUser['db_deaktjava'] == 1) ? " checked='checked'":'';
  310. $parse['user_settings_rep'] = ($CurrentUser['settings_rep'] == 1) ? " checked='checked'":'';
  311. $parse['user_settings_esp'] = ($CurrentUser['settings_esp'] == 1) ? " checked='checked'":'';
  312. $parse['user_settings_wri'] = ($CurrentUser['settings_wri'] == 1) ? " checked='checked'":'';
  313. $parse['user_settings_mis'] = ($CurrentUser['settings_mis'] == 1) ? " checked='checked'":'';
  314. $parse['user_settings_bud'] = ($CurrentUser['settings_bud'] == 1) ? " checked='checked'":'';
  315. $parse['db_deaktjava'] = ($CurrentUser['db_deaktjava'] > 0) ? " checked='checked'":'';
  316. display(parsetemplate(gettemplate('options/options_body'), $parse));
  317. }
  318. }
  319. }
  320. }
  321. ?>