Subversion Repositories oidplus

Rev

Rev 111 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
54 daniel-mar 1
#!/usr/bin/php
2
-- This file (wellknown_other.sql) contains ASN.1 and IRI names of OIDs which are either
3
-- a) Root OIDs
4
-- b) Unicode labels which are long arcs
5
-- c) Standardized ASN.1 identifiers
6
-- d) OIDs where potential users of this software can register OIDs in these arcs (e.g. an "identified organization" arc)
7
 
8
<?php
9
 
10
require_once __DIR__ . '/../includes/oidplus.inc.php';
11
 
12
OIDplus::init(false);
13
if (!defined('OIDINFO_API_URL')) {
14
	die("OIDINFO_API_URL not available (API is currently not public)\n");
15
}
16
 
17
$output = array();
18
 
19
function _is_standardized($oid, $asn1id) {
20
	$std = asn1_get_standardized_array();
21
	$x = oid_up($oid) == $oid ? '' : oid_up($oid).".";
22
	return isset( $std[$x.$asn1id]) && ($std[$x.$asn1id] == $oid);
23
}
24
 
25
function _is_long($oid) {
26
	$oid = '/'.str_replace('.', '/', $oid);
27
	return in_array($oid, iri_get_long_arcs());
28
}
29
 
30
function _process_oid($oid) {
31
	global $output;
32
 
33
	if (!isset($output[$oid])) {
34
		if ($oid == '0.0.23') {
35
			// Rec. ITU-T X.660 | ISO/IEC 9834-3, clause A.3.3.1 allows "0.0.w", although it is illegal, since no W-series exist
36
			$data = array();
37
			$data['oid'] = array();
38
			$data['oid']['identifier'] = array('w');
39
			$data['oid']['unicode-label'] = array('W');
40
		} else {
41
			$data = ft_get_oid_data($oid);
42
		}
43
 
44
                $output[$oid] = array();
45
		$output[$oid]['asn1id'] = array();
46
		$output[$oid]['iri'] = array();
47
 
48
		if (isset($data['oid']['identifier'])) {
49
			foreach ($data['oid']['identifier'] as $asn1id) {
150 daniel-mar 50
				$std = _is_standardized($oid, $asn1id);
111 daniel-mar 51
				$output[$oid]['asn1id'][] = "INSERT INTO `asn1id` (oid, name, standardized, well_known) VALUES ('oid:$oid', '$asn1id', $std, 1);";
54 daniel-mar 52
			}
53
		} else {
111 daniel-mar 54
			//echo "-- Warning: Has no ASN.1 identifier: $oid\n";
54 daniel-mar 55
		}
56
		if (isset($data['oid']['unicode-label'])) {
57
			foreach ($data['oid']['unicode-label'] as $iri) {
150 daniel-mar 58
				$std = _is_long($oid);
54 daniel-mar 59
 
60
				if (strpos($iri, '&#') !== false) {
61
					$iri = "from_base64('".base64_encode(html_entity_decode($iri, ENT_COMPAT | ENT_HTML401, "UTF-8"))."')";
62
				} else {
63
					$iri = "'$iri'";
64
				}
65
 
111 daniel-mar 66
				$output[$oid]['iri'][] = "INSERT INTO `iri` (oid, name, longarc, well_known) VALUES ('oid:$oid', $iri, $std, 1);";
54 daniel-mar 67
			}
68
		}
69
	}
70
 
71
	return $output[$oid];
72
}
73
 
74
// ---
75
 
76
$interesting_oids = array();
77
 
78
foreach (asn1_get_standardized_array() as $tmp => $oid) {
79
	$interesting_oids[] = $oid;
80
}
81
 
82
foreach (iri_get_long_arcs() as $tmp => $oid) {
83
	$oid = substr(str_replace('/', '.', $oid),1);
84
	$interesting_oids[] = $oid;
85
}
86
 
62 daniel-mar 87
// ----------------------------------------------------------------
54 daniel-mar 88
 
62 daniel-mar 89
$interesting_oids[] = '0'; // itu-t
90
	$interesting_oids[] = '0.2'; // telecom operators
91
	$interesting_oids[] = '0.3'; // network-operator
92
	$interesting_oids[] = '0.4'; // identified-organization
93
		$interesting_oids[] = '0.4.0'; // etsi
94
			$interesting_oids[] = '0.4.0.127'; // reserved
95
				$interesting_oids[] = '0.4.0.127.0'; // etsi-identified-organization
96
$interesting_oids[] = '1'; // iso
97
	$interesting_oids[] = '1.1'; // registration-authority
98
		$interesting_oids[] = '1.1.19785'; // cbeff
99
			$interesting_oids[] = '1.1.19785.0'; // organization
100
	$interesting_oids[] = '1.2'; // member-body
101
		// country_getter defines the country OIDs
111 daniel-mar 102
		//$interesting_oids[] = '1.2.158'; // tw
62 daniel-mar 103
			$interesting_oids[] = '1.2.158.1'; // organization
111 daniel-mar 104
		//$interesting_oids[] = '1.2.276'; // de
62 daniel-mar 105
			$interesting_oids[] = '1.2.276.0'; // din-certco
111 daniel-mar 106
		//$interesting_oids[] = '1.2.344'; // hk
62 daniel-mar 107
			$interesting_oids[] = '1.2.344.1'; // organization
111 daniel-mar 108
		//$interesting_oids[] = '1.2.616'; // pl
62 daniel-mar 109
			$interesting_oids[] = '1.2.616.1'; // organization
111 daniel-mar 110
		//$interesting_oids[] = '1.2.826'; // gb
62 daniel-mar 111
			$interesting_oids[] = '1.2.826.0'; // national
112
				$interesting_oids[] = '1.2.826.0.1'; // eng-ltd
113
					$interesting_oids[] = '1.2.826.0.1.3680043'; // Medical Connections ( https://www.medicalconnections.co.uk/FreeUID/ )
111 daniel-mar 114
		//$interesting_oids[] = '1.2.840'; // us
62 daniel-mar 115
			$interesting_oids[] = '1.2.840.1'; // organization
116
				$interesting_oids[] = '1.2.840.113556'; // microsoft
117
					$interesting_oids[] = '1.2.840.113556.1'; // Microsoft Active Directory
118
						$interesting_oids[] = '1.2.840.113556.1.8000'; // companies
119
							$interesting_oids[] = '1.2.840.113556.1.8000.2554'; // customer usage
120
					$interesting_oids[] = '1.2.840.113556.2'; // DICOM
121
	$interesting_oids[] = '1.3'; // identified-organization
122
		$interesting_oids[] = '1.3.6'; // dod
123
			$interesting_oids[] = '1.3.6.1'; // internet
124
				$interesting_oids[] = '1.3.6.1.2'; // mgmt
125
					$interesting_oids[] = '1.3.6.1.2.1'; // mib-2
126
						$interesting_oids[] = '1.3.6.1.4'; // private
127
							$interesting_oids[] = '1.3.6.1.4.1'; // enterprise
128
								$interesting_oids[] = '1.3.6.1.4.1.19376'; // Integrating the Healthcare Enterprise International
129
									$interesting_oids[] = '1.3.6.1.4.1.19376.3'; // Organizations (not in Repo!)
130
									$interesting_oids[] = '1.3.6.1.4.1.19376.3.276'; // IHE Deutschland
131
										$interesting_oids[] = '1.3.6.1.4.1.19376.3.276.1'; // OID für das OID Konzept Version 1
132
											$interesting_oids[] = '1.3.6.1.4.1.19376.3.276.1.4'; // Identifikation des ID-Pools für Institutionen (Organisationen, Einheiten, etc.)
133
													$interesting_oids[] = '1.3.6.1.4.1.19376.3.276.1.4.1'; // Krankenhäuser
134
													$interesting_oids[] = '1.3.6.1.4.1.19376.3.276.1.4.2'; // Praxen niedergelassener Ärzte
135
													$interesting_oids[] = '1.3.6.1.4.1.19376.3.276.1.4.3'; // Systeme
136
								$interesting_oids[] = '1.3.6.1.4.1.12798'; // Members of Internet-Käyttäjät Ikuisesti (IKI)
137
									$interesting_oids[] = '1.3.6.1.4.1.12798.1'; // member
138
								$interesting_oids[] = '1.3.6.1.4.1.37476'; // ViaThinkSoft
139
									$interesting_oids[] = '1.3.6.1.4.1.37476.9000'; // freeoid
140
$interesting_oids[] = '2'; // joint-iso-itu-t
141
	$interesting_oids[] = '2.16'; // country
142
		// country_getter defines the country OIDs
111 daniel-mar 143
		//$interesting_oids[] = '2.16.158'; // tw
62 daniel-mar 144
			$interesting_oids[] = '2.16.158.1'; // organization
111 daniel-mar 145
		//$interesting_oids[] = '2.16.344'; // hk
62 daniel-mar 146
			$interesting_oids[] = '2.16.344.1'; // organization
111 daniel-mar 147
		//$interesting_oids[] = '2.16.616'; // pl
62 daniel-mar 148
			$interesting_oids[] = '2.16.616.1'; // organization
111 daniel-mar 149
		//$interesting_oids[] = '2.16.840'; // us
62 daniel-mar 150
			$interesting_oids[] = '2.16.840.1'; // organization
151
				$interesting_oids[] = '2.16.840.1.113883'; // hl7
152
					$interesting_oids[] = '2.16.840.1.113883.3'; // externalUseRoots
153
					$interesting_oids[] = '2.16.840.1.113883.6'; // externalCodeSystems
154
					$interesting_oids[] = '2.16.840.1.113883.13'; // externalValueSets
155
	$interesting_oids[] = '2.23'; // international-organizations
156
	$interesting_oids[] = '2.25'; // uuid
157
	$interesting_oids[] = '2.40'; // upu
158
		$interesting_oids[] = '2.40.2'; // member-body
159
		$interesting_oids[] = '2.40.3'; // identified-organization
160
	$interesting_oids[] = '2.49'; // alerting
161
		$interesting_oids[] = '2.49.0'; // wmo
162
			$interesting_oids[] = '2.49.0.0'; // authority (Countries)
111 daniel-mar 163
				// country_getter defines the country OIDs beneath 2.49.0.0
62 daniel-mar 164
			$interesting_oids[] = '2.49.0.1'; // country-msg
111 daniel-mar 165
				// country_getter defines the country OIDs beneath 2.49.0.1
62 daniel-mar 166
			$interesting_oids[] = '2.49.0.2'; // org
167
			$interesting_oids[] = '2.49.0.3'; // org-msg
168
 
169
// ----------------------------------------------------------------
170
 
54 daniel-mar 171
$interesting_oids = array_unique($interesting_oids);
172
natsort($interesting_oids);
173
 
174
$output = array();
175
foreach ($interesting_oids as $oid) {
176
	_process_oid($oid);
177
}
178
 
179
$check_sum = '';
180
foreach ($output as $oid => $data) {
111 daniel-mar 181
	if (count($data['asn1id']) + count($data['iri']) == 0) continue;
182
 
54 daniel-mar 183
	echo "-- $oid\n";
184
	foreach ($data['asn1id'] as $line_asn1) {
185
		$check_sum .= $oid.'='.$line_asn1.'/';
186
		echo "$line_asn1\n";
187
	}
188
	foreach ($data['iri'] as $line_iri) {
189
		$check_sum .= $oid.'='.$line_iri.'/';
190
		echo "$line_iri\n";
191
	}
192
	echo "\n";
193
}
111 daniel-mar 194
echo '-- Generator "generate_wellknown_other" checksum '.dechex(crc32($check_sum))."\n";
54 daniel-mar 195
 
196
# ---
197
 
198
function ft_get_oid_data($oid) {
199
	$url = OIDINFO_API_URL . '&oid='.urlencode($oid);
200
	$cont_json = @file_get_contents($url);
201
	if (!$cont_json) {
202
		sleep(5);
203
                $cont_json = @file_get_contents($url);
204
                if (!$cont_json) return false;
205
	}
206
	$data = json_decode($cont_json,true);
207
 
208
	return $data;
209
}