-
-
Notifications
You must be signed in to change notification settings - Fork 106
/
index.php
executable file
·191 lines (171 loc) · 7.27 KB
/
index.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?php
////////////////////////////////////////////////////////////////////////////////
// Copyright (C) Ubilling Development Team //
// https://ubilling.net.ua //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY, without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
// //
// This product released under GNU General Public License v2 //
////////////////////////////////////////////////////////////////////////////////
/**
* is Xhprof Hierarchical Profiler enabled?
*/
$minimalBillingConfig = @parse_ini_file('config/billing.ini');
if (@$minimalBillingConfig['XHPROF']) {
define('XHPROF', 1);
} else {
define('XHPROF', 0);
}
if (XHPROF) {
//xhprof installed?
if (file_exists('modules/foreign/xhprof/xhprof_lib/utils/xhprof_lib.php')) {
define("XHPROF_ROOT", __DIR__ . '/modules/foreign/xhprof');
require_once (XHPROF_ROOT . '/xhprof_lib/utils/xhprof_lib.php');
require_once (XHPROF_ROOT . '/xhprof_lib/utils/xhprof_runs.php');
//append XHPROF_FLAGS_NO_BUILTINS if your PHP instance crashes
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
}
}
////////////////////////////////////////////////////////////////////////////////
// Initializations //
////////////////////////////////////////////////////////////////////////////////
define('RCMS_ROOT_PATH', './');
require_once(RCMS_ROOT_PATH . 'common.php');
$menu_points = parse_ini_file(CONFIG_PATH . 'menus.ini', true);
// Page gentime start
$starttime = explode(' ', microtime());
$starttime = $starttime[1] + $starttime[0];
// Send main headers
header('Last-Modified: ' . gmdate('r'));
header('Content-Type: text/html; charset=' . $system->config['encoding']);
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Pragma: no-cache");
/**
* Maintance mode
*/
if (file_exists('UPDATE')) {
die('Ubilling maintance in progress');
}
/**
* Stargazer PID control
*/
$ubillingMainConf = parse_ini_file(CONFIG_PATH . 'billing.ini');
if (isset($ubillingMainConf['NOSTGCHECKPID'])) {
if ($ubillingMainConf['NOSTGCHECKPID']) {
$checkStgPid = false;
} else {
$checkStgPid = true;
}
} else {
$checkStgPid = true;
}
if ($checkStgPid) {
$stgPidPath = $ubillingMainConf['STGPID'];
if (!file_exists($stgPidPath)) {
$stgPidAlert = __('Stargazer currently not running. We strongly advise against trying to use Ubilling in this case. If you are absolutely sure of what you are doing - you can turn off this alert with the option NOSTGCHECKPID');
die($stgPidAlert);
}
}
/**
* IP ACL implementation
*/
if (@$ubillingMainConf['IPACL_ENABLED']) {
$ipAclAllowedIps = rcms_scandir(IPACLALLOWIP_PATH);
$ipAclAllowedNets = rcms_scandir(IPACLALLOWNETS_PATH);
//checks only if at least one ACL exists
if (!empty($ipAclAllowedIps) OR ! empty($ipAclAllowedNets)) {
$ipAclAllowedFlag = false;
$ipAclAllowedIps = array_flip($ipAclAllowedIps);
$ipAclRemoteIp = $_SERVER['REMOTE_ADDR'];
//localhost is always allowed
if ($ipAclRemoteIp != '127.0.0.1') {
//checking is remote IP in allowed list
if (isset($ipAclAllowedIps[$ipAclRemoteIp])) {
$ipAclAllowedFlag = true;
}
} else {
$ipAclAllowedFlag = true;
}
//if user IP isnt still allowed as-is - check on nets ACL
if (!$ipAclAllowedFlag) {
if (!empty($ipAclAllowedNets)) {
foreach ($ipAclAllowedNets as $ipAclIndex => $ipAclNeteach) {
$ipAclNetCidr = str_replace('_', '/', $ipAclNeteach);
$ipAclNetParams = ipcidrToStartEndIP($ipAclNetCidr);
if (multinet_checkIP($ipAclRemoteIp, $ipAclNetParams['startip'], $ipAclNetParams['endip'])) {
$ipAclAllowedFlag = true;
}
}
}
}
//Interrupt execution if remote user is not allowed explicitly
if (!$ipAclAllowedFlag) {
require_once(SKIN_PATH . 'acldenied.html');
die();
}
}
}
// Loading main module
$system->setCurrentPoint('__MAIN__');
if (!empty($_GET['module']))
$module = basename($_GET['module']);
else
$module = 'index';
if (!empty($system->modules['main'][$module]))
include_once(MODULES_PATH . $module . '/index.php');
// Load menu modules
include_once(CUR_SKIN_PATH . 'skin.php');
if (!empty($menu_points)) {
foreach ($menu_points as $point => $menus) {
$system->setCurrentPoint($point);
if (!empty($menus) && isset($skin['menu_point'][$point])) {
foreach ($menus as $menu) {
if (substr($menu, 0, 4) == 'ucm:' && is_readable(DF_PATH . substr($menu, 4) . '.ucm')) {
$file = file(DF_PATH . substr($menu, 4) . '.ucm');
$title = preg_replace("/[\n\r]+/", '', $file[0]);
$align = preg_replace("/[\n\r]+/", '', $file[1]);
unset($file[0]);
unset($file[1]);
show_window($title, implode('', $file), $align);
} elseif (!empty($system->modules['menu'][$menu])) {
$module = $menu;
$module_dir = MODULES_PATH . $menu;
require(MODULES_PATH . $menu . '/index.php');
} else {
show_window('', __('Module not found'), 'center');
}
}
}
}
}
if (XHPROF) {
if (defined('XHPROF_ROOT')) {
$xhprof_data = xhprof_disable();
$xhprof_runs = new XHProfRuns_Default();
$xhprof_run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_ubilling");
$xhprof_content = '<iframe src="modules/foreign/xhprof/xhprof_html/index.php?run=' . $xhprof_run_id . '&source=xhprof_ubilling" width="100%" height="750"></iframe>';
$xhprof_link = wf_modal(wf_img_sized('skins/xhprof.png', __('XHPROF'), 20), 'XHProf current page results', $xhprof_content, '', '1024', '768');
} else {
$xhprof_install_url = '?module=report_sysload&xhprofmoduleinstall=true';
$xhprof_install_form = wf_AjaxLink($xhprof_install_url, wf_img('skins/icon_download.png') . ' ' . __('Download') . ' ' . __('XHProf'), 'xhprofinstall', true, 'ubButton');
$xhprof_install_form .= wf_AjaxContainer('xhprofinstall');
$xhprof_link = wf_modal(wf_img_sized('skins/xhprof.png', __('XHPROF'), 20), __('Download') . ' XHProf', $xhprof_install_form, '', '320', '200');
}
}
// Start output
require_once(CUR_SKIN_PATH . 'skin.general.php');
//
// Everything is better with unicorns
//
// _______\)%%%%%%%%._
//`''''-'-; % % % % %'-._
// :b) \ '-.
// : :__)' .' .'
// :.::/ '.' .'
// o_i/ : ;
// : .'
// ''`
// Glory to Ukraine!
//