test
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1 @@
|
||||
_base/
|
||||
_old/
|
@@ -1,14 +0,0 @@
|
||||
<!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>
|
@@ -1,61 +0,0 @@
|
||||
<?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>
|
@@ -1,68 +0,0 @@
|
||||
<?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>
|
@@ -1,89 +0,0 @@
|
||||
<?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>
|
@@ -1,79 +0,0 @@
|
||||
<?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 ?)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -1,9 +0,0 @@
|
||||
<?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");
|
@@ -1,43 +0,0 @@
|
||||
<?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 +0,0 @@
|
||||
deny from all
|
@@ -1,3 +0,0 @@
|
||||
<?php
|
||||
|
||||
$pdo = new PDO('mysql:host=mysqlsrv;dbname=contrib', "contrib_root", "123abc");
|
Reference in New Issue
Block a user