Browse Source

Merge pull request #403 from ControlPanel-gg/development

Installer Updates
Dennis 3 years ago
parent
commit
5b83b672d1
4 changed files with 27 additions and 48 deletions
  1. 1 0
      .gitignore
  2. 7 5
      public/install/forms.php
  3. 8 13
      public/install/functions.php
  4. 11 30
      public/install/index.php

+ 1 - 0
.gitignore

@@ -23,3 +23,4 @@ storage/app/public/logo.png
 *vscode
  - Kopie.env
 public/install/logs.txt
+install.lock

+ 7 - 5
public/install/forms.php

@@ -206,8 +206,6 @@ if (isset($_POST['createUser'])) {
     }
 
 
-    $name = $_POST['user'];
-    $mail = $_POST['email'];
     $pteroID = $_POST['pteroID'];
     $pass = $_POST['pass'];
     $repass = $_POST['repass'];
@@ -231,9 +229,8 @@ if (isset($_POST['createUser'])) {
     $result = json_decode($response, true);
     curl_close($ch); // Close the connection
 
-
-    if ($result["attributes"]["email"] !== $mail) {
-        header("LOCATION: index.php?step=6&message=The Email is not the same as the one used on Pterodactyl");
+    if (!$result["attributes"]["email"]) {
+        header("LOCATION: index.php?step=6&message=Could not find the user with pterodactyl ID ".$pteroID);
         die();
     }
     if ($pass !== $repass) {
@@ -241,6 +238,8 @@ if (isset($_POST['createUser'])) {
         die();
     }
 
+    $mail = $result["attributes"]["email"];
+    $name = $result["attributes"]["username"];
     $pass = password_hash($pass, PASSWORD_DEFAULT);
 
     $pteroURL = $pterobaseurl["value"] . "/api/application/users/" . $pteroID;
@@ -269,11 +268,14 @@ if (isset($_POST['createUser'])) {
         die();
     }
 
+
+
     $query1 = "INSERT INTO `" . getEnvironmentValue("DB_DATABASE") . "`.`users` (`name`, `role`, `credits`, `server_limit`, `pterodactyl_id`, `email`, `password`, `created_at`) VALUES ('$name', 'admin', '250', '1', '$pteroID', '$mail', '$pass', CURRENT_TIMESTAMP)";
 
 
 
     if ($db->query($query1)) {
+        wh_log("[USER MAKER] Created user with Email ".$mail. " and pterodactyl ID ". $pteroID);
         header("LOCATION: index.php?step=7");
     } else {
         wh_log($db->error);

+ 8 - 13
public/install/functions.php

@@ -1,17 +1,18 @@
 <?php
 
 
-$required_extentions = array("openssl", "gd", "mysql", "PDO", "mbstring", "tokenizer", "bcmath", "xml", "curl", "zip", "fpm");
+$required_extentions = array("openssl", "gd", "mysql", "PDO", "mbstring", "tokenizer", "bcmath", "xml", "curl", "zip", "intl");
 
 $requirements = [
-    "php" => "7.4",
+    "minPhp" => "7.4",
+    "maxPhp" => "8.1", // This version is not supported
     "mysql" => "5.7.22",
 ];
 
 function checkPhpVersion()
 {
     global $requirements;
-    if (version_compare(phpversion(), $requirements["php"], '>=')) {
+    if (version_compare(phpversion(), $requirements["minPhp"], '>=') && version_compare(phpversion(), $requirements["maxPhp"], '<')) {
         return "OK";
     }
     return "not OK";
@@ -22,8 +23,7 @@ function checkWriteable()
 }
 function checkHTTPS()
 {
-    return
-        (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
+    return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
         || $_SERVER['SERVER_PORT'] == 443;
 }
 
@@ -84,7 +84,6 @@ function checkExtensions()
             array_push($not_ok, $ext);
     }
     return $not_ok;
-
 }
 
 function setEnvironmentValue($envKey, $envValue)
@@ -119,7 +118,6 @@ function getEnvironmentValue($envKey)
 
 
     return $value;
-
 }
 
 
@@ -133,14 +131,11 @@ function run_console($command)
 function wh_log($log_msg)
 {
     $log_filename = "log";
-    if (!file_exists($log_filename))
-    {
+    if (!file_exists($log_filename)) {
         // create directory/folder uploads.
         mkdir($log_filename, 0777, true);
     }
-    $log_file_data = $log_filename.'/log_' . date('d-M-Y') . '.log';
+    $log_file_data = $log_filename . '/log_' . date('d-M-Y') . '.log';
     // if you don't add `FILE_APPEND`, the file will be erased each time you add a log
-    file_put_contents($log_file_data, "[".date('h:i:s')."] " . $log_msg . "\n", FILE_APPEND);
+    file_put_contents($log_file_data, "[" . date('h:i:s') . "] " . $log_msg . "\n", FILE_APPEND);
 }
-
-?>

+ 11 - 30
public/install/index.php

@@ -22,6 +22,7 @@ if (file_exists("../../install.lock")) {
             left: 50%;
             margin-right: -50%;
             transform: translate(-50%, -50%);
+            width: 30%;
         }
 
         .ok {
@@ -68,7 +69,7 @@ if (!isset($_GET['step'])) {
     <p class="<?php print(checkWriteable() == true ? "ok" : "notok"); ?>">Write-permissions on .env-file</p>
 
     <p class="<?php print(checkPhpVersion() === "OK" ? "ok" : "notok"); ?>"> php
-        version: <?php echo phpversion(); ?> (required <?php echo $requirements["php"]; ?>)</p>
+        version: <?php echo phpversion(); ?> (minimum required <?php echo $requirements["minPhp"]; ?>)</p>
     <p class="<?php print(getMySQLVersion() === "OK" ? "ok" : "notok"); ?>"> mysql
         version: <?php echo getMySQLVersion(); ?> (minimum required <?php echo $requirements["mysql"]; ?>)</p>
 
@@ -399,29 +400,18 @@ echo $cardheader;
                     <form method="POST" enctype="multipart/form-data" class="mb-3"
                           action="/install/forms.php" name="createUser">
 
-                        <div class="row">
-                            <div class="col-md-12">
-                                <div class="form-group">
-                                    <div class="custom-control mb-3">
-                                        <label for="user">Your Username</label>
-                                        <input id="user" name="user"
-                                               type="text" required
-                                               value="" class="form-control">
-                                    </div>
-                                </div>
-                                <div class="form-group">
-                                    <div class="custom-control mb-3">
-                                        <label for="email">Your Email Adress (used to Login)</label>
-                                        <input id="email" name="email"
-                                               type="text" required
-                                               value="" class="form-control">
-                                    </div>
-                                </div>
-
+                        <div class="form-group">
+                            <div class="custom-control mb-3">
+                                <label for="pteroID">Your Pterodactyl User-ID (found in the users-list on your pterodactyl dashboard)</label>
+                                <input id="pteroID" name="pteroID" type="text"
+                                       required
+                                       value="1" class="form-control">
+                            </div>
+                        </div>
 
                                 <div class="form-group">
                                     <div class="custom-control mb-3">
-                                        <label for="pass">Password</label>
+                                        <label for="pass">Password (this will be your new pterodactyl password aswell!)</label>
                                         <input id="pass" name="pass" type="password"
                                                required
                                                value="" minlength="8" class="form-control">
@@ -436,15 +426,6 @@ echo $cardheader;
                                     </div>
                                 </div>
 
-                                <div class="form-group">
-                                    <div class="custom-control mb-3">
-                                        <label for="pteroID">Your Pterodactyl User-ID</label>
-                                        <input id="pteroID" name="pteroID" type="text"
-                                               required
-                                               value="" class="form-control">
-                                    </div>
-                                </div>
-
                             </div>
 
                             <button class="btn btn-primary" name="createUser">Submit</button>