This commit is contained in:
raphael.palaffre 2019-04-20 23:29:27 +02:00
commit 4f610b9138
13 changed files with 888 additions and 0 deletions

BIN
.DS_Store vendored

Binary file not shown.

BIN
WEB/.DS_Store vendored Normal file

Binary file not shown.

18
WEB/connectionBD.php Normal file
View File

@ -0,0 +1,18 @@
<?php
/**
* Created by PhpStorm.
* User: REMI
* Date: 16/04/2019
* Time: 14:46
*/
function connexionBD(){
$host = "localhost";
$dbname = "projet";
$user = "utilisateur";
$pass = "-stri-";
$db = pg_connect("host=$host port=5432 dbname=$dbname user=$user password=$pass") or die("Erreur lors de la connexion à la base de données.");
return $db;
}

368
WEB/index.html Executable file
View File

@ -0,0 +1,368 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Apache2 Debian Default Page: It works</title>
<style type="text/css" media="screen">
* {
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
}
body, html {
padding: 3px 3px 3px 3px;
background-color: #D8DBE2;
font-family: Verdana, sans-serif;
font-size: 11pt;
text-align: center;
}
div.main_page {
position: relative;
display: table;
width: 800px;
margin-bottom: 3px;
margin-left: auto;
margin-right: auto;
padding: 0px 0px 0px 0px;
border-width: 2px;
border-color: #212738;
border-style: solid;
background-color: #FFFFFF;
text-align: center;
}
div.page_header {
height: 99px;
width: 100%;
background-color: #F5F6F7;
}
div.page_header span {
margin: 15px 0px 0px 50px;
font-size: 180%;
font-weight: bold;
}
div.page_header img {
margin: 3px 0px 0px 40px;
border: 0px 0px 0px;
}
div.table_of_contents {
clear: left;
min-width: 200px;
margin: 3px 3px 3px 3px;
background-color: #FFFFFF;
text-align: left;
}
div.table_of_contents_item {
clear: left;
width: 100%;
margin: 4px 0px 0px 0px;
background-color: #FFFFFF;
color: #000000;
text-align: left;
}
div.table_of_contents_item a {
margin: 6px 0px 0px 6px;
}
div.content_section {
margin: 3px 3px 3px 3px;
background-color: #FFFFFF;
text-align: left;
}
div.content_section_text {
padding: 4px 8px 4px 8px;
color: #000000;
font-size: 100%;
}
div.content_section_text pre {
margin: 8px 0px 8px 0px;
padding: 8px 8px 8px 8px;
border-width: 1px;
border-style: dotted;
border-color: #000000;
background-color: #F5F6F7;
font-style: italic;
}
div.content_section_text p {
margin-bottom: 6px;
}
div.content_section_text ul, div.content_section_text li {
padding: 4px 8px 4px 16px;
}
div.section_header {
padding: 3px 6px 3px 6px;
background-color: #8E9CB2;
color: #FFFFFF;
font-weight: bold;
font-size: 112%;
text-align: center;
}
div.section_header_red {
background-color: #CD214F;
}
div.section_header_grey {
background-color: #9F9386;
}
.floating_element {
position: relative;
float: left;
}
div.table_of_contents_item a,
div.content_section_text a {
text-decoration: none;
font-weight: bold;
}
div.table_of_contents_item a:link,
div.table_of_contents_item a:visited,
div.table_of_contents_item a:active {
color: #000000;
}
div.table_of_contents_item a:hover {
background-color: #000000;
color: #FFFFFF;
}
div.content_section_text a:link,
div.content_section_text a:visited,
div.content_section_text a:active {
background-color: #DCDFE6;
color: #000000;
}
div.content_section_text a:hover {
background-color: #000000;
color: #DCDFE6;
}
div.validator {
}
</style>
</head>
<body>
<div class="main_page">
<div class="page_header floating_element">
<img src="/icons/openlogo-75.png" alt="Debian Logo" class="floating_element"/>
<span class="floating_element">
Apache2 Debian Default Page
</span>
</div>
<!-- <div class="table_of_contents floating_element">
<div class="section_header section_header_grey">
TABLE OF CONTENTS
</div>
<div class="table_of_contents_item floating_element">
<a href="#about">About</a>
</div>
<div class="table_of_contents_item floating_element">
<a href="#changes">Changes</a>
</div>
<div class="table_of_contents_item floating_element">
<a href="#scope">Scope</a>
</div>
<div class="table_of_contents_item floating_element">
<a href="#files">Config files</a>
</div>
</div>
-->
<div class="content_section floating_element">
<div class="section_header section_header_red">
<div id="about"></div>
It works!
</div>
<div class="content_section_text">
<p>
This is the default welcome page used to test the correct
operation of the Apache2 server after installation on Debian systems.
If you can read this page, it means that the Apache HTTP server installed at
this site is working properly. You should <b>replace this file</b> (located at
<tt>/var/www/html/index.html</tt>) before continuing to operate your HTTP server.
</p>
<p>
If you are a normal user of this web site and don't know what this page is
about, this probably means that the site is currently unavailable due to
maintenance.
If the problem persists, please contact the site's administrator.
</p>
</div>
<div class="section_header">
<div id="changes"></div>
Configuration Overview
</div>
<div class="content_section_text">
<p>
Debian's Apache2 default configuration is different from the
upstream default configuration, and split into several files optimized for
interaction with Debian tools. The configuration system is
<b>fully documented in
/usr/share/doc/apache2/README.Debian.gz</b>. Refer to this for the full
documentation. Documentation for the web server itself can be
found by accessing the <a href="/manual">manual</a> if the <tt>apache2-doc</tt>
package was installed on this server.
</p>
<p>
The configuration layout for an Apache2 web server installation on Debian systems is as follows:
</p>
<pre>
/etc/apache2/
|-- apache2.conf
| `-- ports.conf
|-- mods-enabled
| |-- *.load
| `-- *.conf
|-- conf-enabled
| `-- *.conf
|-- sites-enabled
| `-- *.conf
</pre>
<ul>
<li>
<tt>apache2.conf</tt> is the main configuration
file. It puts the pieces together by including all remaining configuration
files when starting up the web server.
</li>
<li>
<tt>ports.conf</tt> is always included from the
main configuration file. It is used to determine the listening ports for
incoming connections, and this file can be customized anytime.
</li>
<li>
Configuration files in the <tt>mods-enabled/</tt>,
<tt>conf-enabled/</tt> and <tt>sites-enabled/</tt> directories contain
particular configuration snippets which manage modules, global configuration
fragments, or virtual host configurations, respectively.
</li>
<li>
They are activated by symlinking available
configuration files from their respective
*-available/ counterparts. These should be managed
by using our helpers
<tt>
a2enmod,
a2dismod,
</tt>
<tt>
a2ensite,
a2dissite,
</tt>
and
<tt>
a2enconf,
a2disconf
</tt>. See their respective man pages for detailed information.
</li>
<li>
The binary is called apache2. Due to the use of
environment variables, in the default configuration, apache2 needs to be
started/stopped with <tt>/etc/init.d/apache2</tt> or <tt>apache2ctl</tt>.
<b>Calling <tt>/usr/bin/apache2</tt> directly will not work</b> with the
default configuration.
</li>
</ul>
</div>
<div class="section_header">
<div id="docroot"></div>
Document Roots
</div>
<div class="content_section_text">
<p>
By default, Debian does not allow access through the web browser to
<em>any</em> file apart of those located in <tt>/var/www</tt>,
<a href="http://httpd.apache.org/docs/2.4/mod/mod_userdir.html" rel="nofollow">public_html</a>
directories (when enabled) and <tt>/usr/share</tt> (for web
applications). If your site is using a web document root
located elsewhere (such as in <tt>/srv</tt>) you may need to whitelist your
document root directory in <tt>/etc/apache2/apache2.conf</tt>.
</p>
<p>
The default Debian document root is <tt>/var/www/html</tt>. You
can make your own virtual hosts under /var/www. This is different
to previous releases which provides better security out of the box.
</p>
</div>
<div class="section_header">
<div id="bugs"></div>
Reporting Problems
</div>
<div class="content_section_text">
<p>
Please use the <tt>reportbug</tt> tool to report bugs in the
Apache2 package with Debian. However, check <a
href="http://bugs.debian.org/cgi-bin/pkgreport.cgi?ordering=normal;archive=0;src=apache2;repeatmerged=0"
rel="nofollow">existing bug reports</a> before reporting a new bug.
</p>
<p>
Please report bugs specific to modules (such as PHP and others)
to respective packages, not to the web server itself.
</p>
</div>
</div>
</div>
<div class="validator">
</div>
</body>
</html>

87
WEB/index.php Normal file
View File

@ -0,0 +1,87 @@
<?php
require("connectionBD.php");
$db = connexionBD();
init();
function printError(){
if(isset($_GET['error'])){
$erreur = getError($_GET['error']);
echo "<p class = 'error'>$erreur</p>";
}
}
function getError($code){
switch ($code){
case 1:
return "Adresse mail ou mot de passe invalide.";
}
}
function authentification($db, $mail, $password){
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE mail = $1;", array($mail));
if ($result){
$row = pg_fetch_array($result);
return (strcmp($row["passwd"], $password)) == 0;
}
return false;
}
function init(){
global $db;
session_start();
if(!isset($_SESSION['mail'])){
if (isset($_POST['mail_field'])){
$mail = htmlentities(pg_escape_string ($_POST['mail_field']));
$password = htmlentities(pg_escape_string($_POST['password']));
$result = authentification($db, $mail, $password);
if($result) {
$_SESSION['mail'] = $mail;
header('Location: tableauBord/tableauBord.php');
}
else {
header('Location: index.php?error=1');
}
}
}
else{
header('Location: tableauBord/tableauBord.php');
}
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="index_inscription.css">
<title>Bienvenue sur Upssi'Covoit</title>
</head>
<body>
<div id="formulaireMail">
<h1>Bienvenue sur Upssi'Covoit</h1>
<form method="post" action="index.php">
<div class="line">
<label for="mail_field">Adresse mail : </label>
<input id="mail_field" class="form" name="mail_field" type="email" maxlength="150" required>
</div>
<div class="line">
<label for="password_field">Mot de passe : </label>
<input id="password_field" class="form" id="password" name="password" type="password" maxlength="16" required>
</div>
<?php
if(isset($_GET['error'])){
$erreur = getError($_GET['error']);
echo "<p class = 'error'>$erreur</p>";
}
?>
<input id="submit" class="button" type="submit" value="Se connecter">
</form>
<p id="enregistrer">Si vous n'avez pas de compte <a href="inscription.php" title="Créer un compte">cliquez ici</a>.</p>
</div>
</body>
</html>

115
WEB/index_inscription.css Normal file
View File

@ -0,0 +1,115 @@
*{
margin: 0;
padding: 0;
font-family: "Arial";
font-size: 1em;
}
body{
background-image: url("wallpaper.jpg");
background-attachment: fixed;
padding-top: 5%;
padding-bottom: 5%;
}
#formulaireMail{
margin-top: 50vh;
transform: translate(-50%, -50%);
}
#formulaire{
transform: translate(-50%);
}
#formulaire, #formulaireMail{
background-color: white;
margin-left: 50vw;
border-radius: 10px;
padding: 4em;
width: 40%;
}
#enregistrer{
margin-top: 1em;
text-align: center;
}
h1{
text-align: center;
}
form{
margin-top: 3em;
}
.form{
width: 55%;
box-sizing: border-box;
border: 1px solid grey;
margin-bottom: 0.7em;
}
.button{
cursor: pointer;
font-weight: bold;
padding: 8px;
color: white;
background-color: rgb(65, 154, 28);
border-radius: 5em;
border: none;
}
.button:hover{
background-color: rgb(48, 112, 20);
border-color: rgb(48, 112, 20);
}
.button:disabled{
cursor: not-allowed;
background-color: grey;
}
#submit{
margin-top: 1em;
margin-left: 50%;
transform: translate(-50%);
}
.line{
display: flex;
flex-wrap: wrap;
flex-direction: row;
width: 100%;
}
#error{
margin-bottom: 1em;
}
.error{
color: red;
text-align: center;
}
label{
font-size: 1.1em;
word-break: break-all;
box-sizing: border-box;
display: block;
width: 43%;
}
input{
margin-left: 2%;
font-size: 1em;
}
h1{
font-size: 2em;
}
button{
color: forestgreen;
border-color: forestgreen;
border-radius: 5em;
}

25
WEB/inscription.js Normal file
View File

@ -0,0 +1,25 @@
let messageAffiche = false;
window.onload = init;
function init(){
let password = document.getElementById("password");
let confirmation = document.getElementById("confirmation");
password.oninput = verifPassword;
confirmation.oninput = verifPassword;
}
function verifPassword() {
let message = "Les mots de passe ne correspondent pas.";
if( !messageAffiche && password.value != "" && confirmation.value!="" && password.value != confirmation.value ){
confirmation.insertAdjacentHTML("afterend", "<p id='error' class='error'>" + message + "</p>");
document.getElementById("submit").disabled = true;
messageAffiche = true;
}
else if ( messageAffiche && password.value == confirmation.value ) {
let child = document.getElementById("error");
child.parentNode.removeChild(child);
document.getElementById("submit").disabled = false;
messageAffiche = false;
}
}

145
WEB/inscription.php Normal file
View File

@ -0,0 +1,145 @@
<?php
require ('connectionBD.php');
$db = connexionBD();
init();
function printError(){
if(isset($_GET['error'])){
$erreur = getError($_GET['error']);
echo "<p class = 'error'>$erreur</p>";
}
}
function getError($code){
switch ($code){
case 1:
return "Cette adresse est déjà associée à un compte.";
case 2:
return "Ce login est déjà associé à un compte.";
case 3:
return "Erreur lors de la création du compte.";
case 4:
return "Erreur lors de la vérification de l'unicité de l'adresse mail.";
}
}
function isMailUnique($db, $mail){
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE mail = $1;", array($mail));
if($result){
$row = pg_fetch_array($result);
return (strcmp($row['mail'], $mail) != 0);
}
return false;
}
function isLoginUnique($db, $login){
$result = pg_query_params($db, "SELECT * FROM Utilisateur WHERE login = $1;", array($login));
if($result){
$row = pg_fetch_array($result);
return (strcmp($row['login'], $login) != 0);
}
return false;
}
function creerUtilisateur($db, $mail, $password, $prenom, $nom, $login, $phone, $dateN){
$result = pg_query_params($db, "INSERT INTO Utilisateur VALUES ($1, $2, $3, $4, $5, $6, to_date($7, 'YYYY/MM/DD'), false);", array($mail, $password, $prenom, $nom, $login, $phone, $dateN));
return $result;
}
function init(){
global $db;
session_start();
if(!isset($_SESSION['mail'])){
if(isset($_POST['mail_field'])){
$login = htmlentities(pg_escape_string ($_POST['login_field']));
$password = htmlentities(pg_escape_string ($_POST['password']));
$prenom = htmlentities(pg_escape_string ($_POST['prenom']));
$nom = htmlentities(pg_escape_string ($_POST['nom']));
$dateN = htmlentities(pg_escape_string ($_POST['dateN']));
$mail = htmlentities(pg_escape_string ($_POST['mail_field']));
$phone = htmlentities(pg_escape_string ($_POST['phone']));
if(!isMailUnique($db, $mail)){
header('Location: inscription.php?error=1');
}
elseif(!isLoginUnique($db, $mail)){
header('Location: inscription.php?error=2');
}
else{
$result = creerUtilisateur($db, $mail, $password, $prenom, $nom, $login, $phone, $dateN);
if($result){
header('Location: index.php');
}
else{
header('Location: inscription.php?error=3');
}
}
}
}
else{
header('Location: tableauBord/tableauBord.php');
}
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="index_inscription.css">
<title>Inscription</title>
<script src="inscription.js"></script>
</head>
<body>
<div id="formulaire">
<h1>Inscription</h1>
<form method="post" action="inscription.php">
<div class="line">
<label for="mail_field">Adresse mail : </label>
<input id="mail_field" class="form" name="mail_field" type="email" maxlength="100" required>
</div>
<div class="line">
<label for="login_field">Login : </label>
<input id="login_field" class="form" name="login_field" type="text" maxlength="50" required>
</div>
<div class="line">
<label for="password">Mot de passe : </label>
<input class="form" id="password" name="password" type="password" maxlength="50" required>
</div>
<div class="line">
<label for="confirmation">Confirmation : </label>
<input class="form" id="confirmation" name="confirmation" type="password" maxlength="16">
</div>
<div class="line">
<label for="prenom_field">Prénom : </label>
<input id="prenom_field" class="form" name="prenom" type="text" maxlength="50" required>
</div>
<div class="line">
<label for="nom_field">Nom : </label>
<input id="nom_field" class="form" name="nom" type="text" maxlength="50" required>
</div>
<div class="line">
<label for="dateN_field">Date de naissance : </label>
<input id="dateN_field" class="form" name="dateN" type="date" required>
</div>
<div class="line">
<label for="phone_field">Numéro de téléphone : </label>
<input id="phone_field" class="form" name="phone" type="tel" pattern="[0-9]{10}" maxlength="10" required>
</div>
<?php
printError();
?>
<input id="submit" class="button" type="submit" value="S'inscrire">
</form>
<p id="enregistrer">Si vous avez déjà un compte <a href="index.php" title="S'identifier">cliquez ici</a>.</p>
</div>
</body>
</html>

View File

@ -0,0 +1,49 @@
*{
margin: 0;
padding: 0;
font-family: "Calibri Light";
}
#content{
margin-top: 8vh;
background-color: aqua;
margin-left: 50vw;
border-radius: 10px;
padding: 4em;
width: 84%;
transform: translate(-50%);
}
.menu {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
background-color: rgb(65, 154, 28);
}
.menuItem {
color: white;
width: 10%;
min-width: 5em;
font-weight: bold;
text-decoration: none;
padding: 0.8em;
border-bottom: 4px solid rgb(65, 154, 28);
font-size: 1.1em;
text-align: center;
}
.menuItem:hover{
cursor: pointer;
border-bottom: 4px solid orange;
}
#imgProfil{
margin-top: 30px;
margin-left: 50%;
transform: translate(-50%);
max-width: 300px;
max-height: 300px;
border-radius: 10px;
}

View File

@ -0,0 +1,10 @@
window.onload = init;
function init(){
let button = document.getElementById('btnDeco');
button.onclick = deconnexion;
}
function deconnexion() {
document.getElementById('formDeco').submit();
}

View File

@ -0,0 +1,71 @@
<?php
require ('../connectionBD.php');
$mail = null;
$db = connexionBD();
init();
function init(){
global $mail;
session_start();
//Si on est pas connecté redirection vers la page de connexion
if(!isset($_SESSION['mail'])){
header('Location: ../index.php');
}
else{
$mail = $_SESSION['mail'];
//Si clic sur le bouton de déconnexion détruire la session et rediriger l'utilisateur
if(isset($_POST['deco'])){
session_unset();
session_destroy();
header('Location: ../index.php');
}
}
}
function getPrenom($db, $mail){
$result = pg_query_params($db, "SELECT prenom from Utilisateur WHERE mail = $1;", array($mail));
if($result){
$row = pg_fetch_array($result);
$prenom = $row[0];
return " $prenom";
}
return "";
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="tableauBord.css">
<title>Tableau de bord</title>
<script src="tableauBord.js"></script>
</head>
<body>
<nav class="menu">
<a class="menuItem" href="./../inscription.php">Tableau de bord</a>
<a class="menuItem" href="../inscription.php">Trajets publiés</a>
<a class="menuItem" href="../inscription.php">Trajets réservés</a>
<a class="menuItem" href="../inscription.php">Messagerie</a>
<a class="menuItem" href="../inscription.php">Avis reçus</a>
<a class="menuItem" href="../inscription.php">Avis laissés</a>
<a class="menuItem" href="../inscription.php">Profil</a>
<a id="btnDeco" class="menuItem">Se déconnecter</a>
<form id="formDeco" method="post" action="tableauBord.php">
<input type="hidden" value="true" name="deco">
</form>
</nav>
<div id="content">
<h1>Bonjour<?php
echo getPrenom($db,$mail);
?>
</h1>
<div id="cotent">
<img id="imgProfil" src="../wallpaper.jpg">
</div>
</div>
</body>
</html>

BIN
WEB/wallpaper.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB