settings.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) 2008 - 2018 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. "page_auto_refresh" => $_REQUEST['page_auto_refresh'],
  40. "smtp_server" => $_REQUEST['smtp_server'],
  41. "smtp_port" => $_REQUEST['smtp_port'],
  42. "smtp_login" => $_REQUEST['smtp_login'],
  43. "smtp_passw" => $_REQUEST['smtp_passw'],
  44. "smtp_ssl" => $ssl,
  45. "smtp_tls" => $tls,
  46. "panel_email_address" => $_REQUEST['panel_email_address'],
  47. "remote_query" => $_REQUEST['remote_query'],
  48. "feed_enable" => $_REQUEST['feed_enable'],
  49. "feed_url" => $_REQUEST['feed_url'],
  50. "query_cache_life" => $_REQUEST['query_cache_life'],
  51. "query_num_servers_stop" => $_REQUEST['query_num_servers_stop'],
  52. "steam_user" => $_REQUEST['steam_user'],
  53. "steam_pass" => $_REQUEST['steam_pass'],
  54. "steam_guard" => $_REQUEST['steam_guard'],
  55. "editable_email" => $_REQUEST['editable_email'],
  56. "old_dashboard_behavior" => $_REQUEST['old_dashboard_behavior'],
  57. "rsync_available" => $_REQUEST['rsync_available'],
  58. "support_widget_title" => $_REQUEST['support_widget_title'],
  59. "support_widget_content" => $_REQUEST['support_widget_content'],
  60. "support_widget_link" => $_REQUEST['support_widget_link'],
  61. "check_expiry_by" => $_REQUEST['check_expiry_by'],
  62. "recaptcha_site_key" => $_REQUEST['recaptcha_site_key'],
  63. "recaptcha_secret_key" => $_REQUEST['recaptcha_secret_key'],
  64. "recaptcha_use_login" => $_REQUEST['recaptcha_use_login'],
  65. "login_attempts_before_banned" => $_REQUEST['login_attempts_before_banned'],
  66. "custom_github_update_username" => $_REQUEST['custom_github_update_username'],
  67. "custom_github_update_branch_name" => $_REQUEST['custom_github_update_branch_name'],
  68. "show_server_id_game_monitor" => $_REQUEST['show_server_id_game_monitor'],
  69. "default_game_server_home_path_prefix" => $_REQUEST['default_game_server_home_path_prefix'],
  70. "use_authorized_hosts" => $_REQUEST['use_authorized_hosts'],
  71. "allow_setting_cpu_affinity" => $_REQUEST['allow_setting_cpu_affinity'],
  72. "regex_invalid_file_name_chars" => addslashes($_REQUEST['regex_invalid_file_name_chars']),
  73. "login_ban_time" => $_REQUEST['login_ban_time']
  74. );
  75. $db->setSettings($settings);
  76. if(array_key_exists("reset_game_server_order", $_REQUEST) && $_REQUEST["reset_game_server_order"] == 1){
  77. $db->resetGameServerOrder();
  78. }
  79. echo "<h2>".get_lang('settings')."</h2>";
  80. print_success(get_lang('settings_updated'));
  81. $view->refresh("?m=settings");
  82. return;
  83. }
  84. function formatOffset($offset) {
  85. $hours = $offset / 3600;
  86. $remainder = $offset % 3600;
  87. $sign = $hours > 0 ? '+' : '-';
  88. $hour = (int) abs($hours);
  89. $minutes = (int) abs($remainder / 60);
  90. if ($hour == 0 AND $minutes == 0) {
  91. $sign = ' ';
  92. }
  93. return $sign . str_pad($hour, 2, '0', STR_PAD_LEFT) .':'. str_pad($minutes,2, '0');
  94. }
  95. $utc = new DateTimeZone('UTC');
  96. $dt = new DateTime('now', $utc);
  97. foreach(DateTimeZone::listIdentifiers() as $tz) {
  98. $current_tz = new DateTimeZone($tz);
  99. $offset = $current_tz->getOffset($dt);
  100. $transition = $current_tz->getTransitions($dt->getTimestamp(), $dt->getTimestamp());
  101. $abbr = $transition[0]['abbr'];
  102. $zones["$tz"] = $tz . '[' . $abbr . ' ' . formatOffset($offset) . ']';
  103. }
  104. $rsync_options = array("1" => get_lang('all_available_servers'), "2" => get_lang('only_remote_servers'), "3" => get_lang('only_local_servers'));
  105. $row = $db->getSettings();
  106. echo "<h2>".get_lang('settings')."</h2>";
  107. if(@$row['use_authorized_hosts']){
  108. echo "<h4><a href='?m=settings&p=api_hosts'>".get_lang('setup_api_authorized_hosts')."</a></h4>";
  109. }
  110. $ft = new FormTable();
  111. $ft->start_form("?m=settings", "post", "autocomplete=\"off\"");
  112. $ft->start_table();
  113. $ft->add_field('string','panel_name',@$row['panel_name']);
  114. $locale_files = makefilelist("lang/", ".|..|.svn", true, "folders");
  115. $locale_files = array('' => "-") + $locale_files;
  116. $ft->add_custom_field('panel_language',
  117. create_drop_box_from_array($locale_files,"panel_language",@$row['panel_language']));
  118. $zones = array('' => "-") + $zones;
  119. $ft->add_custom_field('time_zone',
  120. create_drop_box_from_array($zones,"time_zone",@$row['time_zone'],false));
  121. $ft->add_field('text','header_code',@$row['header_code'], 38);
  122. $ft->add_field('on_off','maintenance_mode',@$row['maintenance_mode']);
  123. $ft->add_field('string','maintenance_title',@$row['maintenance_title']);
  124. $ft->add_field('text','maintenance_message',@$row['maintenance_message'], 38);
  125. $ft->add_field('on_off','page_auto_refresh',@$row['page_auto_refresh']);
  126. $ft->add_field('string','panel_email_address',@$row['panel_email_address']);
  127. $ft->add_field('string','smtp_server',@$row['smtp_server']);
  128. $ft->add_field('string','smtp_port',@$row['smtp_port']);
  129. $ssl = (isset($row['smtp_ssl']) and $row['smtp_ssl'] == 1) ? "checked='checked'" : "";
  130. $tls = (isset($row['smtp_tls']) and $row['smtp_tls'] == 1) ? "checked='checked'" : "";
  131. $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'" : "";
  132. $ft->add_custom_field('smtp_secure','<input type=radio name=smtp_secure value=0 '.$no.
  133. '>'.get_lang('no').'&nbsp;&nbsp;<input type=radio name=smtp_secure value=ssl '.$ssl.
  134. '>SSL&nbsp;&nbsp;<input type=radio name=smtp_secure value=tls '.$tls.'>TLS');
  135. $ft->add_field('string','smtp_login',@$row['smtp_login']);
  136. $ft->add_field('password','smtp_passw',@$row['smtp_passw']);
  137. $ft->add_field('on_off','remote_query',@$row['remote_query']);
  138. $ft->add_field('on_off','feed_enable',@$row['feed_enable']);
  139. $ft->add_field('string','feed_url',@$row['feed_url']);
  140. $query_cache_life = (isset($row['query_cache_life']) and $row['query_cache_life'] != "" )? $row['query_cache_life'] : "30";
  141. $ft->add_field('string','query_cache_life',$query_cache_life);
  142. $query_num_servers_stop = (isset($row['query_num_servers_stop']) and $row['query_num_servers_stop'] != "" )? $row['query_num_servers_stop'] : "15";
  143. $ft->add_field('string','query_num_servers_stop',$query_num_servers_stop);
  144. $ft->add_field('string','steam_user',@$row['steam_user']);
  145. $ft->add_field('password','steam_pass',@$row['steam_pass']);
  146. $ft->add_field('password','steam_guard',@$row['steam_guard']);
  147. $mail_setting = isset($row['editable_email']) ? $row['editable_email'] : "1";
  148. $ft->add_field('on_off','editable_email',$mail_setting);
  149. $ft->add_field('on_off','old_dashboard_behavior',@$row['old_dashboard_behavior']);
  150. $ft->add_custom_field('rsync_available',
  151. create_drop_box_from_array($rsync_options,"rsync_available",@$row['rsync_available'],false));
  152. $ft->add_field('string','support_widget_title',@$row['support_widget_title']);
  153. $ft->add_field('text','support_widget_content',@$row['support_widget_content'], 38);
  154. $ft->add_field('string','support_widget_link',@$row['support_widget_link']);
  155. $ft->add_custom_field('check_expiry_by',
  156. create_drop_box_from_array(array('once_logged_in' => get_lang('once_logged_in'), 'cron_job' => get_lang('cron_job')),"check_expiry_by",@$row['check_expiry_by'],false));
  157. $ft->add_field('string','recaptcha_site_key',@$row['recaptcha_site_key']);
  158. $ft->add_field('string','recaptcha_secret_key',@$row['recaptcha_secret_key']);
  159. $ft->add_field('on_off','recaptcha_use_login',@$row['recaptcha_use_login']);
  160. $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";
  161. $ft->add_field('string','login_attempts_before_banned',$login_attempts_before_banned);
  162. $ft->add_field('string','login_ban_time', array_key_exists("login_ban_time", $row) && !empty($row["login_ban_time"]) && is_numeric($row["login_ban_time"]) ? $row["login_ban_time"] : '');
  163. $ft->add_field('string','custom_github_update_username',@$row['custom_github_update_username']);
  164. $ft->add_field('string','custom_github_update_branch_name',@$row['custom_github_update_branch_name']);
  165. $ft->add_field('on_off','show_server_id_game_monitor',@$row['show_server_id_game_monitor']);
  166. $ft->add_field('string','default_game_server_home_path_prefix',@$row['default_game_server_home_path_prefix']);
  167. // Use authorized hosts for API - this should be disabled by default since using the KEY alone should be secure enough
  168. $ft->add_field('on_off','use_authorized_hosts',@$row['use_authorized_hosts']);
  169. // Allow setting the cpu affinity for game servers
  170. $ft->add_field('on_off','allow_setting_cpu_affinity',@$row['allow_setting_cpu_affinity']);
  171. // Add regex setting for file manager
  172. $ft->add_field('string','regex_invalid_file_name_chars',(@empty($row['regex_invalid_file_name_chars']) ? htmlentities('/[\^\$\*\+\?\(\)\[\{\\\\\\|\]!@#%&=~`,\\\'<>"}\s]/i', ENT_COMPAT | ENT_HTML401 | ENT_QUOTES) : htmlentities(@$row['regex_invalid_file_name_chars'], ENT_COMPAT | ENT_HTML401 | ENT_QUOTES)));
  173. // Add option to reset game server order to default
  174. $ft->add_field('checkbox','reset_game_server_order','0');
  175. $ft->end_table();
  176. $ft->add_button("submit","update_settings",get_lang('update_settings'));
  177. $ft->end_form();
  178. }
  179. ?>