From ChekMate Security Group
<?
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2002 Michael Earls |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| 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. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| php-syslog-ng: php4 mysql syslog-ng |
+-------------------------------------------------------------------------+
| This code is currently maintained and debugged by Michael Earls, any |
| questions or comments regarding this code should be directed to: |
| - michael@michaelearls.com |
+-------------------------------------------------------------------------+
| - vermeer - http://www.vermeer.org/ |
+-------------------------------------------------------------------------+
*/
?><html><header>
<?
echo "<META HTTP-EQUIV=\"refresh\" content=\"300;URL=$PHP_SELF?offset=$offset&Field1=$Field1&Condition1=$Condition1&Substring1=$Substring1&Boolean1=$Boolean1&Field2=$Field2&Condition2=$Condition2&Substring2=$Substring2&Boolean2=$Boolean2&Field3=$Field3&Condition3=$Condition3&Substring3=$Substring3&Boolean3=$Boolean3&Field4=$Field4&Condition4=$Condition4&Substring4=$Substring4&limit=$limit\">";
if ($_GET['Field1'] == "") { $Field1 = $_POST['Field1']; } else { $Field1 = $_GET['Field1']; }
if ($_GET['Field2'] == "") { $Field2 = $_POST['Field2']; } else { $Field2 = $_GET['Field2']; }
if ($_GET['Field3'] == "") { $Field3 = $_POST['Field3']; } else { $Field3 = $_GET['Field3']; }
if ($_GET['Field4'] == "") { $Field4 = $_POST['Field4']; } else { $Field4 = $_GET['Field4']; }
if ($_GET['Condition1'] == "") { $Condition1 = $_POST['Condition1']; } else { $Condition1 = $_GET['Condition1']; }
if ($_GET['Condition2'] == "") { $Condition2 = $_POST['Condition2']; } else { $Condition2 = $_GET['Condition2']; }
if ($_GET['Condition3'] == "") { $Condition3 = $_POST['Condition3']; } else { $Condition3 = $_GET['Condition3']; }
if ($_GET['Condition4'] == "") { $Condition4 = $_POST['Condition4']; } else { $Condition4 = $_GET['Condition4']; }
if ($_GET['Substring1'] == "") { $Substring1 = $_POST['Substring1']; } else { $Substring1 = $_GET['Substring1']; }
if ($_GET['Substring2'] == "") { $Substring2 = $_POST['Substring2']; } else { $Substring2 = $_GET['Substring2']; }
if ($_GET['Substring3'] == "") { $Substring3 = $_POST['Substring3']; } else { $Substring3 = $_GET['Substring3']; }
if ($_GET['Substring4'] == "") { $Substring4 = $_POST['Substring4']; } else { $Substring4 = $_GET['Substring4']; }
if ($_GET['Boolean1'] == "") { $Boolean1 = $_POST['Boolean1']; } else { $Boolean1 = $_GET['Boolean1']; }
if ($_GET['Boolean2'] == "") { $Boolean2 = $_POST['Boolean2']; } else { $Boolean2 = $_GET['Boolean2']; }
if ($_GET['Boolean3'] == "") { $Boolean3 = $_POST['Boolean3']; } else { $Boolean3 = $_GET['Boolean3']; }
if (strtolower($Substring1) == "error") { $Substring1 = "err"; }
if (strtolower($Substring2) == "error") { $Substring2 = "err"; }
if (strtolower($Substring3) == "error") { $Substring3 = "err"; }
if (strtolower($Substring4) == "error") { $Substring4 = "err"; }
?>
<head>
<title>
Network Syslog Advanced Search Results
</title>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
</head>
<body><font face=arial size=2>
<?
include("dbinfo.inc.php");
@ $db = mysql_pconnect("$hostname", "$username", "$password");
if (!$db)
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}
@mysql_select_db( "$dbName") or die( "Unable to select database");
?>
<?
if ($limit == "") { $limit = 25; }
$message = urldecode($message);
?>
<div align="center">
<center>
<table border="0" cellspacing="0" id="AutoNumber2">
<tr>
<td align="center" rowspan="2"><font face="arial" size="2">
<a href="index.php" border="0">
<img src="images/NetworkSyslogViewer.gif" border="0" width="211" height="74"></a></font></td>
<td align="center" rowspan="2"><font face="arial" size="2">
<p align="center"> </p>
</font>
<p> </td>
</tr>
<tr>
<td>
<form method="POST" action="advanced.php">
<table border="0" id="AutoNumber1">
<tr>
<td align="left" colspan="2"> <font face="Arial" size="2"><b>Corporate Network Advanced Search</b></font></td>
<td align="center"> <font face="Arial" size="2">Records per page</font></td>
<td align="center">
<font face="Arial" size="2"><select name="limit">
<option <?if ($limit == "25") {echo "selected"; }?>>25</option>
<option <?if ($limit == "50") {echo "selected"; }?>>50</option>
<option <?if ($limit == "100") {echo "selected"; }?>>100</option>
<option <?if ($limit == "200") {echo "selected"; }?>>200</option>
<option <?if ($limit == "500") {echo "selected"; }?>>500</option>
<option <?if ($limit == "1000") {echo "selected"; }?>>1000</option>
</select></font></td>
</tr>
<tr>
<td align="center"> <select size="1" name="Field1">
<option> </option>
<option <?if ($Field1 == "host") {echo "Selected"; }?> value="host">Host</option>
<option <?if ($Field1 == "facility") {echo "Selected"; }?> value="facility">Facility</option>
<option <?if ($Field1 == "priority") {echo "Selected"; }?> value="priority">Priority</option>
<option <?if ($Field1 == "date") {echo "Selected"; }?> value="date">Date</option>
<option <?if ($Field1 == "time") {echo "Selected"; }?> value="time">Time</option>
<option <?if ($Field1 == "program") {echo "Selected"; }?> value="program">Program</option>
<option <?if ($Field1 == "msg") {echo "Selected"; }?> value="msg">Msg</option>
</select></td>
<td align="center"> <select size="1" name="Condition1">
<option <?if ($Condition1 == "Equals") {echo "Selected"; }?>>Equals</option>
<option <?if ($Condition1 == "Not Equal To") {echo "Selected"; }?>>Not Equal To</option>
<option <?if ($Condition1 == "Less Than or Equals") {echo "Selected"; }?>>Less Than or Equals</option>
<option <?if ($Condition1 == "Greater Than or Equals") {echo "Selected"; }?>>Greater Than or Equals</option>
</select></td>
<td align="center"> <input type="text" name="Substring1" value="<?echo $Substring1?>" size="20"></td>
<td align="center">
<select size="1" name="Boolean1">
<option <?if ($Boolean1 == "AND") {echo "selected"; }?>>AND</option>
<option <?if ($Boolean1 == "OR") {echo "selected"; }?>>OR</option>
</select></td>
</tr>
<tr>
<td align="center"> <select size="1" name="Field2">
<option> </option>
<option <?if ($Field2 == "host") {echo "Selected"; }?> value="host">Host</option>
<option <?if ($Field2 == "facility") {echo "Selected"; }?> value="facility">Facility</option>
<option <?if ($Field2 == "priority") {echo "Selected"; }?> value="priority">Priority</option>
<option <?if ($Field2 == "date") {echo "Selected"; }?> value="date">Date</option>
<option <?if ($Field2 == "time") {echo "Selected"; }?> value="time">Time</option>
<option <?if ($Field2 == "program") {echo "Selected"; }?> value="program">Program</option>
<option <?if ($Field2 == "msg") {echo "Selected"; }?> value="msg">Msg</option>
</select></td>
<td align="center"> <select size="1" name="Condition2">
<option <?if ($Condition2 == "Equals") {echo "Selected"; }?>>Equals</option>
<option <?if ($Condition2 == "Not Equal To") {echo "Selected"; }?>>Not Equal To</option>
<option <?if ($Condition2 == "Less Than or Equals") {echo "Selected"; }?>>Less Than or Equals</option>
<option <?if ($Condition2 == "Greater Than or Equals") {echo "Selected"; }?>>Greater Than or Equals</option>
</select></td>
<td align="center"> <input type="text" name="Substring2" value="<?echo $Substring2?>" size="20"></td>
<td align="center">
<select size="1" name="Boolean2">
<option <?if ($Boolean2 == "AND") {echo "selected"; }?>>AND</option>
<option <?if ($Boolean2 == "OR") {echo "selected"; }?>>OR</option>
</select></td>
</tr>
<tr>
<td align="center"> <select size="1" name="Field3">
<option> </option>
<option <?if ($Field3 == "host") {echo "Selected"; }?> value="host">Host</option>
<option <?if ($Field3 == "facility") {echo "Selected"; }?> value="facility">Facility</option>
<option <?if ($Field3 == "priority") {echo "Selected"; }?> value="priority">Priority</option>
<option <?if ($Field3 == "date") {echo "Selected"; }?> value="date">Date</option>
<option <?if ($Field3 == "time") {echo "Selected"; }?> value="time">Time</option>
<option <?if ($Field3 == "program") {echo "Selected"; }?> value="program">Program</option>
<option <?if ($Field3 == "msg") {echo "Selected"; }?> value="msg">Msg</option>
</select></td>
<td align="center"> <select size="1" name="Condition3">
<option <?if ($Condition3 == "Equals") {echo "Selected"; }?>>Equals</option>
<option <?if ($Condition3 == "Not Equal To") {echo "Selected"; }?>>Not Equal To</option>
<option <?if ($Condition3 == "Less Than or Equals") {echo "Selected"; }?>>Less Than or Equals</option>
<option <?if ($Condition3 == "Greater Than or Equals") {echo "Selected"; }?>>Greater Than or Equals</option>
</select></td>
<td align="center"> <input type="text" name="Substring3" value="<?echo $Substring3?>" size="20"></td>
<td align="center">
<select size="1" name="Boolean3">
<option <?if ($Boolean3 == "AND") {echo "selected"; }?>>AND</option>
<option <?if ($Boolean3 == "OR") {echo "selected"; }?>>OR</option>
</select></td>
</tr>
<tr>
<td align="center"> <select size="1" name="Field4">
<option> </option>
<option <?if ($Field4 == "host") {echo "Selected"; }?> value="host">Host</option>
<option <?if ($Field4 == "facility") {echo "Selected"; }?> value="facility">Facility</option>
<option <?if ($Field4 == "priority") {echo "Selected"; }?> value="priority">Priority</option>
<option <?if ($Field4 == "date") {echo "Selected"; }?> value="date">Date</option>
<option <?if ($Field4 == "time") {echo "Selected"; }?> value="time">Time</option>
<option <?if ($Field4 == "program") {echo "Selected"; }?> value="program">Program</option>
<option <?if ($Field4 == "msg") {echo "Selected"; }?> value="msg">Msg</option>
</select></td>
<td align="center"> <select size="1" name="Condition4">
<option <?if ($Condition4 == "Equals") {echo "Selected"; }?>>Equals</option>
<option <?if ($Condition4 == "Not Equal To") {echo "Selected"; }?>>Not Equal To</option>
<option <?if ($Condition4 == "Less Than or Equals") {echo "Selected"; }?>>Less Than or Equals</option>
<option <?if ($Condition4 == "Greater Than or Equals") {echo "Selected"; }?>>Greater Than or Equals</option>
</select></td>
<td align="center"> <input type="text" name="Substring4" value="<?echo $Substring4?>" size="20"></td>
<td align="center">
<input type="submit" value="Search" name="Search"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</center>
</div>
<font face="arial" size="2"></font>
<?
// begin script
if (($Field1) OR ($Field2) OR ($Field3) OR ($Field4)) {
mysql_select_db("$dbName");
$where = "";
$query = "select host, priority, msg, date, time from logs";
if($where !="") { $query = $query." where ".$where; }
if (($Field1 <> "") && ($Substring1)) {
if ($Condition1 == "Equals") {
if ($Field1 == "date") {$whereis .= "$Field1 = '$Substring1'"; } else { $whereis .= "$Field1 LIKE '%$Substring1%'"; }
}
if ($Condition1 == "Not Equal To") {
if ($Field1 == "date") {$whereis .= "$Field1 <> '$Substring1'"; } else { $whereis .= "$Field1 NOT LIKE '%$Substring1%'"; }
}
if ($Condition1 == "Less Than or Equals") {
$whereis .= "$Field1 <= '$Substring1'";
}
if ($Condition1 == "Greater Than or Equals") {
$whereis .= "$Field1 >= '$Substring1'";
}
}
if (($Field2 <> "") && ($Substring2)) {
if ($Boolean1 == "AND") { $whereis = $whereis . " AND "; } else { $whereis = $whereis . " OR ";}
if ($Condition2 == "Equals") {
if ($Field2 == "date") {$whereis .= "$Field2 = '$Substring2'"; } else { $whereis .= "$Field2 LIKE '%$Substring2%'"; }
}
if ($Condition2 == "Not Equal To") {
if ($Field2 == "date") {$whereis .= "$Field2 <> '$Substring2'"; } else { $whereis .= "$Field2 NOT LIKE '%$Substring2%'"; }
}
if ($Condition2 == "Less Than or Equals") {
$whereis .= "$Field2 <= '$Substring2'";
}
if ($Condition2 == "Greater Than or Equals") {
$whereis .= "$Field2 >= '$Substring2'";
}
}
if (($Field3 <> "") && ($Substring3)) {
if ($Boolean2 == "AND") { $whereis = $whereis . " AND "; } else { $whereis = $whereis . " OR ";}
if ($Condition3 == "Equals") {
if ($Field3 == "date") {$whereis .= "$Field3 = '$Substring3'"; } else { $whereis .= "$Field3 LIKE '%$Substring3%'"; }
}
if ($Condition3 == "Not Equal To") {
if ($Field3 == "date") {$whereis .= "$Field3 <> '$Substring3'"; } else { $whereis .= "$Field3 NOT LIKE '%$Substring3%'"; }
}
if ($Condition3 == "Less Than or Equals") {
$whereis .= "$Field3 <= '$Substring3'";
}
if ($Condition3 == "Greater Than or Equals") {
$whereis .= "$Field3 >= '$Substring3'";
}
}
if (($Field4 <> "") && ($Substring4)) {
if ($Boolean3 == "AND") { $whereis = $whereis . " AND "; } else { $whereis = $whereis . " OR ";}
if ($Condition4 == "Equals") {
if ($Field4 == "date") {$whereis .= "$Field4 = '$Substring4'"; } else { $whereis .= "$Field4 LIKE '%$Substring4%'"; }
}
if ($Condition4 == "Not Equal To") {
if ($Field4 == "date") {$whereis .= "$Field4 <> '$Substring4'"; } else { $whereis .= "$Field4 NOT LIKE '%$Substring4%'"; }
}
if ($Condition4 == "Less Than or Equals") {
$whereis .= "$Field4 <= '$Substring4'";
}
if ($Condition4 == "Greater Than or Equals") {
$whereis .= "$Field4 >= '$Substring4'";
}
}
if ($neworder == 1) {
if ($order == 1) {
$order = 0;
} else {
$order = 1;
}
}
if ($order == 1) {
$orderby = "";
} else {
$orderby = "DESC";
}
$Field1 = urlencode($Field1);
$Field2 = urlencode($Field2);
$Field3 = urlencode($Field3);
$Field4 = urlencode($Field4);
$Condition1 = urlencode($Condition1);
$Condition2 = urlencode($Condition2);
$Condition3 = urlencode($Condition3);
$Condition4 = urlencode($Condition4);
$Substring1 = urlencode($Substring1);
$Substring2 = urlencode($Substring2);
$Substring3 = urlencode($Substring3);
$Substring4 = urlencode($Substring4);
$Boolean1 = urlencode($Boolean1);
$Boolean2 = urlencode($Boolean2);
$Boolean3 = urlencode($Boolean3);
if($sort !="") {
$doorder = " order by ".$sort." $orderby, date DESC, time DESC";
} else {
$doorder = " order by date $orderby, time DESC";
}
$query = "select host, priority, msg, date, time from logs where $whereis $doorder";
$result = mysql_query($query);
if ($result == 0) {
echo "<center><br><br><b>Searching the logs where $whereis produced No Results.</b></center>";
} else {
$num_results = mysql_num_rows($result);
if (empty($offset)) {
$offset=1;
}
$offsettemp=$offset-1;
$startoffsetnum = $offset;
$endoffsetnum = $offset + $limit;
if ($endoffsetnum > $num_results) {$endoffsetnum = $num_results;}
$results = mysql_query("$query limit $offsettemp, $limit");
if ($host <> "*") {
$searchstring = "Host = " . $host;
}
if ($priority <> "*") {
if ($searchstring <> "") { $searchstring = $searchstring . "</b> and <b>"; }
$searchstring = $searchstring . "Priority = $priority";
}
if ($date <> "*") {
if ($searchstring <> "") { $searchstring = $searchstring . "</b> and <b>"; }
$searchstring = $searchstring . "Date = $date";
}
if ($message <> "") {
if ($searchstring <> "") { $searchstring = $searchstring . "</b> and <b>"; }
if (strlen($message) > 30) {
$formattedmessage = substr($message, 0, 30) . '...';
} else {
$formattedmessage = $message;
}
$searchstring = $searchstring . "Keywords = $formattedmessage";
}
if ($searchstring == "") { $searchstring = "for <b>All Results</b>"; } else {$searchstring = "where <b>" . $searchstring . "</b>"; }
if ($sort == "") { $sortmsg = "Date and Time"; } else { $sortmsg = ucwords($sort); }
if ($order == 1) { $sortmsg = $sortmsg." in Descending Order"; } else { $sortmsg = $sortmsg." in Ascending Order"; }
$sortmsg = "<b>$sortmsg</b>";
echo "<table width=100% bgcolor=#3366cc><tr><td><font face=arial size=2 color=white>Searched the logs where $whereis.</font></td><td align=right><font face=arial size=2 color=white>Results: <b>$startoffsetnum</b> - <b>$endoffsetnum</b> of <b>$num_results</b>.</font></td></tr></table>";
echo "<div align=center>";
echo "<table border=0 bordercolor=#000000 width=100%>";
echo "<tr bgcolor=#99CCFF>";
if ($neworder == 1) {$neworder=0; } else { $neworder=1;}
echo "<td ALIGN=CENTER><a href=$PHP_SELF?offset=1&Field1=$Field1&Condition1=$Condition1&Substring1=$Substring1&Boolean1=$Boolean1&Field2=$Field2&Condition2=$Condition2&Substring2=$Substring2&Boolean2=$Boolean2&Field3=$Field3&Condition3=$Condition3&Substring3=$Substring3&Boolean3=$Boolean3&Field4=$Field4&Condition4=$Condition4&Substring4=$Substring4&limit=$limit&order=$order&neworder=$neworder&sort=host><b><font size=2 color=#3366cc>Host</b></a></td>";
echo "<td ALIGN=CENTER><a href=$PHP_SELF?offset=1&Field1=$Field1&Condition1=$Condition1&Substring1=$Substring1&Boolean1=$Boolean1&Field2=$Field2&Condition2=$Condition2&Substring2=$Substring2&Boolean2=$Boolean2&Field3=$Field3&Condition3=$Condition3&Substring3=$Substring3&Boolean3=$Boolean3&Field4=$Field4&Condition4=$Condition4&Substring4=$Substring4&limit=$limit&order=$order&neworder=$neworder&sort=priority><b><font size=2 color=#3366cc>Priority</b></a></td>";
echo "<td ALIGN=CENTER><a href=$PHP_SELF?offset=1&Field1=$Field1&Condition1=$Condition1&Substring1=$Substring1&Boolean1=$Boolean1&Field2=$Field2&Condition2=$Condition2&Substring2=$Substring2&Boolean2=$Boolean2&Field3=$Field3&Condition3=$Condition3&Substring3=$Substring3&Boolean3=$Boolean3&Field4=$Field4&Condition4=$Condition4&Substring4=$Substring4&limit=$limit&order=$order&neworder=$neworder&sort=date><b><font size=2 color=#3366cc>Date</b></a></td>";
echo "<td ALIGN=CENTER><a href=$PHP_SELF?offset=1&Field1=$Field1&Condition1=$Condition1&Substring1=$Substring1&Boolean1=$Boolean1&Field2=$Field2&Condition2=$Condition2&Substring2=$Substring2&Boolean2=$Boolean2&Field3=$Field3&Condition3=$Condition3&Substring3=$Substring3&Boolean3=$Boolean3&Field4=$Field4&Condition4=$Condition4&Substring4=$Substring4&limit=$limit&order=$order&neworder=$neworder&order=time><b><font size=2 color=#3366cc>Time</b></a></td>";
echo "<td><a href=$PHP_SELF?offset=1&Field1=$Field1&Condition1=$Condition1&Substring1=$Substring1&Boolean1=$Boolean1&Field2=$Field2&Condition2=$Condition2&Substring2=$Substring2&Boolean2=$Boolean2&Field3=$Field3&Condition3=$Condition3&Substring3=$Substring3&Boolean3=$Boolean3&Field4=$Field4&Condition4=$Condition4&Substring4=$Substring4&limit=$limit&order=$order&neworder=$neworder&sort=msg><b><font size=2 color=#3366cc>Message</b></a></td>";
echo "</tr>";
while ($row = mysql_fetch_array($results))
{
if ($bgcolor == "#FFFFCC") {$bgcolor = "#FFFFFF";} else {$bgcolor = "#FFFFCC";}
echo "<tr bgcolor=$bgcolor>";
echo "<td ALIGN=CENTER VALIGN=TOP><font size=2>$row[host]</font></td>";
if ($row[priority] == "info") {
echo "<td ALIGN=CENTER VALIGN=TOP BGCOLOR=#FAEBD7><font size=2>Info</font></td>";
} else if ($row[priority] == "debug") {
echo "<td ALIGN=CENTER VALIGN=TOP BGCOLOR=#C1FFC1><font size=2>Debug</font></td>";
} else if ($row[priority] == "notice") {
echo "<td ALIGN=CENTER VALIGN=TOP BGCOLOR=#CAFF70><font size=2>Notice</font></td>";
} else if ($row[priority] == "warning") {
echo "<td ALIGN=CENTER VALIGN=TOP BGCOLOR=#FFFF00><font size=2>Warning</font></td>";
} else if ($row[priority] == "err") {
echo "<td ALIGN=CENTER VALIGN=TOP BGCOLOR=#FFA500><font size=2><b>Error</b></font></td>";
} else if ($row[priority] == "crit") {
echo "<td ALIGN=CENTER VALIGN=TOP BGCOLOR=#CC4500><font size=2><b>Critical</b></font></td>";
} else if ($row[priority] == "alert") {
echo "<td ALIGN=CENTER VALIGN=TOP BGCOLOR=#FF0000><font size=2><b>Alert</b></font></td>";
} else {
echo "<td ALIGN=CENTER VALIGN=TOP BGCOLOR=#C0C0C0><font size=2>$row[priority]</font></td>";
}
$displaydate = date("y/m/d",strtotime($row[date]));
echo "<td ALIGN=CENTER VALIGN=TOP><font size=2>$displaydate</font></td>";
echo "<td ALIGN=CENTER VALIGN=TOP><font size=2>$row[time]</font></td>";
# echo "<td VALIGN=TOP><font size=2>".htmlspecialchars($row[msg])."</font></td>";
echo "<td VALIGN=TOP><font size=2>".$row[msg]."</font></td>";
echo "</tr>";
}
echo "</table>";
echo "<hr>";
echo "Result Page: ";
if ($offset!=1) { // bypass PREV link if offset is 0
$firstoffset=0;
print "<a href=\"$PHP_SELF?offset=$firstoffset&Field1=$Field1&Condition1=$Condition1&Substring1=$Substring1&Boolean1=$Boolean1&Field2=$Field2&Condition2=$Condition2&Substring2=$Substring2&Boolean2=$Boolean2&Field3=$Field3&Condition3=$Condition3&Substring3=$Substring3&Boolean3=$Boolean3&Field4=$Field4&Condition4=$Condition4&Substring4=$Substring4&limit=$limit\"><font color=#000000><< First</font></a> \n";
$prevoffset=$offset-$limit ;
print "<a href=\"$PHP_SELF?offset=$prevoffset&Field1=$Field1&Condition1=$Condition1&Substring1=$Substring1&Boolean1=$Boolean1&Field2=$Field2&Condition2=$Condition2&Substring2=$Substring2&Boolean2=$Boolean2&Field3=$Field3&Condition3=$Condition3&Substring3=$Substring3&Boolean3=$Boolean3&Field4=$Field4&Condition4=$Condition4&Substring4=$Substring4&limit=$limit\"><font color=#000000>< Previous</font></a> \n";
}
$pages=intval($num_results/$limit);
if ($num_results%$limit) {
$pages++;
}
$page = intval($offset / $limit);
$min = intval($page - 8);
if ($min < 1) { $min = 1; }
$max = intval($page + 10);
if (($max - $min) == $pages) { $max = $max - 1; }
if ($max > $pages) { $max = $pages; }
if ($min > 1) {
print "..... ";
}
#for ($i=1;$i<=$pages;$i++) {
for ($i=$min;$i<=$max;$i++) {
$newoffset=$limit*($i-1)+1;
if ((intval($offset/$limit)+1)==$i )
print "<font color=#800000 face=arial size=3><b>$i</b></font> \n";
else
print "<a href=\"$PHP_SELF?offset=$newoffset&Field1=$Field1&Condition1=$Condition1&Substring1=$Substring1&Boolean1=$Boolean1&Field2=$Field2&Condition2=$Condition2&Substring2=$Substring2&Boolean2=$Boolean2&Field3=$Field3&Condition3=$Condition3&Substring3=$Substring3&Boolean3=$Boolean3&Field4=$Field4&Condition4=$Condition4&Substring4=$Substring4&limit=$limit\"><font color=#000000>$i</font></a> \n";
}
if ($max < $pages) {
print ".....";
}
if (!(intval($offset/$limit)+1==$pages) && $pages!=1) {
// not last page so give NEXT link
$newoffset=$offset+$limit;
print "   <a href=\"$PHP_SELF?offset=$newoffset&Field1=$Field1&Condition1=$Condition1&Substring1=$Substring1&Boolean1=$Boolean1&Field2=$Field2&Condition2=$Condition2&Substring2=$Substring2&Boolean2=$Boolean2&Field3=$Field3&Condition3=$Condition3&Substring3=$Substring3&Boolean3=$Boolean3&Field4=$Field4&Condition4=$Condition4&Substring4=$Substring4&limit=$limit\"><font color=#000000>Next ></font></a>\n";
$lastoffset=$limit*($pages-1)+1;
print " <a href=\"$PHP_SELF?offset=$lastoffset&Field1=$Field1&Condition1=$Condition1&Substring1=$Substring1&Boolean1=$Boolean1&Field2=$Field2&Condition2=$Condition2&Substring2=$Substring2&Boolean2=$Boolean2&Field3=$Field3&Condition3=$Condition3&Substring3=$Substring3&Boolean3=$Boolean3&Field4=$Field4&Condition4=$Condition4&Substring4=$Substring4&limit=$limit\"><font color=#000000>Last >></font></a> \n";
}
echo "</div>";
}}
echo "<div align=right><br><br>\n";
$LoggedInUser = $_SERVER['REMOTE_USER'];
$CurrentDate = date('Y/m/d H:i:s',time());
$DateStamp = date('YmdHis',time());
echo "<hr>User <b>$LoggedInUser</b> on <b>$CurrentDate</b><br>\n";
if ($LoggedInUser == "smcnaught" || $LoggedInUser == "dchervenka" || $LoggedInUser == "khook" || $LoggedInUser == "lmcintosh") {
echo "<a href=summary_report.php><font size=1 color=#000000>Daily Summary Report</font></a>";
echo " - <a href=tracking.txt?$DateStamp><font size=1 color=#000000>History</font></a>";
}
echo "<br>\n";
$LogFile = "tracking.txt";
$fp = fopen($LogFile, "a");
$querymsg = strip_tags("Searched the logs $searchstring sorted by: $sortmsg.");
$log = "$CurrentDate - $LoggedInUser - Detailed - $querymsg\n";
fwrite($fp, $log);
fclose($fp);
?>
<br>
<br></div>
</font></body>
</html>