threadr.lostcave.ddnss.de/strassenkind.php

61 lines
2.0 KiB
PHP
Raw Normal View History

2020-02-12 04:24:26 +01:00
<!DOCTYPE html>
<!--
<?php
echo "Getting status commands...";
$status_file_name = "commands_status.conf";
$status_file = fopen($status_file_name, "r") or die("Could not read file $status_file_name. Aborting.");
$status_commands = explode(PHP_EOL, fread($status_file, filesize($status_file_name)));
fclose($status_file);
echo "Done.";
echo "Getting ondemand commands...";
$ondemand_file_name = "commands_ondemand.conf";
$ondemand_file = fopen($ondemand_file_name, "r") or die("Could not read file $ondemand_file_name. Aborting.");
$ondemand_commands = explode(PHP_EOL, fread($ondemand_file, filesize($ondemand_file_name)));
fclose($ondemand_file);
echo "Done.";
?>
2020-02-12 04:45:55 +01:00
-->
<html>
<head>
2020-02-12 05:26:21 +01:00
<title> Strassenkind Server Status Page </title>
2020-03-04 21:49:18 +01:00
<link rel="stylesheet" type="text/css" href="style.css" />
2020-02-12 05:26:21 +01:00
<?php
if (!isset($_POST['ondemand'])) {
echo "<meta http-equiv=\"refresh\" content=\"20\" />";
}
?>
2020-02-12 04:45:55 +01:00
</head>
2020-02-12 05:26:21 +01:00
<body class="status_page">
<h1> Strassenkind Server Status </h1>
<hr />
2020-02-12 06:21:22 +01:00
<?php
if (!isset($_POST['ondemand'])) {
echo "<form action=\"\" method=\"post\"><input type=\"submit\" value=\"Run ondemand commands\" name=\"ondemand\" /></form><hr />";
} else {
2020-02-12 06:23:02 +01:00
echo "<a href=\"\"><button> Return to regular status commands </button></a><hr />";
2020-02-12 06:21:22 +01:00
}
2020-03-05 03:35:16 +01:00
function execute_command_list($commands){
foreach ($commands as $command) {
2020-03-05 03:07:56 +01:00
if ($command != ""){
// === is here on purpose.
if (strpos($command, '>') === false) {
$command = $command . " 2>&1";
}
2020-03-05 03:07:56 +01:00
$output = shell_exec($command);
echo "<pre class=\"commandLine\"> $command </pre>\n<pre class=\"commandLine\"> $output </pre>\n<hr />";
}
2020-02-12 05:26:21 +01:00
}
2020-03-05 03:35:16 +01:00
}
// run ondemand command list if demanded
if (isset($_POST['ondemand'])) {
execute_command_list($ondemand_commands);
} else {
//run status command list otherwise
execute_command_list($status_commands);
2020-02-12 05:26:21 +01:00
}
?>
2020-02-12 04:45:55 +01:00
</body>
2020-03-04 21:49:18 +01:00
</html>