diff --git a/accueil.php b/accueil.php index 49b12a23f7878889f88e55493c8eceaf43115d91..21d604914167bd9e269f540e7b66accb64f2fa87 100644 --- a/accueil.php +++ b/accueil.php @@ -1,4 +1,5 @@ <?php +session_start(); require_once"fonction.php"; $bdd=bdd(); ?> @@ -10,36 +11,36 @@ $bdd=bdd(); <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="./bootstrap/css/bootstrap.css"> + <link rel="stylesheet" href="./bootstrap/css/mystyle.css"> <script src="./bootstrap/js/jquery.min.js"></script> <script src="./bootstrap/js/bootstrap.min.js"></script> </head> <body> <div class="container-fluid"> - <div class="jumbotron"> + <div class="jumbotron"> <h1><span style="color: white">Com-Ensiie</span></h1> - <?php - if(isset($_SESSION['id'])) - { - $pseudo = $_SESSION['pseudo']; - ?> - <div> - <button type="button" class="btn btn-success btn-right" onclick="location.href='./deconnexion.php'" >Deconnexion</button> - <button type="button" class="btn btn-success btn-right" onclick="location.href='./edit.php'" >Edit</button> - <label for="hello"><?php echo "Bonjour, $pseudo";?></label> - </div> - <?php - } - else - { - ?> - </div> - <button type="button" class="btn btn-success btn-right" onclick="location.href='./login.php'" >Log In</button> - <button type="button" class="btn btn-success btn-right" onclick="location.href='./register.php'">Register</button> - </div> - <?php - } - ?> - + + + </div> + <?php + if (isset($_SESSION['pseudo'])) { + $pseudo=$_SESSION['pseudo']; + ?> + <button type="button" class="btn btn-success btn-right" onclick="location.href='./edit.php'" >Edit</button> + <button type="button" class="btn btn-success btn-right" onclick="location.href='./deconnexion.php'">Deconnexion</button> + <label for="hello"><?php echo "Bonjour, $pseudo";?></label> + <?php + } + else + { + ?> + <button type="button" class="btn btn-success btn-right" onclick="location.href='./login.php'" >Se connecter</button> + <button type="button" class="btn btn-success btn-right" onclick="location.href='./register.php'">S'enregistrer</button> + <?php + } + ?> + </div> +<div> <nav class="navbar navbar-inverse"> <div class="navbar-header"> <a class="navbar-brand" href="accueil.php">Com-Ensiie</a> diff --git a/class/connexion.class.php b/class/connexion.class.php index a0aac6705bc28a5fae33c21ac233ce64054358b8..4c7fb7cb4c8a17037fb440f9ea8af73dc7df811e 100644 --- a/class/connexion.class.php +++ b/class/connexion.class.php @@ -31,11 +31,11 @@ class connexion public function session() { - $requete = ("SELECT id FROM users WHERE pseudo ='$this->pseudo'"); + $requete = ("SELECT * FROM users WHERE pseudo ='$this->pseudo'"); $sql = pg_fetch_array(pg_query($requete)); $_SESSION['id'] = $sql['id']; $_SESSION['pseudo'] = $this->pseudo; - + $_SESSION['su'] = $sql['su']; return 1; } } diff --git a/deconnexion.php b/deconnexion.php new file mode 100644 index 0000000000000000000000000000000000000000..46b20841c4d0a497b81de838bd718f6271a6f82f --- /dev/null +++ b/deconnexion.php @@ -0,0 +1,6 @@ +<?php +session_start(); +session_unset(); +session_destroy(); + +header('Location: ./accueil.php'); diff --git a/fonction.php b/fonction.php index 7e7b6e3427ccf9474cb75397297d2af1066e9bd0..d364c5bdc6ecd69778a9cbcc30d6a3ced6b0357a 100644 --- a/fonction.php +++ b/fonction.php @@ -1,5 +1,4 @@ <?php - session_start(); function bdd() { $bdd=pg_connect("host=localhost dbname=buyIIE user=postgres password=NASS12m26") or die("Erreur de connection à la base de données"); diff --git a/jkqppl3h.saa.txt b/jkqppl3h.saa.txt new file mode 100644 index 0000000000000000000000000000000000000000..d6d79260508b4784f0acb49f140c714fa227da68 --- /dev/null +++ b/jkqppl3h.saa.txt @@ -0,0 +1,43 @@ + +# Please enter the commit message for your changes. Lines starting +# with '#' will be ignored, and an empty message aborts the commit. +# On branch master +# +# Initial commit +# +# Changes to be committed: +# new file: README.md +# new file: accueil.php +# new file: base.sql +# new file: bootstrap/css/bootstrap-theme.css +# new file: bootstrap/css/bootstrap-theme.css.map +# new file: bootstrap/css/bootstrap-theme.min.css +# new file: bootstrap/css/bootstrap-theme.min.css.map +# new file: bootstrap/css/bootstrap.css +# new file: bootstrap/css/bootstrap.css.map +# new file: bootstrap/css/bootstrap.min.css +# new file: bootstrap/css/bootstrap.min.css.map +# new file: bootstrap/css/mystyle.css +# new file: bootstrap/fonts/glyphicons-halflings-regular.eot +# new file: bootstrap/fonts/glyphicons-halflings-regular.svg +# new file: bootstrap/fonts/glyphicons-halflings-regular.ttf +# new file: bootstrap/fonts/glyphicons-halflings-regular.woff +# new file: bootstrap/fonts/glyphicons-halflings-regular.woff2 +# new file: bootstrap/js/bootstrap.js +# new file: bootstrap/js/bootstrap.min.js +# new file: bootstrap/js/jquery.min.js +# new file: bootstrap/js/npm.js +# new file: class/connexion.class.php +# new file: class/inscription.class.php +# new file: fonction.php +# new file: img/ad1.jpg +# new file: img/ad2.jpg +# new file: img/animal.jpg +# new file: img/autre.png +# new file: img/bg.jpg +# new file: img/multimedia.jpg +# new file: img/vetement.png +# new file: login.php +# new file: register.php +# + diff --git a/login.php b/login.php index 8bb25cc942c420fbb2b2b4bbcd7376da131774d6..4a1c2fa4c314e56e45b7f5b2d78eefd964bae59f 100644 --- a/login.php +++ b/login.php @@ -1,8 +1,10 @@ <?php +session_start(); require_once"fonction.php"; require_once"class/connexion.class.php"; + $bdd=bdd(); -if (!isset($_SESSION['id'])) { + if (isset($_POST['pseudo']) AND isset($_POST['mdp'])) { $pseudo = $_POST['pseudo']; @@ -11,37 +13,38 @@ if (isset($_POST['pseudo']) AND isset($_POST['mdp'])) $verif = $connexion->verify(); if($verif == 1) { - header("Location: ./accueil.php"); + if ($connexion->session()) { + header("Location: ./accueil.php"); + } } else { $erreur = $verif; } } -} + ?> <!DOCTYPE html> - -<html> - <head> - <title>Authentification</title> - <meta charset="UTF-8"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <link href="./bootstrap/css/bootstrap.min.css" rel="stylesheet"> - <script src="./bootstrap/js/jquery.min.js"></script> - <script src="./bootstrap/js/bootstrap.min.js"></script> - </head> - <body> - - - <div class="container-fluid"> - <div class="jumbotron"> - <h1><span style="color: white">Com-Ensiie</span></h1> +<html lang="en"> +<head> + <title>Com-Ensiie</title> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel="stylesheet" href="./bootstrap/css/bootstrap.css"> + <link rel="stylesheet" href="./bootstrap/css/mystyle.css"> + <script src="./bootstrap/js/jquery.min.js"></script> + <script src="./bootstrap/js/bootstrap.min.js"></script> +</head> +<body> + <div class="container-fluid"> + <div class="jumbotron"> + <h1><span style="color: white">Com-Ensiie</span></h1> + </div> <?php if (!isset($pseudo, $mdp)) { ?> - <button type="button" class="btn btn-success btn-right" onclick="location.href='./login.php'" >Log In</button> + <button type="button" class="btn btn-success btn-right" onclick="location.href='./login.php'" >Se connecter</button> <button type="button" class="btn btn-success btn-right" onclick="location.href='./register.php'" >S'enregistrer</button> <?php } @@ -106,15 +109,15 @@ if (isset($_POST['pseudo']) AND isset($_POST['mdp'])) </form> - <div class="form-group"> + <div > <label for="creer" class="col-sm-2 control-label">Créer un compte</label> - <button type="submit" class="btn btn-primary" onclick="location.href='./register.php'">S'enregistrer</button> + <button type="submit" class="btn btn-success" onclick="location.href='./register.php'">S'enregistrer</button> </div> </div> </div> - <div class="footer"> + <div class="footre"> </div> diff --git a/register.php b/register.php index 6aadb5e10d1c4122afe7a225f4ff19dadf9a3a61..23b697f0256123bd89eae364e3b1764c8f46ca65 100644 --- a/register.php +++ b/register.php @@ -3,43 +3,28 @@ require_once"fonction.php"; require_once"/class/inscription.class.php"; $bdd=bdd(); -if(isset($_POST['pseudo'], $_POST['mail'], $_POST['mdp'], $_POST['mdpC'])) -{ - $inscription = new inscription($_POST['pseudo'], $_POST['mail'], $_POST['mdp'], $_POST['mdpC']); - $erreur = $inscription->verify(); - if($erreur == "ok") - { - if($inscription->enregistrer()) - { - header('Location: ./accueil.php'); - } - } - else - { - $verif=$erreur; - } -} ?> <!DOCTYPE html> - -<html> - <head> - <title>Création de compte</title> - <meta charset="UTF-8"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <link href="./bootstrap/css/bootstrap.min.css" rel="stylesheet"> - <script src="./bootstrap/js/jquery.min.js"></script> - <script src="./bootstrap/js/bootstrap.min.js"></script> - </head> - <body> - - <div class="container-fluid"> - <div class="jumbotron"> - <h1><span style="color: white">Com-Ensiie</span></h1> - <button type="button" class="btn btn-success btn-right" onclick="location.href='./login.php'" >Log In</button> +<html lang="en"> +<head> + <title>Com-Ensiie</title> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel="stylesheet" href="./bootstrap/css/bootstrap.css"> + <link rel="stylesheet" href="./bootstrap/css/mystyle.css"> + <script src="./bootstrap/js/jquery.min.js"></script> + <script src="./bootstrap/js/bootstrap.min.js"></script> +</head> +<body> + <div class="container-fluid"> + <div class="jumbotron"> + <h1><span style="color: white">Com-Ensiie</span></h1> + </div> + <button type="button" class="btn btn-success btn-right" onclick="location.href='./login.php'" >Se connecter</button> <button type="button" class="btn btn-success btn-right" onclick="location.href='./register.php'" >S'enregistrer</button> </div> - + </div> + <div> <nav class="navbar navbar-inverse"> <div class="navbar-header"> <a class="navbar-brand" href="accueil.php">Com-Ensiie</a> @@ -101,13 +86,7 @@ if(isset($_POST['pseudo'], $_POST['mail'], $_POST['mdp'], $_POST['mdpC'])) <div class="form-group"> <div class="col-sm-offset-2 col-xs-4"> - <input type="submit" name="signUp" class="btn btn-primary" value="S'enregistrer"> - <?php - if(isset($verif)) - { - echo $verif; - } - ?> + <input type="submit" name="signup" class="btn btn-primary" value="S'enregistrer"> </div> </div> </form> diff --git a/topiclist.php b/topiclist.php new file mode 100644 index 0000000000000000000000000000000000000000..5fba91cb2960128d1bf1009873e57aeea3625265 --- /dev/null +++ b/topiclist.php @@ -0,0 +1,96 @@ +<?php +session_start(); + require_once"fonction.php"; + $bdd = bdd(); +?> + +<!DOCTYPE html> +<html lang="en"> +<head> + <title>Com-Ensiie</title> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel="stylesheet" href="./bootstrap/css/bootstrap.css"> + <link rel="stylesheet" href="./bootstrap/css/mystyle.css"> + <script src="./bootstrap/js/jquery.min.js"></script> + <script src="./bootstrap/js/bootstrap.min.js"></script> +</head> +<body> + +<div class="container-fluid"> + <div class="jumbotron"> + <h1><span style="color: white">Com-Ensiie</span></h1> + </div> +<?php +if(isset($_SESSION['pseudo'])){ + $pseudo=$_SESSION['pseudo']; +?> + <button type="button" class="btn btn-success btn-right" onclick="location.href='./deconnexion.php'" >Deconnexion</button> + <button type="button" class="btn btn-success btn-right" onclick="location.href='./edit.php'" >Edit</button> + <button type="button" class="btn btn-success btn-right" onclick="location.href='./newtopic.php'" >Nouveau sujet</button> + <label for="hello"><?php echo "Bonjour, $pseudo";?></label> + +<?php +} +else +{ +?> + <button type="button" class="btn btn-success btn-right" onclick="location.href='./login.php'" >Log In</button> + <button type="button" class="btn btn-success btn-right" onclick="location.href='./register.php'">Register</button> + +<?php +} +?> +</div> +<nav class="navbar navbar-inverse"> + <div class="navbar-header"> + <a class="navbar-brand" href="accueil.php">Com-Ensiie</a> + </div> + <ul class="nav navbar-nav"> + <li class="dropdown active"><a class="dropdown-toggle" data-toggle="dropdown" href="./topiclist.php">Commercial <span class="caret"></span></a> + <ul class="dropdown-menu"> + <li><a id="cat" href="./topiclist.php">Multimédia</a></li> + <li><a id="cat" href="./topiclist.php">Vêtement</a></li> + <li><a id="cat" href="./topiclist.php">Animal</a></li> + <li><a id="cat" href="./topiclist.php">Autre</a></li> + </ul> + </li> + </ul> + </nav> +<?php + +$dn2 = pg_query("SELECT * FROM toppics NATURAL JOIN users"); +$nb = pg_fetch_row($dn2); +if($nb>=0) +{ +?> +<div class="col-lg-8 lg-8 text-left"> + <table class="table"> + <col width="20%"> + <col width="60%"> + <col width="20%"> + <thead> + <tr> + <th class="lead">Category</th> + <th class="lead">Sujet</th> + <th class="lead">Date</th> + <?php + if(isset($_SESSION['pseudo']) and $_SESSION['su']) + { + ?> + <th class="lead">Action</th> + <?php + } + ?> + </tr> + </thead> + + </tr> +<div class="message">Cette catégorie ne contient aucun sujet.</div> +<?php +} +?> + + + </body> +</html> \ No newline at end of file