Location: PHPKode > projects > Pothos > pothos-0.1.1/includes/navbar.inc
<?
///////////////////////////////////////////////////////////////////////////////////////
// Pothos - IPTables Firewall Tool
// Copyright (c) 2004, Ken Stanley
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//  - Redistributions of source code must retain the above copyright notice, this list
//    of conditions and the following disclaimer.
//  - Redistributions in binary form must reproduce the above copyright notice, this
//    list of conditions and the following disclaimer in the documentation and/or other
//    materials provided with the distribution.
//  - Neither the name of the Author nor the names of its contributors may be
//    used to endorse or promote products derived from this software without specific
//    prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
// SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// Contact author : hide@address.com
///////////////////////////////////////////////////////////////////////////////////////
if ($start > 0) {
	$page = ceil(ceil($total_records / $limit) - ceil(($total_records - $start)) / $limit);
}
else {
	$page = 1;
}

if (($total_records % $limit) == 0) {
	$last = $total_records - $limit;
	if ($start > 0)  $page += 1;
}
else {
	$last = $total_records - ($total_records % $limit);
	//if ($start > 0)  $page += 1;
}

$navbar = "<table border=0 cellpadding=0 cellspacing=0 width=100%>\n";
$navbar .= " <form action=\"\" method=\"get\" name=\"results\">\n";

if ($_GET['field']) {
	$field = $_GET['field'];
	$navbar .= "  <input type=\"hidden\" name=\"field\" value=\"$field\">\n";
}

if ($_GET['val']) {
	$val = $_GET['val'];
	$navbar .= "  <input type=\"hidden\" name=\"val\" value=\"$val\">\n";
}

$navbar .= " <tr>\n";
$navbar .= "  <td align=\"left\" class=\"navbar\" valign=\"bottom\">\n";
$navbar .= "   Displaying page $page of " . ceil($total_records / $limit);
$navbar .= " out of $total_records records\n";
$navbar .= "  </td>\n";
$navbar .= "  <td align=\"right\" class=\"navbar\" valign=\"bottom\">\n";

if ($start > 0)
	$navbar .= "   <a href=\"?&start=0&limit=$limit&field=$field&val=$val\">\n";

$navbar .= "    <img src=\"" . $preferences['path'] . "/images/first.gif\" border=0></a>\n";

if ($start > 0) {
	$navbar .= "   <a href=\"?&start=" . ($start - $limit);
	$navbar .=  "&limit=$limit&field=$field&val=$val\">\n";
}

$navbar .= "    <img src=\"" . $preferences['path'] . "/images/prev.gif\" border=0></a>\n";
$navbar .= "    <select name=\"limit\" onChange=\"this.form.submit()\">\n";

foreach ($preferences['display']['limit'] as $key => $value) {
	if ($value == "true" && empty($_GET['limit']))
		$navbar .= "     <option value=\"$key\" selected>$key\n";
	else {
		if ("$key" == $_GET['limit'])
			$navbar .= "     <option value=\"$key\" selected>$key\n";
		else
			$navbar .= "     <option value=\"$key\">$key\n";
	}
}
$navbar .= "    </select>\n";

if ($start < ($total_records - $limit)) {
	$navbar .= "   <a href=\"?&start=" . ($start + $limit);
	$navbar .= "&limit=$limit&field=$field&val=$val\">\n";
}

$navbar .= "    <img src=\"" . $preferences['path'] . "/images/next.gif\" border=0></a>\n";

if ($start < ($total_records - $limit)) {
	$navbar .= "    <a href=\"?&start=" . $last;
	$navbar .= "&limit=$limit&field=$field&val=$val\">\n";
}

$navbar .= "    <img src=\"" . $preferences['path'] . "/images/end.gif\" border=0></a>\n";
$navbar .= "  </td>\n";
$navbar .= " </tr>\n";
$navbar .= "   </form>\n";
$navbar .= "</table>\n";

create_table("100%",$preferences['path'],"",$navbar);
?>
Return current item: Pothos