Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wordfenc.../lib
File: wfIpLocation.php
<?php
[0] Fix | Delete
[1] Fix | Delete
class wfIpLocation {
[2] Fix | Delete
[3] Fix | Delete
const LANGUAGE_DEFAULT = 'en';
[4] Fix | Delete
const LANGUAGE_SEPARATOR = '_';
[5] Fix | Delete
[6] Fix | Delete
private $record;
[7] Fix | Delete
[8] Fix | Delete
public function __construct($record) {
[9] Fix | Delete
$this->record = is_array($record) ? $record : array();
[10] Fix | Delete
}
[11] Fix | Delete
[12] Fix | Delete
public function getCountryRecord() {
[13] Fix | Delete
if (array_key_exists('country', $this->record)) {
[14] Fix | Delete
$country = $this->record['country'];
[15] Fix | Delete
if (is_array($country))
[16] Fix | Delete
return $country;
[17] Fix | Delete
}
[18] Fix | Delete
return array();
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
public function getCountryField($field) {
[22] Fix | Delete
$country = $this->getCountryRecord();
[23] Fix | Delete
if (array_key_exists($field, $country))
[24] Fix | Delete
return $country[$field];
[25] Fix | Delete
return null;
[26] Fix | Delete
}
[27] Fix | Delete
[28] Fix | Delete
public function getCountryCode() {
[29] Fix | Delete
$isoCode = $this->getCountryField('iso_code');
[30] Fix | Delete
if (is_string($isoCode) && strlen($isoCode) === 2)
[31] Fix | Delete
return $isoCode;
[32] Fix | Delete
return null;
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
private function findBestLanguageMatch($options, $preferredLanguage = self::LANGUAGE_DEFAULT) {
[36] Fix | Delete
$languages = array();
[37] Fix | Delete
if (is_string($preferredLanguage))
[38] Fix | Delete
$languages[] = $preferredLanguage;
[39] Fix | Delete
if (strpos($preferredLanguage, self::LANGUAGE_SEPARATOR) !== false) {
[40] Fix | Delete
$components = explode(self::LANGUAGE_SEPARATOR, $preferredLanguage);
[41] Fix | Delete
$baseLanguage = $components[0];
[42] Fix | Delete
if ($baseLanguage !== self::LANGUAGE_DEFAULT)
[43] Fix | Delete
$languages[] = $baseLanguage;
[44] Fix | Delete
}
[45] Fix | Delete
if ($preferredLanguage !== self::LANGUAGE_DEFAULT)
[46] Fix | Delete
$languages[] = self::LANGUAGE_DEFAULT;
[47] Fix | Delete
foreach ($languages as $language) {
[48] Fix | Delete
if (array_key_exists($language, $options))
[49] Fix | Delete
return $options[$language];
[50] Fix | Delete
}
[51] Fix | Delete
if (!empty($options))
[52] Fix | Delete
return reset($options);
[53] Fix | Delete
return null;
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
public function getCountryName($preferredLanguage = self::LANGUAGE_DEFAULT) {
[57] Fix | Delete
$names = $this->getCountryField('names');
[58] Fix | Delete
if (is_array($names) && !empty($names))
[59] Fix | Delete
return $this->findBestLanguageMatch($names, $preferredLanguage);
[60] Fix | Delete
return null;
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
}
[64] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function