organic: Add external LKV api
This commit is contained in:
2
www/organic/external/easy-cert/operators.php
vendored
2
www/organic/external/easy-cert/operators.php
vendored
@@ -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));
|
||||
|
||||
|
33
www/organic/external/lkv/operators.php
vendored
Normal file
33
www/organic/external/lkv/operators.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'GET' && $_SERVER['REQUEST_METHOD'] !== 'HEAD') {
|
||||
header('Status: 405');
|
||||
header('Content-Length: 0');
|
||||
header('Allow: GET, HEAD');
|
||||
exit;
|
||||
}
|
||||
|
||||
function jenc($data): string {
|
||||
return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$info = $_SERVER['PATH_INFO'];
|
||||
if ($info !== '') {
|
||||
header('Status: 404');
|
||||
header('Content-Length: 0');
|
||||
exit;
|
||||
}
|
||||
|
||||
header('Content-Type: application/json; charset=UTF-8');
|
||||
|
||||
echo "{\"data\":[\n";
|
||||
passthru(<<<EOF
|
||||
curl -s 'https://lkv.at/at/zertifizierung/themen/BIO/zertifizierte-BIO-Betriebe.php' | grep '<tr' -A 3 \
|
||||
| sed 's@<tr>@ {@;s@</tr>@ },@;s@<td><a .*href="\([^"]*\)".*>\(.*\)</a></td>@ "certUrl":"\\1","certNr":"\\2",@;s@<td>\(.*\)<br/>\(.*\)<br/>\([0-9]*\) \(.*\)</td>@ "name":"\\1","address":"\\2","postalCode":"\\3","city":"\\4"@;s@<td>\(.*\)<br/>\(.*\)</td>@ "name":"\\1","type":"\\2"@;\$s/.$//' \
|
||||
| sed 's@"certUrl":"\(/[^"]*\)"@"certUrl":"https://lkv.at\\1"@' \
|
||||
| sed 's@\s*",@",@g;s@:"\s*@:"@g'
|
||||
EOF);
|
||||
|
||||
echo "]}\n";
|
@@ -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 <<<EOF
|
||||
{"data":[
|
||||
{"id":"AT-BIO-301","countryCode":"AT","handle":"ABG","name":"Austria Bio Garantie GmbH","website":"https://www.bio-garantie.at/","apis":["easy-cert"]},
|
||||
{"id":"AT-BIO-302","countryCode":"AT","handle":"ABG-LW","name":"Austria Bio Garantie – Landwirtschaft GmbH","website":"https://www.bio-garantie.at/","apis":["easy-cert"]},
|
||||
{"id":"AT-BIO-401","countryCode":"AT","handle":"BIOS","name":"BIOS – Biokontrollservice Österreich GmbH","website":"https://www.bios-kontrolle.at/","apis":["bioqs"]},
|
||||
{"id":"AT-BIO-402","countryCode":"AT","handle":"LACON","name":"LACON GmbH ","website":"https://www.lacon-institut.com/","apis":["easy-cert"]},
|
||||
{"id":"AT-BIO-501","countryCode":"AT","handle":"SLK","name":"SLK GesmbH","website":"https://slk.at/","apis":["bioc"]},
|
||||
{"id":"AT-BIO-901","countryCode":"AT","handle":"LVA","name":"LVA GmbH","website":"https://www.lva.at/","apis":[]},
|
||||
{"id":"AT-BIO-902","countryCode":"AT","handle":"SGS","name":"SGS Austria Controll-Co. Ges.m.b.H.","website":"https://www.sgs.com/de-at ","apis":["bioc"]},
|
||||
{"id":"AT-BIO-903","countryCode":"AT","handle":"LKV","name":"LKV Austria Gemeinnützige GmbH","website":"https://www.lkv.at/","apis":["bioc","lkv"]}
|
||||
]}
|
||||
|
||||
EOF;
|
||||
exit;
|
||||
} else if (str_starts_with($info, '/authorities/')) {
|
||||
$code = $parts[2];
|
||||
|
@@ -164,7 +164,7 @@ if ($format === 'text') {
|
||||
$operator = preg_split('@\s+@', trim($data['I.3']));
|
||||
$p1 = array_search($splitAddr, $operator);
|
||||
$p2 = array_search($splitCountry, $operator);
|
||||
$operatorName = implode(' ', array_filter($operator, fn($k,$i) => $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']));
|
||||
|
Reference in New Issue
Block a user