-
Notifications
You must be signed in to change notification settings - Fork 2
/
debug_all.php
293 lines (245 loc) · 10.5 KB
/
debug_all.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
<?php
/**
* debug_all.php
*
* Copyright (C) 2008-2023 Null Team
*
* This software is distributed under multiple licenses;
* see the COPYING file in the main directory for licensing
* information for this specific distribution.
*
* This use of this software may be subject to additional restrictions.
* See the LEGAL file in the main directory for details.
*
* 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.
*/
?>
<?php
require_once "set_debug.php";
require_once "lib.php";
if (is_file("../defaults.php"))
require_once "../defaults.php";
if (is_file("../config.php"))
require_once "../config.php";
global $allow_code_comment,$use_comments_docs;
$allow_code_comment = true;
$use_comments_docs = false;
?>
<html>
<head>
<title> Debug Page </title>
<link type="text/css" rel="stylesheet" href="../css/main.css" />
<script language="javascript" type="text/javascript" src="javascript.js"></script>
<?php
if ($addon_path=is_addon("font-awesome")) {
print "<link type=\"text/css\" rel=\"stylesheet\" href=\"../".$addon_path."/css/font-awesome.min.css\"/>";
}
?>
</head>
<body>
<?php
$array = array(
1 => "E_ERROR",
2 => "E_WARNING",
4 => "E_PARSE",
8 => "E_NOTICE",
16 => "E_CORE_ERROR",
32 => "E_CORE_WARNING",
64 => "E_COMPILE_ERROR",
128 => "E_COMPILE_WARNING",
256 => "E_USER_ERROR",
512 => "E_USER_WARNING",
1024 => "E_USER_NOTICE",
2048 => "E_STRICT",
4096 => "E_RECOVERABLE_ERROR",
8191 => "E_ALL",
6183 => "E_ALL ^ E_NOTICE",
10239 => "E_ALL | E_STRICT",
0 => "disable"
);
$action = getparam("action");
if($action)
$call = "debug_".$action;
else
$call = "debug";
$call();
function debug()
{
global $array, $logs_in, $debug_modules, $debug_filters, $debug_tags_js;
if (!is_array($debug_modules))
$debug_modules = array();
if (!is_array($debug_filters))
$debug_filters = array();
if(!is_array($debug_tags_js))
$debug_tags_js = array();
$error = ini_get("error_reporting");
$errors = $array;
if(isset($array[$error]))
$errors["selected"] = $array[$error];
else{
$errors[$error] = $error;
$errors["selected"] = $errors[$error];
}
$display_errors = (ini_get("display_errors")) ? 't' : 'f';
$dump_xdebug = (isset($_SESSION["dump_xdebug"])) ? "t" : "f";
$debug_queries = (isset($_SESSION["debug_all"])) ? "t" : "f";
$display_logs_on_web = (isset($_SESSION["display_logs_on_web"])) ? $_SESSION["display_logs_on_web"] : false;
$enable_debug_buttons = (isset($_SESSION["enable_debug_buttons"])) ? $_SESSION["enable_debug_buttons"] : false;
$debug_modules = (isset($_SESSION["debug_modules"])) ? $_SESSION["debug_modules"] : implode(",", $debug_modules);
$impl_filters = (isset($_SESSION["debug_filters"])) ? $_SESSION["debug_filters"] : implode(",", $debug_filters);
$debug_tags_js = (isset($_SESSION["debug_tags_js"])) ? $_SESSION["debug_tags_js"] : implode(",", $debug_tags_js);
$log_errors = (ini_get("log_errors")) ? "t" : "f";
$error_log = ($a = ini_get("error_log")) ? $a : '';
$arr = array(
"pass_debug"=>array("compulsory"=>true, "column_name"=>"Password", "comment"=>"Password to be allowed to modify the debugging options (set in config.php usually)"),
// Setting debug levels
"objtitle1"=>array("display"=> "objtitle" , "value"=> "Setting/Activating debug levels"),
"objtitle3"=>array("display"=> "objtitle" , "value"=> "PHP debug options - Messages that appear in web page or log file"),
"enable_debug_buttons"=>array("value"=>$enable_debug_buttons, "display"=>"checkbox"),
"dump_xdebug"=>array("value"=>$dump_xdebug, "display"=>"checkbox", "comment"=>"Dump xdebug log in log file - not the php xdebug, but application and library specific xdebug."),
"debug_queries"=>array("value"=>$debug_queries, "display"=>"checkbox", "comment"=>"Dump query log in log file."),
"display_logs_on_web"=>array("column_name"=>"Display debug in web page<sup>*</sup></br><font style='color:#aaa;size:5px;'>* All debug is shown if no Debug tags/filters are set</font>","value"=>$display_logs_on_web, "display"=>"checkbox", "comment"=>"If checked the logs will be displayed on screen. If 'dump_xdebug'/'debug_queries' is not checked, just module logs will be displayed. By default logs are added in " . implode(",", $logs_in)),
"debug_modules"=>array("value"=>$debug_modules, "comment"=>"Comma delimited list of tags for which the values must be displayed. Overwrites critical_tags, debug_tags value with provided value and debug_all variable becomes false.", "column_name"=>"Debug tags"),
"debug_filters"=>array("value"=>$impl_filters, "comment"=>"Comma separated list of filters: tags or pieces of messages","column_name"=>"Debug filters(tags,pieces of messages)"),
"objtitle4"=>array("display"=> "objtitle" , "value"=> "Javascript debug options - Messages that appear in browser console.log"),
"debug_tags_js"=>array("value"=>$debug_tags_js, "comment"=>"Comma delimited list of javascript function names", "column_name"=>"Debug javascript tags"),
"examples_title"=>array("display"=> "objtitle" , "value"=> "Usage examples"),
"examples"=>array(
"display"=>"message",
"value"=>"
<ul>
<li> Display all Debug::debug_message() function output</li>
<ul>
<li> check 'Display debug in web page' </li>
</ul>
<li> Filter output from Debug::debug_message() </li>
<ul>
<li> Insert comma separated list of tags to be shown in page - Debug tags </li>
<li> Insert comma separated list of string to be matched agains tags or parts of the message - Debug filters </li>
</ul>
<li> View logs from \$_Session['xdebug']</li>
<ul>
<li> by default logs are displayed in \$_Session['xdebug']</li>
<li> use Dump \$_SESSION button to visualize them </li>
</ul>
<li> send all xdebug logs in log file </li>
<ul>
<li> check dump_xdebug </li>
</ul>
<li> display all xdebug logs on screen</li>
<ul>
<li> check dump_xdebug field</li>
<li> check 'Display logs on web' field</li>
</ul>
<li> display just xdebug logs from specific tags on screen</li>
<ul>
<li> check dump_xdebug</li>
<li> check 'Display logs on web' field</li>
<li> add the tags in debug_modules field </li>
</ul>
<li> enable/disable debug buttons</li>
<ul>
<li> check/uncheck 'Enable debug buttons' option</li>
</ul>
</ul>",
"no_escape"=>true),
// Setting php ini
"objtitle2"=>array("display"=> "objtitle" , "value"=> "Overwriting settings from php.ini"),
"error_reporting"=>array($errors, "display"=>"select", "comment"=>"Controls php error_reporting. If set it will be kept in session and it will modify error_reporting until logging out or modifying it again from this form."),
"display_errors"=>array("value"=>$display_errors, "display"=>"checkbox", "comment"=>"Controls php display_errors. If set it will be kept in session and it will modify error_reporting until logging out or modifying it again from this form."),
"log_errors"=>array("value"=>$log_errors, "display"=>"checkbox", "comment"=>"Controls php log_errors. If set it will be kept in session and it will modify error_reporting until logging out or modifying it again from this form."),
"error_log"=>array("value"=>$error_log/*, "display"=>"checkbox"*/),
);
if (is_auth("debug"))
unset($arr["pass_debug"]);
$submit_button = "<input class=\"edit\" name=\"Save\" value=\"Save\" type=\"submit\">";
$reset_button = "<input class=\"edit\" value=\"Reset\" type=\"reset\">";
$cancel_link = previous_page_link();
$cancel_button = "<input class=\"edit\" value=\"Cancel\" onclick=\"location.replace('$cancel_link');\" type=\"button\">";
$arr["buttons"] = array("display"=>"custom_submit", "value"=>$submit_button . " " . $reset_button . " " . $cancel_button);
?> <br/><br/>
<form action="debug_all.php" method="post"><?php
addHidden("database");
editObject(NULL,$arr, "Debug Settings - per session", "no");
?></form><?php
}
function debug_database()
{
global $array, $pass_debug_page;
if (!check_auth("debug")) {
print "Error! Please insert debug password to see this page.";
debug();
return;
}
if (getparam("display_logs_on_web")) {
$_SESSION["display_logs_on_web"] = true;
} else
unset($_SESSION["display_logs_on_web"]);
if (getparam("debug_modules")) {
$debug_modules = getparam("debug_modules");
$_SESSION["debug_modules"] = $debug_modules;
} else
unset($_SESSION["debug_modules"]);
if (getparam("debug_filters")) {
$debug_filters = getparam("debug_filters");
$_SESSION["debug_filters"] = $debug_filters;
} else
unset($_SESSION["debug_filters"]);
if(getparam("debug_tags_js")) {
$debug_tags_js = getparam("debug_tags_js");
$_SESSION["debug_tags_js"] = $debug_tags_js;
} else
unset($_SESSION["debug_tags_js"]);
if (getparam("enable_debug_buttons") == "on")
$_SESSION["enable_debug_buttons"] = "on";
else
unset($_SESSION["enable_debug_buttons"]);
if (getparam("debug_queries") == "on")
$_SESSION["debug_all"] = "on";
else
unset($_SESSION["debug_all"]);
if (getparam("dump_xdebug") == "on")
$_SESSION["dump_xdebug"] = "on";
else
unset($_SESSION["dump_xdebug"]);
$err = getparam("error_reporting");
$error_reporting = NULL;
foreach($array as $key=>$value) {
// print $key. ' '. $value.'<br/>';
if($value == $err) {
$error_reporting = $key;
break;
}
}
if(!$error_reporting)
$error_reporting = $err;
ini_set("error_reporting",$error_reporting);
$_SESSION["error_reporting"] = $error_reporting;
// ini_set('error_reporting', E_ALL);
$display_errors = (getparam("display_errors") == "on") ? true : false;
ini_set("display_errors",$display_errors);
$_SESSION["display_errors"] = $display_errors;
$log_errors = (getparam("log_errors") == "on") ? true : false;
ini_set("log_errors",$log_errors);
$_SESSION["log_errors"] = $log_errors;
$error_log = getparam("error_log");
ini_set("error_log", $error_log);
$_SESSION["error_log"] = $error_log;
$previous_link = previous_page_link() ;
message("Settings were saved!<a href='$previous_link'>Back to previous page.</a>", "no", "", false);
debug();
}
function previous_page_link()
{
if (isset($_SESSION["previous_link"]))
$previous_link = $_SESSION["previous_link"];
else
$previous_link = str_replace("/ansql/debug_all.php", "", $_SERVER["PHP_SELF"]) . "/main.php";
$request_protocol = get_request_protocol();
return $request_protocol . "://" . $_SERVER["HTTP_HOST"] . $previous_link;
}
?>
</body>
</html>