2020-02-12 04:24:26 +01:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<!--
|
|
|
|
<?php
|
2020-03-05 04:17:53 +01:00
|
|
|
function get_command_list($command_file_name){
|
2020-03-05 04:21:12 +01:00
|
|
|
echo "Getting commands from file $command_file_name...\n";
|
|
|
|
$command_file = fopen($command_file_name, "r") or die("Could not read file $command_file_name. Aborting.\n");
|
2020-03-05 04:17:53 +01:00
|
|
|
$commands = explode(PHP_EOL, fread($command_file, filesize($command_file_name)));
|
|
|
|
fclose($command_file);
|
2020-03-05 04:21:12 +01:00
|
|
|
echo "Done.\n";
|
2020-03-05 04:17:53 +01:00
|
|
|
return $commands;
|
|
|
|
}
|
|
|
|
|
|
|
|
$status_commands = get_command_list("commands_status.conf");
|
|
|
|
$ondemand_commands = get_command_list("commands_ondemand.conf");
|
|
|
|
$git_commands = get_command_list("commands_git.conf");
|
2020-02-12 04:24:26 +01:00
|
|
|
?>
|
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
|
2020-03-05 04:27:55 +01:00
|
|
|
if (!isset($_POST['ondemand']) || !isset($_POST['git'])) {
|
2020-02-12 05:26:21 +01:00
|
|
|
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
|
2020-03-05 04:17:53 +01:00
|
|
|
function add_button($button_text, $button_action){
|
|
|
|
if (!isset($_POST[$button_action])) {
|
|
|
|
echo "<form action=\"\" method=\"post\"><input type=\"submit\" value=\"$button_text\" name=\"$button_action\" /></form>";
|
|
|
|
} else {
|
|
|
|
echo "<a href=\"\"><button> Return to regular status commands </button></a>";
|
|
|
|
}
|
2020-02-12 06:21:22 +01:00
|
|
|
}
|
2020-03-05 04:17:53 +01:00
|
|
|
|
|
|
|
add_button("Run ondemand commands", "ondemand");
|
|
|
|
add_button("Force ThreadR update", "git");
|
|
|
|
?>
|
|
|
|
<hr />
|
|
|
|
<?php
|
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 != ""){
|
2020-03-05 03:26:21 +01:00
|
|
|
// === 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);
|
2020-03-05 04:17:53 +01:00
|
|
|
} elseif (isset($_POST['git'])) {
|
|
|
|
execute_command_list($git_commands);
|
2020-03-05 03:35:16 +01:00
|
|
|
} 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>
|