fusion de Remote v1.4

This commit is contained in:
Jérôme Bousquié
2018-11-21 09:11:34 +01:00
parent 1c32685ce9
commit e71efc6638
23 changed files with 221 additions and 137 deletions
+32 -5
View File
@@ -10,6 +10,8 @@ $username = Username();
$profil = Profil($username);
FiltreProfil($profil);
$url = $url_stop;
if ($profil == $niveaux[$roles[3]]) {
$act = "";
@@ -19,14 +21,23 @@ if ($profil == $niveaux[$roles[3]]) {
$eteindre_salle = "éteindre toute la salle";
$restart = "redémarrer cette machine";
$restart_salle = "redémarrer toute la salle";
$start_process = "start processus distant";
$stop_process = "stop processus distant";
$start_machine = "allumer cette machine";
$start_salle = "démarrer toute la salle";
$action_logout = array($logout, $logout_salle);
$action_stop = array($eteindre, $eteindre_salle);
$action_restart = array($restart, $restart_salle);
$action_start_remote = array($start_process);
$action_stop_remote = array($stop_process);
$action_wake = array($start_machine, $start_salle);
$action = $_POST["stop"];
$host_json = $_POST["host"]; // on récupère une chaîne de caractères représentant un tableau json
$mac_json = $_POST["mac"];
$hosts = json_decode($host_json);
$macs = json_decode($mac_json);
// on choisit la valeur de l'option à passer à la commande shutdown sur Ghost
if (in_array($action, $action_logout)) {
@@ -38,12 +49,28 @@ if ($profil == $niveaux[$roles[3]]) {
if (in_array($action, $action_restart)) {
$act = "r";
}
if (in_array($action, $action_start_remote)) {
$act = "p";
$url = $rpc_url;
}
if (in_array($action, $action_stop_remote)) {
$act = "k";
$url = $rpc_url;
}
if (in_array($action, $action_wake)) {
$act = "w";
$url = $wake_url;
}
if ($act != "") {
foreach ($hosts as $host) {
PostURL($url_stop, array('act'=>$act, 'host'=>$host));
foreach ($hosts as $key => $host) {
//echo $host . " " . $mac[$key]. "<br/>";
PostURL($url, array('act'=>$act, 'host'=>$host, 'mac'=>$macs[$key]));
}
}
}
header('Location: salles_live.php');
?>
if ($url == $url_stop) {
header('Location: salles_live.php');
}
else {
header('Location: '.$_SERVER['HTTP_REFERER']);
}