利用ThinkPHP的行为扩展做系统日志
1:模块配置:
<?phpreturn 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;
<?phpnamespace 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); }}?>
版权声明:没有什么版权不版权的,如果你喜欢,拿去用。