settings.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. "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. "custom_github_update_username" => $_REQUEST['custom_github_update_username'],
  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. );
  71. $db->setSettings($settings);
  72. echo "<h2>".get_lang('settings')."</h2>";
  73. print_success(get_lang('settings_updated'));
  74. $view->refresh("?m=settings");
  75. return;
  76. }
  77. function formatOffset($offset) {
  78. $hours = $offset / 3600;
  79. $remainder = $offset % 3600;
  80. $sign = $hours > 0 ? '+' : '-';
  81. $hour = (int) abs($hours);
  82. $minutes = (int) abs($remainder / 60);
  83. if ($hour == 0 AND $minutes == 0) {
  84. $sign = ' ';
  85. }
  86. return $sign . str_pad($hour, 2, '0', STR_PAD_LEFT) .':'. str_pad($minutes,2, '0');
  87. }
  88. $utc = new DateTimeZone('UTC');
  89. $dt = new DateTime('now', $utc);
  90. foreach(DateTimeZone::listIdentifiers() as $tz) {
  91. $current_tz = new DateTimeZone($tz);
  92. $offset = $current_tz->getOffset($dt);
  93. $transition = $current_tz->getTransitions($dt->getTimestamp(), $dt->getTimestamp());
  94. $abbr = $transition[0]['abbr'];
  95. $zones["$tz"] = $tz . '[' . $abbr . ' ' . formatOffset($offset) . ']';
  96. }
  97. $rsync_options = array("1" => get_lang('all_available_servers'), "2" => get_lang('only_remote_servers'), "3" => get_lang('only_local_servers'));
  98. echo "<h2>".get_lang('settings')."</h2>";
  99. echo "<h4><a href='?m=settings&p=api_hosts'>".get_lang('setup_api_authorized_hosts')."</a></h4>";
  100. $row = $db->getSettings();
  101. $ft = new FormTable();
  102. $ft->start_form("?m=settings", "post", "autocomplete=\"off\"");
  103. $ft->start_table();
  104. $ft->add_field('string','panel_name',@$row['panel_name']);
  105. $locale_files = makefilelist("lang/", ".|..|.svn", true, "folders");
  106. $locale_files = array('' => "-") + $locale_files;
  107. $ft->add_custom_field('panel_language',
  108. create_drop_box_from_array($locale_files,"panel_language",@$row['panel_language']));
  109. $zones = array('' => "-") + $zones;
  110. $ft->add_custom_field('time_zone',
  111. create_drop_box_from_array($zones,"time_zone",@$row['time_zone'],false));
  112. $ft->add_field('string','charset',@$row['charset']);
  113. $ft->add_field('text','header_code',@$row['header_code'], 38);
  114. $ft->add_field('on_off','maintenance_mode',@$row['maintenance_mode']);
  115. $ft->add_field('string','maintenance_title',@$row['maintenance_title']);
  116. $ft->add_field('text','maintenance_message',@$row['maintenance_message'], 38);
  117. $ft->add_field('on_off','page_auto_refresh',@$row['page_auto_refresh']);
  118. $ft->add_field('string','panel_email_address',@$row['panel_email_address']);
  119. $ft->add_field('string','smtp_server',@$row['smtp_server']);
  120. $ft->add_field('string','smtp_port',@$row['smtp_port']);
  121. $ssl = (isset($row['smtp_ssl']) and $row['smtp_ssl'] == 1) ? "checked='checked'" : "";
  122. $tls = (isset($row['smtp_tls']) and $row['smtp_tls'] == 1) ? "checked='checked'" : "";
  123. $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'" : "";
  124. $ft->add_custom_field('smtp_secure','<input type=radio name=smtp_secure value=0 '.$no.
  125. '>'.get_lang('no').'&nbsp;&nbsp;<input type=radio name=smtp_secure value=ssl '.$ssl.
  126. '>SSL&nbsp;&nbsp;<input type=radio name=smtp_secure value=tls '.$tls.'>TLS');
  127. $ft->add_field('string','smtp_login',@$row['smtp_login']);
  128. $ft->add_field('password','smtp_passw',@$row['smtp_passw']);
  129. $ft->add_field('on_off','remote_query',@$row['remote_query']);
  130. $ft->add_field('on_off','feed_enable',@$row['feed_enable']);
  131. $ft->add_field('string','feed_url',@$row['feed_url']);
  132. $query_cache_life = (isset($row['query_cache_life']) and $row['query_cache_life'] != "" )? $row['query_cache_life'] : "30";
  133. $ft->add_field('string','query_cache_life',$query_cache_life);
  134. $query_num_servers_stop = (isset($row['query_num_servers_stop']) and $row['query_num_servers_stop'] != "" )? $row['query_num_servers_stop'] : "15";
  135. $ft->add_field('string','query_num_servers_stop',$query_num_servers_stop);
  136. $ft->add_field('string','steam_user',@$row['steam_user']);
  137. $ft->add_field('password','steam_pass',@$row['steam_pass']);
  138. $ft->add_field('password','steam_guard',@$row['steam_guard']);
  139. $mail_setting = isset($row['editable_email']) ? $row['editable_email'] : "1";
  140. $ft->add_field('on_off','editable_email',$mail_setting);
  141. $ft->add_field('on_off','old_dashboard_behavior',@$row['old_dashboard_behavior']);
  142. $ft->add_custom_field('rsync_available',
  143. create_drop_box_from_array($rsync_options,"rsync_available",@$row['rsync_available'],false));
  144. $ft->add_field('string','support_widget_title',@$row['support_widget_title']);
  145. $ft->add_field('text','support_widget_content',@$row['support_widget_content'], 38);
  146. $ft->add_field('string','support_widget_link',@$row['support_widget_link']);
  147. $ft->add_custom_field('check_expiry_by',
  148. 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));
  149. $ft->add_field('string','recaptcha_site_key',@$row['recaptcha_site_key']);
  150. $ft->add_field('string','recaptcha_secret_key',@$row['recaptcha_secret_key']);
  151. $ft->add_field('on_off','recaptcha_use_login',@$row['recaptcha_use_login']);
  152. $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";
  153. $ft->add_field('string','login_attempts_before_banned',$login_attempts_before_banned);
  154. $ft->add_field('string','custom_github_update_username',@$row['custom_github_update_username']);
  155. $ft->add_field('on_off','show_server_id_game_monitor',@$row['show_server_id_game_monitor']);
  156. $ft->add_field('string','default_game_server_home_path_prefix',@$row['default_game_server_home_path_prefix']);
  157. $ft->end_table();
  158. $ft->add_button("submit","update_settings",get_lang('update_settings'));
  159. $ft->end_form();
  160. }
  161. ?>