Update 3 files
- /minecraft.php - /README.md - /mineautoshutdown.sh
This commit is contained in:
@@ -9,7 +9,7 @@ if ($_GET['password'] !== $PASSWORD) {
|
||||
exit("Invalid password.");
|
||||
}
|
||||
|
||||
if ($_GET['action'] == "on") {
|
||||
if ($_POST['action'] == "on") {
|
||||
|
||||
$out = `curl -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
@@ -17,31 +17,44 @@ $out = `curl -X POST \
|
||||
-d '{"type":"power_on"}' \
|
||||
"https://api.digitalocean.com/v2/droplets/$DROPLET_ID/actions"`;
|
||||
|
||||
} elseif ($_GET['action'] == "off") {
|
||||
} elseif ($_POST['action'] == "off") {
|
||||
|
||||
$out = `curl -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
|
||||
|
||||
-d '{"type":"power_off"}' \
|
||||
"https://api.digitalocean.com/v2/droplets/$DROPLET_ID/actions"`;
|
||||
|
||||
} elseif ($_GET['action'] == "status") {
|
||||
} elseif ($_POST['action'] == "status") {
|
||||
|
||||
$out = `curl -X GET \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
|
||||
"https://api.digitalocean.com/v2/droplets/$DROPLET_ID"`;
|
||||
|
||||
} else {
|
||||
|
||||
echo "Invalid action.";
|
||||
|
||||
}
|
||||
|
||||
$json = json_decode($out, true);
|
||||
if ($out) {
|
||||
$json = json_decode($out, true);
|
||||
|
||||
if ($json['action']) {
|
||||
echo $json['action']['status'];
|
||||
} elseif ($json['droplet']) {
|
||||
echo $json['droplet']['status'];
|
||||
if ($json['action']) {
|
||||
$status = $json['action']['status'];
|
||||
} elseif ($json['droplet']) {
|
||||
$status = $json['droplet']['status'];
|
||||
}
|
||||
}
|
||||
|
||||
?><html>
|
||||
<head><title>MineCollective Minecraft Server</title></head>
|
||||
<body>
|
||||
<p>
|
||||
Press this button to turn on the server. It'll take up to 5 minutes to boot, and turn off
|
||||
after about 30 minutes of inactivity.
|
||||
</p>
|
||||
<form action="#" method="POST">
|
||||
<input type="hidden" name="action" value="on" />
|
||||
<input type="submit" value="Turn On" />
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user