Commit | Line | Data |
---|---|---|
fb6aedc2 JB |
1 | <?php |
2 | require('header.php'); | |
3 | ||
4 | include('libs/db.php'); | |
5 | /** | |
6 | * Let's use an array as the list of tunables. | |
7 | * Put in a variable the inclusion of this file: | |
8 | * $config_var = include('config.php'); | |
9 | */ | |
10 | $configs = include('config.php'); | |
11 | ||
12 | /** | |
13 | * [session_start start a unique session for the current browser client] | |
14 | */ | |
15 | session_start(); | |
16 | ||
17 | if (!isset($page)) { | |
18 | $page = ""; | |
19 | } | |
20 | ||
21 | /** | |
22 | * [valid_page validate if the current page is a valid site actions] | |
23 | * @param [string] $page [the viewed page name] | |
24 | * @return [string] [the valid matching action or the default action | |
25 | * if the action name do not exist ] | |
26 | */ | |
27 | function valid_page($page_name) | |
28 | { | |
29 | global $configs; | |
30 | ||
31 | foreach ($configs['actions'] as $action) { | |
32 | if ($page_name === $action) { | |
33 | return $action; | |
34 | // The actions list can't have duplicated entries | |
35 | break; | |
36 | } else { | |
37 | return $configs['actions'][0]; | |
38 | } | |
39 | } | |
40 | } | |
41 | ||
42 | function display_action($action_name) | |
43 | { | |
44 | global $configs; | |
45 | ||
46 | foreach ($configs['actions'] as $action) { | |
47 | if ($action_name === $action) { | |
48 | include("$action.php"); | |
49 | break; | |
50 | } else { | |
51 | echo "Action to display do not exist"; | |
52 | } | |
53 | } | |
54 | } | |
55 | ||
56 | display_action(valid_page($page)); | |
57 | ||
58 | session_destroy(); | |
59 | ||
60 | require('footer.html'); | |
61 | ?> |