<?php
/////////////////////////////////////////////////////////////////////////////////////
// IPTable log analyzer
// Copyright (C) 2002 Gerald GARCIA
//
// 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.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Plac<B2>e - Suite 330, Boston, MA 02111-1307, USA.
//
// Contact author : hide@address.com
/////////////////////////////////////////////////////////////////////////////////////
// $Id: show_protos.php,v 1.2 2007/04/03 23:45:36 tarbuck Exp $
require_once("../conf/config.php");
require_once("conf/config.php");
#require_once("utils/Misc.php");
?>
<html>
<head>
<title>IPTables logs</title>
<meta content="text/html;charset=UTF-8" http-equiv="content-type">
<link rel="stylesheet" type="text/css" href="<? echo $url_base . "/themes/" . $css_styles[$css_style] . "/" . $css_styles[$css_style]; ?>.css" />
</head>
<body>
<br>
<blockquote class="ModuleTitle">IP Protocol Information</blockquote>
<?php
$order_by = "ORDER BY num";
$where = '';
if (!isset($_REQUEST['start'])) {
$start = 0;
} else {
$start = $_REQUEST['start'];
}
if (!isset($_REQUEST['limit'])) {
$limit = 50;
} else {
$limit = $_REQUEST['limit'];
}
$limit_clause = "LIMIT $start,$limit";
$query = "SELECT count(num) FROM protos WHERE 1=1 $where";
$result = db_query ($query);
$nb_records=db_nextvalue($result);
$query = "SELECT num, name, description FROM protos WHERE 1=1 $where $order_by $limit_clause";
$result = db_query ($query);
?>
<blockquote>
<table cellspacing="1" cellpadding="1" width="100%">
<tr bgcolor="#DDDDDD"><td>
<table cellspacing="1" cellpadding="1" width="100%">
<tr>
<td width="100%" align=center colspan=3>
<table cellspacing="1" cellpadding="1" width="100%">
<tr>
<td width="10%" align=left valign=top><font size=-2><?
if ($start <= $limit) { echo " "; } else {
echo "<a href='show_protos.php?start=" . ($start - $limit) .
"&limit=$limit'> < Prev</a>";
}
echo "<br><a href='show_protos.php?start=0&limit=$limit'><< First</a>";
?></font></td>
<td align=center><?
echo "<form name=cache_form method=post action=show_protos.php>\n" .
"<input type=hidden name=start value=$start>\nDisplaying " .
"<select name=limit onchange='this.form.submit();'>\n";
foreach (array(10,25,50,100) as $i) {
echo "<option";
if ($i == $limit) { echo " selected"; }
echo ">$i</option>\n";
}
echo "</select> of $nb_records protocols, from $start. \n ";
#echo "</td><td width=\"40%\" align=left valign=top>";
if ($nb_records > $limit) {
$num_pages = ceil($nb_records / $limit);
$this_page = ceil($start / $limit) + 1;
echo "Page <select name=start onChange='this.form.submit()'>\n";
if ($num_pages <= 10) {
for ($i = 1;$i <= $num_pages;$i++) {
echo "<option value=" . $i * $limit;
if ($i == $this_page) { echo " selected"; }
echo ">$i</option>\n";
}
} else {
if ($this_page > ($num_pages - 3)) {
$start_page = $num_pages - 5;
echo "<option value=0>1</option>\n<option value=0>...</option>\n";
for ($i = 9;$i < $start_page;$i += 10) {
echo "<option value=" . ($limit * $i) . ">" . ($i + 1) . "</option>\n";
}
} elseif ($this_page > 3) {
$append_page = "";
echo "<option value=0>1</option>\n<option value=0>...</option>\n";
for ($i = ceil(($this_page + 3)/10)*10 -1;$i < $num_pages;$i += 10) {
$append_page .= "<option value=" . ($limit * $i) . ">" . ($i + 1) . "</option>\n";
}
if ($this_page > ($num_pages - 5)) {
$start_page = ($num_pages - 5);
} else {
$start_page = $this_page - 2 ;
$append_page .= "<option value=" . ($limit * ($num_pages - 1)) .
">...</option>\n<option value=" . ($limit * ($num_pages - 1)) .
">$num_pages</option>\n";
}
for ($i = 9;$i < $start_page;$i += 10) {
echo "<option value=" . ($limit * $i) . ">" . ($i + 1) . "</option>\n";
}
} else {
$start_page = 1;
for ($i = 9;$i < $num_page;$i += 10) {
echo "<option value=" . ($limit * $i) . ">" . ($i + 1) . "</option>\n";
}
$append_page = "";
for ($i = ceil(($this_page + 3)/10)*10 -1;$i < $num_pages;$i += 10) {
$append_page .= "<option value=" . ($limit * $i) . ">" . ($i + 1) . "</option>\n";
}
$append_page .= "<option value=" . ($limit * ($num_pages - 1)) .
">...</option>\n<option value=" . ($limit * ($num_pages - 1)) .
">$num_pages</option>\n";
}
for ($i = $start_page - 1;$i <= ($start_page + 4);$i++) {
echo "<option value=" . $i * $limit;
if ($i == ($this_page - 1)) { echo " selected"; }
echo ">" . ($i + 1) . "</option>\n";
}
if (isset($append_page)) { echo $append_page; }
}
echo "</select>\n of $num_pages.";
}
echo "</form>\n";
?></td>
<td width="10%" align=right valign=top><font size=-2><?
if (($start + $limit) < ($nb_records - $limit)) {
echo "<a href=\"show_protos.php?start=" . ($start + $limit) .
"&limit=$limit\">Next ></a>";
}
?>
<br>
<a href='show_protos.php?start=<?
echo $nb_records - $limit . "&limit=$limit";
?>'>Last >></a></font>
</td>
</tr>
</table></td></tr>
<tr>
<td><center>Protocol Number</center></td>
<td><center>Name</center></td>
<td><center>Description</center></td>
</tr>
<?
while($line = db_nextobject($result)){
print "<tr bgcolor=\"#FFFFFF\">";
print "<td><center>$line->num</center></td>";
print "<td>$line->name</td>";
print "<td>$line->description</td>";
print "</tr>\n";
}
?>
<tr>
<td width="100%" align=center colspan=3>
<table cellspacing="1" cellpadding="1" width="100%">
<tr>
<td width="10%" align=left valign=top><font size=-2><?
if ($start <= $limit) { echo " "; } else {
echo "<a href='show_protos.php?start=" . ($start - $limit) .
"&limit=$limit'> < Prev</a>";
}
echo "<br><a href='show_protos.php?start=0&limit=$limit'><< First</a>";
?></font></td>
<td> </td>
<td width="10%" align=right valign=top><font size=-2><?
if (($start + $limit) < ($nb_records - $limit)) {
echo "<a href=\"show_protos.php?start=" . ($start + $limit) .
"&limit=$limit\">Next ></a>";
}
?>
<br>
<a href='show_protos.php?start=<?
echo $nb_records - $limit . "&limit=$limit";
?>'>Last >></a></font>
</td>
</tr></table>
</td></tr>
</table>
</td></tr>
</table>
</blockquote>
<center><a href="javascript:window.close()">close</a></center>
<br>
</body>
</html>