Non Numeric Page Number";
include("footer.php");
exit;
}
if (!($order == "asc" || $order == "desc"))
{
echo "Entry order can only be 'asc' or 'desc'";
include("footer.php");
exit;
}
// -----------------------------------------------------------------------------------
if ($page == "") { $page = 1; }
$fwd = $page - 1;
$rwd = $page +1;
// Setting the default values for number of records per page -------------------------
$perpage = 10;
//$filename = "list.php";
// Reading in all the records, putting each guestbook entry in one Array Element -----
$filename = "data/list.txt";
$handle = fopen($filename, "r");
if (filesize($filename) == 0){ // mpg are there any entries to display
print "There are currently no entries to display"; // mpg no inform user
}
else
{
$datain = fread($handle, filesize($filename));
fclose($handle);
$out = explode("", $datain);
$outCount = count($out) - 1;
$j = $outCount-1;
if ($order == "desc")
{
for ($i=0; $i<=$outCount; $i++)
{
$lines[$j] = unserialize($out[$i]);
$j = $j - 1;
}
}
else
{
for ($i=0; $i<=$outCount; $i++)
{
$lines[$i] = unserialize($out[$i]);
}
}
// Counting the total number of entries (lines) in the data text file ----------------
$result = count($lines);
$count = $result-1;
//echo $count."
";
// Caclulate how many pages there are ----------------------------------------
if ($count == 0) { $totalpages = 0; }
else { $totalpages = intval(($count - 1) / $perpage) + 1; }
$page = $totalpages - ($page - 1);
$end = $count - (($totalpages - $page) * $perpage);
$start = $end - ($perpage - 1); if ($start < 1) { $start = 1; }
//$end = ($perpage * $page) - 1;
//$start = $end - $perpage;
if ($start < 0) { $start = 0; }
//for ($i = $end; $i>=($start-1); $i--)
//for ($i = 0; $i<$outCount; $i++)
//for ($i=$start-1; $i<$end; $i++)
for ($i=$end-1; $i>$start-2; $i--)
{
//echo $i."
end-".$end."-start-".$start;
echo "
";
echo "$listDatetxt: ";
$lines[$i]->showDate();
echo " $listnametxt: "; $lines[$i]->showFrom(); echo " $listemailtxt: showEmail(); echo "\">"; $lines[$i]->showEmail(); echo " $listMessagetxt: "; $lines[$i]->showMessage(); echo " |