Guestbook Admin Interface



Non Numeric Page Number"; echo "

 

"; echo "

"; echo "

"; echo " Admin Main -"; echo " Logout"; echo "

"; echo ""; echo ""; exit; } if (!($order == "asc" || $order == "desc" || $order == "")) { echo "Entry order can only be 'asc' or 'desc'"; echo "

 

"; echo "

"; echo "

"; echo " Admin Main -"; echo " Logout"; echo "

"; echo ""; echo ""; exit; } // Check page value ------------------------------------------------------------------ $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 delete print "No enteries to delete"; // mpg no inform user } else { // there are entries let the user select one $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 "Delete
"; echo "
"; echo "$listDatetxt: "; $lines[$i]->showDate(); echo "
$listnametxt: "; $lines[$i]->showFrom(); echo "
$listemailtxt: showEmail(); echo "\">"; $lines[$i]->showEmail(); echo "

$listMessagetxt: "; $lines[$i]->showMessage(); echo "

"; } echo "
"; // Creating the Forward and Backward links ------------------------------------- if ($fwd > 0 && $rwd > 0 && $rwd<$totalpages+1) { echo "
<<"; echo ">>
"; } else if ($fwd == 0) { echo ">>
"; } else if ($rwd == 0) { echo "
<<"; } else if ($rwd == $totalpages+1) { echo "<<
"; } for ($i = 1; $i<=$totalpages; $i++) { echo " [$i] "; } echo "
"; }// end of mpg //include("footer.inc"); ?>

 

Admin Main - Logout