-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
70 lines (57 loc) · 1.95 KB
/
bootstrap.php
File metadata and controls
70 lines (57 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
require_once __DIR__ . '/vendor/autoload.php';
use UEDF\Config\Config;
use UEDF\Core\Router;
// Initialize config
$config = Config::getInstance();
// Set error reporting based on environment
if ($config->get('app.debug')) {
error_reporting(E_ALL);
ini_set('display_errors', 1);
} else {
error_reporting(0);
ini_set('display_errors', 0);
}
// Start session
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
// Initialize router
$router = new Router();
// Define routes
$router->add('/', 'DashboardController', 'index', 'GET');
$router->add('/dashboard', 'DashboardController', 'index', 'GET');
$router->add('/login', 'AuthController', 'login', 'GET');
$router->add('/login', 'AuthController', 'authenticate', 'POST');
$router->add('/logout', 'AuthController', 'logout', 'GET');
// Drone routes
$router->add('/drones', 'DroneController', 'index', 'GET');
$router->add('/drones/{id}', 'DroneController', 'show', 'GET');
$router->add('/api/drones', 'DroneController', 'apiStatus', 'GET');
// Threat routes
$router->add('/threats', 'ThreatController', 'index', 'GET');
$router->add('/threats/{id}', 'ThreatController', 'show', 'GET');
// Analytics
$router->add('/analytics', 'AnalyticsController', 'index', 'GET');
$router->add('/reports', 'ReportController', 'index', 'GET');
// System
$router->add('/system/monitor', 'MonitorController', 'index', 'GET');
$router->add('/system/audit', 'AuditController', 'index', 'GET');
// Debug route (remove in production)
if ($config->get('app.debug')) {
$router->add('/debug', function() {
phpinfo();
}, 'GET');
}
// Dispatch the request
try {
$router->dispatch($_SERVER['REQUEST_URI'], $_SERVER['REQUEST_METHOD']);
} catch (Exception $e) {
if ($config->get('app.debug')) {
echo "<h1>Router Error</h1>";
echo "<pre>" . $e->getMessage() . "</pre>";
} else {
header("HTTP/1.0 500 Internal Server Error");
echo "500 - Internal Server Error";
}
}