feat: remove deprecated AI-optimized deployment script

- Delete deploy_to_hetzner_AI.sh which was superseded by main deployment script
- Remove cache-busting implementation for index_noSIG_AIopt.html
- Clean up unused SFTP deployment workflow with sshpass authentication
This commit is contained in:
2025-12-15 17:03:08 +01:00
parent 76798a215a
commit dc7dcdd650
7 changed files with 276 additions and 64 deletions

87
src/manual/auth.php Normal file
View File

@@ -0,0 +1,87 @@
<?php
session_start();
const SW_MANUAL_LOG_FILE = __DIR__ . '/logs/access.log';
function sw_load_users(): array {
$cfgPath = __DIR__ . '/auth.config.php';
if (!file_exists($cfgPath)) {
return [];
}
$cfg = require $cfgPath;
return $cfg['users'] ?? [];
}
function sw_verify_login(string $username, string $password): bool {
$users = sw_load_users();
if (!isset($users[$username])) {
return false;
}
$expected = (string)$users[$username];
return hash_equals($expected, $password);
}
function sw_current_user(): ?string {
return $_SESSION['sw_manual_user'] ?? null;
}
function sw_require_login(): void {
if (!sw_current_user()) {
header('Location: login.php');
exit;
}
}
function sw_record_login(string $username): void {
$dir = dirname(SW_MANUAL_LOG_FILE);
if (!is_dir($dir)) {
@mkdir($dir, 0775, true);
}
$ts = (new DateTimeImmutable('now', new DateTimeZone('Europe/Berlin')))->format(DateTimeInterface::ATOM);
$ip = $_SERVER['REMOTE_ADDR'] ?? '-';
$ua = $_SERVER['HTTP_USER_AGENT'] ?? '-';
$line = $ts . ';' . $username . ';' . $ip . ';' . str_replace("\n", ' ', $ua) . "\n";
@file_put_contents(SW_MANUAL_LOG_FILE, $line, FILE_APPEND | LOCK_EX);
}
function sw_last_login_for_user(string $username): ?DateTimeImmutable {
if (!file_exists(SW_MANUAL_LOG_FILE)) {
return null;
}
$fh = @fopen(SW_MANUAL_LOG_FILE, 'r');
if (!$fh) {
return null;
}
$last = null;
while (($line = fgets($fh)) !== false) {
$parts = explode(';', trim($line));
if (count($parts) < 2) {
continue;
}
[$ts, $user] = $parts;
if ($user !== $username) {
continue;
}
try {
$dt = new DateTimeImmutable($ts);
if ($last === null || $dt > $last) {
$last = $dt;
}
} catch (Exception $e) {
continue;
}
}
fclose($fh);
return $last;
}
function sw_format_dt(?DateTimeImmutable $dt): string {
if ($dt === null) {
return '';
}
return $dt->setTimezone(new DateTimeZone('Europe/Berlin'))->format('d.m.Y, H:i \U\h\r');
}