<?php
!defined("MONKEYMAO") && die("Accessed Defined!");
if($del){
	$db -> query("DELETE FROM {$tablepre}guestbook WHERE gid='$del'");
	cpmsg('succeeded',"index.php?action=guestbook");

}else{
	$page = ispage($page) ? $page : 1;
	$pagenum = 5;
	$start_limit = ($page-1) * $pagenum;
	
	$msgs = array();
	$query = $db -> query("SELECT COUNT(*) FROM {$tablepre}guestbook");
	$lines = $db -> result($query, 0);
	$paging = paging($lines, $pagenum, $page, 'index.php?action=guestbook');
	$query = $db -> query("SELECT * FROM {$tablepre}guestbook ORDER BY postime DESC LIMIT $start_limit, $pagenum");
	while($msg = $db -> fetch_array($query)){
	
		$msg['postime'] = gmdate("$dateformat $timeformat", $msg['postime'] + ($timeoffset * 3600));
		$msg['replaytime'] = $msg['replaytime'] ? gmdate("$dateformat $timeformat", $msg['replaytime'] + ($timeoffset * 3600)) : 0;
		$msg['msg'] = nl2br(htmlconvert($msg['msg']));
		$msgs[$msg['gid']] = $msg;
	}

	include theme('guestbook', 'themes/admin','admin');
}

?>