forked from NB-Core/lotgd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.php
79 lines (69 loc) · 2.76 KB
/
debug.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
<?php
// translator ready
// addnews ready
// mail ready
require_once("common.php");
require_once("lib/dhms.php");
require_once("lib/http.php");
tlschema("debug");
check_su_access(SU_EDIT_CONFIG);
require_once("lib/superusernav.php");
superusernav();
addnav("Debug Options");
addnav("",$_SERVER['REQUEST_URI']);
$sort = httpget('sort');
addnav("Get Pageruntimes","debug.php?debug=pageruntime&sort=".URLEncode($sort));
addnav("Get Modulehooktimes","debug.php?debug=hooksort&sort=".URLEncode($sort));
page_header("Debug Analysis");
$order = "sum";
if ($sort!="") $order=$sort;
$debug=httpget('debug');
if ($debug=='') $debug='pageruntime';
$ascdesc_raw=(int)httpget('direction');
if ($ascdesc_raw) $ascdesc="ASC";
else $ascdesc="DESC";
addnav("Sorting");
addnav("By Total","debug.php?debug=".$debug."&sort=sum&direction=".$ascdesc_raw);
addnav("By Average","debug.php?debug=".$debug."&sort=medium&direction=".$ascdesc_raw);
addnav("Switch ASC/DESC","debug.php?debug=".$debug."&sort=".URLEncode($sort)."&direction=".(!$ascdesc_raw));
switch ($debug) {
case "hooksort":
$sql = "Select category,subcategory, value+0 as sum, (value+0)/count(id) as medium,count(id) AS counter FROM ".db_prefix('debug')." WHERE type='hooktime' group by type,category,subcategory order by $order $ascdesc limit 30";
$category=translate_inline("Setting");
$subcategory=translate_inline("Module Name");
$sum_desc=translate_inline("Total Seconds");
$med_desc=translate_inline("Average per Hit");
$hits=translate_inline("Hits");
break;
case "pageruntime":
default:
$sql = "Select category,subcategory, value+0 as sum, (value+0)/count(id) as medium,count(id) AS counter FROM ".db_prefix('debug')." WHERE type='pagegentime' group by type,category,subcategory order by $order $ascdesc limit 30";
$category=translate_inline("Setting");
$subcategory=translate_inline("Module Name");
$sum_desc=translate_inline("Total Seconds");
$med_desc=translate_inline("Average per Hit");
$hits=translate_inline("Hits");
}
$none = translate_inline("`iNone`i");
$notset = translate_inline("`iNot set`i");
rawoutput("<table border=0 cellpadding=2 cellspacing=1><tr class='trhead'><td>$category</td><td>$subcategory</td><td>$sum_desc</td><td>$med_desc</td><td>$hits</td></tr>");
debug($sql);
$result = db_query($sql);
$i=true;
while ($row = db_fetch_assoc($result)) {
$i=!$i;
rawoutput("<tr class='".($i?'trdark':'trlight')."'><td valign='top'>");
output_notl("`b".$row['category']."`b");
rawoutput("</td><td valign='top'>");
output_notl("`b".$row['subcategory']."`b");
rawoutput("</td><td valign='top'>");
output_notl($row['sum']);
rawoutput("</td><td valign='top'>");
output_notl($row['medium']);
rawoutput("</td><td valign='top'>");
output_notl($row['counter']);
rawoutput("</td></tr>");
}
rawoutput("</table>");
page_footer();
?>