18,21 → 18,15 |
require_once __DIR__ . '/../../shared/php_includes/common_functions.inc.php'; |
require_once __DIR__ . '/rirs.inc.php'; |
|
define('IANA_CACHE_DIR', __DIR__ . '/../.cache/pattern-generator/iana'); |
define('PATTERN_DIR', __DIR__ . '/../../main/pattern'); |
define('RIRSTATS_CACHE_DIR', __DIR__ . '/../.cache/pattern-generator/rirstats'); |
define('CACHE_FILE_DIR', __DIR__ . '/../.cache/cache'); |
|
if (USE_IANA_DATA) { |
echo "IPv4 Preparation: Get IANA delegation file\n"; |
|
$iana_root_url = 'ftp://ftp.iana.org/assignments/ipv4-address-space/ipv4-address-space.txt'; |
$iana_root_cache = IANA_CACHE_DIR . '/ipv4-address-space.txt'; |
if ((USE_CACHE) && (file_exists($iana_root_cache))) { |
@mkdir(dirname($iana_root_cache), 0777, true); |
$iana_root_data = file($iana_root_cache, FILE_IGNORE_NEW_LINES); |
} else { |
$iana_root_data = file($iana_root_url, FILE_IGNORE_NEW_LINES); |
} |
$iana_root_data = explode("\n", cached_file(IANA_IPV4_ASSIGNMENTS, CACHE_FILE_DIR)); |
$iana_root_data = array_map('trim', $iana_root_data); |
|
$iana_root_ver = trim(str_replace('-', '', $iana_root_data[3])); |
$iana_root_data = grep($iana_root_data, 'whois.'); |
} |
48,13 → 42,7 |
echo "IPv4 $rir: Step $step - Get RIR statistics file\n"; |
|
$rirstat_url = $rirstat_urls[$rir]; |
$rirstat_cache = RIRSTATS_CACHE_DIR . "/$rir"; |
if ((USE_CACHE) && (file_exists($rirstat_cache))) { |
@mkdir(dirname($rirstat_cache), 0777, true); |
$rirstat_file = file($rirstat_cache); |
} else { |
$rirstat_file = file($rirstat_url); |
} |
$rirstat_file = explode("\n", cached_file($rirstat_url, CACHE_FILE_DIR)); |
|
$rirstat_file = antigrep($rirstat_file, '#'); |
|
74,7 → 62,7 |
$out .= "# ".strtoupper($rir)." IPv4\n"; |
$out .= "# Automatically generated by ".__DIR__."/gwhois-pattern-update\n"; |
$out .= "# Generation timestamp: ".date('Y-m-d H:i:s \G\M\TO')."\n"; |
if (USE_IANA_DATA) $out .= "# Source: ($iana_root_ver) $iana_root_url\n"; |
if (USE_IANA_DATA) $out .= "# Source: ($iana_root_ver) ".IANA_IPV4_ASSIGNMENTS."\n"; |
if (USE_RIR_STAT_DATA) $out .= "# Source: ($rirstat_ver) $rirstat_url\n"; |
$out .= "\n"; |
|