Make environment loading compatible with Plesk

This commit is contained in:
2026-07-22 10:11:15 +02:00
parent 9518bb8c6a
commit cadb633d51
6 changed files with 62 additions and 19 deletions
+19 -2
View File
@@ -1,7 +1,7 @@
<?php
require_once __DIR__ . '/app.php';
$username = getenv("username");
$password = getenv("password");
$username = app_env('username');
$password = app_env('password');
function sendAPICompanyInfoRequest(string $username, string $password, string $uid): string|bool {
@@ -118,6 +118,11 @@ function sendAPICommunityRequest(string $username, string $password): string|boo
function communityCSV(string $username, string $password): string {
if ($username === '' || $password === '') {
error_log('ZEFIX credentials are not configured.');
return '';
}
$response = sendAPICommunityRequest($username, $password);
if (!is_string($response)) {
return '';
@@ -131,6 +136,10 @@ function communityCSV(string $username, string $password): string {
$csvOutput = "id,bfsId,Kanton,Gemeindename,registryOfCommerceId,replacedById\n";
foreach ($communityArray as $item) {
if (!is_array($item)) {
return '';
}
$row = [
$item['id'] ?? '',
$item['bfsId'] ?? '',
@@ -184,6 +193,11 @@ function sendAPILegalFormRequest(string $username, string $password): string|boo
}
function legalFormCSV(string $username, string $password): string {
if ($username === '' || $password === '') {
error_log('ZEFIX credentials are not configured.');
return '';
}
$response = sendAPILegalFormRequest($username, $password);
if (!is_string($response)) {
return '';
@@ -196,6 +210,9 @@ function legalFormCSV(string $username, string $password): string {
// Create CSV rows
foreach ($legalformArray as $item) {
if (!is_array($item) || !isset($item['name']) || !is_array($item['name'])) {
return '';
}
$csvOutput .= $item["id"].",".$item["name"]["de"] . "\n";
}
return $csvOutput;