Skip to content

Commit

Permalink
Merge pull request #56 from open-source-contributions/add_require_block
Browse files Browse the repository at this point in the history
Add require block to define required extensions
  • Loading branch information
sgiehl authored Jan 13, 2020
2 parents 95eeeb2 + 772490e commit 64248e1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
24 changes: 12 additions & 12 deletions MatomoTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function __construct($idSite, $apiUrl = '')
$this->sendImageResponse = true;

$this->visitorCustomVar = $this->getCustomVariablesFromCookie();

$this->outgoingTrackerCookies = array();
$this->incomingTrackerCookies = array();
}
Expand Down Expand Up @@ -1122,7 +1122,7 @@ public function getUrlTrackAction($actionUrl, $actionType)
*
* Allowed only for Admin/Super User, must be used along with setTokenAuth()
* @see setTokenAuth()
* @param string $dateTime Date with the format 'Y-m-d H:i:s', or a UNIX timestamp.
* @param string $dateTime Date with the format 'Y-m-d H:i:s', or a UNIX timestamp.
* If the datetime is older than one day (default value for tracking_requests_require_authentication_when_custom_timestamp_newer_than), then you must call setTokenAuth() with a valid Admin/Super user token.
* @return $this
*/
Expand Down Expand Up @@ -1576,7 +1576,7 @@ protected function sendRequest($url, $method = 'GET', $data = null, $force = fal
$options[CURLOPT_COOKIE] = http_build_query($this->outgoingTrackerCookies);
$this->outgoingTrackerCookies = array();
}

$ch = curl_init();
curl_setopt_array($ch, $options);
ob_start();
Expand All @@ -1587,7 +1587,7 @@ protected function sendRequest($url, $method = 'GET', $data = null, $force = fal
if (!empty($response)) {
list($header, $content) = explode("\r\n\r\n", $response, $limitCount = 2);
}

$this->parseIncomingCookies(explode("\r\n", $header));

} elseif (function_exists('stream_context_create')) {
Expand All @@ -1596,7 +1596,7 @@ protected function sendRequest($url, $method = 'GET', $data = null, $force = fal
'method' => $method,
'user_agent' => $this->userAgent,
'header' => "Accept-Language: " . $this->acceptLanguage . "\r\n",
'timeout' => $this->requestTimeout, // PHP 5.2.1
'timeout' => $this->requestTimeout,
),
);

Expand All @@ -1614,11 +1614,11 @@ protected function sendRequest($url, $method = 'GET', $data = null, $force = fal
$stream_options['http']['header'] .= 'Cookie: ' . http_build_query($this->outgoingTrackerCookies) . "\r\n";
$this->outgoingTrackerCookies = array();
}

$ctx = stream_context_create($stream_options);
$response = file_get_contents($url, 0, $ctx);
$content = $response;

$this->parseIncomingCookies($http_response_header);
}

Expand Down Expand Up @@ -1977,7 +1977,7 @@ public function setOutgoingTrackerCookie($name, $value)
$this->outgoingTrackerCookies[$name] = $value;
}
}

/**
* Gets a cookie which was set by the tracking server.
*
Expand All @@ -1990,7 +1990,7 @@ public function getIncomingTrackerCookie($name)
if (isset($this->incomingTrackerCookies[$name])) {
return $this->incomingTrackerCookies[$name];
}

return false;
}

Expand All @@ -2002,11 +2002,11 @@ public function getIncomingTrackerCookie($name)
protected function parseIncomingCookies($headers)
{
$this->incomingTrackerCookies = array();

if (!empty($headers)) {
$headerName = 'set-cookie:';
$headerNameLength = strlen($headerName);

foreach($headers as $header) {
if (strpos(strtolower($header), $headerName) !== 0) {
continue;
Expand All @@ -2018,7 +2018,7 @@ protected function parseIncomingCookies($headers)
}
parse_str($cookies, $this->incomingTrackerCookies);
}
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion PiwikTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ function Piwik_getUrlTrackGoal($idSite, $idGoal, $revenue = 0.0)
*
* @deprecated use MatomoTracker instead
*/
class PiwikTracker extends MatomoTracker {}
class PiwikTracker extends MatomoTracker {}
7 changes: 7 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
"issues": "https://github.com/matomo-org/matomo-php-tracker/issues",
"source": "https://github.com/matomo-org/matomo-php-tracker"
},
"require": {
"php": "^5.3",
"ext-json": "*"
},
"suggest": {
"ext-curl": "Using this extension to issue the HTTPS request to Matomo"
},
"autoload": {
"classmap": ["."]
}
Expand Down

0 comments on commit 64248e1

Please sign in to comment.