操作日志公用函数移到extend.php中

master
zhengyongxing 5 years ago
parent 2de1d9bccb
commit 756b3b9975

@ -2198,4 +2198,68 @@ function a_array_unique($array){
return $data;
}
}
/**
* 操作日志
* array(
* op_type=>操作类型 1:编辑 2:删除 3:下载,
* op_name=>操作说明 例如:编辑,删除,锁定等,
* url=>需要跳转的url 添加去列表加唯一id编辑直接去编辑页面下载可以重新下载(新开页面),
* key=>关键词:用户的账号,游戏的名词等
* )
*/
function addOperationLog($options)
{
$checkarr = ['op_type','url','key'];
foreach ($checkarr as $v) {
if(!array_key_exists($v,$options)){
return false;
}
}
if(!array_key_exists("op_name",$options)){
$options['op_name'] = ($options['op_type'] == 1 ? "编辑" : ($options['op_type'] == 2 ? "删除" :"下载"));
}
//获取ip
$addarray = [
"op_ip"=>$_SERVER['REMOTE_ADDR'],
'admin_id'=>$_SESSION['onethink_admin']['user_auth']['uid'],
'admin_account'=>$_SESSION['onethink_admin']['user_auth']['username'],
'op_type'=>$options['op_type'],
'op_name'=>$options['op_name'],
'url'=>$options['url'],
'key'=>$options['key'],
'create_time'=>time()
];
//获取菜单名词
$act = CONTROLLER_NAME.'/'.ACTION_NAME;
$arr = [];
$menuname = D("menu")->field('title,pid,group')->where("url = '{$act}'")->find();
if($menuname){
$arr[] = $menuname['title'];
if(!empty($menuname['group'])){
$arr[] = $menuname['group'];
}
getLink($menuname['pid'],$arr);
}
$addarray['menu'] = implode ( "-",array_reverse($arr));
M("OperationLog","tab_")->add($addarray);
}
function getLink($pid=0,&$arr){
if($pid == 0){
return;
}
$menuname = D("menu")->field('title,pid,group')->where("id = '{$pid}'")->find();
if($menuname){
$arr[] = $menuname['title'];
if(!empty($menuname['group'])){
$arr[] = $menuname['group'];
}
if($menuname['pid'] != 0){
getLink($menuname['pid'], $arr);
}
}
}
?>

@ -663,67 +663,6 @@ class AdminController extends Controller {
}
}
}
/**
* 操作日志
* array(
* op_type=>操作类型 1:编辑 2:删除 3:下载,
* op_name=>操作说明 例如:编辑,删除,锁定等,
* url=>需要跳转的url 添加去列表加唯一id编辑直接去编辑页面下载可以重新下载(新开页面),
* key=>关键词:用户的账号,游戏的名词等
* )
*/
public function addOperationLog($options)
{
$checkarr = ['op_type','url','key'];
foreach ($checkarr as $v) {
if(!array_key_exists($v,$options)){
$this->error('操作日志添加,参数错误');
}
}
if(!array_key_exists("op_name",$options)){
$options['op_name'] = ($options['op_type'] == 1 ? "编辑" : ($options['op_type'] == 2 ? "删除" :"导出"));
}
//获取ip
$addarray = [
"op_ip"=>$_SERVER['REMOTE_ADDR'],
'admin_id'=>$_SESSION['onethink_admin']['user_auth']['uid'],
'admin_account'=>$_SESSION['onethink_admin']['user_auth']['username'],
'op_type'=>$options['op_type'],
'op_name'=>$options['op_name'],
'url'=>$options['url'],
'key'=>$options['key'],
'create_time'=>time()
];
//获取菜单名词
$act = CONTROLLER_NAME.'/'.ACTION_NAME;
$arr = [];
$menuname = D("menu")->field('title,pid,group')->where("url = '{$act}'")->find();
if($menuname){
$arr[] = $menuname['title'];
if(!empty($menuname['group'])){
$arr[] = $menuname['group'];
}
$this-> getLink($menuname['pid'],$arr);
}
$addarray['menu'] = implode ( "-",array_reverse($arr));
M("OperationLog","tab_")->add($addarray);
}
public function getLink($pid=0,&$arr){
if($pid == 0){
return;
}
$menuname = D("menu")->field('title,pid,group')->where("id = '{$pid}'")->find();
if($menuname){
$arr[] = $menuname['title'];
if(!empty($menuname['group'])){
$arr[] = $menuname['group'];
}
if($menuname['pid'] != 0){
$this->getLink($menuname['pid'], $arr);
}
}
}
}

@ -4125,7 +4125,8 @@ class ExportController extends Controller
$xlsSummary[] = $data['sum'][$key];
} else {
}
else {
$start = I('start',date('Y-m-d',strtotime('-1 day')));

Loading…
Cancel
Save