Rev 731 | Rev 760 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 731 | Rev 758 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | <?php |
1 | <?php |
2 | 2 | ||
3 | /* |
3 | /* |
4 | * OIDplus 2.0 |
4 | * OIDplus 2.0 |
5 | * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft |
5 | * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft |
6 | * |
6 | * |
7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
8 | * you may not use this file except in compliance with the License. |
8 | * you may not use this file except in compliance with the License. |
9 | * You may obtain a copy of the License at |
9 | * You may obtain a copy of the License at |
10 | * |
10 | * |
Line 176... | Line 176... | ||
176 | $out[] = "status: Information available"; // DO NOT TRANSLATE! |
176 | $out[] = "status: Information available"; // DO NOT TRANSLATE! |
177 | } |
177 | } |
178 | 178 | ||
179 | $row = $res ? $res->fetch_object() : null; |
179 | $row = $res ? $res->fetch_object() : null; |
180 | 180 | ||
181 | if (!is_null($row)) $out[] = 'name: ' . $row->title; // DO NOT TRANSLATE! |
- | |
182 | - | ||
183 | if (!is_null($row)) { |
181 | if (!is_null($row)) { |
- | 182 | $out[] = 'name: ' . $row->title; // DO NOT TRANSLATE! |
|
- | 183 | ||
184 | $cont = $row->description; |
184 | $cont = $row->description; |
185 | $cont = preg_replace('@<a[^>]+href\s*=\s*["\']([^\'"]+)["\'][^>]*>(.+)<\s*/\s*a\s*>@ismU', '\2 (\1)', $cont); |
185 | $cont = preg_replace('@<a[^>]+href\s*=\s*["\']([^\'"]+)["\'][^>]*>(.+)<\s*/\s*a\s*>@ismU', '\2 (\1)', $cont); |
186 | $cont = preg_replace('@<br.*>@', "\n", $cont); |
186 | $cont = preg_replace('@<br.*>@', "\n", $cont); |
187 | $cont = preg_replace('@\\n+@', "\n", $cont); |
187 | $cont = preg_replace('@\\n+@', "\n", $cont); |
188 | $out[] = 'description: ' . trim(html_entity_decode(strip_tags($cont))); // DO NOT TRANSLATE! |
188 | $out[] = 'description: ' . trim(html_entity_decode(strip_tags($cont))); // DO NOT TRANSLATE! |
Line 327... | Line 327... | ||
327 | $format = $serverCommands['format']; |
327 | $format = $serverCommands['format']; |
328 | } else { |
328 | } else { |
329 | $format = 'text'; // default |
329 | $format = 'text'; // default |
330 | } |
330 | } |
331 | 331 | ||
332 | if (($format != 'txt') && ($format != 'text') && ($format != 'json') && ($format != 'xml')) { |
332 | if (($format != 'txt') && ($format != 'text') && ($format != 'json') && ($format != 'xml') && ($format != 'html')) { |
333 | $format = 'text'; // default |
333 | $format = 'text'; // default |
334 | } |
334 | } |
335 | 335 | ||
336 | if (($format == 'text') || ($format == 'txt')) { |
336 | if (($format == 'text') || ($format == 'txt')) { |
337 | header('Content-Type:text/plain; charset=UTF-8'); |
337 | header('Content-Type:text/plain; charset=UTF-8'); |
Line 420... | Line 420... | ||
420 | // Note that this syntax is VS Code-specific and not part of the JSON Schema specification. |
420 | // Note that this syntax is VS Code-specific and not part of the JSON Schema specification. |
421 | //'$schema' => 'https://oidplus.viathinksoft.com/oidplus/plugins/publicPages/100_whois/whois/json_schema.json', |
421 | //'$schema' => 'https://oidplus.viathinksoft.com/oidplus/plugins/publicPages/100_whois/whois/json_schema.json', |
422 | '$schema' => OIDplus::webpath(__DIR__,true).'json_schema.json', |
422 | '$schema' => OIDplus::webpath(__DIR__,true).'json_schema.json', |
423 | 423 | ||
424 | // we need this NAMED root, otherwise PHP will name the sections "0", "1", "2" if the array is not sequencial (e.g. because "signature" is added) |
424 | // we need this NAMED root, otherwise PHP will name the sections "0", "1", "2" if the array is not sequencial (e.g. because "signature" is added) |
425 | 'whois' => $ary |
425 | 'oidip' => $ary |
426 | ); |
426 | ); |
427 | 427 | ||
428 | if (OIDplus::getPkiStatus()) { |
428 | if (OIDplus::getPkiStatus()) { |
429 | $cont = json_encode($ary); |
429 | $cont = json_encode($ary); |
430 | $signature = ''; |
430 | $signature = ''; |
Line 438... | Line 438... | ||
438 | header('Content-Type:application/json; charset=UTF-8'); |
438 | header('Content-Type:application/json; charset=UTF-8'); |
439 | echo json_encode($ary); |
439 | echo json_encode($ary); |
440 | } |
440 | } |
441 | 441 | ||
442 | if ($format == 'xml') { |
442 | if ($format == 'xml') { |
443 | $xml = '<whois><section>'; |
443 | $xml = '<oidip><section>'; |
444 | foreach ($out as $line) { |
444 | foreach ($out as $line) { |
445 | if ($line == '') { |
445 | if ($line == '') { |
446 | $xml .= '</section><section>'; |
446 | $xml .= '</section><section>'; |
447 | } else { |
447 | } else { |
448 | list($key,$val) = explode(':', $line, 2); |
448 | list($key,$val) = explode(':', $line, 2); |
Line 450... | Line 450... | ||
450 | if (!empty($val)) { |
450 | if (!empty($val)) { |
451 | $xml .= "<$key>".htmlspecialchars($val)."</$key>"; |
451 | $xml .= "<$key>".htmlspecialchars($val)."</$key>"; |
452 | } |
452 | } |
453 | } |
453 | } |
454 | } |
454 | } |
455 | $xml .= '</section></whois>'; |
455 | $xml .= '</section></oidip>'; |
456 | 456 | ||
457 | $xml = preg_replace('@<section><(.+)>(.+)</section>@ismU', '<\\1Section><\\1>\\2</\\1Section>', $xml); |
457 | $xml = preg_replace('@<section><(.+)>(.+)</section>@ismU', '<\\1Section><\\1>\\2</\\1Section>', $xml); |
458 | 458 | ||
459 | if (OIDplus::getPkiStatus()) { |
459 | if (OIDplus::getPkiStatus()) { |
460 | $cont = $xml; |
460 | $cont = $xml; |
Line 474... | Line 474... | ||
474 | echo ' xsi:schemaLocation="urn:oid:1.3.6.1.4.1.37476.2.5.2.5.1.1 '.OIDplus::webpath(__DIR__,true).'xml_schema.xsd">'; |
474 | echo ' xsi:schemaLocation="urn:oid:1.3.6.1.4.1.37476.2.5.2.5.1.1 '.OIDplus::webpath(__DIR__,true).'xml_schema.xsd">'; |
475 | echo $xml; |
475 | echo $xml; |
476 | echo '</root>'; |
476 | echo '</root>'; |
477 | } |
477 | } |
478 | 478 | ||
- | 479 | if ($format == 'html') { |
|
- | 480 | // TODO |
|
- | 481 | throw new OIDplusException(_L('The output format "%1" has not yet been implemented!')); |
|
- | 482 | } |
|
- | 483 | ||
479 | # --- |
484 | # --- |
480 | 485 | ||
481 | function show_asn1_appendix($id) { |
486 | function show_asn1_appendix($id) { |
482 | if (substr($id,0,4) === 'oid:') { |
487 | if (substr($id,0,4) === 'oid:') { |
483 | $appendix_asn1ids = array(); |
488 | $appendix_asn1ids = array(); |