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.../vendor/wordfenc.../mmdb-rea.../src
File: DatabaseMetadata.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Wordfence\MmdbReader;
[2] Fix | Delete
[3] Fix | Delete
use Wordfence\MmdbReader\Exception\FormatException;
[4] Fix | Delete
[5] Fix | Delete
class DatabaseMetadata {
[6] Fix | Delete
[7] Fix | Delete
const MAX_LENGTH = 131072; //128 * 1024;
[8] Fix | Delete
[9] Fix | Delete
const FIELD_MAJOR_VERSION = 'binary_format_major_version';
[10] Fix | Delete
const FIELD_NODE_COUNT = 'node_count';
[11] Fix | Delete
const FIELD_RECORD_SIZE = 'record_size';
[12] Fix | Delete
const FIELD_IP_VERSION = 'ip_version';
[13] Fix | Delete
const FIELD_BUILD_EPOCH = 'build_epoch';
[14] Fix | Delete
[15] Fix | Delete
private $data;
[16] Fix | Delete
[17] Fix | Delete
public function __construct($data) {
[18] Fix | Delete
$this->data = $data;
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
private function getField($key, $default = null, &$exists = null) {
[22] Fix | Delete
if (!array_key_exists($key, $this->data)) {
[23] Fix | Delete
$exists = false;
[24] Fix | Delete
return $default;
[25] Fix | Delete
}
[26] Fix | Delete
$exists = true;
[27] Fix | Delete
return $this->data[$key];
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
private function requireField($key) {
[31] Fix | Delete
$value = $this->getField($key, null, $exists);
[32] Fix | Delete
if (!$exists)
[33] Fix | Delete
throw new FormatException("Metadata field {$key} is missing");
[34] Fix | Delete
return $value;
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
public function requireInteger($key) {
[38] Fix | Delete
$value = $this->requireField($key);
[39] Fix | Delete
if (!is_int($value))
[40] Fix | Delete
throw new FormatException("Field {$key} should be an integer, received: " . print_r($value, true));
[41] Fix | Delete
return $value;
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
public function getMajorVersion() {
[45] Fix | Delete
return $this->requireInteger(self::FIELD_MAJOR_VERSION);
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
public function getNodeCount() {
[49] Fix | Delete
return $this->requireInteger(self::FIELD_NODE_COUNT);
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
public function getRecordSize() {
[53] Fix | Delete
return $this->requireInteger(self::FIELD_RECORD_SIZE);
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
public function getIpVersion() {
[57] Fix | Delete
return $this->requireInteger(self::FIELD_IP_VERSION);
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
public function getBuildEpoch() {
[61] Fix | Delete
return $this->requireInteger(self::FIELD_BUILD_EPOCH);
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
public static function parse($handle) {
[65] Fix | Delete
$offset = $handle->getPosition();
[66] Fix | Delete
$parser = new DataFieldParser($handle, $offset);
[67] Fix | Delete
$value = $parser->parseField();
[68] Fix | Delete
if (!is_array($value))
[69] Fix | Delete
throw new FormatException('Unexpected field type found when metadata map was expected: ' . print_r($value, true));
[70] Fix | Delete
return new self($value);
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
}
[74] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function