Initial commit of the HUGo project web application.
[Project_webapp.git] / index.php
CommitLineData
fb6aedc2
JB
1<?php
2require('header.php');
3
4include('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 */
15session_start();
16
17if (!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 */
27function 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
42function 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
56display_action(valid_page($page));
57
58session_destroy();
59
60require('footer.html');
61?>