isErrNo($e, '1060')) { throw $e; } } } public function uninstall() { // add column hostname / hostname ext in the visit table $query = "ALTER TABLE `" . Common::prefixTable('log_visit') . "` DROP `location_provider`"; Db::exec($query); } public function postLoad() { Piwik::addAction('Template.footerUserCountry', array('Piwik\Plugins\Provider\Provider', 'footerUserCountry')); } public static function footerUserCountry(&$out) { $out .= '

' . Piwik::translate('Provider_WidgetProviders') . '

'; $out .= FrontController::getInstance()->fetchDispatch('Provider', 'getProvider'); } /** * Returns the hostname extension (site.co.jp in fvae.VARG.ceaga.site.co.jp) * given the full hostname looked up from the IP * * @param string $hostname * * @return string */ 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]; } } } }