load(); $db = new PDO( "mysql:host={$_ENV['DB_HOST']};dbname={$_ENV['DB_NAME']};charset=utf8mb4", $_ENV['DB_USER'], $_ENV['DB_PASS'], [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION] ); $errors = []; $success = []; // Run migration try { $sql = file_get_contents(__DIR__ . '/migrations/003_add_authentication.sql'); // Split by semicolons and execute each statement $statements = array_filter(array_map('trim', explode(';', $sql))); foreach ($statements as $statement) { if (!empty($statement)) { try { $db->exec($statement); } catch (PDOException $e) { // Ignore duplicate entry errors (tables already exist) if ($e->getCode() != '42S01' && $e->getCode() != 23000) { $errors[] = "SQL Error: " . $e->getMessage(); } } } } $success[] = "Database migration completed"; } catch (Exception $e) { $errors[] = "Migration failed: " . $e->getMessage(); } // Create admin user with proper password hash $adminPassword = 'Admin@2026!'; $adminHash = password_hash($adminPassword, PASSWORD_BCRYPT); try { $stmt = $db->prepare(" INSERT INTO users (username, email, password_hash, role, is_active) VALUES ('admin', 'admin@telvero.nl', ?, 'admin', 1) ON DUPLICATE KEY UPDATE password_hash = VALUES(password_hash) "); $stmt->execute([$adminHash]); $success[] = "Admin user created/updated (username: admin, password: {$adminPassword})"; } catch (Exception $e) { $errors[] = "Failed to create admin user: " . $e->getMessage(); } // Create guest user with proper password hash $guestPassword = 'Guest@2026!'; $guestHash = password_hash($guestPassword, PASSWORD_BCRYPT); try { $stmt = $db->prepare(" INSERT INTO users (username, email, password_hash, role, is_active) VALUES ('guest', 'guest@telvero.nl', ?, 'guest', 1) ON DUPLICATE KEY UPDATE password_hash = VALUES(password_hash) "); $stmt->execute([$guestHash]); $success[] = "Guest user created/updated (username: guest, password: {$guestPassword})"; } catch (Exception $e) { $errors[] = "Failed to create guest user: " . $e->getMessage(); } // Create lock file if (empty($errors)) { file_put_contents($lockFile, date('Y-m-d H:i:s')); } // Output results $isCli = php_sapi_name() === 'cli'; if ($isCli) { echo "\n=== Authentication Setup ===\n\n"; if (!empty($success)) { echo "✓ SUCCESS:\n"; foreach ($success as $msg) { echo " - {$msg}\n"; } } if (!empty($errors)) { echo "\n✗ ERRORS:\n"; foreach ($errors as $msg) { echo " - {$msg}\n"; } } echo "\n=== Default Credentials ===\n"; echo "Admin: admin / Admin@2026!\n"; echo "Guest: guest / Guest@2026!\n"; echo "\n⚠️ IMPORTANT: Change these passwords after first login!\n"; echo "\n✓ Setup complete. This script can now be deleted.\n\n"; } else { ?> Auth Setup - Telvero Talpa

Authentication Setup

✓ Succesvol
✗ Fouten
⚠️ Standaard Inloggegevens
GebruikerWachtwoordRol
admin Admin@2026! Admin
guest Guest@2026! Guest
Belangrijk: Wijzig deze wachtwoorden na de eerste login!