-
Notifications
You must be signed in to change notification settings - Fork 0
/
sqlerrorlog.php
163 lines (126 loc) · 5.19 KB
/
sqlerrorlog.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
<?php
// turn on output buffering, to speed up php processing, and use gzip compression for sending the files !
//ob_start();
ini_set('zlib.output_compression_level', 3);
ob_start("ob_gzhandler");
//prevents caching
header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: post-check=0, pre-check=0",false);
session_cache_limiter("nocache");
session_start();
$path = ""; // add ../ to increase levels eg $path = "../"; if this page is in a subdirectory
//require the config file
require $path . ("config.php");
/////// CONFIRMED WORKING
// BEGIN CODE handle special characters to stop malicious users
$deleteentry = strip_tags($_REQUEST["deleteentry"]);
$deleteerror = strip_tags($_REQUEST["deleteerror"]);
// END CODE
//////
/////// CONFIRMED WORKING
// BEGIN CODE handle special characters to stop malicious users
$deleteentry = htmlspecialchars($deleteentry, ENT_QUOTES);
$deleteerror = htmlspecialchars($deleteerror, ENT_QUOTES);
// END CODE
//////
/////// CONFIRMED WORKING
// BEGIN CODE handle special characters to stop malicious users
$deleteentry = (int)$deleteentry;
// END CODE
//////
if ($deleteerror == 1){
//make query to the database
$sql1213 ="SELECT * FROM $sqltable_errorlog WHERE `datetime` = '$deleteentry'";
$result1213 = @mysqli_query($connection,$sql1213); // or die(mysqli_error());
if (!$result1213){
$errorsql = addslashes($sql1213);
$errormsg = addslashes(mysqli_error($connection));
$errorlog = mysqli_query($connection,"INSERT INTO `$sqltable_errorlog` VALUES ('$_SERVER[PHP_SELF]', '$errormsg', '$errorsql', '$timestamp', '$_SESSION[firstname] $_SESSION[lastname]', '$ip')");
die("An Error Occurred, the error has been logged for the admin to investigate.");
}
//get the number of rows in the result set
$num1213 = mysqli_num_rows($result1213);
//print a message or redirect elsewhere,based on result
if ($num1213 != 0){
$sql1214 = "DELETE FROM $sqltable_errorlog WHERE `datetime` = '$deleteentry' LIMIT 1";
$result1214 = @mysqli_query($connection,$sql1214); // or die(mysqli_error());
if (!$result1214){
$errorsql = addslashes($sql1214);
$errormsg = addslashes(mysqli_error($connection));
$errorlog = mysqli_query($connection,"INSERT INTO `$sqltable_errorlog` VALUES ('$_SERVER[PHP_SELF]', '$errormsg', '$errorsql', '$timestamp', '$_SESSION[firstname] $_SESSION[lastname]', '$ip')");
die("An Error Occurred, the error has been logged for the admin to investigate.");
}
echo "<p>The error entry has been deleted</p>";
}else{
echo "<p>Entry could not be found for deletion.</p>";
}
$deleteerror = 0;
}
$pagesubtitle = "SQL Error Log";
//include the page top file
include $path . "includes/pagehead.php";
?>
<br>
<div class="sgc">
<h2>MySQL Error log</h2>
</div>
<BR>
<div class="sgul sgc sg14 sgmargin0 sgdiv">
<?php
/////////////////
//BEGIN CODE get image table display
$sql217 ="SELECT * FROM `$sqltable_errorlog`";
$result217 = @mysqli_query($connection,$sql217); // or die("Some Error Occured");//die(mysqli_error());
if (!$result217){
$errorsql = addslashes($sql217);
$errormsg = addslashes(mysqli_error($connection));
$errorlog = mysqli_query($connection,"INSERT INTO `$sqltable_errorlog` VALUES ('$_SERVER[PHP_SELF]', '$errormsg', '$errorsql', '$timestamp', '$_SESSION[firstname] $_SESSION[lastname]', '$ip')");
die("An Error Occurred, the error has been logged for the admin to investigate.");
}
//get the number of rows in the result set
$num217 = mysqli_num_rows($result217);
if ($num217 != 0) {
$bgcolor = "row1colour"; // set initial background colour
echo "<table border=\"0\" width=\"95%\" align=\"center\" class=\"bgcolour6\">";
echo "<tr class=\"bgcolour6\">";
echo "<td align=\"center\" width=\"10%\">Page Name</td>";
echo "<td align=\"center\" width=\"20%\">SQL Error</td>";
echo "<td align=\"center\" width=\"39%\">SQL Query</td>";
echo "<td align=\"center\" width=\"8%\">IP Address</td>";
echo "<td align=\"center\" width=\"15%\">Date Time</td>";
echo "</tr>";
while ($sql217 = mysqli_fetch_object($result217)) {
if($bgcolor=="row1colour"){
$bgcolor="row2colour";
}else{
$bgcolor="row1colour";
}
$sqlerrorpagename = $sql217 -> pagename;
$sqlerrorerror = $sql217 -> errormessage;
$sqlerrorerrorsql = $sql217 -> errorsql;
$sqlerrordatetime = $sql217 -> datetime;
$sqlerrorip = $sql217 -> ip;
$sqlerrordatetimeview = gmdate($datetimeformat, $sqlerrordatetime); // confirmed correct
echo "<tr class=\"$bgcolor\">";
echo "<td align=\"center\"><span class=\"sg10\">$sqlerrorpagename<br><a href=\"$_SERVER[PHP_SELF]?deleteentry=$sqlerrordatetime&deleteerror=1\">Delete this entry</a></span></td>";
echo "<td align=\"center\"><span class=\"sg10\">$sqlerrorerror</span></td>";
echo "<td align=\"center\"><span class=\"sg10\">$sqlerrorerrorsql</span></td>";
echo "<td align=\"left\"><span class=\"sg10\">$sqlerrorip</span></td>";
echo "<td align=\"center\"><span class=\"sg10\">$sqlerrordatetimeview</span></td>";
echo "</tr>";
}
echo "</table><BR><BR>";
}
else{
echo "<br>There are no errors logged in the database.<BR><BR>";
}
// END CODE
///////////////
?>
</div>
<BR>
<?php
//include the footer file
include $path . "includes/pagefoot.php";
?>