Commit 13bd3d9482a2b8989a6809a37e9b41e38ac8dc44
1 parent
064570f9
MAJ
Showing
2 changed files
with
48 additions
and
1 deletions
Show diff stats
site/accesBase.php
... | ... | @@ -205,6 +205,16 @@ |
205 | 205 | return (int)$tab['version']; |
206 | 206 | } |
207 | 207 | |
208 | + function getVersion($nom) | |
209 | + { | |
210 | + $db = connexion(); | |
211 | + $query = "SELECT version FROM capteurs where nom = '$nom'"; | |
212 | + $result = pg_query($db, $query) or die("La requète a echoué : ".pg_last_error()); | |
213 | + $tab = pg_fetch_assoc($result); | |
214 | + deconnexion($db); | |
215 | + return (int)$tab['version']; | |
216 | + } | |
217 | + | |
208 | 218 | function getRaspberrys() |
209 | 219 | { |
210 | 220 | $db = connexion(); |
... | ... | @@ -363,6 +373,16 @@ |
363 | 373 | return $tab['numero']; |
364 | 374 | } |
365 | 375 | |
376 | + function getRaspberry($nom) | |
377 | + { | |
378 | + $db = connexion(); | |
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()); | |
381 | + $tab = pg_fetch_assoc($result); | |
382 | + deconnexion($db); | |
383 | + return $tab['raspberry']; | |
384 | + } | |
385 | + | |
366 | 386 | function getTime($type) |
367 | 387 | { |
368 | 388 | $db = connexion(); | ... | ... |
site/stop.php
1 | 1 | <?php |
2 | -echo $_POST['nom']; | |
2 | +require_once("accesBase.php"); | |
3 | + | |
4 | +$arduino_simple = "[Arduino_stop]\r\n"; | |
5 | +$arduino_spi = "[Arduino_stop]\r\n"; | |
6 | +$nucleo = "[Nucleo_stop]\r\n"; | |
7 | + | |
8 | +$version = getVersion($_POST['nom']); | |
9 | + | |
10 | +if($version == 0) | |
11 | +{ | |
12 | + $ini = $arduino_simple; | |
13 | +} | |
14 | +elseif($version == 1) | |
15 | +{ | |
16 | + $ini = $arduino_spi; | |
17 | +} | |
18 | +elseif($version == 2) | |
19 | +{ | |
20 | + $ini = $nucleo; | |
21 | +} | |
22 | + | |
23 | +$numero = getNumero($_POST['nom']); | |
24 | +$raspberry = getRaspberry($_POST['nom']); | |
25 | +$ini = $ini.$raspberry." capteur=".$numero."-".$version." setup=0\n"; | |
26 | +file_put_contents('upload/inventaire.ini', $ini); | |
27 | + | |
28 | +//exec("super cmd.sh"); | |
29 | +header("Location: accueil.php"); | |
3 | 30 | ?> | ... | ... |