Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. class Logger {
  3. private $db;
  4. function __construct() {
  5. global $db;
  6. $this->db = $db;
  7. }
  8. public function logUserAccess($user=null, $result=0, $msg='', $dataProvided=null) {
  9. if (is_array($user) && !empty($user)) {
  10. $user_id = $user['id'];
  11. } else {
  12. $user_id = 0;
  13. }
  14. $data = [
  15. 'user_id' => $user_id,
  16. 'remote_ip' => $_SERVER['REMOTE_ADDR'],
  17. 'access_result' => $result,
  18. 'access_message' => $msg,
  19. 'data_provided' => json_encode($dataProvided),
  20. 'time_zone' => date_default_timezone_get(),
  21. 'user_agent' => $_SERVER['HTTP_USER_AGENT'],
  22. 'created_at' => date('Y-m-d H:i:s')
  23. ];
  24. $this->db->insert('log_access', $data);
  25. }
  26. public function logUserAction($userId=0, $actionType=null, $errorMsg=null) {
  27. $data = [
  28. 'user_id' => $userId,
  29. 'remote_ip' => $_SERVER['REMOTE_ADDR'],
  30. 'action_type' => $actionType,
  31. 'user_agent' => $_SERVER['HTTP_USER_AGENT'],
  32. 'error_msg' => $errorMsg,
  33. 'created_at' => date('Y-m-d H:i:s')
  34. ];
  35. $this->db->insert('log_actions', $data);
  36. }
  37. }