Commit 627c235bb3044c134b75af73825f30b2ff3009c8

Authored by Guillaume
1 parent 36ef1f60

MAJ site

site/add.php
... ... @@ -22,6 +22,7 @@ session_start();
22 22 <?php
23 23 if(add($_POST['nom'], $_POST['type'], $_POST['raspberry'], $_POST['numero'], $_POST['unite'], $_POST['version']))
24 24 {
  25 + include("ansibleSensor.php");
25 26 ?>
26 27 <div class="alert alert-success" role="alert">
27 28 Le capteur a bien été ajouté !
... ...
site/ansibleSensor.php
1   -$ini = "";
2 1 $arduino_simple = "[Arduino_init]\r\n";
3 2 $arduino_spi = "[Arduino_spi_init]\r\n";
4 3 $nucleo = "[Nucleo_init]\r\n";
5 4  
6   -
7   -
8   -foreach($_POST['sensor'] as $sensor => $value)
  5 +if($_POST['version'] == 0)
9 6 {
10   - $version = -1;
11   - $val = explode(":", $value);
12   -
13   - if(count($types)<>0 && !in_array($val[2], $types)) {$err = true;}
14   - else {$types[] = $val[2];}
15   -
16   - $version = getSensorVersion($val[0], $val[1]);
17   - if($version == 0)
18   - {
19   - $a_simple = true;
20   - $arduino_simple = $arduino_simple.$val[0]." capteur=".$val[1]."\n";
21   - }
22   - elseif($version == 1)
23   - {
24   - $a_spi = true;
25   - $arduino_spi = $arduino_spi.$val[0]." capteur=".$val[1]."\n";
26   - }
27   - elseif($version == 2)
28   - {
29   - $n = true;
30   - $nucleo = $nucleo.$val[0]." capteur=".$val[1]."\n";
31   - }
  7 + $ini = $arduino_simple;
32 8 }
33   -
34   -if($a_simple) {$ini = $ini.$arduino_simple."\n";}
35   -if($a_spi) {$ini = $ini.$arduino_spi."\n";}
36   -if($n) {$ini = $ini.$nucleo."\n";}
37   -
38   -if(!$err)
  9 +elseif($_POST['version'] == 1)
  10 +{
  11 + $ini = $arduino_spi;
  12 +}
  13 +elseif($_POST['version'] == 2)
39 14 {
40   - file_put_contents('upload/inventaire.ini', $ini);
41   -}
42 15 \ No newline at end of file
  16 + $ini = $nucleo
  17 +}
  18 +$ini = $ini.$_POST['raspberry']." capteur=".$_POST['numero']."\n";
  19 +file_put_contents('upload/inventaire.ini', $ini);
43 20 \ No newline at end of file
... ...
site/ansibleSensor.php~ 0 → 100644
... ... @@ -0,0 +1,41 @@
  1 +$ini = "";
  2 +$arduino_simple = "[Arduino_init]\r\n";
  3 +$arduino_spi = "[Arduino_spi_init]\r\n";
  4 +$nucleo = "[Nucleo_init]\r\n";
  5 +
  6 +
  7 +
  8 +foreach($_POST['sensor'] as $sensor => $value)
  9 +{
  10 + $version = -1;
  11 + $val = explode(":", $value);
  12 +
  13 + if(count($types)<>0 && !in_array($val[2], $types)) {$err = true;}
  14 + else {$types[] = $val[2];}
  15 +
  16 + $version = getSensorVersion($val[0], $val[1]);
  17 + if($version == 0)
  18 + {
  19 + $a_simple = true;
  20 + $arduino_simple = $arduino_simple.$val[0]." capteur=".$val[1]."\n";
  21 + }
  22 + elseif($version == 1)
  23 + {
  24 + $a_spi = true;
  25 + $arduino_spi = $arduino_spi.$val[0]." capteur=".$val[1]."\n";
  26 + }
  27 + elseif($version == 2)
  28 + {
  29 + $n = true;
  30 + $nucleo = $nucleo.$val[0]." capteur=".$val[1]."\n";
  31 + }
  32 +}
  33 +
  34 +if($a_simple) {$ini = $ini.$arduino_simple."\n";}
  35 +if($a_spi) {$ini = $ini.$arduino_spi."\n";}
  36 +if($n) {$ini = $ini.$nucleo."\n";}
  37 +
  38 +if(!$err)
  39 +{
  40 + file_put_contents('upload/inventaire.ini', $ini);
  41 +}
0 42 \ No newline at end of file
... ...