Blame view

site/removeRpi.php 2.35 KB
62c28743   grouille   Suppression RPI +...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  <?php
  session_start();
  ?>
  <!DOCTYPE html>
  
  <html>
          <head>
                  <?php include("head.php"); ?>
          </head>
  
          <!-- Contenu du site -->
          <body>
                  <?php 
                  include("header.php");
                  if(isset($_SESSION['Login'], $_SESSION['Password']))
                  {
                          ?>
  			<div class="row">
  			        <div class="col-6 col-md-6 offset-md-3 offset-3">
                  			<br/>
                  			<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>
  					<?php
258ea4b3   grouille   MAJ
23
24
25
26
27
28
29
30
31
32
33
34
35
  					$capteurs = getSensorByRaspberry($_POST['ip']);
  
  					$ini = "";
  					$arduino_simple = "[Arduino_delete]\r\n";
  					$arduino_spi = "[Arduino_delete]\r\n";
  					$nucleo = "[Nucleo_delete]\r\n";
  
  					$a_simple = false;
  					$a_spi = false;
  					$n = false;
  
  					foreach($capteurs as $capteur)
  					{
efa97e8a   grouille   MAJ
36
  						$numero = $capteur['numero'];
258ea4b3   grouille   MAJ
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  						$raspberry = $capteur['raspberry'];
  						$version = $capteur['version'];
  						if($version == 0)
  						{
  							$a_simple = true;
  							$arduino_simple = $arduino_simple.$raspberry." capteur=".$numero."-".$version." setup=0\n";
  						}
  						elseif($version == 1)
  						{
  							$a_spi = true;
  							$arduino_spi= $arduino_spi.$raspberry." capteur=".$numero."-".$version." setup=0\n";
  						}
  						elseif($version == 2)
  						{
  							$n = true;
  							$nucleo = $nucleo.$raspberry." capteur=".$numero."-".$version." setup=0\n";
  						}
  					}
  
  					if($a_simple) {$ini = $ini.$arduino_simple."\n";}
  					if($a_spi) {$ini = $ini.$arduino_spi."\n";}
  					if($n) {$ini = $ini.$nucleo."\n";}
  
  					if(removeRpi($_POST['ip']))
62c28743   grouille   Suppression RPI +...
61
  					{
258ea4b3   grouille   MAJ
62
63
  						file_put_contents('upload/inventaire.ini', $ini);
  						//exec("super cmd.sh");
62c28743   grouille   Suppression RPI +...
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
  						?>
  						<div class="alert alert-success" role="alert">
  					     		La Raspberry a bien été supprimée !
  						</div>
  						<?php
  					}
  					else
  					{
  						?>
  						<div class="alert alert-danger" role="alert">
  					     		Echec lors de la suppression.
  						</div>
  						<meta http-equiv="Refresh" content="3;url=gestionRaspberry.php" />
  						<?php
  					}
  					?>
          			</div>
  			</div>
  			<?php
                  }
                  else
                  {
                          include("formConnexion.php");
                  }
                  ?>
          </body>
  </html>