Commit 258ea4b3fbda79f5b5880cfd8fdeb1557e58702c
1 parent
88207336
MAJ
Showing
2 changed files
with
51 additions
and
2 deletions
Show diff stats
site/accesBase.php
@@ -378,9 +378,19 @@ | @@ -378,9 +378,19 @@ | ||
378 | $db = connexion(); | 378 | $db = connexion(); |
379 | $query = "SELECT raspberry FROM capteurs WHERE nom = '$nom'"; | 379 | $query = "SELECT raspberry FROM capteurs WHERE nom = '$nom'"; |
380 | $result = pg_query($db, $query) or die("La requ te a echou : ".pg_last_error()); | 380 | $result = pg_query($db, $query) or die("La requ te a echou : ".pg_last_error()); |
381 | + $tab = pg_fetch_all($result); | ||
382 | + deconnexion($db); | ||
383 | + return $tab; | ||
384 | + } | ||
385 | + | ||
386 | + function getSensorByRaspberry($ip) | ||
387 | + { | ||
388 | + $db = connexion(); | ||
389 | + $query = "SELECT nom FROM capteurs WHERE raspberry = '$ip'"; | ||
390 | + $result = pg_query($db, $query) or die("La requ te a echou : ".pg_last_error()); | ||
381 | $tab = pg_fetch_assoc($result); | 391 | $tab = pg_fetch_assoc($result); |
382 | deconnexion($db); | 392 | deconnexion($db); |
383 | - return $tab['raspberry']; | 393 | + return $tab['nom']; |
384 | } | 394 | } |
385 | 395 | ||
386 | function getTime($type) | 396 | function getTime($type) |
site/removeRpi.php
@@ -20,8 +20,47 @@ session_start(); | @@ -20,8 +20,47 @@ 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> Suppression d'une Raspberry</h1> | 21 | <h1 style="margin-bottom:20px; margin-top:60px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-history"></i> Suppression d'une Raspberry</h1> |
22 | <?php | 22 | <?php |
23 | - if(removeRpi($_POST['ip'])) | 23 | + $capteurs = getSensorByRaspberry($_POST['ip']); |
24 | + | ||
25 | + $ini = ""; | ||
26 | + $arduino_simple = "[Arduino_delete]\r\n"; | ||
27 | + $arduino_spi = "[Arduino_delete]\r\n"; | ||
28 | + $nucleo = "[Nucleo_delete]\r\n"; | ||
29 | + | ||
30 | + $a_simple = false; | ||
31 | + $a_spi = false; | ||
32 | + $n = false; | ||
33 | + | ||
34 | + foreach($capteurs as $capteur) | ||
35 | + { | ||
36 | + $numero = $capteur['numero'], | ||
37 | + $raspberry = $capteur['raspberry']; | ||
38 | + $version = $capteur['version']; | ||
39 | + if($version == 0) | ||
40 | + { | ||
41 | + $a_simple = true; | ||
42 | + $arduino_simple = $arduino_simple.$raspberry." capteur=".$numero."-".$version." setup=0\n"; | ||
43 | + } | ||
44 | + elseif($version == 1) | ||
45 | + { | ||
46 | + $a_spi = true; | ||
47 | + $arduino_spi= $arduino_spi.$raspberry." capteur=".$numero."-".$version." setup=0\n"; | ||
48 | + } | ||
49 | + elseif($version == 2) | ||
50 | + { | ||
51 | + $n = true; | ||
52 | + $nucleo = $nucleo.$raspberry." capteur=".$numero."-".$version." setup=0\n"; | ||
53 | + } | ||
54 | + } | ||
55 | + | ||
56 | + if($a_simple) {$ini = $ini.$arduino_simple."\n";} | ||
57 | + if($a_spi) {$ini = $ini.$arduino_spi."\n";} | ||
58 | + if($n) {$ini = $ini.$nucleo."\n";} | ||
59 | + | ||
60 | + if(removeRpi($_POST['ip'])) | ||
24 | { | 61 | { |
62 | + file_put_contents('upload/inventaire.ini', $ini); | ||
63 | + //exec("super cmd.sh"); | ||
25 | ?> | 64 | ?> |
26 | <div class="alert alert-success" role="alert"> | 65 | <div class="alert alert-success" role="alert"> |
27 | La Raspberry a bien été supprimée ! | 66 | La Raspberry a bien été supprimée ! |