threadr.lostcave.ddnss.de/strassenkind.php

51 lines
1.7 KiB
PHP

<!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.";
?>
-->
<html>
<head>
<title> Strassenkind Server Status Page </title>
<link rel="stylesheet" type="text/css" href="./common/content/style.css" />
<?php
if (!isset($_POST['ondemand'])) {
echo "<meta http-equiv=\"refresh\" content=\"20\" />";
}
?>
</head>
<body class="status_page">
<h1> Strassenkind Server Status </h1>
<hr />
<form action="" method="post">
<input type="submit" value="Run ondemand commands" name="ondemand" />
</form>
<hr />
<?php
// run ondemand command list if demanded
if (isset($_POST['ondemand'])) {
foreach ($ondemand_commands as $command) {
$output = shell_exec($command);
echo "<pre class=\"commandLine\"> $command </pre>\n<pre class=\"commandLine\"> $output </pre>\n<hr />";
}
} else {
//run status command list otherwise
foreach ($status_commands as $command) {
$output = shell_exec($command);
echo "<pre class=\"commandLine\"> $command </pre>\n<pre class=\"commandLine\"> $output </pre>\n<hr />";
}
}
?>
</body>
</html>