repositories
/
Project_webapp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Change the color scheme to be more IHM rules compliant.
[Project_webapp.git]
/
index.php
diff --git
a/index.php
b/index.php
index 9d22f3e15361790b8c2fe89561b28cc88ebd0cf2..33db471dab67fc5cf393608b7f00565ffa2f8f09 100644
(file)
--- a/
index.php
+++ b/
index.php
@@
-1,56
+1,63
@@
<?php
<?php
-require('header.php');
+require('
includes/
header.php');
include('lib/db.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);
$page = filter_input(INPUT_GET, 'page', FILTER_SANITIZE_URL);
-$is
P
age = true;
+$is
_p
age = true;
if (!isset($page)) {
if (!isset($page)) {
- $is
P
age = false;
+ $is
_p
age = false;
$page = "";
}
/**
$page = "";
}
/**
- * form MUST have an hidden field named 'form' to enable proper routing
+ * form MUST have an hidden field named 'form' to enable proper routing
here
*/
$form = filter_input(INPUT_POST, 'form', FILTER_SANITIZE_URL);
*/
$form = filter_input(INPUT_POST, 'form', FILTER_SANITIZE_URL);
-$is
F
orm = true;
+$is
_f
orm = true;
if (!isset($form)) {
if (!isset($form)) {
- $is
F
orm = false;
+ $is
_f
orm = false;
$form = "";
}
$form = "";
}
+//var_dump($_SESSION);
+
+/**
+ * [get_action_type description]
+ * @return [type] [description]
+ */
function get_action_type() {
function get_action_type() {
- global $is
Page, $isF
orm;
+ global $is
_page, $is_f
orm;
- if ($is
Page && !$isF
orm && is_get_request()) {
+ if ($is
_page && !$is_f
orm && is_get_request()) {
return "page";
return "page";
- } elseif ($is
Form && !$isP
age && is_post_request()) {
+ } elseif ($is
_form && !$is_p
age && is_post_request()) {
return "form";
return "form";
- } elseif (!$is
Page && !$isF
orm && is_get_request()){
+ } elseif (!$is
_page && !$is_f
orm && is_get_request()){
return "empty";
} else {
return "unknown";
}
}
return "empty";
} else {
return "unknown";
}
}
-function get_url_action() {
+/**
+ * [get_url_action description]
+ * @param [type] $action_type [description]
+ * @return [type] [description]
+ */
+function get_url_action($action_type) {
global $page, $form;
global $page, $form;
- if (
get_action_type()
=== "page") {
+ if (
$action_type
=== "page") {
return $page;
return $page;
- } elseif (
get_action_type()
=== "form") {
+ } elseif (
$action_type
=== "form") {
return $form;
return $form;
- } elseif (
get_action_type()
=== "empty") {
+ } elseif (
$action_type
=== "empty") {
return "";
return "";
- } elseif (
get_action_type()
=== "unknown") {
- die('Cannot get a valid action from URL parameters');
+ } elseif (
$action_type
=== "unknown") {
+ die('Cannot get a valid action from URL parameters
or form fields.
');
}
}
}
}
@@
-74,36
+81,46
@@
function validate_url_action($action_name)
return $configs['actions'][0];
}
return $configs['actions'][0];
}
-function display_action($action_name)
+/**
+ * [display_action description]
+ * @param [type] $action_name [description]
+ * @param [type] $action_type [description]
+ * @return [type] [description]
+ */
+function display_action($action_name, $action_type)
{
{
- global $configs, $isPage, $isForm;
+ global $configs;
+ $includes_rpath = 'includes';
$found_action = false;
foreach ($configs['actions'] as $action) {
if (strcmp($action_name, $action) === 0) {
// HTTP GET case
$found_action = false;
foreach ($configs['actions'] as $action) {
if (strcmp($action_name, $action) === 0) {
// HTTP GET case
- if (
get_action_type() === "page" || get_action_type()
=== "empty") {
- include($action . ".php");
+ if (
$action_type === "page" || $action_type
=== "empty") {
+ include($
includes_rpath . "/" . $
action . ".php");
// HTTP POST case
// HTTP POST case
- } elseif (
get_action_type()
=== "form") {
- include(
"
form" . $action . ".php");
+ } elseif (
$action_type
=== "form") {
+ include(
$includes_rpath . "/
form" . $action . ".php");
} else {
} else {
- echo "Unknown error in action displaying";
+ echo "Unknown error in action displaying
. <br>
";
}
$found_action = true;
break;
}
}
if (!$found_action) {
}
$found_action = true;
break;
}
}
if (!$found_action) {
- echo "Action to display do not exist";
+ echo "Action to display do not exist
. <br>
";
}
}
}
}
-$url_action = get_url_action();
+$action_type = get_action_type();
+$url_action = get_url_action($action_type);
$action = validate_url_action($url_action);
$action = validate_url_action($url_action);
-display_action($action);
+display_action($action, $action_type);
+
+$connection->close();
-session_
destroy
();
+session_
write_close
();
-require('footer.html');
+require('
includes/
footer.html');
?>
?>