This repository has been archived by the owner on Dec 28, 2018. It is now read-only.
/
index.php
111 lines (92 loc) · 2.32 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
/**
* @package ifips.framework
*/
// Control access FROM index ONLY
define('_INDEX', true);
// Require configuration
require('config.php');
// Require libraries
for($i=0; $i<count($GLOBALS['libraries']); $i++)
{
if( !file_exists(_LIB_DIR . $GLOBALS['libraries'][$i]) )
{
throw new FileNotFoundException('Library '.$GLOBALS['libraries'][$i]);
}
require(_LIB_DIR . $GLOBALS['libraries'][$i]);
}
// Activate Assertions if mode DEBUG
assert_options(ASSERT_ACTIVE, _DEBUG);
//assert_options(ASSERT_QUIET_EVAL, TRUE);
assert_options(ASSERT_BAIL, TRUE);
date_default_timezone_set('Europe/Paris');
set_error_handler('Tools::handlerError');
assert_options(ASSERT_CALLBACK, 'Tools::handlerAsserts');
Tools::clean_gpc();
if( _DEBUG )
F::i('Benchmark')->addStep('init');
try
{
if( !_DEBUG )
ob_start();
// What the visitor want to do ?
$action = (isset($_GET['action']) && !empty($_GET['action'])) ? $_GET['action'] : _DEFAULT_ACTION;
// Initiate Cookies
Factory::getInstance('Cookie', _COOKIE_NAME);
// Initiate Session
Factory::getInstance('Session');
// Initiate Lang
Factory::getInstance('Lang');
// What Params ? Priority to the requested
$params = $_GET + $_POST;
try
{
// Control !
$output = Controller::check($action, $params);
}
catch(FileNotFoundException $e)
{
// 404
header('HTTP/1.1 404 File Not Found');
exit;
}
F::i('Session')->close();
$output = Tools::parseOutput($output);
if( !_DEBUG )
ob_end_clean();
}
catch(DatabaseException $e)
{
Record::note($e->__toString());
die('DB Error : '.$e->getMessage());
}
catch(SessionException $e)
{
// Hacking attempt
Record::note($e->__toString());
die('Hacking Attempt : '.$e->getMessage());
}
catch(ControllerException $e)
{
// Bad Access
Record::note($e->__toString());
die('Bad Access : '.$e->getMessage());
}
catch(ModelException $e)
{
// Error while generating
Record::note($e->__toString());
die('Error while generating : '.$e->getMessage());
}
catch(ViewException $e)
{
// Error while displaying
Record::note($e->__toString());
die('Error while displaying : '.$e->getMessage());
}
catch(Exception $e)
{
// Unexpected Exception so STOP !
trigger_error('Unexcepted Exception : '.$e->__toString(), E_USER_ERROR);
}
echo($output);