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
This commit is contained in:
35
public/index.php
Normal file
35
public/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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';
|
||||
}
|
||||
Reference in New Issue
Block a user