| Server IP : 213.186.33.4 / Your IP : 216.73.216.193 Web Server : Apache System : Linux webm006.cluster103.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : awebpaca ( 35430) PHP Version : 8.5.0 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/awebpaca/piwik/plugins/UserCountry/ |
Upload File : |
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\UserCountry;
use Piwik\Config;
use Piwik\Container\StaticContainer;
use Piwik\Intl\Data\Provider\RegionDataProvider;
use Piwik\Plugins\GeoIp2\LocationProvider\GeoIp2;
/**
*
*/
class UserCountry extends \Piwik\Plugin
{
/**
* @see \Piwik\Plugin::registerEvents
*/
public function registerEvents()
{
return array(
'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
'AssetManager.getJavaScriptFiles' => 'getJsFiles',
'Tracker.setTrackerCacheGeneral' => 'setTrackerCacheGeneral',
'Insights.addReportToOverview' => 'addReportToInsightsOverview',
);
}
public function addReportToInsightsOverview(&$reports)
{
$reports['UserCountry_getCountry'] = array();
}
public function setTrackerCacheGeneral(&$cache)
{
$cache['currentLocationProviderId'] = LocationProvider::getCurrentProviderId();
}
public function getStylesheetFiles(&$stylesheets)
{
$stylesheets[] = "plugins/UserCountry/stylesheets/userCountry.less";
}
public function getJsFiles(&$jsFiles)
{
$jsFiles[] = "plugins/UserCountry/angularjs/location-provider-selection/location-provider-selection.controller.js";
$jsFiles[] = "plugins/UserCountry/angularjs/location-provider-selection/location-provider-selection.directive.js";
}
/**
* Returns a list of country codes for a given continent code.
*
* @param string $continent The continent code.
* @return array
*/
public static function getCountriesForContinent($continent)
{
/** @var RegionDataProvider $regionDataProvider */
$regionDataProvider = StaticContainer::get('Piwik\Intl\Data\Provider\RegionDataProvider');
$result = array();
$continent = strtolower($continent);
foreach ($regionDataProvider->getCountryList() as $countryCode => $continentCode) {
if ($continent == $continentCode) {
$result[] = $countryCode;
}
}
return array('SQL' => "'" . implode("', '", $result) . "', ?",
'bind' => '-'); // HACK: SegmentExpression requires a $bind, even if there's nothing to bind
}
/**
* Returns true if a GeoIP provider is installed & working, false if otherwise.
*
* @return bool
*/
public function isGeoIPWorking()
{
$provider = LocationProvider::getCurrentProvider();
return $provider instanceof GeoIp2
&& $provider->isAvailable() === true
&& $provider->isWorking() === true;
}
public static function isGeoLocationAdminEnabled()
{
return (bool) Config::getInstance()->General['enable_geolocation_admin'];
}
}