-
Notifications
You must be signed in to change notification settings - Fork 160
/
admin.php
139 lines (111 loc) · 3.55 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
<?php
/**
* This file is part of MajorDoMo system. More details at http://smartliving.ru/
*
* @package MajorDoMo
* @author Serge Dzheigalo <jey@tut.by>
* @version 1.3
*/
include_once("./config.php");
include_once("./lib/perfmonitor.class.php");
startMeasure('TOTAL');
startMeasure('loader');
include_once("./lib/loader.php");
endMeasure('loader');
include_once(DIR_MODULES . "panel.class.php");
$session = new session("prj");
startMeasure('db connection');
$db = new mysql(DB_HOST, '', DB_USER, DB_PASSWORD, DB_NAME);
endMeasure('db connection');
include_once("./load_settings.php");
include_once(DIR_MODULES . "control_modules/control_modules.class.php");
$cl = new control_modules();
$app = new panel();
if ($md != $app->name)
$app->restoreParams();
else
$app->getParams();
startMeasure('apprun');
$result = $app->run();
endMeasure('apprun');
startMeasure('part2');
// BEGIN: filter output
if ($filterblock != '')
{
$blockPattern = '/<!-- begin_data \[' . $filterblock . '\] -->(.*?)<!-- end_data \[' . $filterblock . '\] -->/is';
preg_match($blockPattern, $result, $match);
$result = $match[1];
}
// END: filter output
// BEGIN: language constants
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 />";
}
}
}
// END: language constants
if (!headers_sent())
{
header("HTTP/1.0: 200 OK\n");
header('Content-Type: text/html; charset=utf-8');
//ob_start("ob_gzhandler"); // should be un-commented for production server
}
$result = str_replace("nf.php", "admin.php", $result);
require(ROOT.'lib/utils/postprocess_result.inc.php');
if (!defined('DISABLE_PANEL_ACCELERATION') || DISABLE_PANEL_ACCELERATION!=1) {
if (preg_match_all('/href="(\/admin\.php.+?)">/is',$result,$matches)) {
$total = count($matches[1]);
for ($i = 0; $i < $total; $i++) {
$result=str_replace($matches[0][$i],'href="'.$matches[1][$i].'" onclick="return partLoad(this.href);">',$result);
}
}
}
endMeasure('part2');
if ($_GET['part_load']) {
$res=array();
$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 (is_integer(mb_strpos($res['CONTENT'], '$(document).ready')) || is_integer(mb_strpos($res['CONTENT'], 'js/codemirror'))) {
$res['CONTENT']='';
$res['NEED_RELOAD']=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);
}
echo $result;exit;
$session->save();
$db->Disconnect(); // closing database connection
exit;
}
startMeasure('echoall');
echo $result;
endMeasure('echoall');
$session->save();
$db->Disconnect(); // closing database connection
// end calculation of execution time
endMeasure('TOTAL');
// print performance report
performanceReport();