Advertisement
Guest User

Untitled

a guest
Nov 20th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. Чтобы расследовать инциденты, было принято решение сохранять данные о просмотрах страниц и ошибки в PostgreSQL:
  2.  
  3. <?php
  4. /*
  5. CREATE TABLE http_requests (
  6. created_at timestamp,
  7. host text,
  8. uri text,
  9. method text,
  10. params text,
  11. referer text,
  12. ip text,
  13. errors text[]
  14. );
  15. */
  16.  
  17. $statement = $db->prepare('
  18. INSERT INTO http_requests (created_at, host, uri, method, params, ip, referer, errors)
  19. VALUES(:created_at, :host, :uri, :method, :params, :ip, :referer, :errors)
  20. ');
  21.  
  22. $statement->execute([
  23. 'created_at' => date('Y-m-d H:i:s'),
  24. 'host' => $_SERVER['HTTP_HOST'],
  25. 'uri' => explode('?', $_SERVER['REQUEST_URI'], 2)[0],
  26. 'method' => $_SERVER['REQUEST_METHOD'],
  27. 'params' => json_encode($_REQUEST),
  28. 'ip' => $_SERVER['REMOTE_ADDR'],
  29. 'errors' => $errors,
  30. ]);
  31.  
  32.  
  33. Вопрос 1: Какие проблемы вы видите в этой реализации? Как их можно решить, не используя другие технологии?
  34. Вопрос 2: Если бы вы могли выбрать другую технологию, то какую и почему?
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement