public static function getCleanHostname($hostname)
{
$extToExclude = array('com', 'net', 'org', 'co');
$off = strrpos($hostname, '.');
$ext = substr($hostname, $off);
if (empty($off) || is_numeric($ext) || strlen($hostname) < 5) {
return 'Ip';
} else {
$cleanHostname = null;
/**
* Triggered when prettifying a hostname string.
*
* This event can be used to customize the way a hostname is displayed in the
* Providers report.
*
* **Example**
*
* public function getCleanHostname(&$cleanHostname, $hostname)
* {
* if ('fvae.VARG.ceaga.site.co.jp' == $hostname) {
* $cleanHostname = 'site.co.jp';
* }
* }
*
* @param string &$cleanHostname The hostname string to display. Set by the event
* handler.
* @param string $hostname The full hostname.
*/
Piwik::postEvent('Provider.getCleanHostname', array(&$cleanHostname, $hostname));
if ($cleanHostname !== null) {
return $cleanHostname;
}
$e = explode('.', $hostname);
$s = sizeof($e);
// if extension not correct
if (isset($e[$s - 2]) && in_array($e[$s - 2], $extToExclude)) {
return $e[$s - 3] . "." . $e[$s - 2] . "." . $e[$s - 1];
} else {
return $e[$s - 2] . "." . $e[$s - 1];
}
}
}