Initial commit
This commit is contained in:
47
minecraft.php
Normal file
47
minecraft.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
$DIGITALOCEAN_TOKEN="dop_your_digitalocean_token_here";
|
||||
$DROPLET_ID="your_droplet_id_here";
|
||||
$PASSWORD="your_password_here";
|
||||
|
||||
if ($_GET['password'] !== $PASSWORD) {
|
||||
usleep(rand(0,999999));
|
||||
exit("Invalid password.");
|
||||
}
|
||||
|
||||
if ($_GET['action'] == "on") {
|
||||
|
||||
$out = `curl -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
|
||||
-d '{"type":"power_on"}' \
|
||||
"https://api.digitalocean.com/v2/droplets/$DROPLET_ID/actions"`;
|
||||
|
||||
} elseif ($_GET['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") {
|
||||
|
||||
$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 ($json['action']) {
|
||||
echo $json['action']['status'];
|
||||
} elseif ($json['droplet']) {
|
||||
echo $json['droplet']['status'];
|
||||
}
|
||||
Reference in New Issue
Block a user