Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refs #3697 Prettify ISP names #42

Merged
merged 6 commits into from
Apr 2, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions core/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
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 @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion plugins/Provider/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
21 changes: 21 additions & 0 deletions plugins/Provider/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions tests/PHPUnit/IntegrationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down