Some checks are pending
CI / PHP Lint (push) Waiting to run
CI / PHP Lint-1 (push) Waiting to run
CI / Unit Tests & Static Analysis (push) Waiting to run
CI / PHP Lint (pull_request) Successful in 35s
CI / PHP Lint-1 (pull_request) Successful in 46s
CI / Unit Tests & Static Analysis (pull_request) Successful in 37s
Die Lizenzhinweise standen bisher nur in den Dateien. Unter Integration & Wartung gibt es jetzt eine Karte "Über diese Installation" mit Version, PHP-Version, Lizenz, Entwickler und Quellcode sowie einer Tabelle der mitgelieferten Komponenten Dritter, die direkt auf die ausgelieferten Lizenztexte verlinkt. Die Liste kommt aus Ui::thirdParty(), damit Oberfläche und THIRD-PARTY-NOTICES.md nicht auseinanderlaufen; drei Tests prüfen, dass jede gelistete Komponente ihren Lizenztext wirklich mitliefert, in den Notices auftaucht und LICENSE vorhanden ist. Außerdem: - docker-publish.yml entfernt – der Workflow veröffentlichte nach ghcr.io und stammte noch aus der GitHub-Zeit - Readme: der Actions-Runner läuft jetzt, entsprechende Hinweise angepasst; Test-Badge durch das echte CI-Badge der Forgejo-Instanz ersetzt Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
267 lines
15 KiB
PHP
267 lines
15 KiB
PHP
<?php
|
||
error_reporting(E_ALL);
|
||
ini_set('display_errors', 0);
|
||
ini_set('log_errors', 1);
|
||
|
||
require_once __DIR__ . '/../config.php';
|
||
require_once __DIR__ . '/../includes/Database.php';
|
||
require_once __DIR__ . '/../includes/Auth.php';
|
||
require_once __DIR__ . '/../includes/Notifier.php';
|
||
require_once __DIR__ . '/../includes/I18n.php';
|
||
|
||
$auth = new Auth();
|
||
$auth->requireAdmin();
|
||
I18n::init();
|
||
|
||
$db = Database::getInstance();
|
||
$appTitle = $db->getSetting('app_title', 'UniFi Voucher System');
|
||
|
||
$error = '';
|
||
$success = '';
|
||
|
||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['save'])) {
|
||
if (!$auth->validateCsrfToken($_POST['csrf_token'] ?? '')) {
|
||
$error = __('error_csrf');
|
||
} else {
|
||
$db->setSetting('enforce_2fa_admins', isset($_POST['enforce_2fa_admins']) ? '1' : '0');
|
||
$db->setSetting('session_driver', ($_POST['session_driver'] ?? 'php') === 'db' ? 'db' : 'php');
|
||
$cm = in_array($_POST['captcha_mode'] ?? 'off', ['off','math','hcaptcha'], true) ? $_POST['captcha_mode'] : 'off';
|
||
$db->setSetting('captcha_mode', $cm);
|
||
$db->setSetting('captcha_site_key', trim($_POST['captcha_site_key'] ?? ''));
|
||
if (!empty($_POST['captcha_secret'])) { $db->setSetting('captcha_secret', trim($_POST['captcha_secret'])); }
|
||
$db->setSetting('sms_enabled', isset($_POST['sms_enabled']) ? '1' : '0');
|
||
$db->setSetting('twilio_sid', trim($_POST['twilio_sid'] ?? ''));
|
||
$db->setSetting('twilio_from', trim($_POST['twilio_from'] ?? ''));
|
||
if (!empty($_POST['twilio_token'])) { $db->setSetting('twilio_token', trim($_POST['twilio_token'])); }
|
||
$db->setSetting('oidc_enabled', isset($_POST['oidc_enabled']) ? '1' : '0');
|
||
$db->setSetting('oidc_name', trim($_POST['oidc_name'] ?? 'SSO'));
|
||
$db->setSetting('oidc_client_id', trim($_POST['oidc_client_id'] ?? ''));
|
||
$db->setSetting('oidc_auth_url', trim($_POST['oidc_auth_url'] ?? ''));
|
||
$db->setSetting('oidc_token_url', trim($_POST['oidc_token_url'] ?? ''));
|
||
$db->setSetting('oidc_userinfo_url', trim($_POST['oidc_userinfo_url'] ?? ''));
|
||
$db->setSetting('oidc_scopes', trim($_POST['oidc_scopes'] ?? 'openid profile email'));
|
||
if (!empty($_POST['oidc_client_secret'])) { $db->setSetting('oidc_client_secret', trim($_POST['oidc_client_secret'])); }
|
||
$db->setSetting('user_daily_voucher_limit', max(0, (int)($_POST['user_daily_voucher_limit'] ?? 0)));
|
||
$db->setSetting('trusted_proxy', trim($_POST['trusted_proxy'] ?? ''));
|
||
$db->setSetting('webhook_enabled', isset($_POST['webhook_enabled']) ? '1' : '0');
|
||
$db->setSetting('webhook_url', trim($_POST['webhook_url'] ?? ''));
|
||
$db->setSetting('cleanup_expired_days', max(0, (int)($_POST['cleanup_expired_days'] ?? 0)));
|
||
$db->setSetting('cleanup_audit_days', max(0, (int)($_POST['cleanup_audit_days'] ?? 0)));
|
||
$db->setSetting('cleanup_login_days', max(0, (int)($_POST['cleanup_login_days'] ?? 30)));
|
||
$auth->writeAuditLog($_SESSION['user_id'], 'settings_update', 'config', null, 'Integration/Wartung gespeichert');
|
||
$success = __('settings_saved');
|
||
}
|
||
}
|
||
|
||
if (isset($_GET['test_webhook']) && isset($_GET['token']) && $auth->validateCsrfToken($_GET['token'])) {
|
||
Notifier::send('✅ Test-Benachrichtigung vom UniFi Voucher System.', ['type' => 'test']);
|
||
$success = __('int_webhook_test_sent');
|
||
}
|
||
|
||
$enforce2fa = $db->getSetting('enforce_2fa_admins', '0') === '1';
|
||
$sessionDriver = $db->getSetting('session_driver', 'php');
|
||
$captchaMode = $db->getSetting('captcha_mode', 'off');
|
||
$captchaSiteKey = $db->getSetting('captcha_site_key', '');
|
||
$captchaSecretSet = $db->getSetting('captcha_secret', '') !== '';
|
||
$smsEnabled = $db->getSetting('sms_enabled', '0') === '1';
|
||
$twilioSid = $db->getSetting('twilio_sid', '');
|
||
$twilioFrom = $db->getSetting('twilio_from', '');
|
||
$twilioTokenSet = $db->getSetting('twilio_token', '') !== '';
|
||
$oidcEnabled = $db->getSetting('oidc_enabled', '0') === '1';
|
||
$oidcName = $db->getSetting('oidc_name', 'SSO');
|
||
$oidcClientId = $db->getSetting('oidc_client_id', '');
|
||
$oidcAuthUrl = $db->getSetting('oidc_auth_url', '');
|
||
$oidcTokenUrl = $db->getSetting('oidc_token_url', '');
|
||
$oidcUserinfoUrl = $db->getSetting('oidc_userinfo_url', '');
|
||
$oidcScopes = $db->getSetting('oidc_scopes', 'openid profile email');
|
||
$oidcSecretSet = $db->getSetting('oidc_client_secret', '') !== '';
|
||
$dailyLimit = (int)$db->getSetting('user_daily_voucher_limit', 0);
|
||
$trustedProxy = $db->getSetting('trusted_proxy', '');
|
||
|
||
// Hinweis, wenn die Anfrage offensichtlich über einen Proxy kam, aber keiner
|
||
// eingetragen ist: dann zählt das Rate-Limit alle Gäste als eine Adresse.
|
||
$remoteAddr = (string)($_SERVER['REMOTE_ADDR'] ?? '');
|
||
$proxyWarning = trim($trustedProxy) === ''
|
||
&& (!empty($_SERVER['HTTP_X_FORWARDED_FOR']) || !empty($_SERVER['HTTP_X_REAL_IP']));
|
||
$webhookEnabled = $db->getSetting('webhook_enabled', '0') === '1';
|
||
$webhookUrl = $db->getSetting('webhook_url', '');
|
||
$cleanupExpired = (int)$db->getSetting('cleanup_expired_days', 0);
|
||
$cleanupAudit = (int)$db->getSetting('cleanup_audit_days', 0);
|
||
$cleanupLogin = (int)$db->getSetting('cleanup_login_days', 30);
|
||
$lastCleanup = $db->getSetting('last_cleanup', '');
|
||
$csrf = $auth->getCsrfToken();
|
||
$currentPage = 'integrations';
|
||
$adminBase = '';
|
||
?>
|
||
<!DOCTYPE html>
|
||
<html lang="<?= I18n::getLanguage() ?>">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title><?= __('int_title') ?> – <?= htmlspecialchars($appTitle) ?></title>
|
||
<?php require __DIR__ . '/../includes/admin_nav.php'; ?>
|
||
<div class="page-header">
|
||
<div>
|
||
<h1 class="page-title"><?= __('int_title') ?></h1>
|
||
<p class="page-subtitle"><?= __('int_subtitle') ?></p>
|
||
</div>
|
||
</div>
|
||
|
||
<?php if ($error): ?><div class="alert alert-error"><?= htmlspecialchars($error) ?></div><?php endif; ?>
|
||
<?php if ($success): ?><div class="alert alert-ok"><?= htmlspecialchars($success) ?></div><?php endif; ?>
|
||
|
||
<form method="post">
|
||
<input type="hidden" name="csrf_token" value="<?= htmlspecialchars($csrf) ?>">
|
||
|
||
<div class="card">
|
||
<h2><?= __('int_security') ?></h2>
|
||
<p class="muted"><?= __('int_security_hint') ?></p>
|
||
<label class="chk"><input type="checkbox" name="enforce_2fa_admins" <?= $enforce2fa ? 'checked' : '' ?>> <?= __('int_enforce_2fa') ?></label>
|
||
<label><?= __('int_daily_limit') ?></label>
|
||
<input class="input" type="number" min="0" name="user_daily_voucher_limit" value="<?= $dailyLimit ?>" style="max-width:200px;">
|
||
<label><?= __('int_session_driver') ?></label>
|
||
<select class="input" name="session_driver" style="max-width:340px;">
|
||
<option value="php" <?= $sessionDriver==='php'?'selected':'' ?>><?= __('int_session_php') ?></option>
|
||
<option value="db" <?= $sessionDriver==='db'?'selected':'' ?>><?= __('int_session_db') ?></option>
|
||
</select>
|
||
<label><?= __('int_captcha') ?></label>
|
||
<select class="input" name="captcha_mode" style="max-width:340px;">
|
||
<option value="off" <?= $captchaMode==='off'?'selected':'' ?>><?= __('int_captcha_off') ?></option>
|
||
<option value="math" <?= $captchaMode==='math'?'selected':'' ?>><?= __('int_captcha_math') ?></option>
|
||
<option value="hcaptcha" <?= $captchaMode==='hcaptcha'?'selected':'' ?>>hCaptcha</option>
|
||
</select>
|
||
<div class="row3" style="margin-top:10px;">
|
||
<div><label>hCaptcha Site-Key</label><input class="input" type="text" name="captcha_site_key" value="<?= htmlspecialchars($captchaSiteKey) ?>"></div>
|
||
<div><label>hCaptcha Secret<?= $captchaSecretSet ? __('int_secret_set') : '' ?></label><input class="input" type="password" name="captcha_secret" placeholder="<?= $captchaSecretSet ? __('int_secret_placeholder') : '' ?>"></div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="card">
|
||
<h2><?= __('int_proxy') ?></h2>
|
||
<p class="muted"><?= __('int_proxy_hint') ?> <code>X-Forwarded-For</code> <?= __('int_proxy_hint2') ?></p>
|
||
<input class="input" type="text" name="trusted_proxy" value="<?= htmlspecialchars($trustedProxy) ?>" placeholder="z.B. 10.0.0.1, 172.18.0.1">
|
||
<?php if ($proxyWarning): ?>
|
||
<div class="alert alert-warning" style="margin-top:12px;">
|
||
<i class="fas fa-triangle-exclamation" aria-hidden="true"></i>
|
||
<span>
|
||
<?= str_replace('{ip}', htmlspecialchars($remoteAddr), __('int_proxy_warning')) ?><br>
|
||
<?= __('int_proxy_suggestion') ?> <code><?= htmlspecialchars($remoteAddr) ?></code>
|
||
</span>
|
||
</div>
|
||
<?php endif; ?>
|
||
</div>
|
||
|
||
<div class="card">
|
||
<h2><?= __('int_webhook') ?></h2>
|
||
<p class="muted"><?= __('int_webhook_hint') ?></p>
|
||
<label class="chk"><input type="checkbox" name="webhook_enabled" <?= $webhookEnabled ? 'checked' : '' ?>> <?= __('int_webhook_active') ?></label>
|
||
<label><?= __('int_webhook_url') ?></label>
|
||
<input class="input" type="url" name="webhook_url" value="<?= htmlspecialchars($webhookUrl) ?>" placeholder="https://hooks.slack.com/services/…">
|
||
<div style="margin-top:12px;">
|
||
<a class="btn btn-secondary" href="?test_webhook=1&token=<?= urlencode($csrf) ?>"><?= __('int_webhook_test') ?></a>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="card">
|
||
<h2><?= __('int_sms') ?></h2>
|
||
<p class="muted"><?= __('int_sms_hint') ?></p>
|
||
<label class="chk"><input type="checkbox" name="sms_enabled" <?= $smsEnabled ? 'checked' : '' ?>> <?= __('int_sms_active') ?></label>
|
||
<div class="row3" style="margin-top:10px;">
|
||
<div><label>Account SID</label><input class="input" type="text" name="twilio_sid" value="<?= htmlspecialchars($twilioSid) ?>"></div>
|
||
<div><label>Auth Token<?= $twilioTokenSet ? __('int_secret_set') : '' ?></label><input class="input" type="password" name="twilio_token" placeholder="<?= $twilioTokenSet ? __('int_secret_placeholder') : '' ?>"></div>
|
||
<div><label><?= __('int_sms_from') ?></label><input class="input" type="text" name="twilio_from" value="<?= htmlspecialchars($twilioFrom) ?>" placeholder="+49…"></div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="card">
|
||
<h2><?= __('int_sso') ?></h2>
|
||
<p class="muted"><?= __('int_sso_hint') ?> <code><?= htmlspecialchars(((!empty($_SERVER['HTTPS'])&&$_SERVER['HTTPS']!=='off')?'https':'http').'://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['SCRIPT_NAME']),'/').'/../oidc_callback.php') ?></code></p>
|
||
<label class="chk"><input type="checkbox" name="oidc_enabled" <?= $oidcEnabled ? 'checked' : '' ?>> <?= __('int_sso_active') ?></label>
|
||
<div class="row3" style="margin-top:10px;">
|
||
<div><label><?= __('int_sso_button') ?></label><input class="input" type="text" name="oidc_name" value="<?= htmlspecialchars($oidcName) ?>"></div>
|
||
<div><label>Client ID</label><input class="input" type="text" name="oidc_client_id" value="<?= htmlspecialchars($oidcClientId) ?>"></div>
|
||
<div><label>Client Secret<?= $oidcSecretSet ? __('int_secret_set') : '' ?></label><input class="input" type="password" name="oidc_client_secret" placeholder="<?= $oidcSecretSet ? __('int_secret_placeholder') : '' ?>"></div>
|
||
</div>
|
||
<label>Authorization Endpoint</label><input class="input" type="url" name="oidc_auth_url" value="<?= htmlspecialchars($oidcAuthUrl) ?>" placeholder="https://idp/authorize">
|
||
<label>Token Endpoint</label><input class="input" type="url" name="oidc_token_url" value="<?= htmlspecialchars($oidcTokenUrl) ?>" placeholder="https://idp/token">
|
||
<label>Userinfo Endpoint</label><input class="input" type="url" name="oidc_userinfo_url" value="<?= htmlspecialchars($oidcUserinfoUrl) ?>" placeholder="https://idp/userinfo">
|
||
<label>Scopes</label><input class="input" type="text" name="oidc_scopes" value="<?= htmlspecialchars($oidcScopes) ?>">
|
||
</div>
|
||
|
||
<div class="card">
|
||
<h2><?= __('int_cleanup') ?></h2>
|
||
<p class="muted"><?= __('int_cleanup_hint') ?> <code>cron_cleanup.php</code> <?= __('int_cleanup_hint2') ?>
|
||
<?php if ($lastCleanup): ?><br><?= __('int_cleanup_last') ?> <?= htmlspecialchars($lastCleanup) ?><?php endif; ?>
|
||
</p>
|
||
<div class="row">
|
||
<div><label><?= __('int_cleanup_expired') ?></label><input class="input" type="number" min="0" name="cleanup_expired_days" value="<?= $cleanupExpired ?>"></div>
|
||
<div><label><?= __('int_cleanup_audit') ?></label><input class="input" type="number" min="0" name="cleanup_audit_days" value="<?= $cleanupAudit ?>"></div>
|
||
<div><label><?= __('int_cleanup_logins') ?></label><input class="input" type="number" min="0" name="cleanup_login_days" value="<?= $cleanupLogin ?>"></div>
|
||
</div>
|
||
</div>
|
||
|
||
<button class="btn btn-primary" type="submit" name="save"><?= __('btn_save') ?></button>
|
||
</form>
|
||
|
||
<div class="card about-card">
|
||
<h2><?= __('about_title') ?></h2>
|
||
<p class="muted"><?= __('about_hint') ?></p>
|
||
|
||
<dl class="about-list">
|
||
<dt><?= __('about_app') ?></dt>
|
||
<dd>UniFi Voucher Management System</dd>
|
||
|
||
<dt><?= __('about_version') ?></dt>
|
||
<dd><?= Ui::version() !== '' ? htmlspecialchars(Ui::version()) : '–' ?></dd>
|
||
|
||
<dt><?= __('about_php') ?></dt>
|
||
<dd><?= htmlspecialchars(PHP_VERSION) ?></dd>
|
||
|
||
<dt><?= __('about_license') ?></dt>
|
||
<dd><?= Ui::LICENSE ?> –
|
||
<a href="<?= Ui::LICENSE_URL ?>" target="_blank" rel="noopener"><?= __('about_license_view') ?></a>
|
||
</dd>
|
||
|
||
<dt><?= __('about_developer') ?></dt>
|
||
<dd><a href="<?= Ui::CREDIT_URL ?>" target="_blank" rel="noopener"><?= Ui::CREDIT_NAME ?></a></dd>
|
||
|
||
<dt><?= __('about_repository') ?></dt>
|
||
<dd><a href="<?= Ui::REPOSITORY_URL ?>" target="_blank" rel="noopener">git.loheide.cloud</a></dd>
|
||
</dl>
|
||
|
||
<h3><?= __('about_third_party') ?></h3>
|
||
<p class="muted"><?= __('about_third_party_hint') ?></p>
|
||
<div class="table-container">
|
||
<table class="table table-stack">
|
||
<thead>
|
||
<tr>
|
||
<th><?= __('about_component') ?></th>
|
||
<th><?= __('about_version') ?></th>
|
||
<th><?= __('about_license') ?></th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php foreach (Ui::thirdParty() as $component): ?>
|
||
<tr>
|
||
<td data-label="<?= __('about_component') ?>">
|
||
<a href="<?= htmlspecialchars($component['url']) ?>" target="_blank" rel="noopener">
|
||
<?= htmlspecialchars($component['name']) ?>
|
||
</a>
|
||
</td>
|
||
<td data-label="<?= __('about_version') ?>"><?= htmlspecialchars($component['version']) ?></td>
|
||
<td data-label="<?= __('about_license') ?>">
|
||
<a href="<?= htmlspecialchars('../' . $component['license_file']) ?>" target="_blank" rel="noopener">
|
||
<?= htmlspecialchars($component['license']) ?>
|
||
</a>
|
||
</td>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
</main>
|
||
<script src="../assets/global.js"></script>
|
||
</body>
|
||
</html>
|