Ajaxify system reboot/shutdown

This commit is contained in:
billz
2023-10-08 19:21:43 +02:00
parent 2ac5f94594
commit 21f703b5a9
4 changed files with 32 additions and 11 deletions

View File

@@ -0,0 +1,21 @@
<?php
require '../../includes/csrf.php';
$action = escapeshellcmd($_POST['a']);
if (isset($action)) {
switch($action) {
case "reboot":
$response = shell_exec("sudo /sbin/reboot");
break;
case "shutdown":
$response = shell_exec("sudo /sbin/shutdown -h now");
break;
default:
$response = 'Unknown action: '.$action;
}
echo json_encode($response);
}