-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.php
More file actions
137 lines (131 loc) · 4.1 KB
/
Copy patherror.php
File metadata and controls
137 lines (131 loc) · 4.1 KB
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
<?PHP
// EXCEPTION
set_error_handler(function($errno,$error,$file,$line){});
// START
$sandbox = false;
$content = READ_FILE('error_log');
$collection = SCAN_FILE($content);
if ($sandbox == true) {
var_dump
(
$content,
$collection
);}
// LOGIC
function READ_FILE ($directory)
{
$flag = 'r';
$size = filesize($directory);
$file_object = fopen($directory,$flag) or
die('No such file or directory "'.$directory.'"!');
$content = array();
while (!feof($file_object))
{
$stream = fgets($file_object); // IF FILE NOT EMPTY
if ($stream)
array_push($content,$stream);
}
fclose($file_object);
return $content;
}
function SCAN_FILE ($content)
{
$collection = array();
foreach ($content as $key => $value)
{
$hashmap = new stdClass();
// ERROR
$hashmap->ERROR = trim($value);
$arr_main = explode('] ',$value);
// DATE, TIME AND TIME ZONE
$str_dtz = substr($arr_main[0],1);
$arr_dtz = explode(' ',$str_dtz);
$hashmap->DATE = $arr_dtz[0];
$d = strtotime($arr_dtz[0]);
$hashmap->DATE_BUFF = date('D, M d, Y',$d);
$hashmap->TIME = $arr_dtz[1];
$t = strtotime($arr_dtz[1]);
$hashmap->TIME_BUFF = date('h:i A',$t);
$hashmap->TIME_ZONE = $arr_dtz[2];
// ERROR TYPE
$arr_ert = explode(': ',$arr_main[1]);
$hashmap->TYPE = $arr_ert[0];
// ERROR TRIMMED
$arr_err = explode(' on line ',$arr_ert[1]);
$hashmap->ERROR_TRIM = $arr_err[0];
// FILES AFFECTED
$arr_erf = explode(' in /',$arr_err[0]);
array_shift($arr_erf);
$hashmap->FILE = $arr_erf;
// SOURCE LINE
$hashmap->LINE = trim($arr_err[1]);
// BUILD HASHMAP
$collection[$key] = $hashmap;
}
return $collection;
}
?>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<title>ERROR_LOG</title>
<style type="text/css">
body {color:#333; font-family:Arial, Helvetica, sans-serif; font-size:14px;}
table {border-collapse:collapse;}
caption {padding:10px 15px; margin-bottom:10px; background-color:#ebf8a4; text-align:left; border:solid thin #5da555; border-radius:5px 5px 0 0; border-bottom:none;}
th {padding:5px 10px; background-color:#dfdfdf; color:#235a93; font-weight:bold; border:solid thin #fff;}
th {
background: #dfdfdf; /* For browsers that do not support gradients */
background: -webkit-linear-gradient(#fff, #dfdfdf); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(#fff, #dfdfdf); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(#fff, #dfdfdf); /* For Firefox 3.6 to 15 */
background: linear-gradient(#fff, #dfdfdf); /* Standard syntax */
}
th:hover {text-decoration:underline; cursor:pointer;}
td {padding:10px; font-weight:lighter; line-height:1.2;}
td[nowrap="true"] {white-space:nowrap;}
tr:nth-child(even) td {background-color:#dfdfdf;}
tr:hover td {background-color:#bdcbd9;}
</style>
</head>
<body>
<table border="0" width="100%" summary="error log">
<tr>
<th title="S/N">#</th>
<th title="DATE_BUFF">DATE</th>
<th title="TIME_BUFF (TIME_ZONE)">TIME</th>
<th title="ERROR TYPE">TYPE</th>
<th title="ERROR_TRIM">ERROR MESSAGE</th>
<th title="ERROR LINE">LINE</th>
</tr>
<?php
// CAPTION
$total = count($collection);
$index = $total - 1;
$secs = date('s');
$success = 'Showing rows 0 - '.$index.' (~'.$total.' total, Query took 0.00'.$secs.' seconds.)';
$failed = 'MySQL returned an empty result set (i.e. zero rows). (Query took 0.00'.$secs.' seconds.)';
$caption = $total > 0? $success : $failed;
echo '<caption>✔ '.$caption.'</caption>';
// BODY
$sn = 1;
$buffer = '';
krsort($collection); // ORDER BY KEY DESC
foreach ($collection as $i => $e)
{
$buffer .= '<tr valign="top">';
$buffer .= '<td align="right">'.$sn.'</td>';
$buffer .= '<td nowrap="true">'.$e->DATE_BUFF.'</td>';
$buffer .= '<td nowrap="true">'.$e->TIME_BUFF.' ('.$e->TIME_ZONE.')</td>';
$buffer .= '<td>'.$e->TYPE.'</td>';
$buffer .= '<td>'.$e->ERROR_TRIM.'</td>';
$buffer .= '<td>'.$e->LINE.'</td>';
$buffer .= '</tr>';
$sn++;
}
echo $buffer;
?>
</table>
</body>
</html>