Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2014-10-09 08:10:04 +0400
committermattab <matthieu.aubry@gmail.com>2014-10-09 08:10:04 +0400
commit6532bfd71135cbf24fb606b05d1625a97c3c06a9 (patch)
treed53a273416ee06aebcffde7a4ee521d8a22e7875 /core/Tracker/Request.php
parent740a7f1f99548cdbed7b7bdec15a972929ebd04c (diff)
If cdt is set, use it as current timestamp
Diffstat (limited to 'core/Tracker/Request.php')
-rw-r--r--core/Tracker/Request.php36
1 files changed, 24 insertions, 12 deletions
diff --git a/core/Tracker/Request.php b/core/Tracker/Request.php
index e78aae6b61..8f18296278 100644
--- a/core/Tracker/Request.php
+++ b/core/Tracker/Request.php
@@ -47,7 +47,6 @@ class Request
$this->params = $params;
$this->tokenAuth = $tokenAuth;
$this->timestamp = time();
- $this->enforcedIp = false;
// When the 'url' and referrer url parameter are not given, we might be in the 'Simple Image Tracker' mode.
// The URL can default to the Referrer, which will be in this case
@@ -319,11 +318,16 @@ class Request
public function getCurrentTimestamp()
{
+ $cdt = $this->getCustomTimestamp();
+ if(!empty($cdt)) {
+ return $cdt;
+ }
return $this->timestamp;
}
- public function getCustomTimestamp()
+ protected function getCustomTimestamp()
{
+ // TODO window
$cdt = $this->getParam('cdt');
if (!is_numeric($cdt)) {
$cdt = strtotime($cdt);
@@ -530,16 +534,7 @@ class Request
public function getIp()
{
- $cip = $this->getParam('cip');
- if(!empty($cip)) {
- if (!$this->isAuthenticated()) {
- throw new Exception("You must specify token_auth parameter to use the 'cip' parameter.");
- }
- $ipString = $cip;
- } else {
- $ipString = IP::getIpFromHeader();
- }
-
+ $ipString = $this->getIpString();
$ip = IP::P2N($ipString);
return $ip;
}
@@ -607,4 +602,21 @@ class Request
{
return substr( sha1( $userId ), 0, 16);
}
+
+ /**
+ * @return mixed|string
+ * @throws Exception
+ */
+ private function getIpString()
+ {
+ $cip = $this->getParam('cip');
+ if (empty($cip)) {
+ return IP::getIpFromHeader();
+ }
+
+ if (!$this->isAuthenticated()) {
+ throw new Exception("You must specify token_auth parameter to use the 'cip' parameter.");
+ }
+ return $cip;
+ }
}