|
@@ -2,10 +2,16 @@
|
|
|
use PHPMailer\PHPMailer\PHPMailer;
|
|
|
use PHPMailer\PHPMailer\SMTP;
|
|
|
use PHPMailer\PHPMailer\Exception;
|
|
|
+ use DevCoder\DotEnv;
|
|
|
|
|
|
+ require 'dotenv.php';
|
|
|
require 'phpmailer/Exception.php';
|
|
|
require 'phpmailer/PHPMailer.php';
|
|
|
require 'phpmailer/SMTP.php';
|
|
|
+
|
|
|
+
|
|
|
+ (new DotEnv(dirname(__FILE__,3)."/.env"))->load();
|
|
|
+
|
|
|
include("functions.php");
|
|
|
|
|
|
if(isset($_POST['checkDB'])){
|
|
@@ -104,6 +110,52 @@ if(isset($_POST['checkSMTP'])){
|
|
|
|
|
|
}
|
|
|
|
|
|
+if(isset($_POST['checkPtero'])){
|
|
|
+ $url = $_POST['url'];
|
|
|
+ $key = $_POST['key'];
|
|
|
+
|
|
|
+ if(substr($url, -1)==="/"){
|
|
|
+ $url = substr_replace($url ,"", -1);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $pteroURL = $url."/api/application/users";
|
|
|
+ $ch = curl_init();
|
|
|
+
|
|
|
+ curl_setopt($ch, CURLOPT_URL, $pteroURL);
|
|
|
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
|
|
+ "Accept: application/json",
|
|
|
+ "Content-Type: application/json",
|
|
|
+ "Authorization: Bearer " . $key
|
|
|
+ ));
|
|
|
+ $response = curl_exec($ch);
|
|
|
+ $result = json_decode($response, true);
|
|
|
+ curl_close($ch); // Close the connection
|
|
|
+
|
|
|
+
|
|
|
+ if(!is_array($result) or in_array($result["errors"][0]["code"],$result)){
|
|
|
+ header("LOCATION: index.php?step=5&message=Couldnt connect to Pterodactyl. Make sure your API key has all read and write permissions!");
|
|
|
+ die();
|
|
|
+ }else{
|
|
|
+ $query1= "UPDATE `dashboard`.`settings` SET `value` = '$url' WHERE (`key` = 'SETTINGS::SYSTEM:PTERODACTYL:URL')";
|
|
|
+ $query2= "UPDATE `dashboard`.`settings` SET `value` = '$key' WHERE (`key` = 'SETTINGS::SYSTEM:PTERODACTYL:TOKEN')";
|
|
|
+
|
|
|
+ $db = new mysqli(getenv("DB_HOST"), getenv("DB_USERNAME"), getenv("DB_PASSWORD"), getenv("DB_DATABASE"), getenv("DB_PORT"));
|
|
|
+ if ($db->connect_error) {
|
|
|
+ header("LOCATION: index.php?step=5&message=Could not connect to the Database");
|
|
|
+ die();
|
|
|
+ }
|
|
|
+
|
|
|
+ if($db->query($query1) && $db->query($query2)){
|
|
|
+ header("LOCATION: index.php?step=6");
|
|
|
+ }else{
|
|
|
+ header("LOCATION: index.php?step=5&message=Something went wrong when communicating with the Database!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
|
|
|
?>
|