<?php
if(!defined('IN_ADMIN')) exit('Access Denied');
if($_SESSION["admin"]!="NewsTeng")showmessage('ÇëµÇÂ½', SCRIPT_NAME.'?file=login');
@set_time_limit(0);
require_once TM_ROOT.'include/guest.class.php';
$guest = new guest();
if(!isset($action)) $action = 'list';
switch ($action){
    case 'list':
    	$page = max(intval($page), 1);
    	$page_size = 15;
    	$r = $db->get_one("SELECT count(*) as num FROM ".DB_PRE."guestbook");
    	$mpurl =SCRIPT_NAME.'?file=guest&action=list&';
    	$dispage =  page($r['num'],$page_size,$page,$mpurl);
      	$n = $guest->listinfo('', 'id DESC', $page, $page_size);
        include admin_tpl('guest');
	break;
	case 'look':
        	$ns = $guest->get(intval($id)); 
            include admin_tpl('guest');
	break;
	case 'del':
		$u = $guest->del(intval($id));
	    if(!$u){
	    	showmessage('É¾³ýÊ§°Ü£¡', 'goback');
	    }
	    showmessage('É¾³ý³É¹¦£¡', 'goback');
	break;
}
?>