1:模块配置:
<?php 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:行为类编写:
<?php 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:效果展示:
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-10-11 16:15:33