diff --git a/core/Common.php b/core/Common.php index e728675c2b3..d6908310d46 100644 --- a/core/Common.php +++ b/core/Common.php @@ -1023,6 +1023,21 @@ static public function getSearchEngineNames() return $searchEngines; } + /** + * Returns list of provider names + * + * @see core/DataFiles/Providers.php + * + * @return array Array of ( dnsName => providerName ) + */ + static public function getProviderNames() + { + require_once PIWIK_INCLUDE_PATH . '/core/DataFiles/Providers.php'; + + $providers = $GLOBALS['Piwik_ProviderNames']; + return $providers; + } + /* * Language, country, continent */ diff --git a/core/DataFiles/Providers.php b/core/DataFiles/Providers.php new file mode 100644 index 00000000000..33467ba165c --- /dev/null +++ b/core/DataFiles/Providers.php @@ -0,0 +1,32 @@ + "Orange", + "proxad" => "Free", + "bbox" => "Bouygues Telecom", + "bouyguestelecom" => "Bouygues Telecom", + "coucou-networks" => "Free Mobile", + "sfr" => "SFR", //Acronym, keep in uppercase + "univ-metz" => "Université de Lorraine", + "unilim" => "Université de Limoges", + "univ-paris5" => "Université Paris Descartes", + + // US + "rr" => "Time Warner Cable Internet", // Not sure + ); +} diff --git a/plugins/Live/Visitor.php b/plugins/Live/Visitor.php index c42ff66233b..ed3f7e84f48 100644 --- a/plugins/Live/Visitor.php +++ b/plugins/Live/Visitor.php @@ -497,7 +497,7 @@ function getScreenTypeIcon() function getProvider() { - return Piwik_getHostnameName( @$this->details['location_provider']); + return Piwik_Provider_getPrettyProviderName( @$this->details['location_provider']); } function getProviderUrl() diff --git a/plugins/Provider/API.php b/plugins/Provider/API.php index d2fe4b3beea..f3747dc20b6 100644 --- a/plugins/Provider/API.php +++ b/plugins/Provider/API.php @@ -39,7 +39,7 @@ public function getProvider( $idSite, $period, $date, $segment = false ) $dataTable = $archive->getDataTable('Provider_hostnameExt'); $dataTable->filter('Sort', array(Piwik_Archive::INDEX_NB_VISITS)); $dataTable->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', 'Piwik_getHostnameUrl')); - $dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_getHostnameName')); + $dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_Provider_getPrettyProviderName')); $dataTable->queueFilter('ReplaceColumnNames'); $dataTable->queueFilter('ReplaceSummaryRowLabel'); return $dataTable; diff --git a/plugins/Provider/functions.php b/plugins/Provider/functions.php index ec1afd4518a..9230f0a6eb6 100644 --- a/plugins/Provider/functions.php +++ b/plugins/Provider/functions.php @@ -61,3 +61,24 @@ function Piwik_getHostnameUrl($in) return "https://startpage.com/do/search?q=".urlencode($in); } } + +/** + * Return a pretty provider name for a given domain name + * + * @param string $in hostname + * @return string Real ISP name, IP (if IP address didn't resolve), or Unknown + */ +function Piwik_Provider_getPrettyProviderName( $in ) +{ + $providerName = Piwik_getHostnameName($in); + + $prettyNames = Piwik_Common::getProviderNames(); + + if(is_array($prettyNames) + && array_key_exists(strtolower($providerName), $prettyNames)) + { + $providerName = $prettyNames[strtolower($providerName)]; + } + + return $providerName; +} diff --git a/tests/PHPUnit/IntegrationTestCase.php b/tests/PHPUnit/IntegrationTestCase.php index 3ee7c7f59ca..c254d2ef2b5 100755 --- a/tests/PHPUnit/IntegrationTestCase.php +++ b/tests/PHPUnit/IntegrationTestCase.php @@ -123,6 +123,7 @@ public static function _setUpBeforeClass( $dbName = false, $createEmptyDatabase include "DataFiles/Countries.php"; include "DataFiles/Currencies.php"; include "DataFiles/LanguageToCountry.php"; + include "DataFiles/Providers.php"; Piwik::createAccessObject(); Piwik_PostEvent('FrontController.initAuthenticationObject');