<?php
/*************************************************************\
+-------------------------------------------------------------+
| 通灵佛教网在线烧香程序 System                                 |
| Copyright (c) 2003-2010 Alfred China                        |
| All rights reserved.                                        |
+-------------------------------------------------------------+
\*************************************************************/
require_once('chk.php');
$pagepermission = 24;
//$pagepermission = 25;
//$pagepermission = 81;
require_once('netgou.php');

if ($REQUEST_METHOD == "POST") {# Delete log in history
	if ($action == "delete_week"){
		db_query("DELETE FROM $sql_tbl[logins] WHERE date_time>=".date('Y-m-d',strtotime("$ctime +7 day")));
		showmsg("操作成功","statistics.php?mode=logins");
	}
	elseif ($action == "delete_month") {
		db_query("DELETE FROM $sql_tbl[logins] WHERE date_time>=".date('Y-m-d',strtotime("$ctime +30 day")));
		showmsg("操作成功","statistics.php?mode=logins");
	}
}
	
$search_condition = " WHERE 1=1";
$txturl = '';
$usertype && $search_condition .= " AND $sql_tbl[logins].usertype = '$usertype'";
$usertype && $txturl .= "&usertype=$usertype";
$user && $search_condition .= " AND $sql_tbl[logins].login = '$user'";
$user && $txturl .= "&user=$user";
$logintype && $search_condition .= " AND $sql_tbl[logins].action = '$logintype'";
$logintype && $txturl .= "&logintype=$logintype";
$loginstatus && $search_condition .= " AND $sql_tbl[logins].status = '$loginstatus'";
$loginstatus && $txturl .= "&loginstatus=$loginstatus";

$count_logins = ng_query_first_cell("SELECT COUNT(login) FROM $sql_tbl[logins] $search_condition");
	
if ($count_logins > 0) {
			
	$objects_per_page = 100;
	$total_items = $count_logins;
	$total_nav_pages = ceil($total_items/$objects_per_page);
	$pageurl = "logins.php?".$txturl;
	include_once ng_dir."/include/navigation.php";
			
	$statistics = ng_query("SELECT * FROM $sql_tbl[logins] $search_condition ORDER BY lid DESC  LIMIT $first_page, $objects_per_page");

	$first_item = $first_page+1;
	$last_item = min($first_page+$objects_per_page, $total_items);
	
}

$ng_obstart && function_exists('ob_gzhandler') ? ob_start('ob_gzhandler') : ob_start();
$ng_obstart ? $ng_gzip="Gzip enabled":$ng_gzip="Gzip disabled";

require_once PrintTemp('logins');
require_once "./footer.php";

$output=str_replace(array('<!--<!--<!---->','<!--<!---->','<!---->'),array('','',''),ob_get_contents());
ob_end_clean();
echo $output;
flush;
exit;
?>