Subversion Repositories oidplus

Compare Revisions

No changes between revisions

Regard whitespace Rev 15 → Rev 16

/trunk/dev/country_getter
0,0 → 1,29
#!/usr/bin/php
<?php
 
// This script generates a part of ../setup/sql/wellknown_ids.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_ids.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);
 
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].'/';
echo "insert into asn1id (oid, name, well_known) values ('oid:$n[2]', '$n[3]', 1); ";
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