Created
October 14, 2019 03:16
-
-
Save BlakeStevenson/414ec2a3046587694b6c566cb14660e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
// allow error reporting | |
ini_set('display_errors', true); | |
// check if parameters are set properly | |
if(isset($_POST['subdomain']) && isset($_POST['port']) && isset($_POST['target']) && isset($_POST['g-recaptcha-response'])) { | |
// include Cloudflare & reCaptcha API Libraries | |
require_once "/var/www/shulker/vendor/autoload.php"; | |
// initialize recaptcha | |
$secret = "YOU THOUGHT?"; | |
$recaptcha = new \ReCaptcha\ReCaptcha($secret); | |
$resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['HTTP_CF_CONNECTING_IP']); | |
if ($resp->isSuccess()) { | |
// Set API Credentials | |
$key = new Cloudflare\API\Auth\APIKey('[email protected]', 'haha you don't get my api key, faggot'); | |
// create adapter | |
$adapter = new Cloudflare\API\Adapter\Guzzle($key); | |
// create endpoint objects | |
$user = new Cloudflare\API\Endpoints\User($adapter); | |
$zones = new \Cloudflare\API\Endpoints\Zones($adapter); | |
$dns = new \Cloudflare\API\Endpoints\DNS($adapter); | |
// Get Zone ID | |
$zoneID = $zones->getZoneID("shulker.me"); | |
// check if subdomain already exists. | |
foreach($dns->listRecords($zoneID)->result as $record) { | |
if($record->name == "_minecraft._tcp." . $_POST['subdomain'] . ".shulker.me") { | |
$_SESSION['success'] = false; | |
$_SESSION['code'] = 2; | |
header('location: /'); | |
} | |
} | |
// set parameters | |
$srvdata = [ | |
'weight' => 100, | |
'priority' => 100, | |
'name' => strtolower($_POST['subdomain']), | |
'proto' => '_tcp', | |
'port' => intval($_POST['port']), | |
'target' => strtolower($_POST['target']), | |
'service' => '_minecraft' | |
]; | |
// create record | |
if ($dns->addRecord($zoneID, "SRV", "", "", 120, false, "", $srvdata)) { | |
$_SESSION['address'] = strtolower($_POST['subdomain']) . ".shulker.me"; | |
header("location: /"); | |
} else { | |
$_SESSION['success'] = false; | |
$_SESSION['code'] = 0; | |
header('location: /'); | |
} | |
} else { | |
$_SESSION['success'] = false; | |
$_SESSION['code'] = 1; | |
header('location: /'); | |
} | |
} else { | |
$_SESSION['success'] = false; | |
$_SESSION['code'] = 0; | |
header('location: /'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment