Unverified Commit f63ca23b authored by David Beniamine's avatar David Beniamine
Browse files

Unbounded actions

parent bf41a157
......@@ -23,7 +23,24 @@
<div id="box" style="font-size:large">
<div id="content">
<h1> Interface de gestion des postes </h1>
<p> test </p>
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$lines=explode(PHP_EOL, shell_exec("../scripts/get_registry.sh"));
?>
<p> <?php echo count($lines); ?> postes sont inscrits sur ce serveur </p>
<h2> Actions globables </h2>
<form action="index.php" method="post">
<input type="hidden" name="action" value="upgradeAll">
<input type="submit" value="Mettre à jour tous les postes" title="Mettre à jour tous les postes">
</form>
<form action="index.php" method="post">
<input type="hidden" name="action" value="upgradeAllApt">
<input type="submit" value="Mettre à jour tous les postes avec mises à jour APT" title="Mettre à jour tous les postes avec mises à jour APT">
</form>
<h2> Gestion des postes </h2>
<table>
<tr>
<th>Nom</th>
......@@ -37,9 +54,8 @@
<th>Actions</th>
</tr>
<?php
$lines=shell_exec("../scripts/get_registry.sh");
$registry = array();
foreach(explode(PHP_EOL, $lines) as $line){
foreach($lines as $line){
if($line != ""){
$entry=explode(' ', $line);
array_push($registry, $entry);
......@@ -62,24 +78,39 @@ foreach(explode(PHP_EOL, $lines) as $line){
}
# Last seen
echo "<td>".$entry[0]."</td>";
echo "<td>Todo</td>";
echo "</tr>";
echo "<td>";
# Actions
?>
<form action="index.php" method="post">
<input type="hidden" name="action" value="wake">
<input type="hidden" name="mac" value="<?php echo $entry[1]; ?>">
<input type="submit" value="Démarrer" title="Démarrer la machine">
</form>
<form action="index.php" method="post">
<input type="hidden" name="action" value="upgrade">
<input type="hidden" name="mac" value="<?php echo $entry[1]; ?>">
<input type="submit" value="Mettre à jour" title="Mettre à jour">
</form>
<form action="index.php" method="post">
<input type="hidden" name="action" value="upgradeAPT">
<input type="hidden" name="mac" value="<?php echo $entry[1]?>;">
<input type="submit" value="Mettre à jour + Apt" title="Mettre à jour + apt">
</form>
<?php
echo "</td></tr>";
}
}
?>
</table>
<pre>
<? json_encode($registry); ?>
<?php json_encode($registry); ?>
</pre>
<p>Merci d'indiquer l'adresse MAC du PC à réveiller</p>
<form action="index.php" method="post">
<input type="hidden" name="action" value="wake">
<input type="text" name="mac" title="MAC Addresse" placeholder="1a:2b:3c:4e:5f:6a">
<input type="submit" value="Démarrer" title="Démarrer la machine">
</form>
<?php
extract($_POST);
if(!isset($action)){
exit();
}
switch($action){
case "wake" :
echo "<div id='result'><p>Démarrage demandé pour la machine $mac, veuillez patienter</p></div>";
......@@ -113,6 +144,19 @@ foreach(explode(PHP_EOL, $lines) as $line){
</script>
<?php
break;
case "upgradeAll" :
echo "I should upgradeAll machines, not implemented yet";
breaK;
case "upgradeAllApt" :
echo "I should upgradeAllApt machines, not implemented yet";
breaK;
case "upgrade" :
echo "I should upgrade $mac, not implemented yet";
break;
case "upgradeAPT" :
echo "I should upgrade $mac with apt, not implemented yet";
break;
}
?>
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment