Subversion Repositories vgwhois

Compare Revisions

Regard whitespace Rev 2 → Rev 3

/trunk/maintenance/pattern-generator/generate_ipv6
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 "IPv6 Preparation: Get IANA delegation file\n";
 
$iana_root_url = 'ftp://ftp.iana.org/assignments/ipv6-unicast-address-assignments/ipv6-unicast-address-assignments.txt';
$iana_root_cache = IANA_CACHE_DIR . '/ipv6-unicast-address-assignments.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_IPV6_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 "IPv6 $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)." IPv6\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_IPV6_ASSIGNMENTS."\n";
if (USE_RIR_STAT_DATA) $out .= "# Source: ($rirstat_ver) $rirstat_url\n";
$out .= "\n";