69 lines
2.3 KiB
PHP
69 lines
2.3 KiB
PHP
<?php
|
|
namespace Admin\Controller;
|
|
use Think\Controller;
|
|
class UserLogController extends AdminController{
|
|
public function __construct(){
|
|
parent::__construct();
|
|
$this->table=D("UserLog");
|
|
$this->typeInc=array(
|
|
"add"=>"增加",
|
|
"update"=>"编辑",
|
|
"delete"=>"删除",
|
|
"other"=>"其它",
|
|
);
|
|
}
|
|
//
|
|
public function index(){
|
|
//搜索
|
|
$where=array();
|
|
$start_time = I("get.start_time");
|
|
$end_time = I("get.end_time");
|
|
if($start_time || $end_time){
|
|
$start_time = strtotime($start_time ? $start_time : 0);
|
|
$end_time = strtotime(($end_time ? $end_time : date("Y-m-d"))."23:59:59");
|
|
$where["addtime"] = array(array("EGT",$start_time),array("ELT",$end_time));
|
|
}
|
|
$type=I("get.type");
|
|
if($type){
|
|
$where['type'] =$type;
|
|
}
|
|
$table_name=I("get.table_name");
|
|
if($table_name){
|
|
$where['table_name'] = array('LIKE','%'.$table_name.'%');
|
|
}
|
|
$primary_key=I("get.primary_key");
|
|
if($primary_key){
|
|
$where['primary_key'] = array('LIKE','%'.$primary_key.'%');
|
|
}
|
|
$username=I("get.username");
|
|
if($username){
|
|
$where['username'] = array('LIKE','%'.$username.'%');
|
|
}
|
|
$userid=I("get.userid");
|
|
if($userid){
|
|
$where['userid'] = $userid;
|
|
}
|
|
|
|
//
|
|
$listRows=C("display.admin_shownum");//每页显示多少条
|
|
$total=$this->table->where($where)->count();
|
|
$page = new \Think\Page($total, $listRows);
|
|
$data=$this->table->where($where)->order("id desc")->limit($page->firstRow, $page->listRows)->select();
|
|
$listpage = $page->show();
|
|
$this->assign("listpage", $listpage);
|
|
$this->assign("data", $data);
|
|
$this->display();
|
|
}
|
|
public function detail($id){
|
|
$this->r=$this->table->find($id);
|
|
$this->pagetitle="日志详情";
|
|
$this->display($type);
|
|
}
|
|
//清空指定时间以前的日志
|
|
public function clearLog(){
|
|
$where[addtime]=array("lt",(time()-(3600*24*180)));
|
|
$this->table->where($where)->delete();
|
|
$this->success();
|
|
}
|
|
}
|