You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Tracking.php 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace SCF\Additionals;
  3. use SCF\Core\Database;
  4. class Tracking
  5. {
  6. private $_db;
  7. private $currentUserIp;
  8. private $currentUserAgent;
  9. private $currentUserReferer;
  10. public function __construct(Database $db)
  11. {
  12. $this->_db = $db;
  13. }
  14. /**
  15. * @param mixed $currentUserIp
  16. */
  17. public function setCurrentUserIp($currentUserIp)
  18. {
  19. $this->currentUserIp = $currentUserIp;
  20. }
  21. /**
  22. * @param mixed $currentUserAgent
  23. */
  24. public function setCurrentUserAgent($currentUserAgent)
  25. {
  26. $this->currentUserAgent = $currentUserAgent;
  27. }
  28. /**
  29. * @param mixed $currentUserReferer
  30. */
  31. public function setCurrentUserReferer($currentUserReferer)
  32. {
  33. $this->currentUserReferer = $currentUserReferer;
  34. }
  35. /**
  36. * @return mixed
  37. */
  38. public function getCurrentUserIp()
  39. {
  40. return $this->currentUserIp;
  41. }
  42. /**
  43. * @return mixed
  44. */
  45. public function getCurrentUserAgent()
  46. {
  47. return $this->currentUserAgent;
  48. }
  49. /**
  50. * @return mixed
  51. */
  52. public function getCurrentUserReferer()
  53. {
  54. return $this->currentUserReferer;
  55. }
  56. public function checkUniqueUser()
  57. {
  58. $this->_db->query("SELECT ip_adress, `timestamp` FROM sks_unique_user WHERE ip_adress = '{$this->getCurrentUserIp()}' ORDER BY `timestamp` ASC LIMIT 1");
  59. $result = $this->_db->single();
  60. $trackedDate = date("Y-m-d", $result['timestamp']);
  61. $currentDate = date("Y-m-d", time());
  62. if ($trackedDate == $currentDate) {
  63. echo 'same Day visit';
  64. } else {
  65. echo 'different Dates visit';
  66. }
  67. }
  68. }