stop.php 1.11 KB
<?php
require_once("accesBase.php");
include("data.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."<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/>";
}

?>
<div class="alert <?php echo $color;?>" role="alert">
	<?php echo $message;?>
</div>
<div class="alert alert-secondary" role="alert">
	<?php echo $ansible;?>
</div>

<?php
//header("Location: data.php");
?>