]> Slayer Assistant Repositories - slayer.unlishema.org/.git/commitdiff
Moved creds out of source
authorunlishema <unlishema@jtryba.com>
Sat, 26 Oct 2024 15:11:29 +0000 (11:11 -0400)
committerunlishema <unlishema@jtryba.com>
Sat, 26 Oct 2024 15:11:29 +0000 (11:11 -0400)
dist/pages/data/assignments.php
dist/pages/data/creatures.php
dist/pages/data/masters.php
src/pages/data/assignments.php
src/pages/data/creatures.php
src/pages/data/masters.php

index 79372301f7743c4d3ca04cfe6962cfd8eb5f076b..4e11ed94b47b3627bca879a525c34068ea13309d 100644 (file)
@@ -1,9 +1,26 @@
 <?php
-// Database credentials
-$host = 'localhost';  
-$db = 'slayer.unlishema.org'; 
-$user = 'slayer.db'; 
-$pass = 'r2YWbde6V9hr'; 
+// Database credentials with default values
+$host = "localhost";
+$user = "username";
+$pass = "password";
+$db = "database";
+
+// Load database creds so they aren't public
+$configPath = $_SERVER['DOCUMENT_ROOT'] . '/../../slayer_assistant_private.json';
+
+if (file_exists($configPath)) {
+    $config = json_decode(file_get_contents($configPath), true);
+    if ($config === null) {
+        die("Invalid configuration format.");
+    }
+    // Update variables with config values if the file is found
+    $host = $config['host'];
+    $user = $config['username'];  // Overrides initial $user = "username"
+    $pass = $config['password'];
+    $db = $config['dbname'];
+} else {
+    die("Configuration file not found.");
+}
 
 // Function to return error as JSON and exit
 function respondWithError($message) {
index 8e3cb97b1c7cea7a106dc2f5765d912f11e21a12..2e1d9a3c9bf5a666d28a6e8d8d5f05f10e713ddc 100644 (file)
@@ -1,9 +1,26 @@
 <?php
-// Database credentials
-$host = 'localhost';  
-$db = 'slayer.unlishema.org'; 
-$user = 'slayer.db'; 
-$pass = 'r2YWbde6V9hr'; 
+// Database credentials with default values
+$host = "localhost";
+$user = "username";
+$pass = "password";
+$db = "database";
+
+// Load database creds so they aren't public
+$configPath = $_SERVER['DOCUMENT_ROOT'] . '/../../slayer_assistant_private.json';
+
+if (file_exists($configPath)) {
+    $config = json_decode(file_get_contents($configPath), true);
+    if ($config === null) {
+        die("Invalid configuration format.");
+    }
+    // Update variables with config values if the file is found
+    $host = $config['host'];
+    $user = $config['username'];  // Overrides initial $user = "username"
+    $pass = $config['password'];
+    $db = $config['dbname'];
+} else {
+    die("Configuration file not found.");
+}
 
 // Function to return error as JSON and exit
 function respondWithError($message) {
index d9a6aedc798230ad9e72380a252d3dca95020c58..a68b881fd2ff201c23ba53ccb728cbdd22e592b2 100644 (file)
@@ -1,9 +1,26 @@
 <?php
-// Database credentials
-$host = 'localhost';  
-$db = 'slayer.unlishema.org'; 
-$user = 'slayer.db'; 
-$pass = 'r2YWbde6V9hr'; 
+// Database credentials with default values
+$host = "localhost";
+$user = "username";
+$pass = "password";
+$db = "database";
+
+// Load database creds so they aren't public
+$configPath = $_SERVER['DOCUMENT_ROOT'] . '/../../slayer_assistant_private.json';
+
+if (file_exists($configPath)) {
+    $config = json_decode(file_get_contents($configPath), true);
+    if ($config === null) {
+        die("Invalid configuration format.");
+    }
+    // Update variables with config values if the file is found
+    $host = $config['host'];
+    $user = $config['username'];  // Overrides initial $user = "username"
+    $pass = $config['password'];
+    $db = $config['dbname'];
+} else {
+    die("Configuration file not found.");
+}
 
 // Function to return error as JSON and exit
 function respondWithError($message) {
index 79372301f7743c4d3ca04cfe6962cfd8eb5f076b..4e11ed94b47b3627bca879a525c34068ea13309d 100644 (file)
@@ -1,9 +1,26 @@
 <?php
-// Database credentials
-$host = 'localhost';  
-$db = 'slayer.unlishema.org'; 
-$user = 'slayer.db'; 
-$pass = 'r2YWbde6V9hr'; 
+// Database credentials with default values
+$host = "localhost";
+$user = "username";
+$pass = "password";
+$db = "database";
+
+// Load database creds so they aren't public
+$configPath = $_SERVER['DOCUMENT_ROOT'] . '/../../slayer_assistant_private.json';
+
+if (file_exists($configPath)) {
+    $config = json_decode(file_get_contents($configPath), true);
+    if ($config === null) {
+        die("Invalid configuration format.");
+    }
+    // Update variables with config values if the file is found
+    $host = $config['host'];
+    $user = $config['username'];  // Overrides initial $user = "username"
+    $pass = $config['password'];
+    $db = $config['dbname'];
+} else {
+    die("Configuration file not found.");
+}
 
 // Function to return error as JSON and exit
 function respondWithError($message) {
index 8e3cb97b1c7cea7a106dc2f5765d912f11e21a12..2e1d9a3c9bf5a666d28a6e8d8d5f05f10e713ddc 100644 (file)
@@ -1,9 +1,26 @@
 <?php
-// Database credentials
-$host = 'localhost';  
-$db = 'slayer.unlishema.org'; 
-$user = 'slayer.db'; 
-$pass = 'r2YWbde6V9hr'; 
+// Database credentials with default values
+$host = "localhost";
+$user = "username";
+$pass = "password";
+$db = "database";
+
+// Load database creds so they aren't public
+$configPath = $_SERVER['DOCUMENT_ROOT'] . '/../../slayer_assistant_private.json';
+
+if (file_exists($configPath)) {
+    $config = json_decode(file_get_contents($configPath), true);
+    if ($config === null) {
+        die("Invalid configuration format.");
+    }
+    // Update variables with config values if the file is found
+    $host = $config['host'];
+    $user = $config['username'];  // Overrides initial $user = "username"
+    $pass = $config['password'];
+    $db = $config['dbname'];
+} else {
+    die("Configuration file not found.");
+}
 
 // Function to return error as JSON and exit
 function respondWithError($message) {
index d9a6aedc798230ad9e72380a252d3dca95020c58..a68b881fd2ff201c23ba53ccb728cbdd22e592b2 100644 (file)
@@ -1,9 +1,26 @@
 <?php
-// Database credentials
-$host = 'localhost';  
-$db = 'slayer.unlishema.org'; 
-$user = 'slayer.db'; 
-$pass = 'r2YWbde6V9hr'; 
+// Database credentials with default values
+$host = "localhost";
+$user = "username";
+$pass = "password";
+$db = "database";
+
+// Load database creds so they aren't public
+$configPath = $_SERVER['DOCUMENT_ROOT'] . '/../../slayer_assistant_private.json';
+
+if (file_exists($configPath)) {
+    $config = json_decode(file_get_contents($configPath), true);
+    if ($config === null) {
+        die("Invalid configuration format.");
+    }
+    // Update variables with config values if the file is found
+    $host = $config['host'];
+    $user = $config['username'];  // Overrides initial $user = "username"
+    $pass = $config['password'];
+    $db = $config['dbname'];
+} else {
+    die("Configuration file not found.");
+}
 
 // Function to return error as JSON and exit
 function respondWithError($message) {