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