0,0 → 1,43 |
#!/usr/bin/php |
<?php |
|
// This script generates a part of ../setup/sql/wellknown_country.sql , based on Country OIDs at oid-info.com |
// If new countries are added to the ISO / ITU arcs, please re-run this script and update ../setup/sql/wellknown_country.sql accordingly |
|
require_once __DIR__ . '/../includes/oidplus.inc.php'; |
|
OIDplus::init(true); |
|
OIDplus::db()->set_charset("UTF8"); |
OIDplus::db()->query("SET NAMES 'utf8'"); |
|
// Generates countries for wellknown OIDs |
|
$options = array('http' => array('user_agent' => 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36')); |
$context = stream_context_create($options); |
$cont = file_get_contents('http://oid-info.com/get/1.2', false, $context). |
file_get_contents('http://oid-info.com/get/2.16', false, $context). |
file_get_contents('http://oid-info.com/get/2.49.0.0', false, $context); |
|
preg_match_all('@<option value="https{0,1}://(www.){0,1}oid-info.com/get/([^"]+)">(..)\(.+\)</option>@ismU', $cont, $m, PREG_SET_ORDER); |
|
$check_sum = ''; |
foreach ($m as $n) { |
$check_sum .= $n[2].'='.$n[3].'/'; |
|
if (strpos($n[2], '2.49.0.0') === 0) { |
// WMO Country OIDs (does not assign Unicode labels) |
|
echo "insert into asn1id (oid, name, well_known) values ('oid:$n[2]', '$n[3]', 1); "; |
|
$n[2] = str_replace('2.49.0.0', '2.49.0.1', $n[2]); // also country-msg |
echo "insert into asn1id (oid, name, well_known) values ('oid:$n[2]', '$n[3]', 1);\n"; |
} else { |
// ISO or JointISOItuT OID Countries |
echo "insert into asn1id (oid, name, well_known) values ('oid:$n[2]', '$n[3]', 1); "; |
|
// TODO: In 2.16, some have unicode labels, some don't! Is that an error at oid-info.com? => reported in job 0091 |
echo "insert into iri (oid, name, longarc, well_known) values ('oid:$n[2]', '".strtoupper($n[3])."', 0, 1);\n"; |
} |
} |
echo '-- Country getter checksum '.dechex(crc32($check_sum))."\n"; |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |