-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
37 lines (29 loc) · 837 Bytes
/
index.php
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
<?php
require_once 'vendor/autoload.php';
require_once 'src/utils.php';
use App\Model\Database;
use App\Model\Searcher;
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();
$action = $_GET['action'] ?? null;
$headless = $_GET['headless'] ?? false;
$pdo = Database::getPDO();
$searcher = new Searcher($pdo);
$q = $_GET['q'] ?? null;
session_start();
if (!$headless)
require "src/Views/header.php";
if (file_exists("src/Controllers/$action.php"))
try {
require "src/Controllers/$action.php";
} catch (Exception $e) {
require "src/Views/errors/500.php";
if ($_SERVER['HOST'] === 'localhost')
dd($e);
}
elseif ($action === null)
require "src/Controllers/home.php";
else
require "src/Views/errors/404.php";
if (!$headless)
require "src/Views/footer.php";