Commit 81f31317fe6b91391be0347eb58ad01b1db24db2
Merge branch 'master' of https://archives.plil.fr/grouille/IMA3_P10
Showing
13 changed files
with
105 additions
and
37 deletions
Show diff stats
site/accesBase.php
@@ -44,6 +44,15 @@ | @@ -44,6 +44,15 @@ | ||
44 | $result = pg_query($db, $query) or die("La requête a echoué : ".pg_last_error()); | 44 | $result = pg_query($db, $query) or die("La requête a echoué : ".pg_last_error()); |
45 | return pg_affected_rows($result); | 45 | return pg_affected_rows($result); |
46 | } | 46 | } |
47 | + | ||
48 | + function members() | ||
49 | + { | ||
50 | + $db = connexion(); | ||
51 | + $query = "SELECT * FROM membres"; | ||
52 | + $result = pg_query($db, $query) or die("La requête a echoué : ".pg_last_error()); | ||
53 | + $tab = pg_fetch_all($result); | ||
54 | + return $tab; | ||
55 | + } | ||
47 | 56 | ||
48 | function inscription($id, $pwd, $nom, $prenom, $groupe) | 57 | function inscription($id, $pwd, $nom, $prenom, $groupe) |
49 | { | 58 | { |
@@ -83,6 +92,16 @@ | @@ -83,6 +92,16 @@ | ||
83 | return $tab['groupe']; | 92 | return $tab['groupe']; |
84 | } | 93 | } |
85 | 94 | ||
95 | + function groupeId($id) | ||
96 | + { | ||
97 | + $db = connexion(); | ||
98 | + $query = "SELECT nom FROM groupes where id = '$id'"; | ||
99 | + $result = pg_query($db, $query) or die("La requête a echoué : ".pg_last_error()); | ||
100 | + $tab = pg_fetch_assoc($result); | ||
101 | + deconnexion($db); | ||
102 | + return $tab['nom']; | ||
103 | + } | ||
104 | + | ||
86 | function getGroupes() | 105 | function getGroupes() |
87 | { | 106 | { |
88 | $db = connexion(); | 107 | $db = connexion(); |
site/add.php
@@ -12,6 +12,7 @@ session_start(); | @@ -12,6 +12,7 @@ session_start(); | ||
12 | <body> | 12 | <body> |
13 | <?php | 13 | <?php |
14 | include("header.php"); | 14 | include("header.php"); |
15 | + require("erreurs.php"); | ||
15 | if(isset($_SESSION['Login'], $_SESSION['Password'])) | 16 | if(isset($_SESSION['Login'], $_SESSION['Password'])) |
16 | { | 17 | { |
17 | ?> | 18 | ?> |
@@ -60,7 +61,7 @@ session_start(); | @@ -60,7 +61,7 @@ session_start(); | ||
60 | } | 61 | } |
61 | else | 62 | else |
62 | { | 63 | { |
63 | - $ansible = "Code retour : ".$statut."<br/>"; | 64 | + $ansible = "Code retour : ".$statut." => ".$errors[$statut]."<br/>"; |
64 | $message = "Echec lors de l'ajout. Vérifiez vos informations !"; | 65 | $message = "Echec lors de l'ajout. Vérifiez vos informations !"; |
65 | $color = "alert-danger"; | 66 | $color = "alert-danger"; |
66 | remove($_POST['nom']); | 67 | remove($_POST['nom']); |
site/capteurs.php
@@ -8,14 +8,13 @@ $sensors = getSensors(); | @@ -8,14 +8,13 @@ $sensors = getSensors(); | ||
8 | <h1 style="margin-bottom:20px; margin-top:60px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-bars"></i> Choix du capteur</h1> | 8 | <h1 style="margin-bottom:20px; margin-top:60px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-bars"></i> Choix du capteur</h1> |
9 | <form action="reception.php" method="post" enctype="multipart/form-data"> | 9 | <form action="reception.php" method="post" enctype="multipart/form-data"> |
10 | <table class="table table-striped table-bordered"> | 10 | <table class="table table-striped table-bordered"> |
11 | + <thead class="thead-dark"> | ||
12 | + <th>Sélection</th> | ||
13 | + <th>Nom</th> | ||
14 | + <th>Raspberry</th> | ||
15 | + <th>Type</th> | ||
16 | + </thead> | ||
11 | <tbody> | 17 | <tbody> |
12 | - <tr> | ||
13 | - <td>Sélection</td> | ||
14 | - <td>Nom</td> | ||
15 | - <td>Raspberry</td> | ||
16 | - <td>Type</td> | ||
17 | - </tr> | ||
18 | - | ||
19 | <?php | 18 | <?php |
20 | $count = 0; | 19 | $count = 0; |
21 | foreach($sensors as $sensor){ | 20 | foreach($sensors as $sensor){ |
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +<?php | ||
2 | +$errors = array(); | ||
3 | +$errors[0] = "Lancement réussi ou aucun hôte correspondant."; | ||
4 | +$errors[1] = "Erreur lors de l'exécution d'Ansible."; | ||
5 | +$errors[2] = "Echec de l'exécution sur un ou plusieurs Raspberry Pi."; | ||
6 | +$errors[3] = "Un ou plusieurs Raspberry Pi est injoignable."; | ||
7 | +$errors[4] = "Erreur d'analyse."; | ||
8 | +$errors[5] = "Mauvaises options ou options incomplètes."; | ||
9 | +$errors[99] = "Exécution interrompue par l'utilisateur."; | ||
10 | +$errors[250] = "Erreur inattendue."; | ||
11 | +?> | ||
12 | + |
site/formInscription.php
@@ -6,7 +6,7 @@ $groupes = getGroupes(); | @@ -6,7 +6,7 @@ $groupes = getGroupes(); | ||
6 | <div class="row"> | 6 | <div class="row"> |
7 | <div class="col-6 col-md-6 offset-md-3 offset-3"> | 7 | <div class="col-6 col-md-6 offset-md-3 offset-3"> |
8 | <br/> | 8 | <br/> |
9 | - <h1 style="margin-bottom:20px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-user-plus"></i> Créer un compte</h1> | 9 | + <h1 style="margin-bottom:20px; margin-top:60px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-user-plus"></i> Créer un compte</h1> |
10 | <form action="inscription.php" method="post"> | 10 | <form action="inscription.php" method="post"> |
11 | <table class="table table-striped table-bordered"> | 11 | <table class="table table-striped table-bordered"> |
12 | <tbody> | 12 | <tbody> |
@@ -52,7 +52,7 @@ $groupes = getGroupes(); | @@ -52,7 +52,7 @@ $groupes = getGroupes(); | ||
52 | </tr> | 52 | </tr> |
53 | </tbody> | 53 | </tbody> |
54 | </table> | 54 | </table> |
55 | - <input type="submit" class="btn btn-dark btn-lg btn-block" style="margin-top:20px; margin-bottom:20px;" value="Ajouter"/> | 55 | + <input type="submit" class="btn btn-dark btn-lg btn-block" style="margin-top:20px;" value="Ajouter"/> |
56 | <br/> | 56 | <br/> |
57 | </form> | 57 | </form> |
58 | </div> | 58 | </div> |
site/formSuppression.php
1 | <?php | 1 | <?php |
2 | if(getGroupe($_SESSION['Login'])!=1) | 2 | if(getGroupe($_SESSION['Login'])!=1) |
3 | { header("Location: accueil.php"); } | 3 | { header("Location: accueil.php"); } |
4 | -$groupes = getGroupes(); | ||
5 | ?> | 4 | ?> |
6 | <div class="row"> | 5 | <div class="row"> |
7 | <div class="col-6 col-md-6 offset-md-3 offset-3"> | 6 | <div class="col-6 col-md-6 offset-md-3 offset-3"> |
site/inscrire.php
1 | <?php | 1 | <?php |
2 | session_start(); | 2 | session_start(); |
3 | +require_once("accesBase.php"); | ||
4 | +$membres = members(); | ||
3 | ?> | 5 | ?> |
4 | 6 | ||
5 | <!DOCTYPE html> | 7 | <!DOCTYPE html> |
@@ -13,11 +15,46 @@ session_start(); | @@ -13,11 +15,46 @@ session_start(); | ||
13 | <body> | 15 | <body> |
14 | <?php | 16 | <?php |
15 | include("header.php"); | 17 | include("header.php"); |
16 | - require_once("accesBase.php"); | ||
17 | if(getGroupe($_SESSION['Login'])==1) | 18 | if(getGroupe($_SESSION['Login'])==1) |
18 | { | 19 | { |
19 | - include("formSuppression.php"); | ||
20 | include("formInscription.php"); | 20 | include("formInscription.php"); |
21 | + ?> | ||
22 | + <div class="row"> | ||
23 | + <div class="col-6 col-md-6 offset-md-3 offset-3"> | ||
24 | + <br/> | ||
25 | + <h1 style="margin-bottom:20px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-database"></i> Membres</h1> | ||
26 | + <table class="table table-striped table-bordered"> | ||
27 | + <thead class="thead-dark"> | ||
28 | + <th>Nom</th> | ||
29 | + <th>Prénom</th> | ||
30 | + <th>Identifiant</th> | ||
31 | + <th>Groupe</th> | ||
32 | + <th>Action</th> | ||
33 | + </thead> | ||
34 | + <tbody> | ||
35 | + <?php | ||
36 | + foreach($membres as $membre){ | ||
37 | + ?> | ||
38 | + <tr> | ||
39 | + <td><?php echo $membre['nom'];?></td> | ||
40 | + <td><?php echo $membre['prenom'];?></td> | ||
41 | + <td><?php echo $membre['identifiant'];?></td> | ||
42 | + <td><?php echo groupeId($membre['groupe']);?></td> | ||
43 | + <td> | ||
44 | + <form action="suppression.php" method="POST"> | ||
45 | + <input type="hidden" name="id" value="<?php echo $membre['identifiant'];?>"> | ||
46 | + <input type="submit" name="supprimer" value="Supprimer"> | ||
47 | + </form> | ||
48 | + </td> | ||
49 | + </tr> | ||
50 | + <?php | ||
51 | + } | ||
52 | + ?> | ||
53 | + </tbody> | ||
54 | + </table> | ||
55 | + </div> | ||
56 | + </div> | ||
57 | + <?php | ||
21 | } | 58 | } |
22 | else | 59 | else |
23 | { header("Location: accueil.php"); } | 60 | { header("Location: accueil.php"); } |
site/reception.php
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | session_start(); | 2 | session_start(); |
3 | require("accesBase.php"); | 3 | require("accesBase.php"); |
4 | $err = false; | 4 | $err = false; |
5 | +require("erreurs.php"); | ||
5 | 6 | ||
6 | if(isset($_POST['sensor'])) | 7 | if(isset($_POST['sensor'])) |
7 | { | 8 | { |
@@ -64,7 +65,7 @@ if(isset($_POST['sensor'])) | @@ -64,7 +65,7 @@ if(isset($_POST['sensor'])) | ||
64 | } | 65 | } |
65 | else | 66 | else |
66 | { | 67 | { |
67 | - $ansible = "Code retour : ".$statut."<br/>"; | 68 | + $ansible = "Code retour : ".$statut." => ".$errors[$statut]."<br/>"; |
68 | $message = "Erreur lors du transfert du fichier..."; | 69 | $message = "Erreur lors du transfert du fichier..."; |
69 | $color = "alert-danger"; | 70 | $color = "alert-danger"; |
70 | } | 71 | } |
site/recherche.php
@@ -20,16 +20,15 @@ session_start(); | @@ -20,16 +20,15 @@ session_start(); | ||
20 | <br/> | 20 | <br/> |
21 | <h1 style="margin-bottom:20px; margin-top:60px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-history"></i> Historique</h1> | 21 | <h1 style="margin-bottom:20px; margin-top:60px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-history"></i> Historique</h1> |
22 | <table class="table table-striped table-bordered"> | 22 | <table class="table table-striped table-bordered"> |
23 | + <thead class="thead-dark"> | ||
24 | + <th>Nom</th> | ||
25 | + <th>Raspberry</th> | ||
26 | + <th>Type</th> | ||
27 | + <th>Valeur</th> | ||
28 | + <th>Unité</th> | ||
29 | + <th>Date</th> | ||
30 | + </thead> | ||
23 | <tbody> | 31 | <tbody> |
24 | - <tr> | ||
25 | - <td>Nom</td> | ||
26 | - <td>Raspberry</td> | ||
27 | - <td>Type</td> | ||
28 | - <td>Valeur</td> | ||
29 | - <td>Unité</td> | ||
30 | - <td>Date</td> | ||
31 | - </tr> | ||
32 | - | ||
33 | <div id="sensors"> | 32 | <div id="sensors"> |
34 | <?php | 33 | <?php |
35 | $name = $_POST['nom']; | 34 | $name = $_POST['nom']; |
site/remove.php
@@ -12,6 +12,7 @@ session_start(); | @@ -12,6 +12,7 @@ session_start(); | ||
12 | <body> | 12 | <body> |
13 | <?php | 13 | <?php |
14 | include("header.php"); | 14 | include("header.php"); |
15 | + require("erreurs.php"); | ||
15 | if(isset($_SESSION['Login'], $_SESSION['Password'])) | 16 | if(isset($_SESSION['Login'], $_SESSION['Password'])) |
16 | { | 17 | { |
17 | ?> | 18 | ?> |
@@ -57,7 +58,7 @@ session_start(); | @@ -57,7 +58,7 @@ session_start(); | ||
57 | } | 58 | } |
58 | else | 59 | else |
59 | { | 60 | { |
60 | - $ansible = "Code retour : ".$statut."<br/>"; | 61 | + $ansible = "Code retour : ".$statut." => ".$errors[$statut]."<br/>"; |
61 | $message = "Echec lors de la suppression !"; | 62 | $message = "Echec lors de la suppression !"; |
62 | $color = "alert-danger"; | 63 | $color = "alert-danger"; |
63 | } | 64 | } |
site/removeRpi.php
@@ -12,6 +12,7 @@ session_start(); | @@ -12,6 +12,7 @@ session_start(); | ||
12 | <body> | 12 | <body> |
13 | <?php | 13 | <?php |
14 | include("header.php"); | 14 | include("header.php"); |
15 | + require("erreurs.php"); | ||
15 | if(isset($_SESSION['Login'], $_SESSION['Password'])) | 16 | if(isset($_SESSION['Login'], $_SESSION['Password'])) |
16 | { | 17 | { |
17 | ?> | 18 | ?> |
@@ -73,7 +74,7 @@ session_start(); | @@ -73,7 +74,7 @@ session_start(); | ||
73 | } | 74 | } |
74 | else | 75 | else |
75 | { | 76 | { |
76 | - $ansible = "Code retour : ".$statut."<br/>"; | 77 | + $ansible = "Code retour : ".$statut." => ".$errors[$statut]."<br/>"; |
77 | $message = "Echec lors de la suppression !"; | 78 | $message = "Echec lors de la suppression !"; |
78 | $color = "alert-danger"; | 79 | $color = "alert-danger"; |
79 | } | 80 | } |
site/stop.php
1 | <?php | 1 | <?php |
2 | require_once("accesBase.php"); | 2 | require_once("accesBase.php"); |
3 | +require("erreurs.php"); | ||
3 | 4 | ||
4 | $arduino_simple = "[Arduino]\r\n"; | 5 | $arduino_simple = "[Arduino]\r\n"; |
5 | $arduino_spi = "[Arduino]\r\n"; | 6 | $arduino_spi = "[Arduino]\r\n"; |
@@ -36,7 +37,7 @@ if($statut == 0) | @@ -36,7 +37,7 @@ if($statut == 0) | ||
36 | } | 37 | } |
37 | else | 38 | else |
38 | { | 39 | { |
39 | - $ansible = "Code retour : ".$statut."<br/>"; | 40 | + $ansible = "Code retour : ".$statut." => ".$errors[$statut]."<br/>"; |
40 | $message = "Echec lors de l'arrêt !"; | 41 | $message = "Echec lors de l'arrêt !"; |
41 | $color = "alert-danger"; | 42 | $color = "alert-danger"; |
42 | } | 43 | } |
@@ -75,7 +76,6 @@ session_start(); | @@ -75,7 +76,6 @@ session_start(); | ||
75 | <div class="alert alert-secondary" role="alert"> | 76 | <div class="alert alert-secondary" role="alert"> |
76 | <?php echo $ansible;?> | 77 | <?php echo $ansible;?> |
77 | </div> | 78 | </div> |
78 | - <meta http-equiv="Refresh" content="5;url=data.php" /> | ||
79 | </div> | 79 | </div> |
80 | </div> | 80 | </div> |
81 | <?php | 81 | <?php |
site/values.php
@@ -3,18 +3,17 @@ | @@ -3,18 +3,17 @@ | ||
3 | <br/> | 3 | <br/> |
4 | <h1 style="margin-bottom:20px; margin-top:60px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-database"></i> Valeurs des capteurs</h1> | 4 | <h1 style="margin-bottom:20px; margin-top:60px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-database"></i> Valeurs des capteurs</h1> |
5 | <table class="table table-striped table-bordered"> | 5 | <table class="table table-striped table-bordered"> |
6 | + <thead class="thead-dark"> | ||
7 | + <th>Nom</th> | ||
8 | + <th>Raspberry</th> | ||
9 | + <th>Type</th> | ||
10 | + <th>Valeur</th> | ||
11 | + <th>Unité</th> | ||
12 | + <th>Action</th> | ||
13 | + </thead> | ||
6 | <tbody> | 14 | <tbody> |
7 | - <tr> | ||
8 | - <td>Nom</td> | ||
9 | - <td>Raspberry</td> | ||
10 | - <td>Type</td> | ||
11 | - <td>Valeur</td> | ||
12 | - <td>Unité</td> | ||
13 | - <td>Arrêt</td> | ||
14 | - </tr> | ||
15 | - | ||
16 | <?php | 15 | <?php |
17 | - $sensors = getSensors(); | 16 | + $sensors = getSensors(); |
18 | foreach($sensors as $sensor){ | 17 | foreach($sensors as $sensor){ |
19 | ?> | 18 | ?> |
20 | <tr> | 19 | <tr> |