| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');include_once(FCPATH . 'application/controllers/Base_Controller.php');class Syslog extends Base_Controller {	public function __construct() {        parent::__construct();        $this->load->model('Syslog_model');    }    // 获取用户日志列表    public function get_list(){    	$keyword = $this->input->post('keyword',true);    	$type = $this->input->post('type',true);    	$page = $this->input->post('page',true);    	$count = $this->input->post('count',true);        $language = $this->session->userdata('version');        $role = $this->get_user_info('role');        $print = $this->input->post('print',true);    	$filter = array();    	if (!empty($keyword)) $filter['S.content|U.username|U.name|S.time'] = $keyword;    	if (!empty($type)) $filter['S.optype'] = $type;        $filter['language'] = empty($language) ? 0 : 1;        $download = $this->input->post('download',true);        if ($role != SYSTEM_ADMIN) $filter['U.company'] = $this->get_user_info('company');    	$page = !isset($page) ? 1 : $page;    	$count = empty($count) ? 20 : $count;        $limit = $count;        $offset = ($page - 1) * $count;    	$field = "S.id,    			  S.time,    			  S.optype as type,    			  S.userid,                  U.username,    			  U.name as realname,    			  S.content,                  S.is_read";    	if (empty($download)) {            $join = array();            $join[] = ['table'=>'user as U','cond'=>'U.id = S.userid','type'=>'left'];            if (isset($print) && !empty($print)) {                $data = $this->Syslog_model->get_list_by_join($filter, $field,3000, 0, $join, 'S.time DESC,S.id DESC', NUll, 'S');            }else{                                $data = $this->Syslog_model->get_list_by_join($filter, $field,$limit, $offset, $join, 'S.time DESC,S.id DESC', NUll, 'S');            }            $total = $this->Syslog_model->get_list_by_multi_join($filter, 'count(*) as total',null, null, $join, null, NUll, 'S',true);            $data = empty($data) ? array() : $data;            $total = $total['total'];            foreach ($data as &$v) {                $v['username'] = empty($v['username']) ? '' : $v['username'];                $v['content'] = empty($v['content']) ? '' : $v['content'];                $v['userid'] = empty($v['userid']) ? '' : $v['userid'];                $v['type'] = empty($v['type']) ? '' : $v['type'];                $v['time'] = empty($v['time']) ? '' : $v['time'];            }            exit(json_result('0000',$this->response['0000'],array('total'=>ceil($total/$count),'list'=>$data)));        }else{            $data = $this->Syslog_model->getList($filter,($page-1)*$count,3000,$field);            $data = empty($data) ? array() : $data;            // 导出到Excel            $version = $this->session->userdata('version');            if (empty($version)) {                $title = array(                    array('编号','操作时间','操作类型','操作用户id','操作用户名','操作内容'),                );            }else{                $title = array(                    array('Index','Operation time','Operation type','User ID','Username','Behavior'),                );            }            $temp = array();            $i = ($page-1)*$count + 1;            foreach ($data as $k=>$v) {                $temp[$k][] = $i;                $temp[$k][] = $v['time'];                $temp[$k][] = $v['type'];                $temp[$k][] = $v['username'];                $temp[$k][] = $v['realname'];                $temp[$k][] = $v['content'];                $i ++;            }            $data = array_merge($title,$temp);            $path = push_excel($data,'syslogExcel_'.date('Ymd'));            exit(json_result('0000',$this->response['0000'],array('path'=>$path)));        }    }}?>
 |