forked from sergejey/majordomo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
98 lines (74 loc) · 2.18 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
<?php
/**
* Main project script
*
* @package MajorDoMo
* @author Serge Dzheigalo <[email protected]>
* @url http://smartliving.ru
* @version 1.2
*/
include_once("./lib/perfmonitor.class.php");
startMeasure('TOTAL');
include_once("./config.php");
include_once("./lib/loader.php");
// start calculation of execution time
startMeasure('prepare');
include_once(DIR_MODULES . "application.class.php");
$session = new session("prj");
startMeasure('load_settings');
include_once("./load_settings.php");
endMeasure('load_settings');
if (!file_exists(ROOT . 'cms/modules_installed/control_modules.installed')) {
include_once(DIR_MODULES . "control_modules/control_modules.class.php");
$ctl = new control_modules();
}
$app = new application();
if ($md != $app->name)
$app->restoreParams();
else
$app->getParams();
if ($app->action != '' && $app->action != 'docs') $fake_doc = '';
$result = $app->run();
$result = str_replace("nf.php", "index.php", $result);
endMeasure('prepare');
require(ROOT.'lib/utils/postprocess_general.inc.php');
require(ROOT.'lib/utils/postprocess_subscriptions.inc.php');
require(ROOT.'lib/utils/postprocess_result.inc.php');
/**
* Echo large text
* @param mixed $string Text
* @param mixed $bufferSize Buffer size
* @return void
*/
function echobig($string, $bufferSize = 8192)
{
$chars = strlen($string) - 1;
for ($start = 0; $start <= $chars; $start += $bufferSize)
{
echo substr($string,$start,$bufferSize);
}
}
startMeasure('final_echo');
if (!headers_sent()) {
header("HTTP/1.0: 200 OK\n");
header('Content-Type: text/html; charset=utf-8');
header('Access-Control-Allow-Origin: *');
if (!ob_get_length()) {
if(!ob_start("ob_gzhandler")) ob_start();
}
}
echobig($result);
endMeasure('final_echo', 1);
if ($cache_filename != '' && $cached_result == '')
{
SaveFile(ROOT . 'cms/cached/' . $cache_filename, $result);
}
$session->save();
if (isset($wsClient) && $wsClient) {
$wsClient->disconnect();
}
// end calculation of execution time
endMeasure('TOTAL');
// print performance report
performanceReport();
ob_end_flush();