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:
Diffstat (limited to 'modules/LogStats/Visit.php')
-rw-r--r--modules/LogStats/Visit.php348
1 files changed, 174 insertions, 174 deletions
diff --git a/modules/LogStats/Visit.php b/modules/LogStats/Visit.php
index 8fa9ce43ce..475cdce845 100644
--- a/modules/LogStats/Visit.php
+++ b/modules/LogStats/Visit.php
@@ -1,14 +1,14 @@
-<?php
-/**
- * Piwik - Open source web analytics
- *
- * @link http://piwik.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
- * @version $Id$
- *
- * @package Piwik_LogStats
- */
-
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
+ * @version $Id$
+ *
+ * @package Piwik_LogStats
+ */
+
/**
* Class used to handle a Visit.
* A visit is either NEW or KNOWN.
@@ -27,8 +27,8 @@ class Piwik_LogStats_Visit
{
protected $cookieLog = null;
protected $visitorInfo = array();
- protected $userSettingsInformation = null;
-
+ protected $userSettingsInformation = null;
+
function __construct( $db )
{
@@ -584,34 +584,34 @@ class Piwik_LogStats_Visit
*/
private function getRefererInformation()
{
- // default values for the referer_* fields
+ // default values for the referer_* fields
$this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_DIRECT_ENTRY;
$this->nameRefererAnalyzed = '';
- $this->keywordRefererAnalyzed = '';
-
+ $this->keywordRefererAnalyzed = '';
+
// get the urls and parse them
$refererUrl = Piwik_Common::getRequestVar( 'urlref', '', 'string');
$currentUrl = Piwik_Common::getRequestVar( 'url', '', 'string');
$this->refererUrlParse = @parse_url($refererUrl);
$this->currentUrlParse = @parse_url($currentUrl);
-
- // if we have a referer available we try to detect something interesting
+
+ // if we have a referer available we try to detect something interesting
// otherwise it's defaulted to "the visitor is a direct entry"
if( !empty($this->refererUrlParse['host']) )
{
$this->refererHost = $this->refererUrlParse['host'];
- if( !$this->detectRefererSearchEngine()
- && !$this->detectRefererNewsletter()
- && !$this->detectRefererPartner()
- && !$this->detectRefererCampaign()
- && !$this->detectRefererDirectEntry()
- )
- {
- // Normal website referer
- $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_WEBSITE;
- $this->nameRefererAnalyzed = $this->refererHost;
+ if( !$this->detectRefererSearchEngine()
+ && !$this->detectRefererNewsletter()
+ && !$this->detectRefererPartner()
+ && !$this->detectRefererCampaign()
+ && !$this->detectRefererDirectEntry()
+ )
+ {
+ // Normal website referer
+ $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_WEBSITE;
+ $this->nameRefererAnalyzed = $this->refererHost;
}
}
@@ -624,153 +624,153 @@ class Piwik_LogStats_Visit
return $refererInformation;
}
-
- /*
- * Search engine detection
- */
- private function detectRefererSearchEngine()
- {
- /*
- * A referer is a search engine if the URL's host is in the SearchEngines array
- * and if we found the keyword in the URL.
- *
- * For example if someone comes from http://www.google.com/partners.html this will not
- * be counted as a search engines, but as a website referer from google.com (because the
- * keyword couldn't be found in the URL)
- */
- require PIWIK_DATAFILES_INCLUDE_PATH . "/SearchEngines.php";
-
- if(array_key_exists($this->refererHost, $GLOBALS['Piwik_SearchEngines']))
- {
- // which search engine ?
- $searchEngineName = $GLOBALS['Piwik_SearchEngines'][$this->refererHost][0];
- $variableName = $GLOBALS['Piwik_SearchEngines'][$this->refererHost][1];
-
- // if there is a query, there may be a keyword...
- if(isset($this->refererUrlParse['query']))
- {
- $query = $this->refererUrlParse['query'];
-
- // search for keywords now &vname=keyword
- $key = trim(strtolower(Piwik_Common::getParameterFromQueryString($query, $variableName)));
-
- if((function_exists('iconv'))
- && (isset($GLOBALS['Piwik_SearchEngines'][$this->refererHost][2])))
- {
- $charset = trim($GLOBALS['Piwik_SearchEngines'][$this->refererHost][2]);
-
- if(!empty($charset))
- {
- $key = htmlspecialchars(
- @iconv( $charset,
+
+ /*
+ * Search engine detection
+ */
+ private function detectRefererSearchEngine()
+ {
+ /*
+ * A referer is a search engine if the URL's host is in the SearchEngines array
+ * and if we found the keyword in the URL.
+ *
+ * For example if someone comes from http://www.google.com/partners.html this will not
+ * be counted as a search engines, but as a website referer from google.com (because the
+ * keyword couldn't be found in the URL)
+ */
+ require PIWIK_DATAFILES_INCLUDE_PATH . "/SearchEngines.php";
+
+ if(array_key_exists($this->refererHost, $GLOBALS['Piwik_SearchEngines']))
+ {
+ // which search engine ?
+ $searchEngineName = $GLOBALS['Piwik_SearchEngines'][$this->refererHost][0];
+ $variableName = $GLOBALS['Piwik_SearchEngines'][$this->refererHost][1];
+
+ // if there is a query, there may be a keyword...
+ if(isset($this->refererUrlParse['query']))
+ {
+ $query = $this->refererUrlParse['query'];
+
+ // search for keywords now &vname=keyword
+ $key = trim(strtolower(Piwik_Common::getParameterFromQueryString($query, $variableName)));
+
+ if((function_exists('iconv'))
+ && (isset($GLOBALS['Piwik_SearchEngines'][$this->refererHost][2])))
+ {
+ $charset = trim($GLOBALS['Piwik_SearchEngines'][$this->refererHost][2]);
+
+ if(!empty($charset))
+ {
+ $key = htmlspecialchars(
+ @iconv( $charset,
'utf-8//TRANSLIT',
- //TODO testthis fnction exists!! use upgrade.php
- htmlspecialchars_decode($key, Piwik_Common::HTML_ENCODING_QUOTE_STYLE))
- , Piwik_Common::HTML_ENCODING_QUOTE_STYLE);
- }
- }
-
-
- if(!empty($key))
- {
- $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_SEARCH_ENGINE;
- $this->nameRefererAnalyzed = $searchEngineName;
- $this->keywordRefererAnalyzed = $key;
-
- return true;
- }
- }
- }
- }
-
- /*
- * Newsletter analysis
- */
- private function detectRefererNewsletter()
- {
- if(isset($this->currentUrlParse['query']))
- {
- $newsletterVariableName = Piwik_LogStats_Config::getInstance()->LogStats['newsletter_var_name'];
- $newsletterVar = Piwik_Common::getParameterFromQueryString( $this->currentUrlParse['query'], $newsletterVariableName);
-
- if(!empty($newsletterVar))
- {
- $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_NEWSLETTER;
- $this->nameRefererAnalyzed = $newsletterVar;
-
- return true;
- }
- }
- }
-
- /*
- * Partner analysis
- */
- private function detectRefererPartner()
- {
- if(isset($this->currentUrlParse['query']))
- {
- $partnerVariableName = Piwik_LogStats_Config::getInstance()->LogStats['partner_var_name'];
- $partnerVar = Piwik_Common::getParameterFromQueryString($this->currentUrlParse['query'], $partnerVariableName);
-
- if(!empty($partnerVar))
- {
- $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_PARTNER;
- $this->nameRefererAnalyzed = $partnerVar;
-
- return true;
- }
- }
- }
-
- /*
- * Campaign analysis
- */
- private function detectRefererCampaign()
- {
- if(isset($this->currentUrlParse['query']))
- {
- $campaignVariableName = Piwik_LogStats_Config::getInstance()->LogStats['campaign_var_name'];
- $campaignName = Piwik_Common::getParameterFromQueryString($this->currentUrlParse['query'], $campaignVariableName);
-
- if( !empty($campaignName))
- {
- $campaignKeywordVariableName = Piwik_LogStats_Config::getInstance()->LogStats['campaign_keyword_var_name'];
- $campaignKeyword = Piwik_Common::getParameterFromQueryString($this->currentUrlParse['query'], $campaignKeywordVariableName);
-
- $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_CAMPAIGN;
- $this->nameRefererAnalyzed = $campaignName;
-
- if(!empty($campaignKeyword))
- {
- $this->keywordRefererAnalyzed = $campaignKeyword;
- }
-
- return true;
- }
- }
- }
-
- /*
- * Direct entry (referer host is similar to current host)
- * And we have previously tried to detect the newsletter/partner/campaign variables in the URL
- * so it can only be a direct access
- */
-
- private function detectRefererDirectEntry()
- {
- if(isset($this->currentUrlParse['host']))
- {
- $currentHost = $this->currentUrlParse['host'];
-
- if($currentHost == $this->refererHost)
- {
- $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_DIRECT_ENTRY;
-
- return true;
- }
- }
-
+ //TODO testthis fnction exists!! use upgrade.php
+ htmlspecialchars_decode($key, Piwik_Common::HTML_ENCODING_QUOTE_STYLE))
+ , Piwik_Common::HTML_ENCODING_QUOTE_STYLE);
+ }
+ }
+
+
+ if(!empty($key))
+ {
+ $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_SEARCH_ENGINE;
+ $this->nameRefererAnalyzed = $searchEngineName;
+ $this->keywordRefererAnalyzed = $key;
+
+ return true;
+ }
+ }
+ }
+ }
+
+ /*
+ * Newsletter analysis
+ */
+ private function detectRefererNewsletter()
+ {
+ if(isset($this->currentUrlParse['query']))
+ {
+ $newsletterVariableName = Piwik_LogStats_Config::getInstance()->LogStats['newsletter_var_name'];
+ $newsletterVar = Piwik_Common::getParameterFromQueryString( $this->currentUrlParse['query'], $newsletterVariableName);
+
+ if(!empty($newsletterVar))
+ {
+ $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_NEWSLETTER;
+ $this->nameRefererAnalyzed = $newsletterVar;
+
+ return true;
+ }
+ }
+ }
+
+ /*
+ * Partner analysis
+ */
+ private function detectRefererPartner()
+ {
+ if(isset($this->currentUrlParse['query']))
+ {
+ $partnerVariableName = Piwik_LogStats_Config::getInstance()->LogStats['partner_var_name'];
+ $partnerVar = Piwik_Common::getParameterFromQueryString($this->currentUrlParse['query'], $partnerVariableName);
+
+ if(!empty($partnerVar))
+ {
+ $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_PARTNER;
+ $this->nameRefererAnalyzed = $partnerVar;
+
+ return true;
+ }
+ }
+ }
+
+ /*
+ * Campaign analysis
+ */
+ private function detectRefererCampaign()
+ {
+ if(isset($this->currentUrlParse['query']))
+ {
+ $campaignVariableName = Piwik_LogStats_Config::getInstance()->LogStats['campaign_var_name'];
+ $campaignName = Piwik_Common::getParameterFromQueryString($this->currentUrlParse['query'], $campaignVariableName);
+
+ if( !empty($campaignName))
+ {
+ $campaignKeywordVariableName = Piwik_LogStats_Config::getInstance()->LogStats['campaign_keyword_var_name'];
+ $campaignKeyword = Piwik_Common::getParameterFromQueryString($this->currentUrlParse['query'], $campaignKeywordVariableName);
+
+ $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_CAMPAIGN;
+ $this->nameRefererAnalyzed = $campaignName;
+
+ if(!empty($campaignKeyword))
+ {
+ $this->keywordRefererAnalyzed = $campaignKeyword;
+ }
+
+ return true;
+ }
+ }
+ }
+
+ /*
+ * Direct entry (referer host is similar to current host)
+ * And we have previously tried to detect the newsletter/partner/campaign variables in the URL
+ * so it can only be a direct access
+ */
+
+ private function detectRefererDirectEntry()
+ {
+ if(isset($this->currentUrlParse['host']))
+ {
+ $currentHost = $this->currentUrlParse['host'];
+
+ if($currentHost == $this->refererHost)
+ {
+ $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_DIRECT_ENTRY;
+
+ return true;
+ }
+ }
+
}
/**
* Returns a MD5 of all the configuration settings