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 | ||
265d1374 JB |
17 | //$page = filter_input(INPUT_GET, $_GET['page'], FILTER_SANITIZE_URL); |
18 | $page = $_GET['page']; | |
19 | ||
fb6aedc2 JB |
20 | if (!isset($page)) { |
21 | $page = ""; | |
22 | } | |
23 | ||
24 | /** | |
25 | * [valid_page validate if the current page is a valid site actions] | |
26 | * @param [string] $page [the viewed page name] | |
27 | * @return [string] [the valid matching action or the default action | |
28 | * if the action name do not exist ] | |
29 | */ | |
30 | function valid_page($page_name) | |
31 | { | |
32 | global $configs; | |
33 | ||
34 | foreach ($configs['actions'] as $action) { | |
265d1374 | 35 | if (strcmp($page_name, $action) === 0) { |
fb6aedc2 | 36 | // The actions list can't have duplicated entries |
265d1374 | 37 | return $action; |
fb6aedc2 JB |
38 | } |
39 | } | |
265d1374 JB |
40 | // Return the default action |
41 | return $configs['actions'][0]; | |
fb6aedc2 JB |
42 | } |
43 | ||
44 | function display_action($action_name) | |
45 | { | |
46 | global $configs; | |
47 | ||
265d1374 | 48 | $found_action = false; |
fb6aedc2 | 49 | foreach ($configs['actions'] as $action) { |
265d1374 | 50 | if (strcmp($action_name, $action) === 0) { |
fb6aedc2 | 51 | include("$action.php"); |
265d1374 | 52 | $found_action = true; |
fb6aedc2 | 53 | break; |
fb6aedc2 JB |
54 | } |
55 | } | |
265d1374 JB |
56 | if (!$found_action) { |
57 | echo "Action to display do not exist"; | |
58 | } | |
fb6aedc2 JB |
59 | } |
60 | ||
265d1374 JB |
61 | $action = valid_page($page); |
62 | display_action($action); | |
fb6aedc2 JB |
63 | |
64 | session_destroy(); | |
65 | ||
66 | require('footer.html'); | |
67 | ?> |