forked from sergejey/majordomo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload_settings.php
118 lines (94 loc) · 4.71 KB
/
load_settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
error_reporting(E_ALL & ~(E_STRICT | E_NOTICE | E_DEPRECATED));
mb_internal_encoding("UTF-8");
// get settings
$settings = SQLSelect('SELECT NAME, VALUE FROM settings');
$total = count($settings);
if (IsSet($_GET['theme'])) {
Define('SETTINGS_THEME', $_GET['theme']);
}
if (IsSet($_GET['disable_websockets'])) {
Define('DISABLE_WEBSOCKETS', 1);
}
if ($_GET['lang']) {
Define("SETTINGS_SITE_LANGUAGE", $_GET['lang']);
$_SESSION['lang'] = SETTINGS_SITE_LANGUAGE;
} elseif ($_SESSION['lang']) {
Define("SETTINGS_SITE_LANGUAGE", $_SESSION['lang']);
}
for ($i = 0; $i < $total; $i++)
Define('SETTINGS_' . $settings[$i]['NAME'], $settings[$i]['VALUE']);
if (!defined('SETTINGS_SITE_LANGUAGE')) {
Define('SETTINGS_SITE_LANGUAGE', 'en');
}
if (!defined('GIT_URL')) {
Define('GIT_URL', 'https://github.com/sergejey/majordomo/');
}
if (!isset($aditional_git_urls)) {
$aditional_git_urls = array();
}
// language selection by settings
if (SETTINGS_SITE_LANGUAGE && file_exists(ROOT . 'languages/' . SETTINGS_SITE_LANGUAGE . '.php')) {
include_once(ROOT . 'languages/' . SETTINGS_SITE_LANGUAGE . '.php');
}
include_once(ROOT . 'languages/default.php');
if (LANG_SETTINGS_SITE_LANGUAGE_CODE) {
Define ('SETTINGS_SITE_LANGUAGE_CODE', LANG_SETTINGS_SITE_LANGUAGE_CODE);
} elseif (SETTINGS_SITE_LANGUAGE=='en') {
Define ('SETTINGS_SITE_LANGUAGE_CODE', 'en_GB');
} else {
Define ('SETTINGS_SITE_LANGUAGE_CODE', '');
}
if (!defined('SETTINGS_SITE_TIMEZONE')) {
Define('SETTINGS_SITE_TIMEZONE', 'Europe/Minsk');
}
ini_set('date.timezone', SETTINGS_SITE_TIMEZONE);
date_default_timezone_set(SETTINGS_SITE_TIMEZONE);
function timezone_offset_string($offset)
{
return sprintf("%s%02d:%02d", ($offset >= 0) ? '+' : '-', abs($offset / 3600), abs($offset % 3600));
}
$offset = timezone_offset_get(new DateTimeZone(SETTINGS_SITE_TIMEZONE), new DateTime());
$offset_text = timezone_offset_string($offset);
SQLExec("SET time_zone = '" . $offset_text . "';");
if (($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST') &&
defined('WAIT_FOR_MAIN_CYCLE') &&
WAIT_FOR_MAIN_CYCLE == 1 &&
!preg_match('/clear_all_history\.php/', $_SERVER['REQUEST_URI']) &&
!preg_match('/diagnostic\.php/', $_SERVER['REQUEST_URI']) &&
!preg_match('/\/ajax\//', $_SERVER['REQUEST_URI']) &&
!preg_match('/\/api/', $_SERVER['REQUEST_URI']) &&
!preg_match('/admin\.php/', $_SERVER['REQUEST_URI']) &&
!preg_match('/xray\.html/', $_SERVER['REQUEST_URI']) &&
!defined('NO_DATABASE_CONNECTION')
) {
$maincycleUpdate = (int)getGlobal('ThisComputer.cycle_mainRun');
$maincycleTimeout = 60;
if ((time() - $maincycleUpdate) > $maincycleTimeout) { //main cycle is offline
echo "<html><head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
<meta http-equiv=\"refresh\" content=\"10\">
<link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css\" integrity=\"sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u\" crossorigin=\"anonymous\">
<link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css\" integrity=\"sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp\" crossorigin=\"anonymous\">
<script src=\"https://code.jquery.com/jquery-3.3.1.min.js\" type=\"text/javascript\"></script>
<script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js\" integrity=\"sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa\" crossorigin=\"anonymous\"></script>
</head><body><div class=\"container\">";
echo " <div class='alert alert-danger'>".LANG_MAINCYCLEDOWN."</div>";
echo '<p>'.LANG_MAINCYCLEDOWN_DETAILS.'</p>';
echo "<div><a href='".ROOTHTML."diagnostic.php' target='_blank' class='btn btn-default'>" . LANG_SUBMIT_DIAGNOSTIC . "</a></div> ";
echo "<div>".LANG_CONTROL_PANEL.": <a href='".ROOTHTML."panel/xray.html?view_mode=services' class='btn btn-default'>Services</a> ";
echo "<a href='".ROOTHTML."panel/xray.html?view_mode=database' class='btn btn-default'>Database</a> ";
echo "<a href='".ROOTHTML."admin.php?md=panel&action=saverestore' class='btn btn-default'>".LANG_SAVE_BACKUP." / ".LANG_RESTORE."</a> ";
echo "</div> ";
echo "</div></body></html>";
exit;
}
}
if (IsSet($_SERVER['SERVER_ADDR']) && IsSet($_SERVER['SERVER_PORT'])) {
Define('SERVER_URL', 'http://' . $_SERVER['HTTP_HOST'] . ':' . $_SERVER['SERVER_PORT']);
Define('SERVER_ADDR', $_SERVER['SERVER_ADDR']);
} else {
Define('SERVER_URL', 'http://localhost:80');
}
if (!defined('WEBSOCKETS_PORT'))
Define('WEBSOCKETS_PORT', 8001);