125f62049964198da07139d78e5286c4990abb5b
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');
10 $configs = include('config.php');
13 * [session_start start a unique session for the current browser client]
17 $page = filter_input(INPUT_GET
, 'page', FILTER_SANITIZE_URL
);
24 $form = filter_input(INPUT_POST
, 'form', FILTER_SANITIZE_URL
);
32 * [validate_url_action validate if the current page is a valid site actions]
33 * @param [string] $page [the viewed page name]
34 * @return [string] [the valid matching action or the default action
35 * if the action name do not exist ]
37 function validate_url_action($action_name)
41 foreach ($configs['actions'] as $action) {
42 if (strcmp($action_name, $action) === 0) {
43 // The actions list can't have duplicated entries
47 // Return the default action
48 return $configs['actions'][0];
51 function get_action_type() {
52 global $page, $form, $isPage, $isForm;
54 if ($isPage && !$isForm) {
56 } elseif ($isForm && !$isPage) {
58 } elseif (!$isPage && !$isForm){
65 function display_action($action_name)
67 global $configs, $isPage, $isForm;
69 $found_action = false;
70 foreach ($configs['actions'] as $action) {
71 if (strcmp($action_name, $action) === 0) {
72 if (get_action_type() === "page" ||
get_action_type() === "empty") {
73 include($action . ".php");
74 } elseif (get_action_type() === "form") {
75 include("form" . $action . ".php");
77 echo "Impossible error";
84 echo "Action to display do not exist";
88 function get_url_action() {
89 global $page, $form, $isPage, $isForm;
91 if (get_action_type() === "page") {
93 } elseif (get_action_type() === "form") {
95 } elseif (get_action_type() === "empty") {
97 } elseif (get_action_type() === "unknown") {
98 die('Cannot get a valid action from URL parameters');
102 $url_action = get_url_action();
103 $action = validate_url_action($url_action);
104 display_action($action);
108 require('footer.html');