-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
155 lines (130 loc) · 4.83 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
<?php
/* This file is part of testMaker.
testMaker is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation.
testMaker 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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/**
* Initializes the system and starts Portal
* @package Portal
*/
// Load developer options from dev.conf
$GLOBALS["is_dev_machine"] = false;
$GLOBALS["enable_stopwatch"] = false;
$GLOBALS["enable_debug"] = false;
$GLOBALS["enable_post"] = false;
$GLOBALS["enable_query"] = false;
$isDevMachine = (file_exists(dirname(__FILE__)."/dev.conf") && !isset($_REQUEST["nodebug"]));
if ($isDevMachine) {
$GLOBALS["is_dev_machine"] = true;
$devConf = dirname(__FILE__)."/dev.conf";
$stopWatchPrintReport = false;
if (file_exists($devConf)) {
$file = file($devConf);
$devOptions = array();
foreach ($file as $lineNum => $line)
{
$temp = explode("=", $line);
$devOptions[$temp[0]] = str_replace("\n", "", $temp[1]);
}
if (array_key_exists("stop_watch", $devOptions) && ($devOptions["stop_watch"] == "1" ))
$GLOBALS["enable_stopwatch"] = true;
if (array_key_exists("test_run_debug_info", $devOptions) && ($devOptions["test_run_debug_info"] == "1" ))
$GLOBALS["enable_debug"] = true;
if (array_key_exists("show_post", $devOptions) && ($devOptions["show_post"] == "1" ))
$GLOBALS["enable_post"] = true;
if (array_key_exists("query_debug", $devOptions) && ($devOptions["query_debug"] == "1" ))
$GLOBALS["enable_query"] = true;
}
}
// Load the StopWatch
require("lib/utilities/StopWatch.php");
start("Initializing");
// Initialize the system
require(dirname(__FILE__)."/init.php");
// Initialize Portal
start("Initializing Portal");
require(ROOT.'portal/init.php');
stop();
stop();
// Start Portal
start("Running Portal");
$GLOBALS["PORTAL"]->run();
stop();
// Show debug output at the end of the page (can be dangerous e.g. with ajax code)
if ($isDevMachine) {
echo "<script language='javascript'>
<!--
function showHide(id)
{
if (document.getElementById(id).style.display == \"none\")
{
document.getElementById(id).style.display = \"block\";
}
else
{
document.getElementById(id).style.display = \"none\";
}
}
//-->
</script>
<div style=\"text-align: left\";>";
// Show script Memory Usage
echo "<p>PHP memory usage for this site: <a href='javascript://' onclick=\"showHide('mem');\">[show/hide]</a></p>";
echo "<span id='mem' style=\"display: none\";>";
$memory = (integer) round(memory_get_peak_usage(true) / 1024)." KB";
printVar($memory);
echo "</span>";
// Show $_SESSION
echo "<p>_SESSION for this site: <a href='javascript://' onclick=\"showHide('ses');\">[show/hide]</a></p>";
echo "<span id='ses' style=\"display: none\";>";
printVar($_SESSION);
echo "</span>";
//Show Querys
if(isset($GLOBALS["enable_query"]) && $GLOBALS["enable_query"] == TRUE) {
echo "<p>query number & querys: <a href='javascript://' onclick=\"showHide('qu');\">[show/hide]</a></p></p>";
echo "<span id='qu' style=\"display: none\";>";
$GLOBALS['all_the_queries'] = @array_unique($GLOBALS['all_the_queries']);
printVar($GLOBALS['global_query_counter']);
printVar($GLOBALS['all_the_queries']);
echo "</span>";
}
// Show $_POST Vars
if(!empty($_POST) && isset($GLOBALS["enable_post"]) && $GLOBALS["enable_post"] == TRUE) {
echo "<p>PHP _POST vars : <a href='javascript://' onclick=\"showHide('postv');\">[show/hide]</a></p>";
echo "<span id='postv' style=\"display: none\";>";
printVar($_POST);
echo "</span>";
}
$found = FALSE;
foreach (headers_list() as $item) {
if(!$found) $found = strpos($item,"text/html");
}
// Show stop watch report
if($found && isset($GLOBALS["enable_stopwatch"]) && $GLOBALS["enable_stopwatch"] == TRUE)
{
echo "<p>page generation time (stopwatch): <a href='javascript://' onclick=\"showHide('sw');\">[show/hide]</a></p></p>";
echo "<span id='sw' style=\"display: none\";>";
$stopWatch = getStopWatch();
$stopWatch->printReport();
echo "</span>";
}
// Print additional debug infos
if(array_key_exists("DEBUG", $_SESSION) && !empty($_SESSION["DEBUG"])) {
echo "<p>additional debug infos: <a href='javascript://' onclick=\"showHide('addb');\">[show/hide]</a></p></p>";
echo "<span id='addb' style=\"display: none\";>";
printVar($_SESSION["DEBUG"]);
echo "</span>";
}
// Unix only
if(function_exists("sys_getloadavg")) {
$load = sys_getloadavg();
echo "Server load: (".round($load[0],1).", ".round($load[1],1).", ".round($load[2],1).")";
}
echo "</div>";
}