<?php
include(dirname(__FILE__)."/require.php");
if($ppurview[5]!=1 && isset($_GET['action']) && $_GET['action'] == "foreground")
  jump("jump.php?id=25&jump=main.php");
if($ppurview[6]!=1 && isset($_GET['action']) && $_GET['action'] == "back")
  jump("jump.php?id=25&jump=main.php");
$phpcolor->table="log";
if(isset($_GET['action']) and $_GET['action'] == "cleared" and isset($_GET['type']))
{
  $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600-604800);
  $phpcolor->where="type = '".$_GET['type']."' && operatetime < '".$time."'";
  $phpcolor->delete(); 
  if($_GET['type']==2)
    jump("log.php?action=foreground");
  jump("log.php?action=back");
}
if(isset($_GET['action']) and $_GET['action'] == "del" and isset($_GET['type']))
{
  $phpcolor->where="id = '".$_GET['id']."'";
  $phpcolor->delete(); 
  if($_GET['type']==2)
    jump("log.php?action=foreground");
  jump("log.php?action=back");
}
if(!isset($_GET['page']))
  $_GET['page']=0;
if(isset($_GET['action']) and $_GET['action'] == "back")
{
  $phpcolor->field="*";
  $phpcolor->where="type = '1'";
  $count = $phpcolor->exist(2);
  $phpcolor->where=" type = '1' order by operatetime desc limit ".($_GET['page']*20).",20";
  $page=pages($count,20,$_GET['page'],'log','&action=','back','0');
}
else
{
  $phpcolor->field="*";
  $phpcolor->where="type = '2'";
  $count = $phpcolor->exist(2);
  $phpcolor->where=" type = '2' order by operatetime desc limit ".($_GET['page']*20).",20";
  $page=pages($count,20,$_GET['page'],'log','&action=','foreground','0');
}
$log=$phpcolor->assignment();
$tpl -> assign("log", $log);
$tpl -> assign("page", $page);
if(isset($_GET['action']) and $_GET['action'] == "back")
  $tpl -> display("log_back.htm");
else
  $tpl -> display("log_foreground.htm");
?>