Rev 1050 | Rev 1064 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1050 | Rev 1053 | ||
---|---|---|---|
Line 44... | Line 44... | ||
44 | } |
44 | } |
45 | 45 | ||
46 | $dos_ids = array(); |
46 | $dos_ids = array(); |
47 | $parent_oids = array(); |
47 | $parent_oids = array(); |
48 | $i = 0; |
48 | $i = 0; |
49 | $dos_ids[''] = '00000000'; |
- | |
50 | $parent_oids[''] = ''; |
- | |
51 | 49 | ||
- | 50 | // Root node |
|
52 | $dos_ids[''] = str_pad(strval($i++), 8, '0', STR_PAD_LEFT); |
51 | $dos_ids[''] = str_pad(strval($i++), 8, '0', STR_PAD_LEFT); |
- | 52 | $parent_oids[''] = ''; |
|
- | 53 | $iri[''] = array(); |
|
- | 54 | $asn1[''] = array(); |
|
- | 55 | $title[''] = 'OID Root'; |
|
- | 56 | $description[''] = 'Exported by OIDplus 2.0'; |
|
- | 57 | $created[''] = ''; |
|
- | 58 | $updated[''] = ''; |
|
- | 59 | ||
- | 60 | // Now check all OIDs |
|
53 | $res = OIDplus::db()->query("select * from ###objects where id like 'oid:%' order by ".OIDplus::db()->natOrder('id')); |
61 | $res = OIDplus::db()->query("select * from ###objects where id like 'oid:%' order by ".OIDplus::db()->natOrder('id')); |
54 | while ($row = $res->fetch_object()) { |
62 | while ($row = $res->fetch_object()) { |
55 | $oid = substr($row->id, strlen('oid:')); |
63 | $oid = substr($row->id, strlen('oid:')); |
56 | $parent_oid = substr($row->parent, strlen('oid:')); |
64 | $parent_oid = substr($row->parent, strlen('oid:')); |
- | 65 | ||
57 | $dos_ids[$oid] = str_pad(strval($i++), 8, '0', STR_PAD_LEFT); |
66 | $dos_ids[$oid] = str_pad(strval($i++), 8, '0', STR_PAD_LEFT); |
- | 67 | fill_asn1($oid, $asn1); |
|
- | 68 | //fill_iri($oid, $iri); |
|
- | 69 | $title[$oid] = $row->title; |
|
- | 70 | $description[$oid] = $row->description; |
|
- | 71 | $created[$oid] = $row->created; |
|
- | 72 | $updated[$oid] = $row->updated; |
|
- | 73 | ||
58 | if ($parent_oid == '') { |
74 | if ((oid_len($oid) > 1) && ($parent_oid == '')) { |
- | 75 | do { |
|
- | 76 | $real_parent = oid_len($oid) > 1 ? oid_up($oid) : ''; |
|
59 | $parent_oids[$oid] = ''; |
77 | $parent_oids[$oid] = $real_parent; |
- | 78 | ||
- | 79 | if (isset($dos_ids[$real_parent])) break; // did we already handle this parent node? |
|
- | 80 | ||
- | 81 | $dos_ids[$real_parent] = str_pad(strval($i++), 8, '0', STR_PAD_LEFT); |
|
- | 82 | fill_asn1($real_parent, $asn1); // well-known OIDs? |
|
- | 83 | //fill_iri($real_parent, $iri); // well-known OIDs? |
|
- | 84 | $title[$real_parent] = ''; |
|
- | 85 | $description[$real_parent] = ''; |
|
- | 86 | $created[$real_parent] = ''; |
|
- | 87 | $updated[$real_parent] = ''; |
|
- | 88 | $res2 = OIDplus::db()->query("select * from ###objects where id = 'oid:$real_parent'"); |
|
- | 89 | while ($row2 = $res2->fetch_object()) { |
|
- | 90 | $title[$real_parent] = $row2->title; |
|
- | 91 | $description[$real_parent] = $row2->description; |
|
- | 92 | $created[$real_parent] = $row2->created; |
|
- | 93 | $updated[$real_parent] = $row2->updated; |
|
- | 94 | } |
|
- | 95 | ||
- | 96 | // next |
|
- | 97 | if ($real_parent == '') break; |
|
- | 98 | $oid = $real_parent; |
|
- | 99 | } while (true); |
|
60 | } else { |
100 | } else { |
61 | $parent_oids[$oid] = $parent_oid; |
101 | $parent_oids[$oid] = $parent_oid; |
62 | } |
102 | } |
63 | } |
103 | } |
64 | 104 | ||
Line 83... | Line 123... | ||
83 | } |
123 | } |
84 | } |
124 | } |
85 | $cont .= "delegates=".($i-1)."\n"; |
125 | $cont .= "delegates=".($i-1)."\n"; |
86 | 126 | ||
87 | if ($oid != '') { |
127 | if ($oid != '') { |
88 | $res = OIDplus::db()->query("select * from ###asn1id where oid = 'oid:$oid'"); |
- | |
89 | $asnids = array(); |
128 | $asnids = array(); |
90 | while ($row = $res->fetch_object()) { |
- | |
91 | $asn1 = $row->name; |
129 | foreach ($asn1[$oid] as $name) { |
92 | $asnids[] = $asn1; |
130 | $asnids[] = $name; |
93 | } |
131 | } |
94 | $asnids = implode(',', $asnids); |
132 | $asnids = implode(',', $asnids); |
95 | if ($asnids != '') $cont .= "asn1id=$asnids\r\n"; |
133 | if ($asnids != '') $cont .= "asn1id=$asnids\r\n"; |
96 | 134 | ||
97 | /* |
135 | /* |
98 | $res = OIDplus::db()->query("select * from ###iri where oid = 'oid:$oid'"); |
- | |
99 | $iris = array(); |
136 | $iris = array(); |
100 | while ($row = $res->fetch_object()) { |
- | |
101 | $iri = $row->name; |
137 | foreach ($iri[$oid] as $name) { |
102 | $iris[] = $iri; |
138 | $iris[] = $name; |
103 | } |
139 | } |
104 | $iris = implode(',', $iris); |
140 | $iris = implode(',', $iris); |
105 | if ($iris != '') $cont .= "iri=$iris\r\n"; |
141 | if ($iris != '') $cont .= "iri=$iris\r\n"; |
106 | */ |
142 | */ |
107 | 143 | ||
108 | $res = OIDplus::db()->query("select * from ###objects where id = 'oid:$oid';"); |
- | |
109 | $row = $res->fetch_object(); |
- | |
110 | - | ||
111 | if ($row->title != '') $cont .= "description=".$row->title."\r\n"; |
144 | if ($title[$oid] != '') $cont .= "description=".$title[$oid]."\r\n"; |
112 | 145 | ||
113 | if ($row->updated != '') $cont .= "updatedate=".explode(' ',$row->updated)[0]."\r\n"; |
146 | if ($updated[$oid] != '') $cont .= "updatedate=".explode(' ',$updated[$oid])[0]."\r\n"; |
114 | if ($row->created != '') $cont .= "createdate=".explode(' ',$row->created)[0]."\r\n"; |
147 | if ($created[$oid] != '') $cont .= "createdate=".explode(' ',$created[$oid])[0]."\r\n"; |
115 | 148 | ||
116 | $desc = handleDesc($row->description); |
149 | $desc = handleDesc($description[$oid]); |
117 | if ($desc != '') { |
150 | if (trim($desc) != '') { |
118 | $cont .= "information=$dos_id.TXT\r\n"; |
151 | $cont .= "information=$dos_id.TXT\r\n"; |
119 | $zip->addFromString("DB//$dos_id.TXT", $desc); |
152 | $zip->addFromString("DB//$dos_id.TXT", $desc); |
120 | } |
153 | } |
121 | } |
154 | } |
122 | } |
155 | } |
Line 127... | Line 160... | ||
127 | $settings = array(); |
160 | $settings = array(); |
128 | $settings[] = '[SETTINGS]'; |
161 | $settings[] = '[SETTINGS]'; |
129 | $settings[] = 'DATA=DB\\'; |
162 | $settings[] = 'DATA=DB\\'; |
130 | $zip->addFromString("OIDPLUS.INI", implode("\r\n",$settings)."\r\n"); |
163 | $zip->addFromString("OIDPLUS.INI", implode("\r\n",$settings)."\r\n"); |
131 | 164 | ||
132 | - | ||
133 | $zip->addFromString('DB//OID.INI', $cont); |
165 | $zip->addFromString('DB//OID.INI', $cont); |
134 | 166 | ||
135 | $exe_url = 'https://github.com/danielmarschall/oidplus_win95/raw/master/OIDPLUS.exe'; |
167 | $exe_url = 'https://github.com/danielmarschall/oidplus_win95/raw/master/OIDPLUS.exe'; |
136 | $exe = url_get_contents($exe_url); |
168 | $exe = url_get_contents($exe_url); |
137 | if (!$exe) { |
169 | if (!$exe) { |
Line 158... | Line 190... | ||
158 | 190 | ||
159 | OIDplus::invoke_shutdown(); |
191 | OIDplus::invoke_shutdown(); |
160 | 192 | ||
161 | # --- |
193 | # --- |
162 | 194 | ||
- | 195 | function fill_asn1($oid, &$asn1) { |
|
- | 196 | if (!isset($asn1[$oid])) $asn1[$oid] = array(); |
|
- | 197 | $res = OIDplus::db()->query("select * from ###asn1id where oid = 'oid:$oid'"); |
|
- | 198 | while ($row = $res->fetch_object()) { |
|
- | 199 | $asn1[$oid][] = $row->name; |
|
- | 200 | } |
|
- | 201 | } |
|
- | 202 | ||
- | 203 | /* |
|
- | 204 | function fill_iri($oid, &$iri) { |
|
- | 205 | if (!isset($iri[$oid])) $iri[$oid] = array(); |
|
- | 206 | $res = OIDplus::db()->query("select * from ###iri where oid = 'oid:$oid'"); |
|
- | 207 | while ($row = $res->fetch_object()) { |
|
- | 208 | $iri[$oid][] = $row->name; |
|
- | 209 | } |
|
- | 210 | } |
|
- | 211 | */ |
|
- | 212 | ||
163 | function handleDesc($desc) { |
213 | function handleDesc($desc) { |
164 | $desc = preg_replace('/\<br(\s*)?\/?\>/i', "\n", $desc); // br2nl |
214 | $desc = preg_replace('/\<br(\s*)?\/?\>/i', "\n", $desc); // br2nl |
165 | $desc = strip_tags($desc); |
215 | $desc = strip_tags($desc); |
166 | $desc = str_replace(' ', ' ', $desc); |
216 | $desc = str_replace(' ', ' ', $desc); |
167 | $desc = html_entity_decode($desc); |
217 | $desc = html_entity_decode($desc); |