common.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 流年 <liu21st@gmail.com>
  10. // +----------------------------------------------------------------------
  11. // 应用公共文件
  12. /**
  13. * 保存后台用户行为
  14. * @param string $remark 日志备注
  15. */
  16. function insert_admin_log($remark)
  17. {
  18. db('user_log')->insert([
  19. 'user_id' => session('id'),
  20. 'uname' => session('uname'),
  21. 'useragent' => request()->server('HTTP_USER_AGENT'),
  22. 'ip' => request()->ip(),
  23. 'url' => request()->url(true),
  24. 'method' => request()->method(),
  25. 'type' => request()->type(),
  26. 'param' => json_encode(request()->param()),
  27. 'remark' => $remark,
  28. 'create_time' => time(),
  29. ]);
  30. }