„vm_control.php“ ändern

This commit is contained in:
Stephan 2022-02-09 21:55:18 +00:00
parent 536fe1e2aa
commit f9eb8c1fbf

View file

@ -15,9 +15,10 @@
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Auswertung der Argumente: // Auswertung der Argumente:
// ----------------------------------------------- // -----------------------------------------------
$error_msg = "";
// leeren Parameter 'vmname' unterbinden: // leeren Parameter 'vmname' unterbinden:
if(!isset($_GET['vmname'])){ if(!isset($_GET['vmname'])){
exit("EXIT - keine VM angegeben!"); $error_msg = "EXIT - keine VM angegeben!<br>";
} }
// ----------------------------------------------- // -----------------------------------------------
@ -37,19 +38,21 @@
} }
include("vm_state.php"); include("vm_state.php");
// -----------------------------------------------
// letzten Zugriff dokumentieren:
$vm_state["letzter Zugriff:"] = "VM: ".$_GET['vmname']." / Status: ".$_GET['state']." / Key: ".$_GET['key']." / Zeitpunkt: ".date("Y-m-d_H-i-s", time());
// ----------------------------------------------- // -----------------------------------------------
// check Key: // check Key:
if(strcmp($_GET['key'], "$defined_key")) { if(strcmp($_GET['key'], "$defined_key")) {
exit("Zugriff verweigert"); $error_msg = $error_msg."Zugriff verweigert!";
} }
// ----------------------------------------------- // -----------------------------------------------
// schreibe Status in Array: // schreibe Status in Array:
$vm_state[$_GET['vmname']] = $_GET['state']; if(empty($error_msg)){
$vm_state[$_GET['vmname']] = $_GET['state'];
}
// -----------------------------------------------
// letzten Zugriff dokumentieren:
$log["LOG: ".date("Y-m-d_H-i-s", time())] = "VM: ".$_GET['vmname']." / Status: ".$_GET['state']." / Key: ".$_GET['key']." / IP: ".$_SERVER['REMOTE_ADDR'];
// ----------------------------------------------- // -----------------------------------------------
// Daten speichern: // Daten speichern:
@ -57,6 +60,7 @@
ftruncate ($fp, 0); ftruncate ($fp, 0);
$input = "<?php\n"; $input = "<?php\n";
$input .= "\$vm_state = ".var_export($vm_state, true).";\n"; $input .= "\$vm_state = ".var_export($vm_state, true).";\n";
$input .= "\$log = ".var_export($log, true).";\n";
$input .= "?>"; $input .= "?>";
fwrite($fp, $input); fwrite($fp, $input);
@ -67,6 +71,11 @@
// ----------------------------------------------- // -----------------------------------------------
// Rückgabe: // Rückgabe:
exit("Status notiert ..."); if(empty($error_msg)){
exit("Status notiert ...");
}
else{
exit($error_msg);
}
?> ?>