--- /dev/null
+ <?php
+
+ return array(
+ 'host' => 'localhost',
+ 'username' => 'fraggle',
+ 'password' => '$Love79!',
+ 'database' => 'bdVols',
+ 'actions' => array (
+ 'home',
+ 'login',
+ 'register',
+ 'booking',
+ 'search',
+ 'account'
+ )
+ );
+
+ /* return array(
+ 'host' => $_SERVER['dbHost'],
+ 'username' => $_SERVER['dbLogin'],
+ 'password' => $_SERVER['dbPass'],
+ 'database' => '$_SERVER['dbBd']'
+ ); */
+
+?>
--- /dev/null
+<div id="footer">
+ ©2018 - Piment Noir
+</div>
+</body>
+</html>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html>
+<head>
+<title>Air Polytech</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<link href="https://fonts.googleapis.com/css?family=Encode+Sans+Semi+Condensed" rel="stylesheet">
+<link rel="stylesheet" type="text/css" href="styles/airpolytech.css" />
+</head>
+<body>
+<div id="header">
+ <!-- Put headers stuff here -->
+ Bienvenue sur Air Polytech !
+</div>
--- /dev/null
+<?php
+include('header.html');
+function display_menu() {
+ switch ($page) {
+ case "home":
+ break;
+ case "register":
+ break;
+ }
+
+}
+?>
--- /dev/null
+<?php
+function home()
+{
+ global $configs;
+
+ $connection = new CustomDB($configs['host'], $configs['username'], $configs['password'], $configs['database']);
+ $requete = "SELECT NumCl, NomCl, CodePosteCl, VilleCl FROM CLIENTS";
+ $result = $connection->query($requete);
+ echo "<table border=1>\n";
+ echo "<tr><td>Code_CL</td><td>Nom</td><td>Rue</td><td>Ville</td></tr>\n";
+ while ($ligne = $result->fetch_row()) {
+ $code = htmlentities($ligne[0]);
+ $nom = htmlentities($ligne[1]);
+ $rue = htmlentities($ligne[2]);
+ $ville = htmlentities($ligne[3]);
+ echo "<tr><td>$code</td><td>$nom</td><td>$rue</td><td>$ville</td></tr>\n";
+ }
+ echo "</table>\n";
+ $result->close();
+ $connection->close();
+}
+
+home();
+
+?>
--- /dev/null
+<?php
+require('header.php');
+
+include('libs/db.php');
+/**
+ * Let's use an array as the list of tunables.
+ * Put in a variable the inclusion of this file:
+ * $config_var = include('config.php');
+ */
+$configs = include('config.php');
+
+/**
+ * [session_start start a unique session for the current browser client]
+ */
+session_start();
+
+if (!isset($page)) {
+ $page = "";
+}
+
+/**
+ * [valid_page validate if the current page is a valid site actions]
+ * @param [string] $page [the viewed page name]
+ * @return [string] [the valid matching action or the default action
+ * if the action name do not exist ]
+ */
+function valid_page($page_name)
+{
+ global $configs;
+
+ foreach ($configs['actions'] as $action) {
+ if ($page_name === $action) {
+ return $action;
+ // The actions list can't have duplicated entries
+ break;
+ } else {
+ return $configs['actions'][0];
+ }
+ }
+}
+
+function display_action($action_name)
+{
+ global $configs;
+
+ foreach ($configs['actions'] as $action) {
+ if ($action_name === $action) {
+ include("$action.php");
+ break;
+ } else {
+ echo "Action to display do not exist";
+ }
+ }
+}
+
+display_action(valid_page($page));
+
+session_destroy();
+
+require('footer.html');
+?>
--- /dev/null
+<?php
+
+/**
+ * [CustomDB description]
+ */
+class CustomDB
+{
+ private $connection;
+ public $connected;
+ private $current_pquery;
+ private $current_stmt;
+
+ /**
+ * [__construct description]
+ * @param [type] $host [description]
+ * @param [type] $username [description]
+ * @param [type] $password [description]
+ * @param [type] $dbname [description]
+ */
+ public function __construct($host, $username, $password, $dbname)
+ {
+ $connection = new mysqli($host, $username, $password, $dbname);
+ $this->connection = $connection;
+
+ if (!$this->connection->connect_errno) {
+ $this->connected = true;
+ } else {
+ die('Fail to connect to the RDBMS');
+ }
+
+ return $this->connection;
+ }
+
+ /**
+ * [close description]
+ * @return [type] [description]
+ */
+ public function close()
+ {
+ if ($this->connected && $this->connection->close()) {
+ $this->connected = false;
+ } else {
+ die('Fail to close the connection to the RDBMS');
+ }
+ }
+
+ /**
+ * [query description]
+ * @param [type] $sql_query [description]
+ * @return [type] [description]
+ */
+ public function query($sql_query)
+ {
+ if ($this->connected && !($query_result = $this->connection->query($sql_query))) {
+ echo "Fail to execute the SQL query : " . $sql_query;
+ }
+ return $query_result;
+ }
+
+ /**
+ * [prepare_query description]
+ * @param [type] $prepared_query [description]
+ * @return [type] [description]
+ */
+ public function prepare_query($prepared_query)
+ {
+ $this->current_pquery = $prepared_query;
+ if ($this->connected && !($this->current_stmt = $this->connection->prepare($this->current_pquery))) {
+ // Empty the currently stored prepared query in the failure case
+ $this->current_pquery = "";
+ echo "Fail to prepare SQL query : (" . $this->connection->errno . ") " . $this->connection->error . " - " . $this->current_pquery;
+ }
+ return $this->current_stmt;
+ }
+
+ /**
+ * [prepared_query_bind_param description]
+ * @param [type] $params [description]
+ * @return [type] [description]
+ */
+ public function prepared_query_bind_param(...$params)
+ {
+ $rt_val = $this->current_stmt->bind_param($params);
+ if (!$rt_val) {
+ echo "Fail to link parameters to SQL query : (" . $this->current_stmt->errno . ") " . $this->current_stmt->error . " - " . $this->current_pquery;
+ }
+ return $rt_val;
+ }
+
+ /**
+ * [run_prepared_query description]
+ * @return [type] [description]
+ */
+ public function run_prepared_query()
+ {
+ $rt_val = $this->current_stmt->execute();
+ if (!$rt_val) {
+ echo "Fail to execute SQL query : (" . $this->current_stmt->errno . ") " . $this->current_stmt->error . " - " . $this->current_pquery;
+ }
+ return $rt_val;
+ }
+
+ /**
+ * [close_prepared_query description]
+ * @return [type] [description]
+ */
+ public function close_prepared_query()
+ {
+ $rt_val = $this->current_stmt->close();
+ if (!$rt_val) {
+ echo "Fail to close SQL query : (" . $this->current_stmt->errno . ") " . $this->current_stmt->error . " - " . $this->current_pquery;
+ }
+ return $rt_val;
+ }
+}
+?>
--- /dev/null
+body {
+ background-color: black;
+ color: #eeeeee;
+ font-family: 'Encode Sans Semi Condensed', Arial, Helvetica, Verdana, sans-serif;
+ display: block;
+ margin: 8px;
+}
+
+#footer {
+ text-align: center;
+}
+
+#header {
+ font-size: 44px;
+ text-align: center;
+}