Zertifikatsprüfung als Opt-in: pro Site und für SMTP
All checks were successful
CI / PHP Lint (push) Successful in 36s
CI / PHP Lint-1 (push) Successful in 38s
CI / Unit Tests & Static Analysis (push) Successful in 42s
CI / PHP Lint (pull_request) Successful in 36s
CI / PHP Lint-1 (pull_request) Successful in 41s
CI / Unit Tests & Static Analysis (pull_request) Successful in 42s
All checks were successful
CI / PHP Lint (push) Successful in 36s
CI / PHP Lint-1 (push) Successful in 38s
CI / Unit Tests & Static Analysis (push) Successful in 42s
CI / PHP Lint (pull_request) Successful in 36s
CI / PHP Lint-1 (pull_request) Successful in 41s
CI / Unit Tests & Static Analysis (pull_request) Successful in 42s
Übernommen aus dem alten Review-Branch claude/tool-review-optimization-q9nyv5, neu gebaut auf dem aktuellen Stand. Der Rest jenes Branches ist durch das Redesign überholt. Bisher galt CURLOPT_SSL_VERIFYPEER => false für jede Verbindung zum Controller, ohne Möglichkeit, das zu ändern. Wer den Controller unter seinem echten Namen mit gültigem Zertifikat betreibt, kann die Prüfung jetzt pro Site einschalten; Standard bleibt aus, weil UniFi-Geräte ab Werk ein selbst signiertes Zertifikat liefern. - Migration 0008, Spalte sites.ssl_verify (Default 0) - UniFiController: fünfter Konstruktor-Parameter, steuert VERIFYPEER und VERIFYHOST; testConnection() ebenso. Alle acht Aufrufer geben den Wert der Site weiter, tolerant über "?? 0" für Alt-Installationen - Site-Verwaltung: Schalter in beiden Modalen, Abzeichen auf der Karte - Mailer: dasselbe über die Einstellung smtp_verify_ssl, Schalter im SMTP-Tab - Backup nimmt die Spalte mit, Readme erklärt, wann man sie einschaltet - 3 Tests auf den Durchgriff bis cURL (75 Tests, 178 Assertions) Nebenbei: der Aufruf von openEditModal() hat fehlende Spalten bisher als leeres Argument gerendert - jetzt über (int)(... ?? 0) abgesichert. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
78819c0c96
commit
4c1e58e68f
19 changed files with 136 additions and 35 deletions
|
|
@ -29,7 +29,7 @@ if (isset($_GET['export']) && isset($_GET['token']) && $auth->validateCsrfToken(
|
|||
'note' => 'Site-Passwörter sind mit dem APP_KEY dieser Installation verschlüsselt.',
|
||||
],
|
||||
'settings' => $db->fetchAll("SELECT setting_key, setting_value FROM settings"),
|
||||
'sites' => $db->fetchAll("SELECT name, site_id, unifi_controller_url, unifi_username, unifi_password, is_active, public_access FROM sites"),
|
||||
'sites' => $db->fetchAll("SELECT name, site_id, unifi_controller_url, unifi_username, unifi_password, ssl_verify, is_active, public_access FROM sites"),
|
||||
'voucher_templates' => $db->fetchAll("SELECT name, max_uses, expire_minutes, description, qos_rate_max_down, qos_rate_max_up, qos_usage_quota, is_active FROM voucher_templates"),
|
||||
// Display-Seiten samt Token: sonst zeigen aufgehängte QR-Codes nach
|
||||
// einem Restore ins Leere. Site und Profil werden über den Namen
|
||||
|
|
@ -84,13 +84,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['import'])) {
|
|||
$exists = $db->fetchOne("SELECT id FROM sites WHERE name = ? AND site_id = ?", [$s['name'], $s['site_id']]);
|
||||
if ($exists) {
|
||||
$db->query(
|
||||
"UPDATE sites SET unifi_controller_url=?, unifi_username=?, unifi_password=?, is_active=?, public_access=? WHERE id=?",
|
||||
[$s['unifi_controller_url'], $s['unifi_username'], $s['unifi_password'], (int)$s['is_active'], (int)$s['public_access'], $exists['id']]
|
||||
"UPDATE sites SET unifi_controller_url=?, unifi_username=?, unifi_password=?, ssl_verify=?, is_active=?, public_access=? WHERE id=?",
|
||||
[$s['unifi_controller_url'], $s['unifi_username'], $s['unifi_password'], (int)($s['ssl_verify'] ?? 0), (int)$s['is_active'], (int)$s['public_access'], $exists['id']]
|
||||
);
|
||||
} else {
|
||||
$db->query(
|
||||
"INSERT INTO sites (name, site_id, unifi_controller_url, unifi_username, unifi_password, is_active, public_access) VALUES (?,?,?,?,?,?,?)",
|
||||
[$s['name'], $s['site_id'], $s['unifi_controller_url'], $s['unifi_username'], $s['unifi_password'], (int)$s['is_active'], (int)$s['public_access']]
|
||||
"INSERT INTO sites (name, site_id, unifi_controller_url, unifi_username, unifi_password, ssl_verify, is_active, public_access) VALUES (?,?,?,?,?,?,?,?)",
|
||||
[$s['name'], $s['site_id'], $s['unifi_controller_url'], $s['unifi_username'], $s['unifi_password'], (int)($s['ssl_verify'] ?? 0), (int)$s['is_active'], (int)$s['public_access']]
|
||||
);
|
||||
}
|
||||
$counts['sites']++;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['do_import'])) {
|
|||
|
||||
$controller = new UniFiController(
|
||||
$site['unifi_controller_url'], $site['unifi_username'],
|
||||
Crypto::decrypt($site['unifi_password']), $site['site_id']
|
||||
Crypto::decrypt($site['unifi_password']), $site['site_id'],
|
||||
$site['ssl_verify'] ?? 0
|
||||
);
|
||||
|
||||
$created = 0;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ if (isset($_GET['ajax_stats'])) {
|
|||
if ($syncFirst) {
|
||||
foreach ($sites as $site) {
|
||||
try {
|
||||
$ctrl = new UniFiController($site['unifi_controller_url'], $site['unifi_username'], Crypto::decrypt($site['unifi_password']), $site['site_id']);
|
||||
$ctrl = new UniFiController($site['unifi_controller_url'], $site['unifi_username'], Crypto::decrypt($site['unifi_password']), $site['site_id'], $site['ssl_verify'] ?? 0);
|
||||
$ctrl->syncVouchersToDatabase($db, $site['id']);
|
||||
} catch (Exception $e) {
|
||||
$syncErrors[$site['id']] = $e->getMessage();
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['save_settings'])) {
|
|||
$settings['smtp_password'] = trim($_POST['smtp_password']);
|
||||
}
|
||||
$settings['smtp_encryption'] = trim($_POST['smtp_encryption'] ?? 'tls');
|
||||
$settings['smtp_verify_ssl'] = isset($_POST['smtp_verify_ssl']) ? '1' : '0';
|
||||
$settings['smtp_from_email'] = trim($_POST['smtp_from_email'] ?? '');
|
||||
$settings['smtp_from_name'] = trim($_POST['smtp_from_name'] ?? '');
|
||||
}
|
||||
|
|
@ -208,6 +209,7 @@ $cs = [
|
|||
'smtp_username' => $db->getSetting('smtp_username', ''),
|
||||
'smtp_password' => $db->getSetting('smtp_password', ''),
|
||||
'smtp_encryption' => $db->getSetting('smtp_encryption', 'tls'),
|
||||
'smtp_verify_ssl' => $db->getSetting('smtp_verify_ssl', '0'),
|
||||
'smtp_from_email' => $db->getSetting('smtp_from_email', ''),
|
||||
'smtp_from_name' => $db->getSetting('smtp_from_name', ''),
|
||||
'system_url' => $db->getSetting('system_url', $autoDetectedUrl),
|
||||
|
|
@ -562,6 +564,8 @@ $adminBase = '';
|
|||
<div class="form-group"><label>Benutzername</label><input type="text" name="smtp_username" value="<?= htmlspecialchars($cs['smtp_username']) ?>"></div>
|
||||
<div class="form-group"><label>Passwort</label><input type="password" name="smtp_password" placeholder="<?= __('settings_leave_empty') ?>"></div>
|
||||
</div>
|
||||
<div class="checkbox-group" style="margin-bottom:6px;"><input type="checkbox" name="smtp_verify_ssl" id="smtp_verify_ssl" <?= $cs['smtp_verify_ssl'] == '1' ? 'checked' : '' ?>><label for="smtp_verify_ssl" style="margin:0;"><?= __('settings_smtp_verify') ?></label></div>
|
||||
<p class="help-text" style="margin-bottom:16px;"><?= __('settings_smtp_verify_hint') ?></p>
|
||||
<div class="form-grid">
|
||||
<div class="form-group"><label>Absender E-Mail</label><input type="email" name="smtp_from_email" value="<?= htmlspecialchars($cs['smtp_from_email']) ?>"></div>
|
||||
<div class="form-group"><label><?= __('settings_smtp_from_name') ?></label><input type="text" name="smtp_from_name" value="<?= htmlspecialchars($cs['smtp_from_name']) ?>"></div>
|
||||
|
|
|
|||
|
|
@ -32,15 +32,16 @@ if ($_SERVER['REQUEST_METHOD']==='POST' && isset($_POST['edit_site'])) {
|
|||
$username = trim($_POST['username']);
|
||||
$password = $_POST['password'];
|
||||
$publicAccess = isset($_POST['public_access']) ? 1 : 0;
|
||||
$sslVerify = isset($_POST['ssl_verify']) ? 1 : 0;
|
||||
if (empty($name)||empty($siteIdStr)||empty($controllerUrl)||empty($username)) throw new Exception(__('error_fill_all'));
|
||||
if (!empty($password)) {
|
||||
$test = UniFiController::testConnection($controllerUrl,$username,$password,$siteIdStr);
|
||||
$test = UniFiController::testConnection($controllerUrl,$username,$password,$siteIdStr,$sslVerify);
|
||||
if ($test !== true) throw new Exception('Verbindung fehlgeschlagen: '.$test);
|
||||
$db->execute("UPDATE sites SET name=?,site_id=?,unifi_controller_url=?,unifi_username=?,unifi_password=?,public_access=? WHERE id=?",
|
||||
[$name,$siteIdStr,$controllerUrl,$username,Crypto::encrypt($password),$publicAccess,$siteId]);
|
||||
$db->execute("UPDATE sites SET name=?,site_id=?,unifi_controller_url=?,unifi_username=?,unifi_password=?,ssl_verify=?,public_access=? WHERE id=?",
|
||||
[$name,$siteIdStr,$controllerUrl,$username,Crypto::encrypt($password),$sslVerify,$publicAccess,$siteId]);
|
||||
} else {
|
||||
$db->execute("UPDATE sites SET name=?,site_id=?,unifi_controller_url=?,unifi_username=?,public_access=? WHERE id=?",
|
||||
[$name,$siteIdStr,$controllerUrl,$username,$publicAccess,$siteId]);
|
||||
$db->execute("UPDATE sites SET name=?,site_id=?,unifi_controller_url=?,unifi_username=?,ssl_verify=?,public_access=? WHERE id=?",
|
||||
[$name,$siteIdStr,$controllerUrl,$username,$sslVerify,$publicAccess,$siteId]);
|
||||
}
|
||||
$auth->writeAuditLog($_SESSION['user_id'],'site_edit','site',$siteId,"Site {$name} aktualisiert");
|
||||
$success = __('sites_updated');
|
||||
|
|
@ -60,11 +61,12 @@ if ($_SERVER['REQUEST_METHOD']==='POST' && isset($_POST['add_site'])) {
|
|||
$username = trim($_POST['username']);
|
||||
$password = $_POST['password'];
|
||||
$publicAccess = isset($_POST['public_access']) ? 1 : 0;
|
||||
$sslVerify = isset($_POST['ssl_verify']) ? 1 : 0;
|
||||
if (empty($name)||empty($siteId)||empty($controllerUrl)||empty($username)) throw new Exception(__('error_fill_all'));
|
||||
$test = UniFiController::testConnection($controllerUrl,$username,$password,$siteId);
|
||||
$test = UniFiController::testConnection($controllerUrl,$username,$password,$siteId,$sslVerify);
|
||||
if ($test !== true) throw new Exception('Verbindung fehlgeschlagen: '.$test);
|
||||
$newId = $db->execute("INSERT INTO sites (name,site_id,unifi_controller_url,unifi_username,unifi_password,public_access) VALUES (?,?,?,?,?,?)",
|
||||
[$name,$siteId,$controllerUrl,$username,Crypto::encrypt($password),$publicAccess]);
|
||||
$newId = $db->execute("INSERT INTO sites (name,site_id,unifi_controller_url,unifi_username,unifi_password,ssl_verify,public_access) VALUES (?,?,?,?,?,?,?)",
|
||||
[$name,$siteId,$controllerUrl,$username,Crypto::encrypt($password),$sslVerify,$publicAccess]);
|
||||
$auth->writeAuditLog($_SESSION['user_id'],'site_create','site',$newId,"Site {$name} erstellt");
|
||||
$success = __('sites_added');
|
||||
} catch (Exception $e) { $error = $e->getMessage(); }
|
||||
|
|
@ -140,6 +142,9 @@ $currentPage = 'sites';
|
|||
<?php if ($site['public_access']): ?>
|
||||
<span class="badge badge-info"><i class="fas fa-globe" aria-hidden="true"></i> <?= __('status_public') ?></span>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($site['ssl_verify'])): ?>
|
||||
<span class="badge badge-secondary" title="<?= __('sites_ssl_verify_hint') ?>"><i class="fas fa-lock" aria-hidden="true"></i> <?= __('sites_ssl_badge') ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="site-info">
|
||||
|
|
@ -157,7 +162,7 @@ $currentPage = 'sites';
|
|||
</div>
|
||||
</div>
|
||||
<div class="site-actions">
|
||||
<button onclick="openEditModal(<?= $site['id'] ?>, '<?= htmlspecialchars($site['name'], ENT_QUOTES) ?>', '<?= htmlspecialchars($site['site_id'], ENT_QUOTES) ?>', '<?= htmlspecialchars($site['unifi_controller_url'], ENT_QUOTES) ?>', '<?= htmlspecialchars($site['unifi_username'], ENT_QUOTES) ?>', <?= $site['public_access'] ?>)"
|
||||
<button onclick="openEditModal(<?= $site['id'] ?>, '<?= htmlspecialchars($site['name'], ENT_QUOTES) ?>', '<?= htmlspecialchars($site['site_id'], ENT_QUOTES) ?>', '<?= htmlspecialchars($site['unifi_controller_url'], ENT_QUOTES) ?>', '<?= htmlspecialchars($site['unifi_username'], ENT_QUOTES) ?>', <?= (int)($site['public_access'] ?? 0) ?>, <?= (int)($site['ssl_verify'] ?? 0) ?>)"
|
||||
class="btn btn-secondary btn-sm">
|
||||
<i class="fas fa-edit" aria-hidden="true"></i> <?= __('btn_edit') ?>
|
||||
</button>
|
||||
|
|
@ -214,6 +219,11 @@ $currentPage = 'sites';
|
|||
<input type="checkbox" id="add_public" name="public_access">
|
||||
<label for="add_public" style="margin:0;"><?= __('sites_public') ?></label>
|
||||
</div>
|
||||
<div class="form-group checkbox-group">
|
||||
<input type="checkbox" id="add_ssl_verify" name="ssl_verify">
|
||||
<label for="add_ssl_verify" style="margin:0;"><?= __('sites_ssl_verify') ?></label>
|
||||
</div>
|
||||
<p class="help-text"><?= __('sites_ssl_verify_hint') ?></p>
|
||||
<div style="display:flex;gap:10px;margin-top:20px;">
|
||||
<button type="submit" class="btn btn-primary" style="flex:1;" id="addSiteSubmitBtn">
|
||||
<i class="fas fa-save" aria-hidden="true"></i> <?= __('sites_add') ?>
|
||||
|
|
@ -264,6 +274,11 @@ $currentPage = 'sites';
|
|||
<input type="checkbox" id="edit_public_access" name="public_access">
|
||||
<label for="edit_public_access" style="margin:0;"><?= __('sites_public') ?></label>
|
||||
</div>
|
||||
<div class="form-group checkbox-group">
|
||||
<input type="checkbox" id="edit_ssl_verify" name="ssl_verify">
|
||||
<label for="edit_ssl_verify" style="margin:0;"><?= __('sites_ssl_verify') ?></label>
|
||||
</div>
|
||||
<p class="help-text"><?= __('sites_ssl_verify_hint') ?></p>
|
||||
<div style="display:flex;gap:10px;margin-top:20px;">
|
||||
<button type="submit" class="btn btn-primary" style="flex:1;" id="editSiteSubmitBtn">
|
||||
<i class="fas fa-save" aria-hidden="true"></i> <?= __('btn_save') ?>
|
||||
|
|
@ -281,7 +296,7 @@ $currentPage = 'sites';
|
|||
function openModal() { document.getElementById('addSiteModal').classList.add('active'); }
|
||||
function closeModal(id) { document.getElementById(id).classList.remove('active'); }
|
||||
|
||||
function openEditModal(id, name, siteIdStr, controllerUrl, username, publicAccess) {
|
||||
function openEditModal(id, name, siteIdStr, controllerUrl, username, publicAccess, sslVerify) {
|
||||
document.getElementById('edit_site_id').value = id;
|
||||
document.getElementById('edit_name').value = name;
|
||||
document.getElementById('edit_site_id_str').value = siteIdStr;
|
||||
|
|
@ -289,6 +304,7 @@ function openEditModal(id, name, siteIdStr, controllerUrl, username, publicAcces
|
|||
document.getElementById('edit_username').value = username;
|
||||
document.getElementById('edit_password').value = '';
|
||||
document.getElementById('edit_public_access').checked = publicAccess == 1;
|
||||
document.getElementById('edit_ssl_verify').checked = sslVerify == 1;
|
||||
document.getElementById('editSiteModal').classList.add('active');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ if (isset($_GET['ajax_get_vouchers']) && isset($_GET['site_id'])) {
|
|||
if (!$site) { echo json_encode(['success'=>false,'message'=>__('error_site_not_found')]); exit; }
|
||||
if ($syncFirst) {
|
||||
try {
|
||||
$ctrl = new UniFiController($site['unifi_controller_url'],$site['unifi_username'],Crypto::decrypt($site['unifi_password']),$site['site_id']);
|
||||
$ctrl = new UniFiController($site['unifi_controller_url'],$site['unifi_username'],Crypto::decrypt($site['unifi_password']),$site['site_id'],$site['ssl_verify'] ?? 0);
|
||||
$ctrl->syncVouchersToDatabase($db,$siteId);
|
||||
$db->execute("INSERT INTO settings (setting_key,setting_value) VALUES ('last_cron_sync',NOW()) ON DUPLICATE KEY UPDATE setting_value=NOW()");
|
||||
} catch (Exception $e) { error_log("Sync error: ".$e->getMessage()); }
|
||||
|
|
@ -83,7 +83,7 @@ if (isset($_POST['ajax_delete']) && isset($_POST['voucher_id']) && isset($_POST[
|
|||
$siteId = (int)$_POST['site_id'];
|
||||
$site = $db->fetchOne("SELECT * FROM sites WHERE id=? AND is_active=1", [$siteId]);
|
||||
if (!$site) { echo json_encode(['success'=>false,'message'=>__('error_site_not_found')]); exit; }
|
||||
$ctrl = new UniFiController($site['unifi_controller_url'],$site['unifi_username'],Crypto::decrypt($site['unifi_password']),$site['site_id']);
|
||||
$ctrl = new UniFiController($site['unifi_controller_url'],$site['unifi_username'],Crypto::decrypt($site['unifi_password']),$site['site_id'],$site['ssl_verify'] ?? 0);
|
||||
if ($ctrl->deleteVoucher($voucherId)) {
|
||||
$db->execute("DELETE FROM vouchers WHERE unifi_voucher_id=? AND site_id=?", [$voucherId,$siteId]);
|
||||
echo json_encode(['success'=>true,'message'=>'Voucher erfolgreich gelöscht!']);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue