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";
|
Reference in New Issue
Block a user