Files
MSCS535_Assignment14/public/index.php
Carlos Gutierrez dea56a7e80 Complete mock secure web application with:
- User registration and login with CSRF protection
- SQL injection prevention and XSS protection
- Real-time form validation
- Password strength requirements
- Show/hide password toggle
- Modern dark theme UI
- Routes for /login, /register, /home, /logout
- API endpoints for CRUD operations
- Prettier and ESLint configure
2026-02-21 18:20:41 -05:00

36 lines
791 B
PHP

<?php
require_once __DIR__ . '/../config/database.php';
$requestUri = $_SERVER['REQUEST_URI'];
$path = rtrim(parse_url($requestUri, PHP_URL_PATH), '/') ?: '/';
if (!empty($_SERVER['QUERY_STRING'])) {
header('Location: ' . $path);
exit;
}
if (strpos($path, '/api/') === 0) {
require __DIR__ . '/../api/index.php';
exit;
}
if ($path === '/') {
header('Location: /login');
exit;
}
if ($path === '/login') {
require __DIR__ . '/views/login.php';
} elseif ($path === '/register') {
require __DIR__ . '/views/register.php';
} elseif ($path === '/home') {
require __DIR__ . '/views/home.php';
} elseif ($path === '/logout') {
session_destroy();
header('Location: /login');
exit;
} else {
http_response_code(404);
echo '404 Not Found';
}