-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathadmin.php
173 lines (138 loc) · 4.72 KB
/
admin.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
<?php
/**
* This file is part of MajorDoMo system. More details at http://smartliving.ru/
*
* @package MajorDoMo
* @author Serge Dzheigalo <[email protected]>
* @version 1.3
*/
Define('ALLOW_RUNNING_WITH_ERRORS', 1);
include_once("./config.php");
include_once("./lib/perfmonitor.class.php");
startMeasure('TOTAL');
startMeasure('loader');
include_once("./lib/loader.php");
endMeasure('loader');
include_once("./load_settings.php");
if (isset($_GET['part_load']) && checkFromCache('reload:' . md5($_SERVER['REQUEST_URI']))) {
$res = array();
$res['TITLE'] = '';
$res['CONTENT'] = '';
$res['NEED_RELOAD'] = 1;
echo json_encode($res);
exit;
}
include_once(DIR_MODULES . "panel.class.php");
$session = new session("prj");
include_once(DIR_MODULES . "control_modules/control_modules.class.php");
$cl = new control_modules();
$app = new panel();
$md = gr('md');
if ($md != $app->name)
$app->restoreParams();
else
$app->getParams();
startMeasure('apprun');
$result = $app->run();
endMeasure('apprun');
startMeasure('part2');
if (isset($filterblock) and $filterblock != '') {
$blockPattern = '/<!-- begin_data \[' . $filterblock . '\] -->(.*?)<!-- end_data \[' . $filterblock . '\] -->/is';
preg_match($blockPattern, $result, $match);
$result = $match[1];
}
startMeasure('languageConstants');
if (preg_match_all('/&\#060\#LANG_(.+?)\#&\#062/is', $result, $matches)) {
$total = count($matches[0]);
for ($i = 0; $i < $total; $i++) {
if (defined('LANG_' . $matches[1][$i])) {
$result = str_replace($matches[0][$i], constant('LANG_' . $matches[1][$i]), $result);
} else {
echo "'" . $matches[1][$i] . "'=>'',<br />";
}
}
}
endMeasure('languageConstants');
$result = str_replace("nf.php", "admin.php", $result);
startMeasure('postProcessGeneral');
require(ROOT . 'lib/utils/postprocess_general.inc.php');
endMeasure('postProcessGeneral');
startMeasure('postProcessSubscriptions');
require(ROOT . 'lib/utils/postprocess_subscriptions.inc.php');
//require(ROOT.'lib/utils/postprocess_result.inc.php');
endMeasure('postProcessSubscriptions');
endMeasure('part2');
if ((defined('ENABLE_PANEL_ACCELERATION') && ENABLE_PANEL_ACCELERATION)) {
startMeasure('accelerationProcess');
$result = preg_replace('/href="(\/admin\.php.+?)">/is', 'href="\1" onclick="return partLoad(this.href);">', $result);
endMeasure('accelerationProcess');
}
if (isset($_GET['part_load'])) {
$res = array();
$res['TITLE'] = '';
$res['CONTENT'] = '';
$res['NEED_RELOAD'] = 1;
$cut_begin = '<div id="partLoadContent">';
$cut_begin_index = mb_strpos($result, $cut_begin);
$cut_end = '</div><!--partloadend-->';
$cut_end_index = mb_strpos($result, $cut_end);
if (is_integer($cut_begin_index) && is_integer($cut_end_index)) {
$cut_begin_index += mb_strlen($cut_begin) + 2;
$res['CONTENT'] = mb_substr($result, $cut_begin_index, ($cut_end_index - $cut_begin_index));
$res['NEED_RELOAD'] = 0;
if (headers_sent()
|| is_integer(mb_strpos($res['CONTENT'], '$(document).ready'))
|| is_integer(mb_strpos($res['CONTENT'], '$(function('))
|| is_integer(mb_strpos($res['CONTENT'], 'codemirror/'))) {
$res['CONTENT'] = '';
$res['NEED_RELOAD'] = 1;
}
if (preg_match('/<title>(.+?)<\/title>/is', $result, $m)) {
$res['TITLE'] = $m[1];
}
} else {
$res['CONTENT'] = '';
$res['NEED_RELOAD'] = 1;
}
$result = json_encode($res);
if (is_integer(mb_strpos($result, '"CONTENT":null')) && !$res['NEED_RELOAD']) {
$res['CONTENT'] = '';
$res['NEED_RELOAD'] = 1;
$result = json_encode($res);
}
if ($res['NEED_RELOAD']) {
saveToCache('reload:' . md5($_SERVER['REQUEST_URI']), 1);
}
header("HTTP/1.0: 200 OK\n");
header('Content-Type: text/html; charset=utf-8');
echo $result;
exit;
$session->save();
exit;
}
startMeasure('echoall');
if (isset($_GET['dynids']) and is_array($_GET['dynids'])) {
$data = array();
foreach ($_GET['dynids'] as $data_id) {
if (preg_match('/id="' . $data_id . '">(.+?)<!--\/dynamic_content-->/uis', $result, $m)) {
$data['blocks'][] = array('name' => $data_id, 'content' => $m[1]);
}
}
header("Content-type: application/json");
echo json_encode($data);
exit;
}
if (!headers_sent()) {
header("HTTP/1.0: 200 OK\n");
header('Content-Type: text/html; charset=utf-8');
if (!ob_get_length()) {
if (!ob_start("ob_gzhandler")) ob_start();
}
}
echo $result;
endMeasure('echoall');
$session->save();
// end calculation of execution time
endMeasure('TOTAL');
// print performance report
performanceReport();