stop.php
1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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
<?php
require_once("accesBase.php");
require("erreurs.php");
$arduino_simple = "[Arduino]\r\n";
$arduino_spi = "[Arduino]\r\n";
$nucleo = "[Nucleo]\r\n";
$version = getVersion($_POST['nom']);
if($version == 0)
{
$ini = $arduino_simple;
}
elseif($version == 1)
{
$ini = $arduino_spi;
}
elseif($version == 2)
{
$ini = $nucleo;
}
$numero = getNumero($_POST['nom']);
$raspberry = getRaspberry($_POST['nom']);
$ini = $ini.$raspberry." capteur=".$numero."-".$version." setup=0 ordre=1\n";
file_put_contents('upload/inventaire.ini', $ini);
$retour = array();
$statut;
exec("super cmd.sh", $retour, $statut);
if($statut == 0)
{
$message = "Le capteur a bien été arrêté !";
$color = "alert-success";
}
else
{
$ansible = "Code retour : ".$statut." => ".$errors[$statut]."<br/>";
$message = "Echec lors de l'arrêt !";
$color = "alert-danger";
}
$size = count($retour);
for($i = 0; $i<$size; $i++)
{
$ansible = $ansible.$retour[$i]."<br/>";
}
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> Arrêt d'un capteur</h1>
<div class="alert <?php echo $color;?>" role="alert">
<?php echo $message;?>
</div>
<div class="alert alert-secondary" role="alert">
<?php echo $ansible;?>
</div>
</div>
</div>
<?php
}
else
{
include("formConnexion.php");
}
?>
</body>
</html>