| Server IP : 193.86.120.172 / Your IP : 216.73.216.67 Web Server : Apache/2.4.63 (Unix) System : Linux JServices 3.10.108 #86003 SMP Wed Oct 22 13:20:46 CST 2025 x86_64 User : kubec ( 1026) PHP Version : 8.2.28 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /volume1/web/hotellesnizatisi_cz/new/includes/ |
Upload File : |
<?php
// ============================================================
// Volitelný zámek veřejného webu heslem — ovládaný z administrace
// (Nastavení). Když je zapnutý, návštěvník musí zadat heslo, než
// uvidí jakoukoli veřejnou stránku. Jednou zadané heslo si pamatuje
// session, dokud prohlížeč nezavře / session nevyprší.
//
// Nezávislé na .htaccess Basic Auth, který chrání celou /new/ složku
// (vč. administrace) na úrovni webserveru — tohle řeší jen veřejné
// stránky a dá se zapínat/vypínat bez zásahu do souborů na serveru.
// ============================================================
require_once __DIR__ . '/db.php';
function site_lock_check(string $lang): void
{
$stmt = db()->prepare("SELECT klic, hodnota FROM web_nastaveni WHERE klic IN ('web_zamknuty', 'web_heslo_hash')");
$stmt->execute();
$settings = [];
foreach ($stmt->fetchAll() as $row) {
$settings[$row['klic']] = $row['hodnota'];
}
if (($settings['web_zamknuty'] ?? '0') !== '1') {
return;
}
if (session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
if (!empty($_SESSION['web_odemceno'])) {
return;
}
$error = false;
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['site_heslo'])) {
$hash = $settings['web_heslo_hash'] ?? '';
if ($hash !== '' && password_verify($_POST['site_heslo'], $hash)) {
$_SESSION['web_odemceno'] = true;
header('Location: ' . strtok($_SERVER['REQUEST_URI'], '?'));
exit;
}
$error = true;
}
$texts = [
'cs' => ['title' => 'Stránka je dočasně chráněná heslem', 'label' => 'Heslo', 'btn' => 'Vstoupit', 'err' => 'Nesprávné heslo, zkuste to znovu.'],
'en' => ['title' => 'This page is temporarily password protected', 'label' => 'Password', 'btn' => 'Enter', 'err' => 'Incorrect password, please try again.'],
'de' => ['title' => 'Diese Seite ist vorübergehend passwortgeschützt', 'label' => 'Passwort', 'btn' => 'Eintreten', 'err' => 'Falsches Passwort, bitte versuchen Sie es erneut.'],
];
$t = $texts[$lang] ?? $texts['cs'];
http_response_code(401);
?>
<!DOCTYPE html>
<html lang="<?= htmlspecialchars($lang) ?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hotel Lesní zátiší</title>
<link href="https://fonts.googleapis.com/css2?family=Work+Sans:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
*{margin:0;padding:0;box-sizing:border-box;}
body{font-family:"Work Sans",sans-serif;background:#EDE8DD;color:#232A1F;min-height:100vh;display:flex;align-items:center;justify-content:center;padding:20px;}
.card{background:#FFFFFF;border:1px solid #E4E0D2;border-radius:10px;width:100%;max-width:380px;padding:36px 32px;box-shadow:0 10px 40px rgba(35,42,31,.08);}
h1{font-size:1.05rem;font-weight:700;margin-bottom:20px;line-height:1.4;}
.field{margin-bottom:16px;}
input{width:100%;padding:11px 13px;border:1px solid #E4E0D2;border-radius:6px;background:#EDE8DD;font-family:inherit;font-size:.92rem;color:#232A1F;}
input:focus{outline:2px solid #C2884F;outline-offset:1px;}
button{width:100%;padding:12px;border:none;border-radius:6px;background:#232A1F;color:#fff;font-weight:600;font-size:.92rem;cursor:pointer;}
button:hover{background:#1a201a;}
.error{background:#F5E4DF;color:#B4543C;border-radius:6px;padding:10px 13px;font-size:.82rem;margin-bottom:18px;}
</style>
</head>
<body>
<div class="card">
<h1><?= htmlspecialchars($t['title']) ?></h1>
<?php if ($error): ?><div class="error"><?= htmlspecialchars($t['err']) ?></div><?php endif; ?>
<form method="post">
<div class="field">
<input type="password" name="site_heslo" placeholder="<?= htmlspecialchars($t['label']) ?>" autofocus required>
</div>
<button type="submit"><?= htmlspecialchars($t['btn']) ?></button>
</form>
</div>
</body>
</html>
<?php
exit;
}