0,0 → 1,116 |
#!/usr/bin/php |
<?php |
|
# |
# generic Whois - Automatic Pattern Generator: TLD |
# |
# (c) 2012-2015 Daniel Marschall, ViaThinkSoft [www.viathinksoft.de] |
# |
# Distribution, usage etc. pp. regulated by the current version of GPL. |
# |
# |
# Version 2015-05-07 |
# |
|
error_reporting(E_ALL | E_NOTICE | E_STRICT | E_DEPRECATED); |
|
require_once __DIR__ . '/config.inc.php'; |
require_once __DIR__ . '/../../shared/php_includes/common_functions.inc.php'; |
require_once __DIR__ . '/rirs.inc.php'; |
require_once __DIR__ . '/iana_functions.inc.php'; |
|
define('PATTERN_DIR', __DIR__ . '/../../main/pattern'); |
define('CACHE_FILE_DIR', __DIR__ . '/../.cache/cache'); |
|
$out = ''; |
$out .= "# TLDs\n"; |
$out .= "# Automatically generated by ".__DIR__."/gwhois-pattern-update\n"; |
$out .= "# Generation timestamp: ".date('Y-m-d H:i:s \G\M\TO')."\n"; |
$out .= "\n"; |
|
$max_version = 0; |
|
# --- |
|
echo "Deleted TLD: Get deleted TLD list (".DELETED_TLD_LIST.")\n"; |
|
$iana_tld_data = cached_file(DELETED_TLD_LIST, CACHE_FILE_DIR); |
$iana_tld_data = str_replace("\r", '', $iana_tld_data); |
$iana_tld_data = trim($iana_tld_data); |
$iana_tld_data = explode("\n", $iana_tld_data); |
|
echo "Deleted TLD: Parsing...\n"; |
|
if (preg_match('@# Latest update detected on (.*)@', $iana_tld_data[0], $m)) { |
$version = $m[1]; |
$version = substr($version, 0, 10); |
$version = str_replace('-', '', $version); |
if ($version > $max_version) $max_version = $version; |
} |
|
array_shift($iana_tld_data); |
|
$tlds = implode('|', $iana_tld_data); |
|
$iana_tld_data = implode("\n", $iana_tld_data); |
|
$out .= "# Source: ($version) ".DELETED_TLD_LIST."\n"; |
$out .= "\n"; |
|
$out .= ":notice||Disallocated by IANA"; |
if ($tld_additional_params['iana'] != '') { |
$out .= '|prefix='.$tld_additional_params['iana'].'|'; |
} |
$out .= "\n"; |
$out .= "^(tld\\s){0,1}($tlds)\$\n"; |
$out .= "\n"; |
|
# --- |
|
echo "TLD: Get IANA delegation file (".IANA_TLD_REGISTRY.")\n"; |
|
$iana_tld_data = get_iana_tld_data(); |
|
echo "TLD: Parsing...\n"; |
|
if (preg_match('@# Version (\d+), Last Updated (.*)@', $iana_tld_data[0], $m)) { |
$version = $m[1]; |
$version = substr($version, 0, 8); |
if ($version > $max_version) $max_version = $version; |
} |
|
array_shift($iana_tld_data); |
|
$tlds = implode('|', $iana_tld_data); |
|
$iana_tld_data = implode("\n", $iana_tld_data); |
|
$out .= "# Source: ($version) ".IANA_TLD_REGISTRY."\n"; |
$out .= "\n"; |
|
$out .= ":whois|".$rir_whois_server['iana']; |
if ($tld_additional_params['iana'] != '') { |
$out .= '|prefix='.$tld_additional_params['iana'].'|'; |
} |
$out .= "\n"; |
$out .= "^($tlds)\$\n"; |
$out .= "\n"; |
$out .= ":whois|".$rir_whois_server['iana']."|strip=tld "; |
if ($tld_additional_params['iana'] != '') { |
$out .= '|prefix='.$tld_additional_params['iana']; |
} |
$out .= "|\n"; |
$out .= "^tld\\s\\S+\$\n"; |
$out .= "\n"; |
|
# --- |
|
$out = "#: version $max_version\n\n".$out; |
|
echo "TLD-Generator: Write to output file\n"; |
|
$h = fopen(PATTERN_DIR.'/tld', 'w') or die('Error opening file '.PATTERN_DIR.'/tld'); |
fwrite($h, $out) or die('Could not write to output file'); |
fclose($h); |
|
echo "TLD-Generator: Finished\n"; |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |