<?php
if(!defined('MOD'))  die("access die");
$action   = $_GET['action'] ? $_GET['action'] : 'manage';
switch($action){
	case 'manage':
		$pageno   = intval($_GET['pageno']);
		$limit = 20;
		if ($pageno < 1) $pageno = 1;
		$offset = ($pageno - 1) * $limit;

		$num = qdb::queryAlone("select count(*) as num from ".TABLEPRE."admin_log");
		$data = qdb::fetchAll("select * from ".TABLEPRE."admin_log limit {$offset}, {$limit}");
		include qbase::template($path . 'log');
	break;

	case 'clear':
		checkAdminReferer();
		$max = qdb::queryAlone("select id from ".TABLEPRE."admin_log order by id desc limit 199,1");
		$max = intval($max);
		if($max > 0){
			qdb::query("delete from ppphp_admin_log where id > {$max}");
		}
		qbase::showmsg("清除管理日志成功，系统会自动保留最近的200条日志", "system.php?sys=log");
	break;

	default:
		qbase::showmsg("bad request", "system.php?sys=log");
	break;
}

?>