php行为日志,利用ThinkPHP的行为扩展做系统日志
1:模塊配置:
return array(
'action_end' => array('Admin\\Behaviors\\LogBehavior'),
);
2:數據庫建表:
create table logs(
id int(11) primary key auto_increment,
url char(30) not null,
operator int(11) not null,
description char(60) not null,
operate_time int(10) not null
)charset=utf8 engine=myisam;
3:行為類編寫:
namespace Admin\Behaviors;
use Think\Behavior;
class LogBehavior extends Behavior{
public function run(&$params){
$data['url'] = substr(__ACTION__, strpos(__ACTION__, 'index.php')+strlen('index.php'));
$data['operator'] = intval(session('admin_id'));
$data['operate_time'] = time();
$node = M('data_node')->where(array('m_c_a'=>$data['url']))->find();
$data['description'] = $node['node_name'];
// var_dump(APP_DEBUG);
M('logs')->add($data);
}
}
?>4:效果展示:
版權聲明:本文為博主原創文章,未經博主允許不得轉載。
原文:http://blog.csdn.net/u014290054/article/details/47703055
總結
以上是生活随笔為你收集整理的php行为日志,利用ThinkPHP的行为扩展做系统日志的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 帅爆了!推荐10款程序员专用高清壁纸!!
- 下一篇: html php获取post数据格式,h