123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
-
- namespace SCF\Additionals;
-
- use SCF\Core\Database;
-
- class Tracking
- {
-
- private $_db;
-
- private $currentUserIp;
-
- private $currentUserAgent;
-
- private $currentUserReferer;
-
- public function __construct(Database $db)
- {
- $this->_db = $db;
- }
-
- /**
- * @param mixed $currentUserIp
- */
- public function setCurrentUserIp($currentUserIp)
- {
- $this->currentUserIp = $currentUserIp;
- }
-
- /**
- * @param mixed $currentUserAgent
- */
- public function setCurrentUserAgent($currentUserAgent)
- {
- $this->currentUserAgent = $currentUserAgent;
- }
-
- /**
- * @param mixed $currentUserReferer
- */
- public function setCurrentUserReferer($currentUserReferer)
- {
- $this->currentUserReferer = $currentUserReferer;
- }
-
- /**
- * @return mixed
- */
- public function getCurrentUserIp()
- {
- return $this->currentUserIp;
- }
-
- /**
- * @return mixed
- */
- public function getCurrentUserAgent()
- {
- return $this->currentUserAgent;
- }
-
- /**
- * @return mixed
- */
- public function getCurrentUserReferer()
- {
- return $this->currentUserReferer;
- }
-
- public function checkUniqueUser()
- {
- $this->_db->query("SELECT ip_adress, `timestamp` FROM sks_unique_user WHERE ip_adress = '{$this->getCurrentUserIp()}' ORDER BY `timestamp` ASC LIMIT 1");
- $result = $this->_db->single();
- $trackedDate = date("Y-m-d", $result['timestamp']);
- $currentDate = date("Y-m-d", time());
- if ($trackedDate == $currentDate) {
- echo 'same Day visit';
- } else {
- echo 'different Dates visit';
- }
-
- }
- }
|