-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.php
84 lines (62 loc) · 1.53 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/*
*
*
* Front Controller
*
*
*/
/*
* Lancement d'une session
*/
session_start();
/*
* Load Dependencies
*/
require_once "config.php";
// composer vendor loading (for twig)
require_once 'vendor/autoload.php';
// Initialize twig templating system - !(PRODUCT) => mod dev
$loader = new \Twig\Loader\FilesystemLoader('view/');
$twig = new \Twig\Environment($loader, [
'debug' => !(PRODUCT),
/* 'cache' => 'E:/WEB/PHP/CrudOO/cache/', */
]);
// twig extension for text
$twig->addExtension(new Twig_Extensions_Extension_Text());
// twig extension for debug
$twig->addExtension(new \Twig\Extension\DebugExtension());
/*
* create class autoload - find class into model's folder
*/
spl_autoload_register(function ($class) {
require_once 'model/' . $class . '.php';
});
// connexion to our DB
try {
$connexion = new MyPDO(
'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';port=' . DB_PORT . ';charset=' . DB_CHARSET,
DB_LOGIN,
DB_PWD,
null,
PRODUCT);
} catch (PDOException $e) {
echo $e->getMessage();
die();
}
// create common's Managers
$thesectionM = new thesectionManager($connexion);
$thestudentM = new thestudentManager($connexion);
$theuserM = new theuserManager($connexion);
// we're connected
if (isset($_SESSION['myKey']) && $_SESSION['myKey'] == session_id()) {
/*
* admin
*/
require_once "controller/adminController.php";
} else {
/*
* public
*/
require_once "controller/publicController.php";
}