PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/administration/settings_time.php

https://gitlab.com/php-fusion/PHP-Fusion
PHP | 139 lines | 123 code | 0 blank | 16 comment | 16 complexity | c22d412bcb26f03118085d81e08039bf MD5 | raw file
Possible License(s): AGPL-3.0, LGPL-2.1, Apache-2.0
  1. <?php
  2. /*-------------------------------------------------------+
  3. | PHP-Fusion Content Management System
  4. | Copyright (C) PHP-Fusion Inc
  5. | https://www.php-fusion.co.uk/
  6. +--------------------------------------------------------+
  7. | Filename: settings_time.php
  8. | Author: Nick Jones (Digitanium)
  9. +--------------------------------------------------------+
  10. | This program is released as free software under the
  11. | Affero GPL license. You can redistribute it and/or
  12. | modify it under the terms of this license which you
  13. | can read by viewing the included agpl.txt or online
  14. | at www.gnu.org/licenses/agpl.html. Removal of this
  15. | copyright header is strictly prohibited without
  16. | written permission from the original author(s).
  17. +--------------------------------------------------------*/
  18. require_once "../maincore.php";
  19. pageAccess('S2');
  20. require_once THEMES."templates/admin_header.php";
  21. include LOCALE.LOCALESET."admin/settings.php";
  22. add_breadcrumb(array('link' => ADMIN."settings_time.php".$aidlink, 'title' => $locale['time_settings']));
  23. if (isset($_POST['savesettings'])) {
  24. $error = 0;
  25. if (!defined('FUSION_NULL')) {
  26. $result = dbquery("UPDATE ".DB_SETTINGS." SET settings_value='".stripinput($_POST['shortdate'])."' WHERE settings_name='shortdate'");
  27. if (!$result) {
  28. $error = 1;
  29. }
  30. $result = dbquery("UPDATE ".DB_SETTINGS." SET settings_value='".stripinput($_POST['longdate'])."' WHERE settings_name='longdate'");
  31. if (!$result) {
  32. $error = 1;
  33. }
  34. $result = dbquery("UPDATE ".DB_SETTINGS." SET settings_value='".stripinput($_POST['forumdate'])."' WHERE settings_name='forumdate'");
  35. if (!$result) {
  36. $error = 1;
  37. }
  38. $result = dbquery("UPDATE ".DB_SETTINGS." SET settings_value='".stripinput($_POST['newsdate'])."' WHERE settings_name='newsdate'");
  39. if (!$result) {
  40. $error = 1;
  41. }
  42. $result = dbquery("UPDATE ".DB_SETTINGS." SET settings_value='".stripinput($_POST['subheaderdate'])."' WHERE settings_name='subheaderdate'");
  43. if (!$result) {
  44. $error = 1;
  45. }
  46. $result = dbquery("UPDATE ".DB_SETTINGS." SET settings_value='".stripinput($_POST['timeoffset'])."' WHERE settings_name='timeoffset'");
  47. if (!$result) {
  48. $error = 1;
  49. }
  50. $result = dbquery("UPDATE ".DB_SETTINGS." SET settings_value='".stripinput($_POST['serveroffset'])."' WHERE settings_name='serveroffset'");
  51. if (!$result) {
  52. $error = 1;
  53. }
  54. $result = dbquery("UPDATE ".DB_SETTINGS." SET settings_value='".stripinput($_POST['default_timezone'])."' WHERE settings_name='default_timezone'");
  55. if (!$result) {
  56. $error = 1;
  57. }
  58. $result = dbquery("UPDATE ".DB_SETTINGS." SET settings_value='".stripinput($_POST['week_start'])."' WHERE settings_name='week_start'");
  59. if (!$result) {
  60. $error = 1;
  61. }
  62. if ($error) {
  63. addNotice('danger', $locale['901']);
  64. } else {
  65. addNotice('success', $locale['900']);
  66. }
  67. redirect(FUSION_SELF.$aidlink);
  68. }
  69. }
  70. $settings2 = array();
  71. $result = dbquery("SELECT * FROM ".DB_SETTINGS);
  72. while ($data = dbarray($result)) {
  73. $settings2[$data['settings_name']] = $data['settings_value'];
  74. }
  75. $timezones = timezone_abbreviations_list();
  76. $timezoneArray = array();
  77. foreach ($timezones as $zones) {
  78. foreach ($zones as $zone) {
  79. if (preg_match('/^(America|Antartica|Arctic|Asia|Atlantic|Europe|Indian|Pacific)\//', $zone['timezone_id'])) {
  80. if (!in_array($zone['timezone_id'], $timezoneArray)) {
  81. $timezoneArray[$zone['timezone_id']] = $zone['timezone_id'];
  82. }
  83. }
  84. }
  85. }
  86. unset($dummy);
  87. unset($timezones);
  88. $weekdayslist = explode("|", $locale['weekdays']);
  89. $timestamp = time()+($settings2['timeoffset']*3600);
  90. $date_opts = array();
  91. foreach ($locale['dateformats'] as $dateformat) {
  92. $date_opts[$dateformat] = strftime($dateformat, $timestamp);
  93. }
  94. unset($dateformat);
  95. opentable($locale['time_settings']);
  96. echo "<div class='well'>".$locale['time_description']."</div>\n";
  97. echo openform('settingsform', 'post', FUSION_SELF.$aidlink, array('max_tokens' => 1));
  98. echo "<table class='table table-condensed table-hover table-responsive'>\n<tbody>\n<tr>\n";
  99. echo "<td valign='top' width='40%' class='tbl'><strong>".$locale['458']." (".$locale['459']."):</strong></td>\n";
  100. echo "<td width='60%' class='tbl'>".strftime($settings2['longdate'], (time())+($settings2['serveroffset']*3600))."</td>\n";
  101. echo "</tr>\n<tr>\n";
  102. echo "<td valign='top' class='tbl'><strong>".$locale['458']." (".$locale['460']."):</strong></td>\n";
  103. echo "<td class='tbl'>".showdate("longdate", time())."</td>\n";
  104. echo "</tr>\n<tr>\n";
  105. echo "<td valign='top' class='tbl'><strong>".$locale['458']." (".$locale['461']."):</strong></td>\n";
  106. echo "<td class='tbl'>".strftime($settings2['longdate'], time()+(($settings2['serveroffset']+$settings2['timeoffset'])*3600))."</td>\n";
  107. echo "</tr>\n</tbody>";
  108. echo "</table>\n";
  109. echo "<div class='row'>\n";
  110. echo "<div class='col-xs-12 col-sm-12 col-md-6'>\n";
  111. openside('');
  112. echo form_select('shortdate', $locale['451'], $settings2['shortdate'], array('options' => $date_opts,
  113. 'placeholder' => $locale['455']));
  114. echo form_select('longdate', $locale['452'], $settings2['longdate'], array('options' => $date_opts,
  115. 'placeholder' => $locale['455']));
  116. echo form_select('forumdate', $locale['453'], $settings2['forumdate'], array('options' => $date_opts,
  117. 'placeholder' => $locale['455']));
  118. echo form_select('newsdate', $locale['457'], $settings2['newsdate'], array('options' => $date_opts,
  119. 'placeholder' => $locale['455']));
  120. echo form_select('subheaderdate', $locale['454'], $settings2['subheaderdate'], array('options' => $date_opts,
  121. 'placeholder' => $locale['455']));
  122. closeside();
  123. echo "</div>\n";
  124. echo "<div class='col-xs-12 col-sm-12 col-md-6'>\n";
  125. openside('');
  126. echo form_select('serveroffset', $locale['463'], $settings2['serveroffset'], array("options" => $timezoneArray));
  127. echo form_select('timeoffset', $locale['456'], $settings2['timeoffset'], array("options" => $timezoneArray));
  128. echo form_select('default_timezone', $locale['464'], $settings2['default_timezone'], array("options" => $timezoneArray));
  129. closeside();
  130. echo "</div>\n";
  131. echo "<div class='col-xs-12 col-sm-12 col-md-6'>\n";
  132. openside('');
  133. echo form_select('week_start', $locale['465'], $settings2['week_start'], array("options" => $weekdayslist));
  134. closeside();
  135. echo "</div>\n</div>\n";
  136. echo form_button('savesettings', $locale['750'], $locale['750'], array('class' => 'btn-success'));
  137. echo closeform();
  138. closetable();
  139. require_once THEMES."templates/footer.php";