Commit fb84723eacd5da4a020f91df9d16bf47cf468898
1 parent
1c58232e
MAJ site ajout Rpi
Showing
6 changed files
with
119 additions
and
11 deletions
Show diff stats
site/accesBase.php
... | ... | @@ -235,6 +235,25 @@ |
235 | 235 | deconnexion($db); |
236 | 236 | } |
237 | 237 | |
238 | + function addRpi($ip) | |
239 | + { | |
240 | + $raspberry = "172.26.145.".$ip; | |
241 | + $db = connexion(); | |
242 | + $query = "SELECT * FROM raspberry WHERE ip = '$raspberry'"; | |
243 | + $result = pg_query($db, $query) or die("La requ te a echou : ".pg_last_error()); | |
244 | + if (pg_affected_rows($result)!=0) | |
245 | + { | |
246 | + deconnexion($db); | |
247 | + return False; | |
248 | + } | |
249 | + else{ | |
250 | + $query = "INSERT INTO raspberry VALUES('$raspberry', 1)"; | |
251 | + $result = pg_query($db, $query) or die("La requ te a echou : ".pg_last_error()); | |
252 | + deconnexion($db); | |
253 | + return pg_affected_rows($result)==1; | |
254 | + } | |
255 | + } | |
256 | + | |
238 | 257 | function add($nom, $type, $raspberry, $numero, $unite, $version) |
239 | 258 | { |
240 | 259 | $db = connexion(); | ... | ... |
... | ... | @@ -0,0 +1,19 @@ |
1 | +<div class="row"> | |
2 | + <div class="col-4 col-md-4 offset-md-4 offset-4"> | |
3 | + <br/> | |
4 | + <h1 style="margin-bottom:20px; margin-top:30px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="far fa-plus-square"></i> Ajout d'un capteur</h1> | |
5 | + <form action="addRpi.php" method="post"> | |
6 | + <table class="table table-striped table-bordered"> | |
7 | + <tbody> | |
8 | + <tr> | |
9 | + <td><label for="ip">Adresse IP : </label></td> | |
10 | + <td>172.26.145.</td> | |
11 | + <td><input type="text" id="ip" name="ip" /></td> | |
12 | + </tr> | |
13 | + </tbody> | |
14 | + </table> | |
15 | + <input type="submit" class="btn btn-dark btn-lg btn-block" style="margin-top:20px; margin-bottom:20px;" value="Ajouter la Raspberry"/> | |
16 | + <br/> | |
17 | + </form> | |
18 | + </div> | |
19 | +</div> | ... | ... |
... | ... | @@ -0,0 +1,53 @@ |
1 | +?php | |
2 | +session_start(); | |
3 | +?> | |
4 | +<!DOCTYPE html> | |
5 | + | |
6 | +<html> | |
7 | + <head> | |
8 | + <?php include("head.php"); ?> | |
9 | + </head> | |
10 | + | |
11 | + <!-- Contenu du site --> | |
12 | + <body> | |
13 | + <?php | |
14 | + include("header.php"); | |
15 | + if(isset($_SESSION['Login'], $_SESSION['Password'])) | |
16 | + { | |
17 | + ?> | |
18 | + <div class="row"> | |
19 | + <div class="col-6 col-md-6 offset-md-3 offset-3"> | |
20 | + <br/> | |
21 | + <h1 style="margin-bottom:20px; margin-top:30px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-history"></i> Historique</h1> | |
22 | + <?php | |
23 | + if(addRpi($_POST['ip']) | |
24 | + { | |
25 | + ?> | |
26 | + <div class="alert alert-success" role="alert"> | |
27 | + La Raspberry a bien été ajouté ! Vous devez maintenant suivre le protocole ci-dessous pour terminer l'installation. | |
28 | + </div> | |
29 | + Protocole | |
30 | + <?php | |
31 | + } | |
32 | + else | |
33 | + { | |
34 | + ?> | |
35 | + <div class="alert alert-danger" role="alert"> | |
36 | + Echec lors de l'ajout. La Raspberry existe peut-être déjà ! | |
37 | + </div> | |
38 | + <meta http-equiv="Refresh" content="3;url=ajoutRaspberry.php" /> | |
39 | + <?php | |
40 | + } | |
41 | + ?> | |
42 | + </div> | |
43 | + </div> | |
44 | + <?php | |
45 | + } | |
46 | + else | |
47 | + { | |
48 | + include("formConnexion.php"); | |
49 | + } | |
50 | + ?> | |
51 | + </body> | |
52 | +</html> | |
53 | + | ... | ... |
... | ... | @@ -0,0 +1,26 @@ |
1 | +<?php | |
2 | +session_start(); | |
3 | +?> | |
4 | +<!DOCTYPE html> | |
5 | + | |
6 | +<html> | |
7 | + <head> | |
8 | + <?php include("head.php"); ?> | |
9 | + </head> | |
10 | + | |
11 | + <!-- Contenu du site --> | |
12 | + <body> | |
13 | + <?php | |
14 | + include("header.php"); | |
15 | + if(isset($_SESSION['Login'], $_SESSION['Password'])) | |
16 | + { | |
17 | + include("addRaspberry.php"); | |
18 | + } | |
19 | + else | |
20 | + { | |
21 | + include("formConnexion.php"); | |
22 | + } | |
23 | + ?> | |
24 | + </body> | |
25 | +</html> | |
26 | + | ... | ... |
site/header.php
... | ... | @@ -10,6 +10,7 @@ |
10 | 10 | $membre = getMembreByIdPwd($_SESSION['Login'], $_SESSION['Password']); |
11 | 11 | ?> |
12 | 12 | <!-- <a href="settings.php"><i class="fa fa-cog"></i> <?php echo $membre['prenom']; echo ' '; echo $membre['nom'];?></a> --> |
13 | + <a href="ajoutRaspberry.php"><i class="far fa-plus-square"></i> Ajouter une Raspberry</a> | |
13 | 14 | <a href="ajoutCapteur.php"><i class="far fa-plus-square"></i> Ajouter un capteur</a> |
14 | 15 | <a href="send.php"><i class="fa fa-file-upload"></i> Envoyer un code</a> |
15 | 16 | <a href="history.php"><i class="fas fa-history"></i> Historique</a> |
... | ... | @@ -17,12 +18,6 @@ |
17 | 18 | <a href="deconnecter.php"><i class="fa fa-power-off"></i> Deconnexion</a> |
18 | 19 | <?php |
19 | 20 | } |
20 | - else | |
21 | - { | |
22 | - ?> | |
23 | - <a href="inscrire.php"><i class="fa fa-user-circle"></i> Inscription</a> | |
24 | - <?php | |
25 | - } | |
26 | 21 | ?> |
27 | 22 | </div> |
28 | 23 | </div> | ... | ... |
site/hist.php
... | ... | @@ -80,13 +80,9 @@ $date_max = $maxs[0]; |
80 | 80 | <td><label for"nombre">Nombre de résultats (entre 1 et 100) :</label></td> |
81 | 81 | <td><input type="text" id="nombre" name="nombre" min="1" max="100" value="10" /></td> |
82 | 82 | </tr> |
83 | - | |
84 | - <tr> | |
85 | - <td></td> | |
86 | - <td><input type="submit" class="btn btn-dark" value="Lancer la recherche"/></td> | |
87 | - </tr> | |
88 | 83 | </tbody> |
89 | 84 | </table> |
85 | + <input type="submit" class="btn btn-dark btn-lg btn-block" style="margin-top:20px; margin-bottom:20px;" value="Lancer la recherche"/> | |
90 | 86 | </form> |
91 | 87 | </div> |
92 | 88 | </div> | ... | ... |