From 40093957a364ea23d4acfc61855be1d77229a6e2 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Mon, 14 Jul 2025 12:00:26 +0200 Subject: [PATCH] organic: Add external LKV api --- www/organic/external/easy-cert/operators.php | 2 +- www/organic/external/lkv/operators.php | 33 ++++++++++++++++++++ www/organic/index.php | 16 ++++++++-- www/organic/pdf.php | 2 +- 4 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 www/organic/external/lkv/operators.php diff --git a/www/organic/external/easy-cert/operators.php b/www/organic/external/easy-cert/operators.php index 5f87c96..9c5008c 100644 --- a/www/organic/external/easy-cert/operators.php +++ b/www/organic/external/easy-cert/operators.php @@ -231,7 +231,7 @@ $replace = [ '"CountryCode":' => '"countryCode":', '"xx"' => 'null', '"XX"' => 'null', - '""' => 'null', + ':""' => ':null', ]; $replaceSed = array_map(fn($v, $k): string => "s/$k/$v/", $replace, array_keys($replace)); diff --git a/www/organic/external/lkv/operators.php b/www/organic/external/lkv/operators.php new file mode 100644 index 0000000..a16173f --- /dev/null +++ b/www/organic/external/lkv/operators.php @@ -0,0 +1,33 @@ +@ {@;s@@ },@;s@\(.*\)@ "certUrl":"\\1","certNr":"\\2",@;s@\(.*\)
\(.*\)
\([0-9]*\) \(.*\)@ "name":"\\1","address":"\\2","postalCode":"\\3","city":"\\4"@;s@\(.*\)
\(.*\)@ "name":"\\1","type":"\\2"@;\$s/.$//' \ +| sed 's@"certUrl":"\(/[^"]*\)"@"certUrl":"https://lkv.at\\1"@' \ +| sed 's@\s*",@",@g;s@:"\s*@:"@g' +EOF); + +echo "]}\n"; diff --git a/www/organic/index.php b/www/organic/index.php index 3f9580f..720cadf 100644 --- a/www/organic/index.php +++ b/www/organic/index.php @@ -51,8 +51,20 @@ if (str_starts_with($info, '/certificates/')) { exit; } else if ($info === '/authorities') { - header('Content-Length: 0'); - header('Status: 501'); + header('Content-Type: application/json; charset=UTF-8'); + echo << $i > 0 && $i < $p1, ARRAY_FILTER_USE_BOTH)); + $operatorName = trim(implode(' ', array_filter($operator, fn($k,$i) => $i > 0 && $i < $p1, ARRAY_FILTER_USE_BOTH)), ', '); [$opAddr, $opPostal, $opCity] = get_address($operator, $p1 + 1, $p2 - 1); $authority = preg_split('@\s+@', trim($data['I.4']));