diff --git a/lang/en.php b/lang/en.php index d000affdcdbe04fe80ec40c54d8a9389fdb55e67..d48003f79bd386b3afc8c3183b027b703b7204d5 100644 --- a/lang/en.php +++ b/lang/en.php @@ -341,7 +341,7 @@ $translations = array( 'General_NotInstalled' => 'Not Installed', 'General_Installed' => 'Installed', 'General_Broken' => 'Broken', - 'General_Info' => 'Info', + 'General_InfoFor' => 'Info for %s', 'Actions_PluginDescription' => 'Reports about the page views, the outlinks and downloads. Outlinks and Downloads tracking is automatic!', 'Actions_Actions' => 'Actions', 'Actions_SubmenuPages' => 'Pages', @@ -1145,7 +1145,7 @@ And thank you for using Piwik!', 'TranslationsAdmin_CannotOpenForWriting' => 'Cannot open %s for writing', 'TranslationsAdmin_InvalidCountry' => 'Invalid country', 'TranslationsAdmin_InvalidLanguage' => 'Invalid language', - 'UserCountry_PluginDescription' => 'Reports the Country of the visitors.', + 'UserCountry_PluginDescription' => 'Reports information regarding visitor location, including country, region, city and geographic coordinates (latitude/longitude).', 'UserCountry_Country' => 'Country', 'UserCountry_Continent' => 'Continent', 'UserCountry_Region' => 'Region', @@ -1451,14 +1451,15 @@ And thank you for using Piwik!', 'UserCountry_GeoIpLocationProviderDesc_ServerBased2' => 'If you have to import log files or do something else that requires setting IP addresses, use the %1$sPECL GeoIP implementation (recommended)%2$s or the %3$sPHP GeoIP implementation%4$s.', 'UserCountry_GeolocationPageDesc' => 'On this page you can change how Piwik determines visitor locations, and view the status of the GeoIp implementations Piwik detects.', 'UserCountry_CurrentLocationIntro' => 'According to this provider, your current location is', - 'UserCountry_CannotFindPeclGeoIPDb' => 'Could not find a country, region or city database for the GeoIP PECL module. Make sure your GeoIP database is located in \'%s\' and is named \'GeoIP.dat\' or \'GeoIPCity.dat\' otherwise the PECL module will not notice it.', - 'UserCountry_PeclGeoIPNoDBDir' => 'The PECL module is looking for databases in \'%s\', but this directory does not exist. Please create it and add the GeoIP databases to it. Alternatively, you can set \'geoip.custom_directory\' to the correct directory in your php.ini file.', - 'UserCountry_PeclGeoLiteError' => 'Your GeoIP database in \'%s\' is named \'GeoLiteCity.dat\'. Unfortunately, the PECL module will not recognize it with this name. Please rename it to \'GeoIPCity.dat\'.', + 'UserCountry_CannotFindPeclGeoIPDb' => 'Could not find a country, region or city database for the GeoIP PECL module. Make sure your GeoIP database is located in %1$s and is named %2$s or %3$s otherwise the PECL module will not notice it.', + 'UserCountry_PeclGeoIPNoDBDir' => 'The PECL module is looking for databases in %1$s, but this directory does not exist. Please create it and add the GeoIP databases to it. Alternatively, you can set %2$s to the correct directory in your php.ini file.', + 'UserCountry_PeclGeoLiteError' => 'Your GeoIP database in %1$s is named %2$s. Unfortunately, the PECL module will not recognize it with this name. Please rename it to %3$s.', 'UserCountry_GeoIpLocationProviderDesc_Pecl1' => 'This location provider uses a GeoIP database and a PECL module to accurately and efficiently determine the location of your visitors.', 'UserCountry_GeoIpLocationProviderDesc_Pecl2' => 'There are no limitations with this provider, so it is the one we recommend using.', 'UserCountry_CannotFindGeoIPServerVar' => 'The %s $_SERVER variable is not set. Your server may not be configured correctly.', 'UserCountry_LocationProvider' => 'Location Provider', - 'UserCountry_TestIPLocatorFailed' => 'Piwik tried checking the location of a known IP address (%1$s), but your server returned \'%2$s, %3$s, %4$s\'. If this provider is configured correctly, it should return \'%5$s, %6$s, %7$s\'.', + 'UserCountry_TestIPLocatorFailed' => 'Piwik tried checking the location of a known IP address (%1$s), but your server returned %2$s. If this provider were configured correctly, it would return %3$s.', + 'UserCountry_CannotLocalizeLocalIP' => 'IP address %s is a local address and cannot be geolocated.', 'UserSettings_VisitorSettings' => 'Visitor Settings', 'UserSettings_BrowserFamilies' => 'Browser families', 'UserSettings_Browsers' => 'Browsers', diff --git a/plugins/UserCountry/Controller.php b/plugins/UserCountry/Controller.php index 72e6860bb0accc6e65229b074e4150f549a33e48..5953ccbd9e5fb3a90faf9cadcb42f8871bc51cba 100644 --- a/plugins/UserCountry/Controller.php +++ b/plugins/UserCountry/Controller.php @@ -39,6 +39,7 @@ class Piwik_UserCountry_Controller extends Piwik_Controller $view->locationProviders = Piwik_UserCountry_LocationProvider::getAllProviderInfo( $newline = '<br/>', $includeExtra = true); $view->currentProviderId = Piwik_UserCountry_LocationProvider::getCurrentProviderId(); + $view->thisIP = Piwik_IP::getIpFromHeader(); $this->setBasicVariablesView($view); $view->menu = Piwik_GetAdminMenu(); diff --git a/plugins/UserCountry/LocationProvider.php b/plugins/UserCountry/LocationProvider.php index bbbe8fe9da1c31bed7429c3f8eb8d3e29b76f09f..8ead0e9f5c5b3fca9c9c949423090c7374abb95b 100755 --- a/plugins/UserCountry/LocationProvider.php +++ b/plugins/UserCountry/LocationProvider.php @@ -202,7 +202,7 @@ abstract class Piwik_UserCountry_LocationProvider */ public static function getAllProviderInfo( $newline = "\n", $includeExtra = false ) { - $result = array(); + $allInfo = array(); foreach (self::getAllProviders() as $provider) { $info = $provider->getInfo(); @@ -238,6 +238,14 @@ abstract class Piwik_UserCountry_LocationProvider $info['statusMessage'] = $statusMessage; $info['location'] = $location; + $allInfo[$info['order']] = $info; + } + + ksort($allInfo); + + $result = array(); + foreach ($allInfo as $info) + { $result[$info['id']] = $info; } return $result; diff --git a/plugins/UserCountry/LocationProvider/Default.php b/plugins/UserCountry/LocationProvider/Default.php index 8f560717f71b5890c0a051a43d4e6d975e5544fa..dcf99dec3a68f1706698cb21c961a29d07f3b854 100755 --- a/plugins/UserCountry/LocationProvider/Default.php +++ b/plugins/UserCountry/LocationProvider/Default.php @@ -99,7 +99,7 @@ class Piwik_UserCountry_LocationProvider_Default extends Piwik_UserCountry_Locat $desc = Piwik_Translate('UserCountry_DefaultLocationProviderDesc1') . ' ' . Piwik_Translate('UserCountry_DefaultLocationProviderDesc2', array('<strong>', '<em>', '</em>', '</strong>')); - return array('id' => self::ID, 'title' => self::TITLE, 'description' => $desc); + return array('id' => self::ID, 'title' => self::TITLE, 'description' => $desc, 'order' => 1); } } diff --git a/plugins/UserCountry/LocationProvider/GeoIp.php b/plugins/UserCountry/LocationProvider/GeoIp.php index 7a639a7da6f3748177832832d785f6982705032b..c08e463510283692f0f270e28d0564ee8e154758 100755 --- a/plugins/UserCountry/LocationProvider/GeoIp.php +++ b/plugins/UserCountry/LocationProvider/GeoIp.php @@ -103,15 +103,20 @@ abstract class Piwik_UserCountry_LocationProvider_GeoIp extends Piwik_UserCountr { $unknown = Piwik_Translate('General_Unknown'); - $bind = array($testIp, + $location = "'" + . (empty($location[self::CITY_NAME_KEY]) ? $unknown : $location[self::CITY_NAME_KEY]) + . ", " + . (empty($location[self::REGION_CODE_KEY]) ? $unknown : $location[self::REGION_CODE_KEY]) + . ", " + . (empty($location[self::COUNTRY_CODE_KEY]) ? $unknown : $location[self::COUNTRY_CODE_KEY]) + . "'" + ; - empty($location[self::CITY_NAME_KEY]) ? $unknown : $location[self::CITY_NAME_KEY], - empty($location[self::REGION_CODE_KEY]) ? $unknown : $location[self::REGION_CODE_KEY], - empty($location[self::COUNTRY_CODE_KEY]) ? $unknown : $location[self::COUNTRY_CODE_KEY], - - $expectedResult[self::CITY_NAME_KEY], - $expectedResult[self::REGION_CODE_KEY], - $expectedResult[self::COUNTRY_CODE_KEY]); + $expectedLocation = "'".$expectedResult[self::CITY_NAME_KEY].", " + . $expectedResult[self::REGION_CODE_KEY].", " + . $expectedResult[self::COUNTRY_CODE_KEY]."'"; + + $bind = array($testIp, $location, $expectedLocation); return Piwik_Translate('UserCountry_TestIPLocatorFailed', $bind); } diff --git a/plugins/UserCountry/LocationProvider/GeoIp/Pecl.php b/plugins/UserCountry/LocationProvider/GeoIp/Pecl.php index 772bd739f49020c2ce9d3f9e41e7094c4085d181..3fbbb52625f34e43ceb44c80e074c32c12a3ad12 100755 --- a/plugins/UserCountry/LocationProvider/GeoIp/Pecl.php +++ b/plugins/UserCountry/LocationProvider/GeoIp/Pecl.php @@ -131,20 +131,23 @@ class Piwik_UserCountry_LocationProvider_GeoIp_Pecl extends Piwik_UserCountry_Lo if (!self::isLocationDatabaseAvailable()) { $dbDir = dirname(geoip_db_filename(GEOIP_COUNTRY_EDITION)).'/'; + $quotedDir = "'$dbDir'"; // check if the directory the PECL module is looking for exists if (!is_dir($dbDir)) { - return Piwik_Translate('UserCountry_PeclGeoIPNoDBDir', $dbDir); + return Piwik_Translate('UserCountry_PeclGeoIPNoDBDir', array($quotedDir, "'geoip.custom_directory'")); } // check if the user named the city database GeoLiteCity.dat if (file_exists($dbDir.'GeoLiteCity.dat')) { - return Piwik_Translate('UserCountry_PeclGeoLiteError', $dbDir); + return Piwik_Translate('UserCountry_PeclGeoLiteError', + array($quotedDir, "'GeoLiteCity.dat'", "'GeoIPCity.dat'")); } - return Piwik_Translate('UserCountry_CannotFindPeclGeoIPDb', $dbDir); + return Piwik_Translate('UserCountry_CannotFindPeclGeoIPDb', + array($quotedDir, "'GeoIP.dat'", "'GeoIPCity.dat'")); } return parent::isWorking(); @@ -228,7 +231,7 @@ class Piwik_UserCountry_LocationProvider_GeoIp_Pecl extends Piwik_UserCountry_Lo { $desc = Piwik_Translate('UserCountry_GeoIpLocationProviderDesc_Pecl1') . '<br/><br/>' . Piwik_Translate('UserCountry_GeoIpLocationProviderDesc_Pecl2'); - return array('id' => self::ID, 'title' => self::TITLE, 'description' => $desc); + return array('id' => self::ID, 'title' => self::TITLE, 'description' => $desc, 'order' => 2); } /** diff --git a/plugins/UserCountry/LocationProvider/GeoIp/Php.php b/plugins/UserCountry/LocationProvider/GeoIp/Php.php index 249a25baf12ac14ffa7b633f1ea7a07f36404939..459998bc6718cef58ae9ab5847ef6bb45d356318 100755 --- a/plugins/UserCountry/LocationProvider/GeoIp/Php.php +++ b/plugins/UserCountry/LocationProvider/GeoIp/Php.php @@ -234,7 +234,7 @@ class Piwik_UserCountry_LocationProvider_GeoIp_Php extends Piwik_UserCountry_Loc . Piwik_Translate('UserCountry_GeoIpLocationProviderDesc_Php2', array('<strong>', '</strong>', '<strong><em>', '</em></strong>', '<strong><em>', '</em></strong>')); - return array('id' => self::ID, 'title' => self::TITLE, 'description' => $desc); + return array('id' => self::ID, 'title' => self::TITLE, 'description' => $desc, 'order' => 4); } /** diff --git a/plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php b/plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php index 4d63ee0e655980ab2354fc7c71afc0295b669fe0..9464f7842914b93513bfea03cea58073f9f4d70a 100755 --- a/plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php +++ b/plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php @@ -197,6 +197,6 @@ class Piwik_UserCountry_LocationProvider_GeoIp_ServerBased extends Piwik_UserCou . Piwik_Translate('UserCountry_GeoIpLocationProviderDesc_ServerBased2', array('<strong><em>', '</em></strong>', '<strong><em>', '</em></strong>')); - return array('id' => self::ID, 'title' => $title, 'description' => $desc); + return array('id' => self::ID, 'title' => $title, 'description' => $desc, 'order' => 3); } } diff --git a/plugins/UserCountry/templates/adminIndex.tpl b/plugins/UserCountry/templates/adminIndex.tpl index dc8b1a76f9e655ec39ee771abd7a1f6d87e7ef31..ba7edcd7b989dd49614889954a8569619e04a69d 100755 --- a/plugins/UserCountry/templates/adminIndex.tpl +++ b/plugins/UserCountry/templates/adminIndex.tpl @@ -12,7 +12,7 @@ <tr> <th>{'UserCountry_LocationProvider'|translate}</th> <th>{'General_Description'|translate}</th> - <th>{'General_Info'|translate}</th> + <th>{'General_InfoFor'|translate:$thisIP}</th> </tr> {foreach from=$locationProviders key=id item=provider} <tr> @@ -40,6 +40,7 @@ <td width="164"> {if $provider.status eq 1} {capture assign=currentLocation} + {if $thisIP neq '127.0.0.1'} {'UserCountry_CurrentLocationIntro'|translate}: <div style="text-align:left;"> <br/> @@ -49,6 +50,9 @@ <div style="text-align:right;"> <a href="#" class="refresh-loc" data-impl-id="{$id}"><em>{'Dashboard_Refresh_js'|translate}</em></a> </div> + {else} + {'UserCountry_CannotLocalizeLocalIP'|translate:$thisIP} + {/if} {/capture} {$currentLocation|inlineHelp} {elseif $provider.status eq 2}