settings.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) Copyright (C) 2008 - 2013 The OGP Development Team
  6. *
  7. * http://www.opengamepanel.org/
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. *
  23. */
  24. function exec_ogp_module()
  25. {
  26. require_once('includes/form_table_class.php');
  27. global $db,$view;
  28. if ( isset($_REQUEST['update_settings']) )
  29. {
  30. $ssl = (isset($_POST['smtp_secure']) and $_POST['smtp_secure'] == 'ssl') ? 1 : 0;
  31. $tls = (isset($_POST['smtp_secure']) and $_POST['smtp_secure'] == 'tls') ? 1 : 0;
  32. $settings = array("panel_name" => $_REQUEST['panel_name'],
  33. "header_code" => $_REQUEST['header_code'],
  34. "maintenance_mode" => $_REQUEST['maintenance_mode'],
  35. "maintenance_title" => $_REQUEST['maintenance_title'],
  36. "maintenance_message" => $_REQUEST['maintenance_message'],
  37. "panel_language" => $_REQUEST['panel_language'],
  38. "time_zone" => $_REQUEST['time_zone'],
  39. "charset" => $_REQUEST['charset'],
  40. "page_auto_refresh" => $_REQUEST['page_auto_refresh'],
  41. "smtp_server" => $_REQUEST['smtp_server'],
  42. "smtp_port" => $_REQUEST['smtp_port'],
  43. "smtp_login" => $_REQUEST['smtp_login'],
  44. "smtp_passw" => $_REQUEST['smtp_passw'],
  45. "smtp_ssl" => $ssl,
  46. "smtp_tls" => $tls,
  47. "panel_email_address" => $_REQUEST['panel_email_address'],
  48. "remote_query" => $_REQUEST['remote_query'],
  49. "feed_enable" => $_REQUEST['feed_enable'],
  50. "feed_url" => $_REQUEST['feed_url'],
  51. "query_cache_life" => $_REQUEST['query_cache_life'],
  52. "query_num_servers_stop" => $_REQUEST['query_num_servers_stop'],
  53. "steam_user" => $_REQUEST['steam_user'],
  54. "steam_pass" => $_REQUEST['steam_pass'],
  55. "steam_guard" => $_REQUEST['steam_guard'],
  56. "editable_email" => $_REQUEST['editable_email'],
  57. "old_dashboard_behavior" => $_REQUEST['old_dashboard_behavior'],
  58. "rsync_available" => $_REQUEST['rsync_available'],
  59. "support_widget_title" => $_REQUEST['support_widget_title'],
  60. "support_widget_content" => $_REQUEST['support_widget_content'],
  61. "support_widget_link" => $_REQUEST['support_widget_link'],
  62. "check_expiry_by" => $_REQUEST['check_expiry_by'],
  63. "recaptcha_site_key" => $_REQUEST['recaptcha_site_key'],
  64. "recaptcha_secret_key" => $_REQUEST['recaptcha_secret_key'],
  65. "recaptcha_use_login" => $_REQUEST['recaptcha_use_login'],
  66. "login_attempts_before_banned" => $_REQUEST['login_attempts_before_banned']);
  67. $db->setSettings($settings);
  68. echo "<h2>".get_lang('settings')."</h2>";
  69. print_success(get_lang('settings_updated'));
  70. $view->refresh("?m=settings");
  71. return;
  72. }
  73. function formatOffset($offset) {
  74. $hours = $offset / 3600;
  75. $remainder = $offset % 3600;
  76. $sign = $hours > 0 ? '+' : '-';
  77. $hour = (int) abs($hours);
  78. $minutes = (int) abs($remainder / 60);
  79. if ($hour == 0 AND $minutes == 0) {
  80. $sign = ' ';
  81. }
  82. return $sign . str_pad($hour, 2, '0', STR_PAD_LEFT) .':'. str_pad($minutes,2, '0');
  83. }
  84. $utc = new DateTimeZone('UTC');
  85. $dt = new DateTime('now', $utc);
  86. foreach(DateTimeZone::listIdentifiers() as $tz) {
  87. $current_tz = new DateTimeZone($tz);
  88. $offset = $current_tz->getOffset($dt);
  89. $transition = $current_tz->getTransitions($dt->getTimestamp(), $dt->getTimestamp());
  90. $abbr = $transition[0]['abbr'];
  91. $zones["$tz"] = $tz . '[' . $abbr . ' ' . formatOffset($offset) . ']';
  92. }
  93. $rsync_options = array("1" => get_lang('all_available_servers'), "2" => get_lang('only_remote_servers'), "3" => get_lang('only_local_servers'));
  94. echo "<h2>".get_lang('settings')."</h2>";
  95. $row = $db->getSettings();
  96. $ft = new FormTable();
  97. $ft->start_form("?m=settings", "post", "autocomplete=\"off\"");
  98. $ft->start_table();
  99. $ft->add_field('string','panel_name',@$row['panel_name']);
  100. $locale_files = makefilelist("lang/", ".|..|.svn", true, "folders");
  101. $locale_files = array('' => "-") + $locale_files;
  102. $ft->add_custom_field('panel_language',
  103. create_drop_box_from_array($locale_files,"panel_language",@$row['panel_language']));
  104. $zones = array('' => "-") + $zones;
  105. $ft->add_custom_field('time_zone',
  106. create_drop_box_from_array($zones,"time_zone",@$row['time_zone'],false));
  107. $ft->add_field('string','charset',@$row['charset']);
  108. $ft->add_field('text','header_code',@$row['header_code']);
  109. $ft->add_field('on_off','maintenance_mode',@$row['maintenance_mode']);
  110. $ft->add_field('string','maintenance_title',@$row['maintenance_title']);
  111. $ft->add_field('text','maintenance_message',@$row['maintenance_message']);
  112. $ft->add_field('on_off','page_auto_refresh',@$row['page_auto_refresh']);
  113. $ft->add_field('string','panel_email_address',@$row['panel_email_address']);
  114. $ft->add_field('string','smtp_server',@$row['smtp_server']);
  115. $ft->add_field('string','smtp_port',@$row['smtp_port']);
  116. $ssl = (isset($row['smtp_ssl']) and $row['smtp_ssl'] == 1) ? "checked='checked'" : "";
  117. $tls = (isset($row['smtp_tls']) and $row['smtp_tls'] == 1) ? "checked='checked'" : "";
  118. $no = (!isset($row['smtp_ssl']) or $row['smtp_ssl'] == 0 AND !isset($row['smtp_tls']) or ( isset($row['smtp_tls']) and $row['smtp_tls'] == 0)) ? "checked='checked'" : "";
  119. $ft->add_custom_field('smtp_secure','<input type=radio name=smtp_secure value=0 '.$no.
  120. '>'.no.'&nbsp;&nbsp;<input type=radio name=smtp_secure value=ssl '.$ssl.
  121. '>SSL&nbsp;&nbsp;<input type=radio name=smtp_secure value=tls '.$tls.'>TLS');
  122. $ft->add_field('string','smtp_login',@$row['smtp_login']);
  123. $ft->add_field('password','smtp_passw',@$row['smtp_passw']);
  124. $ft->add_field('on_off','remote_query',@$row['remote_query']);
  125. $ft->add_field('on_off','feed_enable',@$row['feed_enable']);
  126. $ft->add_field('string','feed_url',@$row['feed_url']);
  127. $query_cache_life = (isset($row['query_cache_life']) and $row['query_cache_life'] != "" )? $row['query_cache_life'] : "30";
  128. $ft->add_field('string','query_cache_life',$query_cache_life);
  129. $query_num_servers_stop = (isset($row['query_num_servers_stop']) and $row['query_num_servers_stop'] != "" )? $row['query_num_servers_stop'] : "15";
  130. $ft->add_field('string','query_num_servers_stop',$query_num_servers_stop);
  131. $ft->add_field('string','steam_user',@$row['steam_user']);
  132. $ft->add_field('password','steam_pass',@$row['steam_pass']);
  133. $ft->add_field('password','steam_guard',@$row['steam_guard']);
  134. $mail_setting = isset($row['editable_email']) ? $row['editable_email'] : "1";
  135. $ft->add_field('on_off','editable_email',$mail_setting);
  136. $ft->add_field('on_off','old_dashboard_behavior',@$row['old_dashboard_behavior']);
  137. $ft->add_custom_field('rsync_available',
  138. create_drop_box_from_array($rsync_options,"rsync_available",@$row['rsync_available'],false));
  139. $ft->add_field('string','support_widget_title',@$row['support_widget_title']);
  140. $ft->add_field('text','support_widget_content',@$row['support_widget_content']);
  141. $ft->add_field('string','support_widget_link',@$row['support_widget_link']);
  142. $ft->add_custom_field('check_expiry_by',
  143. create_drop_box_from_array(array('once_logged_in' => once_logged_in, 'cron_job' => cron_job),"check_expiry_by",@$row['check_expiry_by'],false));
  144. $ft->add_field('string','recaptcha_site_key',@$row['recaptcha_site_key']);
  145. $ft->add_field('string','recaptcha_secret_key',@$row['recaptcha_secret_key']);
  146. $ft->add_field('on_off','recaptcha_use_login',@$row['recaptcha_use_login']);
  147. $login_attempts_before_banned = (isset($row['login_attempts_before_banned']) and $row['login_attempts_before_banned'] != "" and is_numeric($row['login_attempts_before_banned']))? $row['login_attempts_before_banned'] : "6";
  148. $ft->add_field('string','login_attempts_before_banned',$login_attempts_before_banned);
  149. $ft->end_table();
  150. $ft->add_button("submit","update_settings",get_lang('update_settings'));
  151. $ft->end_form();
  152. }
  153. ?>