X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=index.php;h=5c12c9e0477395dd88a9d26353b096dcd9e58440;hb=22f1dc6402dbc9a9c5d2ed2f17ef54044d35ec2a;hp=8bceb64bb6702c58fa45b66bb7f4ea744d6415d5;hpb=b5f60f89589412e18b51326378ab13b9a4fa0f19;p=Project_webapp.git diff --git a/index.php b/index.php index 8bceb64..5c12c9e 100644 --- a/index.php +++ b/index.php @@ -2,19 +2,13 @@ require('includes/header.php'); include('lib/db.php'); -include('lib/utils.php'); - -/** - * [session_start start a unique session for the current browser client] - */ -session_start(); $connection = new CustomDB($configs['host'], $configs['username'], $configs['password'], $configs['database']); $page = filter_input(INPUT_GET, 'page', FILTER_SANITIZE_URL); -$isPage = true; +$is_page = true; if (!isset($page)) { - $isPage = false; + $is_page = false; $page = ""; } @@ -22,20 +16,22 @@ if (!isset($page)) { * form MUST have an hidden field named 'form' to enable proper routing */ $form = filter_input(INPUT_POST, 'form', FILTER_SANITIZE_URL); -$isForm = true; +$is_form = true; if (!isset($form)) { - $isForm = false; + $is_form = false; $form = ""; } +//var_dump($_SESSION); + function get_action_type() { - global $isPage, $isForm; + global $is_page, $is_form; - if ($isPage && !$isForm && is_get_request()) { + if ($is_page && !$is_form && is_get_request()) { return "page"; - } elseif ($isForm && !$isPage && is_post_request()) { + } elseif ($is_form && !$is_page && is_post_request()) { return "form"; - } elseif (!$isPage && !$isForm && is_get_request()){ + } elseif (!$is_page && !$is_form && is_get_request()){ return "empty"; } else { return "unknown"; @@ -52,7 +48,7 @@ function get_url_action($action_type) { } elseif ($action_type === "empty") { return ""; } elseif ($action_type === "unknown") { - die('Cannot get a valid action from URL parameters or form fields'); + die('Cannot get a valid action from URL parameters or form fields.'); } } @@ -91,19 +87,17 @@ function display_action($action_name, $action_type) } elseif ($action_type === "form") { include($includes_rpath . "/form" . $action . ".php"); } else { - echo "Unknown error in action displaying
"; + echo "Unknown error in action displaying.
"; } $found_action = true; break; } } if (!$found_action) { - echo "Action to display do not exist
"; + echo "Action to display do not exist.
"; } } -//password_hash('12345678', PASSWORD_DEFAULT); - $action_type = get_action_type(); $url_action = get_url_action($action_type); $action = validate_url_action($url_action); @@ -111,7 +105,7 @@ display_action($action, $action_type); $connection->close(); -session_destroy(); +session_write_close(); require('includes/footer.html'); ?>