Rev 1116 | Rev 1148 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1116 | Rev 1130 | ||
---|---|---|---|
Line 99... | Line 99... | ||
99 | $zip = new ZipArchive(); |
99 | $zip = new ZipArchive(); |
100 | if ($zip->open($tmp_file, ZipArchive::CREATE)!== true) { |
100 | if ($zip->open($tmp_file, ZipArchive::CREATE)!== true) { |
101 | throw new OIDplusException("cannot open <$tmp_file>"); |
101 | throw new OIDplusException("cannot open <$tmp_file>"); |
102 | } |
102 | } |
103 | 103 | ||
- | 104 | /** |
|
- | 105 | * @param string $command |
|
- | 106 | * @param string $data |
|
- | 107 | * @return string |
|
- | 108 | */ |
|
104 | function make_line($command, $data) { |
109 | function make_line(string $command, string $data): string { |
105 | return $command.$data."\r\n"; |
110 | return $command.$data."\r\n"; |
106 | } |
111 | } |
107 | 112 | ||
108 | // https://github.com/danielmarschall/oidplus_dos/blob/master/OIDFILE.PAS |
113 | // https://github.com/danielmarschall/oidplus_dos/blob/master/OIDFILE.PAS |
109 | const CMD_VERSION = 'VERS'; |
114 | const CMD_VERSION = 'VERS'; |
Line 113... | Line 118... | ||
113 | const CMD_ASN1_IDENTIFIER = 'ASN1'; |
118 | const CMD_ASN1_IDENTIFIER = 'ASN1'; |
114 | const CMD_UNICODE_LABEL = 'UNIL'; |
119 | const CMD_UNICODE_LABEL = 'UNIL'; |
115 | const CMD_DESCRIPTION = 'DESC'; |
120 | const CMD_DESCRIPTION = 'DESC'; |
116 | 121 | ||
117 | foreach ($dos_ids as $oid => $dos_id) { |
122 | foreach ($dos_ids as $oid => $dos_id) { |
118 | $cont = make_line(CMD_VERSION, 2022); |
123 | $cont = make_line(CMD_VERSION, '2022'); |
119 | 124 | ||
120 | $cont .= make_line(CMD_OWN_ID, $dos_id.$oid); |
125 | $cont .= make_line(CMD_OWN_ID, $dos_id.$oid); |
121 | 126 | ||
122 | $parent_oid = $parent_oids[$oid]; |
127 | $parent_oid = $parent_oids[$oid]; |
123 | $parent_id = $dos_ids[$parent_oid]; |
128 | $parent_id = $dos_ids[$parent_oid]; |
Line 137... | Line 142... | ||
137 | 142 | ||
138 | foreach ($iri[$oid] as $name) { |
143 | foreach ($iri[$oid] as $name) { |
139 | $cont .= make_line(CMD_UNICODE_LABEL, $name); |
144 | $cont .= make_line(CMD_UNICODE_LABEL, $name); |
140 | } |
145 | } |
141 | 146 | ||
142 | $desc_ary1 = handleDesc($title[$oid]); |
147 | $desc_ary1 = handleDesc_dos($title[$oid]); |
143 | $desc_ary2 = handleDesc($description[$oid]); |
148 | $desc_ary2 = handleDesc_dos($description[$oid]); |
144 | $desc_ary = array_merge($desc_ary1, $desc_ary2); |
149 | $desc_ary = array_merge($desc_ary1, $desc_ary2); |
145 | $prev_line = ''; |
150 | $prev_line = ''; |
146 | foreach ($desc_ary as $line_idx => $line) { |
151 | foreach ($desc_ary as $line_idx => $line) { |
147 | if ($line == $prev_line) continue; |
152 | if ($line == $prev_line) continue; |
148 | if ($line_idx >= 10/*DESCEDIT_LINES*/) break; |
153 | if ($line_idx >= 10/*DESCEDIT_LINES*/) break; |
Line 175... | Line 180... | ||
175 | 180 | ||
176 | OIDplus::invoke_shutdown(); |
181 | OIDplus::invoke_shutdown(); |
177 | 182 | ||
178 | # --- |
183 | # --- |
179 | 184 | ||
- | 185 | /** |
|
- | 186 | * @param string $oid |
|
- | 187 | * @param array $asn1 |
|
- | 188 | * @return void |
|
- | 189 | * @throws OIDplusException |
|
- | 190 | */ |
|
180 | function fill_asn1($oid, &$asn1) { |
191 | function fill_asn1(string $oid, array &$asn1) { |
181 | if (!isset($asn1[$oid])) $asn1[$oid] = array(); |
192 | if (!isset($asn1[$oid])) $asn1[$oid] = array(); |
182 | $res = OIDplus::db()->query("select * from ###asn1id where oid = 'oid:$oid'"); |
193 | $res = OIDplus::db()->query("select * from ###asn1id where oid = 'oid:$oid'"); |
183 | while ($row = $res->fetch_object()) { |
194 | while ($row = $res->fetch_object()) { |
184 | $asn1[$oid][] = $row->name; |
195 | $asn1[$oid][] = $row->name; |
185 | } |
196 | } |
186 | } |
197 | } |
187 | 198 | ||
- | 199 | /** |
|
- | 200 | * @param string $oid |
|
- | 201 | * @param array $iri |
|
- | 202 | * @return void |
|
- | 203 | * @throws OIDplusException |
|
- | 204 | */ |
|
188 | function fill_iri($oid, &$iri) { |
205 | function fill_iri(string $oid, array &$iri) { |
189 | if (!isset($iri[$oid])) $iri[$oid] = array(); |
206 | if (!isset($iri[$oid])) $iri[$oid] = array(); |
190 | $res = OIDplus::db()->query("select * from ###iri where oid = 'oid:$oid'"); |
207 | $res = OIDplus::db()->query("select * from ###iri where oid = 'oid:$oid'"); |
191 | while ($row = $res->fetch_object()) { |
208 | while ($row = $res->fetch_object()) { |
192 | $iri[$oid][] = $row->name; |
209 | $iri[$oid][] = $row->name; |
193 | } |
210 | } |
194 | } |
211 | } |
195 | 212 | ||
- | 213 | /** |
|
- | 214 | * @param string $desc |
|
- | 215 | * @return array |
|
- | 216 | */ |
|
196 | function handleDesc($desc) { |
217 | function handleDesc_dos(string $desc): array { |
197 | $desc = preg_replace('/\<br(\s*)?\/?\>/i', "\n", $desc); // br2nl |
218 | $desc = preg_replace('/\<br(\s*)?\/?\>/i', "\n", $desc); // br2nl |
198 | $desc = strip_tags($desc); |
219 | $desc = strip_tags($desc); |
199 | $desc = str_replace(' ', ' ', $desc); |
220 | $desc = str_replace(' ', ' ', $desc); |
200 | $desc = html_entity_decode($desc); |
221 | $desc = html_entity_decode($desc); |
201 | $desc = str_replace("\r", "", $desc); |
222 | $desc = str_replace("\r", "", $desc); |