Subversion Repositories oidplus

Rev

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

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