Rev 112 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
16 | daniel-mar | 1 | #!/usr/bin/php |
2 | <?php |
||
3 | |||
62 | daniel-mar | 4 | // This script generates a part of ../setup/sql/wellknown_country.sql , based on Country OIDs at oid-info.com |
5 | // If new countries are added to the ISO / ITU arcs, please re-run this script and update ../setup/sql/wellknown_country.sql accordingly |
||
16 | daniel-mar | 6 | |
7 | require_once __DIR__ . '/../includes/oidplus.inc.php'; |
||
8 | |||
9 | OIDplus::init(true); |
||
10 | |||
11 | // Generates countries for wellknown OIDs |
||
12 | |||
13 | $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')); |
||
14 | $context = stream_context_create($options); |
||
15 | $cont = file_get_contents('http://oid-info.com/get/1.2', false, $context). |
||
62 | daniel-mar | 16 | file_get_contents('http://oid-info.com/get/2.16', false, $context). |
17 | file_get_contents('http://oid-info.com/get/2.49.0.0', false, $context); |
||
16 | daniel-mar | 18 | |
19 | preg_match_all('@<option value="https{0,1}://(www.){0,1}oid-info.com/get/([^"]+)">(..)\(.+\)</option>@ismU', $cont, $m, PREG_SET_ORDER); |
||
20 | |||
111 | daniel-mar | 21 | echo "-- Country OIDs\n"; |
22 | echo "-- Use the tool dev/country_getter.phps to generate these lines\n"; |
||
23 | echo "\n"; |
||
24 | |||
16 | daniel-mar | 25 | $check_sum = ''; |
26 | foreach ($m as $n) { |
||
27 | $check_sum .= $n[2].'='.$n[3].'/'; |
||
62 | daniel-mar | 28 | |
29 | if (strpos($n[2], '2.49.0.0') === 0) { |
||
112 | daniel-mar | 30 | // WMO Country OIDs (does not assign Unicode labels), 2.49.0.0 |
111 | daniel-mar | 31 | echo "INSERT INTO `asn1id` (oid, name, well_known) VALUES ('oid:$n[2]', '$n[3]', 1);\n"; |
62 | daniel-mar | 32 | |
112 | daniel-mar | 33 | // Country-Msg, 2.49.0.1 |
34 | $n[2] = str_replace('2.49.0.0', '2.49.0.1', $n[2]); |
||
111 | daniel-mar | 35 | echo "INSERT INTO `asn1id` (oid, name, well_known) VALUES ('oid:$n[2]', '$n[3]', 1);\n"; |
62 | daniel-mar | 36 | } else { |
112 | daniel-mar | 37 | // ISO or Joint-ISO-ITU-T OID Countries (1.2 and 2.16) |
111 | daniel-mar | 38 | echo "INSERT INTO `asn1id` (oid, name, well_known) VALUES ('oid:$n[2]', '$n[3]', 1);\n"; |
39 | echo "INSERT INTO `iri` (oid, name, longarc, well_known) VALUES ('oid:$n[2]', '".strtoupper($n[3])."', 0, 1);\n"; |
||
62 | daniel-mar | 40 | } |
16 | daniel-mar | 41 | } |
111 | daniel-mar | 42 | |
43 | echo "\n"; |
||
44 | echo '-- Generator generate_wellknown_country checksum '.dechex(crc32($check_sum))."\n"; |