diff --git a/auth.php b/auth.php
new file mode 100644
index 0000000..2871db7
--- /dev/null
+++ b/auth.php
@@ -0,0 +1,91 @@
+ 7200)) {
+ logout();
+ return false;
+ }
+ $_SESSION['wpc_last_activity'] = time();
+ return true;
+ }
+ return false;
+}
+
+/**
+ * Blokkeert ongeautoriseerde toegang en stuurt door naar het inlogscherm.
+ */
+function require_auth() {
+ if (!is_logged_in()) {
+ // Als het een asynchrone AJAX aanroep is, geef HTTP 401 Unauthorized
+ if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) || isset($_GET['action']) || isset($_GET['api'])) {
+ header('HTTP/1.1 401 Unauthorized');
+ header('Content-Type: application/json; charset=utf-8');
+ echo json_encode(['status' => 'unauthorized', 'message' => 'Sessie verlopen of niet ingelogd.']);
+ exit;
+ }
+
+ $redirect = urlencode($_SERVER['REQUEST_URI'] ?? 'index.php');
+ header("Location: login.php?redirect={$redirect}");
+ exit;
+ }
+}
+
+/**
+ * Genereert een CSRF token voor formulieren.
+ */
+function get_csrf_token() {
+ if (empty($_SESSION['wpc_csrf'])) {
+ $_SESSION['wpc_csrf'] = bin2hex(random_bytes(32));
+ }
+ return $_SESSION['wpc_csrf'];
+}
+
+/**
+ * Valideert het ingediende CSRF token.
+ */
+function verify_csrf_token($token) {
+ if (empty($_SESSION['wpc_csrf']) || empty($token)) {
+ return false;
+ }
+ return hash_equals($_SESSION['wpc_csrf'], $token);
+}
+
+/**
+ * Beëindigt de sessie en ruimt cookies op.
+ */
+function logout() {
+ $_SESSION = [];
+ if (ini_get("session.use_cookies")) {
+ $params = session_get_cookie_params();
+ setcookie(session_name(), '', time() - 42000,
+ $params["path"], $params["domain"],
+ $params["secure"], $params["httponly"]
+ );
+ }
+ @session_destroy();
+}
+
diff --git a/index.php b/index.php
index be2da71..b0173ee 100644
--- a/index.php
+++ b/index.php
@@ -4,6 +4,9 @@
* Hoofdpagina voor status, runtime verificatie en Git webhook deployment tests.
*/
+require_once __DIR__ . '/auth.php';
+require_auth();
+
// Snelle API responder voor AJAX pings
if (isset($_GET['api']) && $_GET['api'] === 'status') {
header('Content-Type: application/json; charset=utf-8');
@@ -23,9 +26,10 @@ date_default_timezone_set('Europe/Amsterdam');
$serverTime = date('d-m-Y H:i:s');
$phpVersion = PHP_VERSION;
$serverSoftware = $_SERVER['SERVER_SOFTWARE'] ?? 'Apache / Nginx';
-$host = $_SERVER['HTTP_HOST'] ?? 'www.webenpcstudio.nl';
+$host = $_SERVER['HTTP_HOST'] ?? 'server.webenpcstudio.nl';
$clientIp = $_SERVER['REMOTE_ADDR'] ?? 'Onbekend';
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'HTTPS' : 'HTTP';
+$loggedUser = $_SESSION['wpc_user_email'] ?? 'niek.rabelink@gmail.com';
// Git repository inspectie (met veilige fallback)
$activeBranch = 'dev';
@@ -91,9 +95,10 @@ if (empty($commits)) {
🌙 Thema
+
🚪 Uitloggen
- Git Live
+ server.webenpcstudio.nl
@@ -102,7 +107,7 @@ if (empty($commits)) {
Systeem Dashboard & Git Status
- Realtime omgevingsstatus, Git webhook deploy-verificatie en server-runtime monitoring voor www.webenpcstudio.nl.
+ Realtime omgevingsstatus, Git webhook deploy-verificatie en server-runtime monitoring voor server.webenpcstudio.nl .
diff --git a/lab.php b/lab.php
index 9658f03..d743d4c 100644
--- a/lab.php
+++ b/lab.php
@@ -4,6 +4,9 @@
* Diepgaande diagnostische suite voor CPU, NVMe Disk I/O, RAM en HTTP Concurrency.
*/
+require_once __DIR__ . '/auth.php';
+require_auth();
+
// Helper functies voor benchmarks
function benchmarkCPU() {
$start = microtime(true);
@@ -387,6 +390,7 @@ $serverSoftware = $_SERVER['SERVER_SOFTWARE'] ?? 'Apache / Nginx';
🔈 Geluid: Uit
+ 🚪 Uitloggen
@@ -403,7 +407,7 @@ $serverSoftware = $_SERVER['SERVER_SOFTWARE'] ?? 'Apache / Nginx';
⚡ Volledige Server Benchmark
- Voert in één geautomatiseerde cyclus alle 5 hardware- & softwaretests uit op www.webenpcstudio.nl.
+ Voert in één geautomatiseerde cyclus alle 5 hardware- & softwaretests uit op server.webenpcstudio.nl .
@@ -900,7 +904,7 @@ $serverSoftware = $_SERVER['SERVER_SOFTWARE'] ?? 'Apache / Nginx';
function copyReport() {
let report = "=== WEB & PC STUDIO - WEBSERVER BENCHMARK RAPPORT ===\n" +
- `Domein: www.webenpcstudio.nl\n` +
+ `Domein: server.webenpcstudio.nl\n` +
`Datum: ${new Date().toLocaleString('nl-NL')}\n\n`;
if (lastReport) {
diff --git a/login.php b/login.php
new file mode 100644
index 0000000..d24d20f
--- /dev/null
+++ b/login.php
@@ -0,0 +1,287 @@
+= 5) {
+ $timePassed = time() - $_SESSION['last_attempt_time'];
+ if ($timePassed < $lockoutTime) {
+ $remaining = ceil(($lockoutTime - $timePassed) / 60);
+ $error = "Te veel mislukte inlogpogingen. Probeer het over {$remaining} minuten opnieuw.";
+ } else {
+ // Reset na verloop van blokkade
+ $_SESSION['login_attempts'] = 0;
+ }
+}
+
+// Verwerk inlogverzoek
+if ($_SERVER['REQUEST_METHOD'] === 'POST' && empty($error)) {
+ $csrfToken = $_POST['csrf_token'] ?? '';
+ $username = trim($_POST['username'] ?? '');
+ $password = $_POST['password'] ?? '';
+
+ // Kleine vertraging tegen timing-aanvallen
+ usleep(200000);
+
+ if (!verify_csrf_token($csrfToken)) {
+ $error = 'Beveiligingstoken (CSRF) ongeldig of verlopen. Ververs de pagina.';
+ } else {
+ // Vergelijk gebruikersnaam hash (timing-safe) en wachtwoord via bcrypt
+ $userMatches = hash_equals(AUTH_USER_HASH, hash('sha256', strtolower($username)));
+ $passMatches = password_verify($password, AUTH_PASS_HASH);
+
+ if ($userMatches && $passMatches) {
+ // Sessie fixatie voorkomen via regeneratie
+ session_regenerate_id(true);
+
+ $_SESSION['wpc_auth'] = true;
+ $_SESSION['wpc_user_email'] = htmlspecialchars($username);
+ $_SESSION['wpc_last_activity'] = time();
+ $_SESSION['login_attempts'] = 0;
+
+ // Veilige doorverwijzing
+ $redirect = $_GET['redirect'] ?? 'index.php';
+ // Alleen relatieve redirects toestaan
+ if (empty($redirect) || strpos($redirect, '://') !== false || strpos($redirect, '//') === 0) {
+ $redirect = 'index.php';
+ }
+
+ header("Location: {$redirect}");
+ exit;
+ } else {
+ $_SESSION['login_attempts']++;
+ $_SESSION['last_attempt_time'] = time();
+ $attemptsLeft = max(0, 5 - $_SESSION['login_attempts']);
+ $error = "Ongeldige gebruikersnaam of wachtwoord. (Nog {$attemptsLeft} pogingen)";
+ }
+ }
+}
+
+$csrfToken = get_csrf_token();
+$logoutMessage = isset($_GET['logout']) ? 'U bent succesvol en veilig uitgelogd.' : '';
+?>
+
+
+
+
+
+ Web & PC Studio - Beveiligde Toegang
+
+
+
+
+
+
+
+
+
+
+
= htmlspecialchars($logoutMessage); ?>
+
+
+
+
= htmlspecialchars($error); ?>
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/logout.php b/logout.php
new file mode 100644
index 0000000..5a7b069
--- /dev/null
+++ b/logout.php
@@ -0,0 +1,10 @@
+
🌙 Thema
+
🚪 Uitloggen
- Git Live
+ server.webenpcstudio.nl