Skip to content

Commit

Permalink
Merge pull request from @ksubileau
Browse files Browse the repository at this point in the history
fixes #3697
  • Loading branch information
halfdan committed Apr 2, 2013
2 parents a05bd7b + 1f8fa79 commit c455528
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 2 deletions.
15 changes: 15 additions & 0 deletions core/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,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
*/
Expand Down
32 changes: 32 additions & 0 deletions core/DataFiles/Providers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik
* @package DataFiles
*/

/**
* Providers names
*/
if(!isset($GLOBALS['Piwik_ProviderNames']))
{
$GLOBALS['Piwik_ProviderNames'] = array(
// France
"wanadoo" => "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
);
}
2 changes: 1 addition & 1 deletion plugins/Live/Visitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ function getScreenTypeIcon()

function getProvider()
{
return Piwik_getHostnameName(@$this->details['location_provider']);
return Piwik_Provider_getPrettyProviderName(@$this->details['location_provider']);
}

function getProviderUrl()
Expand Down
2 changes: 1 addition & 1 deletion plugins/Provider/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,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;
Expand Down
21 changes: 21 additions & 0 deletions plugins/Provider/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,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;
}
1 change: 1 addition & 0 deletions tests/PHPUnit/IntegrationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,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');
Expand Down

0 comments on commit c455528

Please sign in to comment.