Piwik\Plugins\UserCountry\LocationProvider\GeoIp\Php::isWorking PHP Метод

isWorking() публичный Метод

Returns true if this provider has been setup correctly, the error message if otherwise.
public isWorking ( ) : boolean | string
Результат boolean | string
    public function isWorking()
    {
        if (!function_exists('mb_internal_encoding')) {
            return Piwik::translate('UserCountry_GeoIPCannotFindMbstringExtension', array('mb_internal_encoding', 'mbstring'));
        }
        $geoIpError = false;
        $catchGeoIpError = function ($errno, $errstr, $errfile, $errline) use(&$geoIpError) {
            $filename = basename($errfile);
            if ($filename == 'geoip.inc' || $filename == 'geoipcity.inc') {
                $geoIpError = array($errno, $errstr, $errfile, $errline);
            } else {
                throw new \Exception("Error in PHP GeoIP provider: {$errstr} on line {$errline} of {$errfile}");
                // unexpected
            }
        };
        // catch GeoIP errors
        set_error_handler($catchGeoIpError);
        $result = parent::isWorking();
        restore_error_handler();
        if ($geoIpError) {
            list($errno, $errstr, $errfile, $errline) = $geoIpError;
            Log::warning("Got GeoIP error when testing PHP GeoIP location provider: %s(%s): %s", $errfile, $errline, $errstr);
            return Piwik::translate('UserCountry_GeoIPIncorrectDatabaseFormat');
        }
        return $result;
    }