threadr.lostcave.ddnss.de/strassenkind.php

54 lines
1.9 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-02-19 03:49:30 +01:00
<link rel="stylesheet" type="text/css" href=".%CONTENT_DIR%/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-02-12 05:26:21 +01:00
<?php
// run ondemand command list if demanded
if (isset($_POST['ondemand'])) {
foreach ($ondemand_commands as $command) {
2020-02-12 05:30:30 +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
}
} else {
//run status command list otherwise
foreach ($status_commands as $command) {
2020-02-12 05:30:30 +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-02-12 04:45:55 +01:00
</body>
</html>