-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
46 lines (37 loc) · 1.11 KB
/
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
38
39
40
41
42
43
44
45
46
<?php
// Fetch framework.
$funmos = require('f3/lib/base.php');
// Fetch configuration files.
require('config/config.php');
require('config/db.php');
// Fetch routes.
require('app/routes/user.php');
require('app/routes/admin.php');
ErrorHandler::instance($funmos);
// Setup DB connection.
$db_type = $funmos->exists('db.type') ? strtoupper($funmos->get('db.type')) : "";
if (strlen(trim($db_type)) > 0) {
switch ($db_type) {
case 'MYSQL':
$db = new \DB\SQL('mysql:host=' . $funmos->get('db.host') .
';port=' . $funmos->get('db.port') .
';dbname=' . $funmos->get('db.name'),
$funmos->get('db.user'),
$funmos->get('db.pass'));
break;
}
}
if (isset($db)) {
$funmos->set('DB', $db);
} else {
echo "Database could not be set. Please check your settings.";
}
// Create a new session.
if ($funmos->get('DB')) {
$session = new \DB\SQL\Session($funmos->get('DB'));
// Save token for CSRF prevention.
$funmos->csrf = $session->csrf();
$funmos->copy('csrf', 'SESSION.csrf');
}
// Run framework.
$funmos->run();