First commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
_base/
|
6
css/bootstrap.min.css
vendored
Normal file
6
css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
10
css/styles.css
Normal file
10
css/styles.css
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#formLogin{
|
||||||
|
background-color: rgb(232, 238, 239);
|
||||||
|
border:1px solid darkcyan;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
td a {
|
||||||
|
color: white !important;;
|
||||||
|
}
|
3
debugSession.php
Normal file
3
debugSession.php
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
var_dump($_SESSION);
|
36
index.php
Normal file
36
index.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<link href="css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link href="css/styles.css" rel="stylesheet">
|
||||||
|
<title>Connexion</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="container">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<form id="formLogin" action="traitements/traiterAuthentification.php" method="post">
|
||||||
|
<h3 class="text-center">Identifiez-vous</h3>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="id">Login :</label><br>
|
||||||
|
<input type="text" name="login" id="id" class="form-control">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="mdp">Pass :</label><br>
|
||||||
|
<input type="password" name="pass" id="mdp" class="form-control">
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<div class="form-group text-end">
|
||||||
|
<input type="submit" name="submit" class="btn btn-primary btn-md" value="Valider">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
7
js/bootstrap.bundle.min.js
vendored
Normal file
7
js/bootstrap.bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
14
pages/accueil.php
Normal file
14
pages/accueil.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Document</title>
|
||||||
|
<link href="../css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<script src="../js/bootstrap.bundle.min.js"></script>
|
||||||
|
</head>
|
||||||
|
<body class="container">
|
||||||
|
<?php include "../utils_inc/inc_navbar.php"; ?>
|
||||||
|
<h1>Hello et bienvenue, co OK.</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
61
pages/gestionMembres.php
Normal file
61
pages/gestionMembres.php
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once "../utils_inc/inc_pdo.php";
|
||||||
|
|
||||||
|
if (!isset($_SESSION["droit"])){
|
||||||
|
// pas connecté : retour au formulaire de connexion
|
||||||
|
header("location:../index.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_SESSION["droit"]!="admin"){
|
||||||
|
header("location:../pages/accueil.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si on arrive là, c'est qu'on a le droit d'y être !
|
||||||
|
|
||||||
|
$textReq = "select * from membre ";
|
||||||
|
$req = $pdo->prepare($textReq);
|
||||||
|
$req->execute();
|
||||||
|
$tabRes = $req->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
//var_dump($tabRes);
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Document</title>
|
||||||
|
<link href="../css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link href="../css/styles.css" rel="stylesheet">
|
||||||
|
<script src="../js/bootstrap.bundle.min.js"></script>
|
||||||
|
</head>
|
||||||
|
<body class="container">
|
||||||
|
<?php include "../utils_inc/inc_navbar.php"; ?>
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>id </th>
|
||||||
|
<th>nom </th>
|
||||||
|
<th>droit </th>
|
||||||
|
<th>contribs</th>
|
||||||
|
<th>suppr</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
foreach($tabRes as $uneLigne){
|
||||||
|
echo "<tr>";
|
||||||
|
echo " <th>".$uneLigne["id"]."</th>";
|
||||||
|
echo " <td>".$uneLigne["nom"]."</td>";
|
||||||
|
echo " <td>".$uneLigne["droit"]."</td>";
|
||||||
|
echo " <td><a href='../pages/listeContribsMembre.php?id=".$uneLigne["id"]."'><button class='btn btn-info'>voir</a></td>";
|
||||||
|
echo " <td><a href='#'><button class='btn btn-danger'>X</a></td>";
|
||||||
|
echo "</tr>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
68
pages/listeContribs.php
Normal file
68
pages/listeContribs.php
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
// Liste de TOUTES les contributions (tous les membres)
|
||||||
|
// Juste pour l'admin
|
||||||
|
require_once "../utils_inc/inc_pdo.php";
|
||||||
|
|
||||||
|
if (!isset($_SESSION["droit"])){
|
||||||
|
// pas connecté : retour au formulaire de connexion
|
||||||
|
header("location:formCo.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_SESSION["droit"]!="admin"){
|
||||||
|
// droits insuffisants : connexion à refaire ou message
|
||||||
|
// "moins gentil"
|
||||||
|
header("location:formCo.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si on arrive là, c'est qu'on a le droit d'y être !
|
||||||
|
|
||||||
|
$textReq = "select contribution.id as numero, membre.nom as nom_membre, projet.nom as nom_projet, duree ";
|
||||||
|
$textReq.= "from membre inner join contribution on membre.id = contribution.membre_id ";
|
||||||
|
$textReq.= " inner join projet on contribution.projet_id = projet.id ";
|
||||||
|
$textReq.= "order by membre.nom, nom_projet ";
|
||||||
|
|
||||||
|
$req = $pdo->prepare($textReq);
|
||||||
|
|
||||||
|
$req->execute();
|
||||||
|
|
||||||
|
$tabRes = $req->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
//var_dump($tabRes);
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Document</title>
|
||||||
|
<link href="../css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<script src="../js/bootstrap.bundle.min.js"></script>
|
||||||
|
</head>
|
||||||
|
<body class="container">
|
||||||
|
<?php include "../utils_inc/inc_navbar.php"; ?>
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Numéro </th>
|
||||||
|
<th>Membre </th>
|
||||||
|
<th>Projet </th>
|
||||||
|
<th>Durée </th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
foreach($tabRes as $uneLigne){
|
||||||
|
echo "<tr>";
|
||||||
|
echo " <th>".$uneLigne["numero"]."</th>";
|
||||||
|
echo " <td>".$uneLigne["nom_membre"]."</td>";
|
||||||
|
echo " <td>".$uneLigne["nom_projet"]."</td>";
|
||||||
|
echo " <td>".$uneLigne["duree"]."</td>";
|
||||||
|
echo "</tr>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
89
pages/listeContribsMembre.php
Normal file
89
pages/listeContribsMembre.php
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once "../utils_inc/inc_pdo.php";
|
||||||
|
|
||||||
|
$idM = $_GET["id"]; // id du membre pour lequel on veut afficher la liste
|
||||||
|
|
||||||
|
if (!isset($_SESSION["droit"])){
|
||||||
|
// pas connecté : retour au formulaire de connexion
|
||||||
|
header("location:formCo.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// accès possible si : admin ou (dev et "ce sont mes contribs")
|
||||||
|
if ( !(($_SESSION["droit"]=="admin") || ($_SESSION["droit"]=="dev" && $_SESSION["login"]==$idM)) ){
|
||||||
|
die("Droits insuffisants");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si on arrive ici, c'est que nos droits sont suffisants
|
||||||
|
|
||||||
|
$textReq = "select contribution.id as numero, membre.nom as nom_membre, projet.nom as nom_projet, duree ";
|
||||||
|
$textReq.= "from membre inner join contribution on membre.id = contribution.membre_id ";
|
||||||
|
$textReq.= " inner join projet on contribution.projet_id = projet.id ";
|
||||||
|
$textReq.= "where membre.id = :id_m ";
|
||||||
|
$textReq.= "order by membre.nom, nom_projet ";
|
||||||
|
|
||||||
|
$req = $pdo->prepare($textReq);
|
||||||
|
$req->bindParam(":id_m",$idM); // protection contre injections SQL
|
||||||
|
|
||||||
|
$req->execute();
|
||||||
|
|
||||||
|
$tabRes = $req->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
//---------------------------------------------------------
|
||||||
|
$reqProjet = $pdo->prepare("select * from projet");
|
||||||
|
$reqProjet->execute();
|
||||||
|
|
||||||
|
$tabProjets = $reqProjet->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
//var_dump($tabRes);
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Document</title>
|
||||||
|
<link href="../css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<script src="../js/bootstrap.bundle.min.js"></script>
|
||||||
|
</head>
|
||||||
|
<body class="container">
|
||||||
|
<?php include "../utils_inc/inc_navbar.php"; ?>
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Numéro </th>
|
||||||
|
<th>Membre </th>
|
||||||
|
<th>Projet </th>
|
||||||
|
<th>Durée </th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
foreach($tabRes as $uneLigne){
|
||||||
|
echo "<tr>";
|
||||||
|
echo " <th>".$uneLigne["numero"]."</th>";
|
||||||
|
echo " <td>".$uneLigne["nom_membre"]."</td>";
|
||||||
|
echo " <td>".$uneLigne["nom_projet"]."</td>";
|
||||||
|
echo " <td>".$uneLigne["duree"]."</td>";
|
||||||
|
echo "</tr>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<form action="../traitements/insererContrib.php" method="get">
|
||||||
|
<input name="idMembre" hidden value='<?php echo $idM; ?>'>
|
||||||
|
<label>Projet</label>
|
||||||
|
<select name="idProjet">
|
||||||
|
<?php
|
||||||
|
foreach ($tabProjets as $projet){
|
||||||
|
echo "<option value='".$projet['id']."'>".$projet['nom']."</option>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
<label>Durée</label>
|
||||||
|
<input name="duree" type="number">
|
||||||
|
<input type="submit">
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
79
traitements/insererContrib.php
Normal file
79
traitements/insererContrib.php
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
// Exécutable si :
|
||||||
|
// admin ou (dev et "je suis le bon utilisateur")
|
||||||
|
if (!isset($_SESSION['droit'])){
|
||||||
|
die("Connexion obligatoire.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !( ($_SESSION['droit']=='admin') ||
|
||||||
|
($_SESSION['droit']=='dev' && $_SESSION['login']==$idM) ) ){
|
||||||
|
die("Accès interdit");
|
||||||
|
}
|
||||||
|
// Exemple insertion :
|
||||||
|
// .../insererContrib.php?idMembre=M001&idProjet=P001&duree=56
|
||||||
|
|
||||||
|
// Récupère membre_id, projet_id, durée en $_GET
|
||||||
|
// include include_once : si fichier pas trouvé, pas d'erreur
|
||||||
|
// require require_once : si fichier pas trouvé, erreur et arrêt
|
||||||
|
// => once : php vérifie que l'inclusion n'est faite qu'une fois
|
||||||
|
require_once "../utils_inc/inc_pdo.php";
|
||||||
|
|
||||||
|
$idM = $_GET["idMembre"];
|
||||||
|
$idP = $_GET["idProjet"];
|
||||||
|
$dudu = $_GET["duree"];
|
||||||
|
|
||||||
|
$texteRequete = "insert into contribution (membre_id, projet_id, duree) ";
|
||||||
|
$texteRequete.= " values(:mId, :pId, :du) ";
|
||||||
|
|
||||||
|
$req = $pdo->prepare($texteRequete);
|
||||||
|
$req->bindParam(":mId",$idM);
|
||||||
|
$req->bindParam(":pId",$idP);
|
||||||
|
$req->bindParam(":du" ,$dudu);
|
||||||
|
|
||||||
|
$req->execute();
|
||||||
|
|
||||||
|
// header : prépare une redirection
|
||||||
|
// qui devient effective à la fin de l'exécution
|
||||||
|
header("location:../pages/listeContribsMembre.php?id=".$idM);
|
||||||
|
// exit(); // pour que la redirection soit immédiate
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// appeler un script php pour l'exécuter en lui transmettant des paramètres dans l'url
|
||||||
|
// Créer un formulaire, utiliser action, method, name, utiliser des champs cachés (hidden)
|
||||||
|
// Utiliser pdo pour :
|
||||||
|
// - se connecter à une base
|
||||||
|
// - faire une requête simple (non paramétrée)
|
||||||
|
// - faire une requête paramétrée (bind)
|
||||||
|
// Extraire les données retournées par une requête et les "traiter"(foreach)
|
||||||
|
// => comprendre la communication client-serveur (qui fait quoi ?)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
9
traitements/logout.php
Normal file
9
traitements/logout.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
// Choix de déconnexion : on supprime les champs de session liés à la connexion
|
||||||
|
unset($_SESSION['droit']);
|
||||||
|
unset($_SESSION['login']);
|
||||||
|
|
||||||
|
// retour au form de connexion
|
||||||
|
header("location:../index.php");
|
43
traitements/traiterAuthentification.php
Normal file
43
traitements/traiterAuthentification.php
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once "../utils_inc/inc_pdo.php"; // $pdo existe ici désormais
|
||||||
|
// http://localhost/contribs/traiterAuthentification.php?login=M001&pass=123
|
||||||
|
|
||||||
|
// Recevoir les données du form de login, et vérifier login/pass dans la base
|
||||||
|
// En version finale : envoi en $_POST obligatoire. Pour le dev $_GET peut être plus pratique.
|
||||||
|
$login = $_POST["login"];
|
||||||
|
$pass = $_POST["pass"];
|
||||||
|
|
||||||
|
// Vérification dans la base si le mot de passe et le login se trouvent dans la base
|
||||||
|
// VERSION mot de passe chiffré
|
||||||
|
$textR = "select droit, password ";
|
||||||
|
$textR.= "from membre ";
|
||||||
|
$textR.= "where id=:login ";
|
||||||
|
$req = $pdo->prepare($textR);
|
||||||
|
$req->bindParam(":login", $login);
|
||||||
|
$req->execute();
|
||||||
|
|
||||||
|
// 2 possibilités : 1 ligne retournée ou 0 ligne retournée
|
||||||
|
$tabRes = $req->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
if (count($tabRes)!=1) {
|
||||||
|
// pas trouvé => retour au formulaire de co
|
||||||
|
// die("Erreur de co");
|
||||||
|
header("Location:../index.php?message=tekitoa");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si on arrive là : login existe (count==1)
|
||||||
|
if (!password_verify($pass, $tabRes[0]["password"])){
|
||||||
|
// die("Erreur de co");
|
||||||
|
header("Location:../index.php?message=tekitoa");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$_SESSION["login"] = $login;
|
||||||
|
$_SESSION["droit"] = $tabRes[0]["droit"];
|
||||||
|
|
||||||
|
// redirection vers accueil, éventuellement spécifique à l'utilisateur
|
||||||
|
header("Location:../pages/accueil.php");
|
||||||
|
// pas besoin d'exit pour déclencher la redirection, puisque fin de script
|
||||||
|
|
||||||
|
|
1
utils_inc/.htaccess_inactif
Normal file
1
utils_inc/.htaccess_inactif
Normal file
@@ -0,0 +1 @@
|
|||||||
|
deny from all
|
0
utils_inc/inc_head.php
Normal file
0
utils_inc/inc_head.php
Normal file
29
utils_inc/inc_navbar.php
Normal file
29
utils_inc/inc_navbar.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php // tirée de https://getbootstrap.com/docs/5.2/components/navbar/ ?>
|
||||||
|
<nav class="navbar navbar-expand-lg bg-light">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link active" aria-current="page" href="../pages/accueil.php">Accueil</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item dropdown">
|
||||||
|
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
|
Contributions
|
||||||
|
</a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a class="dropdown-item" href="../pages/listeContribs.php">Voir toutes</a></li>
|
||||||
|
<li><a class="dropdown-item" href="#">Nada</a></li>
|
||||||
|
<li><hr class="dropdown-divider"></li>
|
||||||
|
<li><a class="dropdown-item" href="#">Nothing</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link " href="../pages/gestionMembres.php">Membres</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="d-flex">
|
||||||
|
<a href="../traitements/logout.php"><button class="btn btn-outline-success">Logout</button></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
3
utils_inc/inc_pdo.php
Normal file
3
utils_inc/inc_pdo.php
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$pdo = new PDO('mysql:host=mysqlsrv;dbname=contrib', "contrib_root", "123abc");
|
Reference in New Issue
Block a user