/
index.php
executable file
·52 lines (39 loc) · 1.8 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
<?php
//include object in session BEFORE initializing the session
set_include_path(get_include_path()
. PATH_SEPARATOR . 'application/conf/'
. PATH_SEPARATOR . 'application/class/'
. PATH_SEPARATOR . 'application/library/'
. PATH_SEPARATOR . 'application/mvc/models/autoLoadedClass/'
);
require_once('AutoLoader.php');
session_start();
setlocale(LC_TIME,"fr_FR.utf8") ;
header('Content-type: text/html; charset=UTF-8');
//test d'admin
if ($_POST["password"] != null && $_POST["login"] != null) {
$xml = simplexml_load_file("application/conf/admin.xml");
if ($_POST["password"] == $xml->Password["value"] && $_POST["login"] == $xml->Login["value"]) {
$_SESSION["user"]->setRole("admin");
} else {
$_SESSION["user"]->setRole("guest");
}
}
$tplEngine = new SimpleTemplate();
//initialize ACL
$_SESSION["user"] = ($_SESSION["user"] == null) ? new User() : $_SESSION["user"];
$tplEngine->initACL( "application/conf/ACL.xml", $_SESSION["user"]->getRole() );
//get MVC map
$pages = PageLoader::loadFromXML("application/conf/MVCMap.xml") ;
if (isset($_REQUEST["displayPage"]) && $_REQUEST["displayPage"] != "" ) {
$displayPage = ( !is_null($pages[strtolower($_REQUEST["displayPage"])]) ) ? $pages[strtolower($_REQUEST["displayPage"])] : $pages["404"] ;
define("MODEL", $displayPage["Model"]);
define("VIEW", $displayPage["View"]);
$page = $tplEngine->getPage($displayPage["Model"], $displayPage["View"]);
} else {
define("MODEL", $pages['home']["Model"]);
define("VIEW", $pages['home']["View"]);
$page = $tplEngine->getPage($pages['home']["Model"], $pages['home']["View"]);
}
echo $page;
?>