]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/commitdiff
Move to new style config, with config in config/ directory.
authorBram Matthys <redacted>
Tue, 11 Apr 2023 17:30:56 +0000 (19:30 +0200)
committerBram Matthys <redacted>
Tue, 11 Apr 2023 17:30:56 +0000 (19:30 +0200)
There is currently a compatibility layer so existing installs
don't have to update their config.php per se... although that
won't be around forever ;)

24 files changed:
Classes/class-log.php
common.php
config/compat.php [new file with mode: 0644]
config/config.defaults.php [new file with mode: 0644]
config/config.php.sample [moved from config.php.sample with 76% similarity]
connection.php
footer.php
header.php
index.php
login/index.php
misc/channel-lookup-misc.php
misc/server-lookup-misc.php
misc/user-lookup-misc.php
plugins.php
plugins/config_blocks/config_blocks.php
plugins/config_blocks/index.php
plugins/sql_auth/SQL/settings.php
plugins/sql_auth/SQL/sql.php
plugins/sql_auth/setup.php
plugins/sql_auth/sql_auth.php
settings/index.php
settings/plugins.php
tools/checkup.php
users/index.php

index 1fd7dd0088dc284529b09d816fda2626366b2ecf..080d0da9a3fc8e2a662d3086580ae78312eb9675 100644 (file)
@@ -23,7 +23,7 @@ class Log
        {
                foreach($string as $str)
                {
-                       if (defined('UNREALIRCD_DEBUG') && UNREALIRCD_DEBUG) {
+                       if (defined('get_config("debug")') && get_config("debug")) {
                                highlight_string(var_export($str, true));
                        }
                }
index d685538b8d2b55b607fa69f4ae54aa488c5ff504..ea488ea85d91528f4cb647f623265aff34fc6744 100644 (file)
@@ -8,8 +8,35 @@ if (version_compare(PHP_VERSION, '8.0.0', '<'))
            "You may also need to choose again the PHP module to load in apache via <code>a2enmod php8.2</code>");
 
 define('UPATH', dirname(__FILE__));
-require_once UPATH . "/config.php";
-if (!defined('BASE_URL')) die("You need to define BASE_URL in config.php (see config.php.sample for documentation)");
+
+function get_config($setting)
+{
+       GLOBAL $config;
+
+       $item = $config;
+       foreach(explode("::", $setting) as $x)
+       {
+               if (isset($item[$x]))
+                       $item = $item[$x];
+               else
+                       return NULL;
+       }
+       return $item;
+}
+
+/* Load config defaults */
+$config = Array();
+require_once UPATH . "/config/config.defaults.php";
+
+if (!file_exists(UPATH."/config/config.php") && file_exists(UPATH."/config.php"))
+{
+       require_once UPATH . "/config.php";
+       require_once UPATH . "/config/compat.php";
+} else {
+       require_once UPATH . "/config/config.php";
+}
+
+if (!get_config("base_url")) die("You need to define the base_url in config/config.php");
 require_once "Classes/class-hook.php";
 if (!is_dir(UPATH . "/vendor"))
        die("The vendor/ directory is missing. Most likely the admin forgot to run 'composer install'\n");
diff --git a/config/compat.php b/config/compat.php
new file mode 100644 (file)
index 0000000..54739e2
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+
+/* Compatibility layer for old config -> new config */
+
+/* Base url */
+if (defined('BASE_URL'))
+       $config["base_url"] = BASE_URL;
+
+/* UnrealIRCd settings */
+if (defined('UNREALIRCD_RPC_USER'))
+       $config["unrealircd"]["rpc_user"] = UNREALIRCD_RPC_USER;
+if (defined('UNREALIRCD_RPC_PASSWORD'))
+       $config["unrealircd"]["rpc_password"] = UNREALIRCD_RPC_PASSWORD;
+if (defined('UNREALIRCD_HOST'))
+       $config["unrealircd"]["host"] = UNREALIRCD_HOST;
+if (defined('UNREALIRCD_PORT'))
+       $config["unrealircd"]["port"] = UNREALIRCD_PORT;
+if (defined('UNREALIRCD_SSL_VERIFY'))
+       $config["unrealircd"]["tls_verify_cert"] = UNREALIRCD_SSL_VERIFY;
+
+/* Debug */
+if (defined('UNREALIRCD_DEBUG'))
+       $config["debug"] = UNREALIRCD_DEBUG;
+
+/* Plugins */
+if (defined('PLUGINS'))
+       $config["plugins"] = PLUGINS;
+
+/* SQL settings */
+if (defined('SQL_IP'))
+       $config["mysql"]["host"] = SQL_IP;
+if (defined('SQL_DATABASE'))
+       $config["mysql"]["database"] = SQL_DATABASE;
+if (defined('SQL_USERNAME'))
+       $config["mysql"]["username"] = SQL_USERNAME;
+if (defined('SQL_PASSWORD'))
+       $config["mysql"]["password"] = SQL_PASSWORD;
+if (defined('SQL_PREFIX'))
+       $config["mysql"]["table_prefix"] = SQL_PREFIX;
+
+// TODO: blacklist thingy and email thingy
diff --git a/config/config.defaults.php b/config/config.defaults.php
new file mode 100644 (file)
index 0000000..ea390b9
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * The configuration file for your admin panel.
+ * 
+ */
+
+if (!defined('UPATH'))
+       die("Access denied");
+
+/**
+ * The base URL, how this panel can be accessed.
+ * This would be '/' if you installed in the web root,
+ * or something like '/webpanel/' if you go to http://x.y.z/webpanel
+ * IMPORTANT: needs a trailing slash!
+*/
+$config["base_url"] = '/unrealircd-webpanel/';
+
+/**
+ *  The RPC User name as defined in your unrealircd.conf
+ *  https://www.unrealircd.org/docs/UnrealIRCd_webpanel#Configuring_UnrealIRCd
+*/
+$config["unrealircd"]["rpc_user"] = 'adminpanel';
+
+/**
+ *  The RPC User password as defined in your unrealircd.conf
+*/
+$config["unrealircd"]["rpc_password"] = 'securepassword';
+
+/** 
+ * The host IP or name of your RPC server
+*/
+$config["unrealircd"]["host"] = '127.0.0.1';
+
+/**
+ * The port of your RPC server as defined in your unrealircd.conf
+*/
+$config["unrealircd"]["port"] = '8600';
+
+/** 
+ * You should set this to true, if your RPC server is not on your local host
+*/
+$config["unrealircd"]["tls_verify_cert"] = false;
+
+/**
+ * You should only need this, if you're developing something.
+*/
+$config["debug"] = false;
+
+/* No plugins loaded by default */
+
+/* No SQL config by default, except for default table prefix: */
+$config["mysql"]["table_prefix"] = "unreal_";
+
+// TODO: DNSBL defaults ?
+
+// TODO: mailer defaults ?
similarity index 76%
rename from config.php.sample
rename to config/config.php.sample
index 14f0fba778c361be3dd96f15047410f7990e774c..545fb18a5b987a5c66c569a0be41251e7d40c64d 100644 (file)
@@ -5,7 +5,7 @@
  * 
  */
 
- if (!defined('UPATH'))
+if (!defined('UPATH'))
        die("Access denied");
 
 /**
  * or something like '/webpanel/' if you go to http://x.y.z/webpanel
  * IMPORTANT: needs a trailing slash!
 */
-define( 'BASE_URL', '/unrealircd-webpanel/' );
+$config["base_url"] = '/unrealircd-webpanel/';
 
 /**
  *  The RPC User name as defined in your unrealircd.conf
  *  https://www.unrealircd.org/docs/UnrealIRCd_webpanel#Configuring_UnrealIRCd
 */
-define( 'UNREALIRCD_RPC_USER', 'adminpanel' );
+$config["unrealircd"]["rpc_user"] = 'adminpanel';
 
 /**
  *  The RPC User password as defined in your unrealircd.conf
 */
-define( 'UNREALIRCD_RPC_PASSWORD', 'securepassword' );
+$config["unrealircd"]["rpc_password"] = 'securepassword';
 
 /** 
  * The host IP or name of your RPC server
 */
-define( 'UNREALIRCD_HOST', '127.0.0.1' );
+$config["unrealircd"]["host"] = '127.0.0.1';
 
 /**
  * The port of your RPC server as defined in your unrealircd.conf
 */
-define( 'UNREALIRCD_PORT', '8600' );
+$config["unrealircd"]["port"] = '8600';
 
 /** 
  * You should set this to true, if your RPC server is not on your local host
 */
-define( 'UNREALIRCD_SSL_VERIFY', false );
+$config["unrealircd"]["tls_verify_cert"] = false;
 
 /**
  * You should only need this, if you're developing something.
 */
-define( 'UNREALIRCD_DEBUG', false );
+$config["debug"] = false;
 
 /**
  * Your list of plugins:
  */
 define(
-       'PLUGINS', [
+       'get_config("plugins")', [
 
                /*  This is where you should type the name(s) of your plugins. 
                 *  Uncomment the following line to view the live example
@@ -72,32 +72,33 @@ define(
   * SQL IP address or hostname
   * You may specify a unix domain socket directory address
   * E.g:
-  *     define('SQL_IP', "/path/to/unix/domain/socket");
+  *     define('get_config("mysql::host")', "/path/to/unix/domain/socket");
   *
   * Path to unix socket MUST start with a slash "/"
   */
-define('SQL_IP', "127.0.0.1");
+//$config["mysql"]["host"] = "127.0.0.1";
 
 /**
  * SQL Dabase name
  */
-define('SQL_DATABASE', "unrealircdwebpanel");
+//$config["mysql"]["database"] = "unrealircdwebpanel";
+
 /**
  * SQL Username
  */
-define('SQL_USERNAME', "unrealircdwebpanel");
+//$config["mysql"]["username"] = "unrealircdwebpanel";
 
 /**
  * SQL Password
  */
-define('SQL_PASSWORD', "replace_this_with_your_sql_password");
+//$config["mysql"]["password"] = "replace_this_with_your_sql_password";
 
 /**
  * SQL Table prefix
  * You should only need to change this if you have already have one
  * or more instances of webpanel on the same database
  */
-define('SQL_PREFIX', "unreal_");
+//$config["mysql"]["table_prefix"] = "unreal_";
 
 
 /** 
@@ -105,10 +106,10 @@ define('SQL_PREFIX', "unreal_");
  * the plugin, the user defined below will be created. It suggested
  * that you remove it after you've logged in successfully.
  */
-define('SQL_DEFAULT_USER', [
-       "username" => "default",
-       "password" => "testing"
-]);
+//define('SQL_DEFAULT_USER', [
+//     "username" => "default",
+//     "password" => "testing"
+//]);
 
 /**
  * Also part of the SQL_Auth plugin. This protects your login page.
index 0368fbe683c4ec72bf594b70752ff8a1fcddc0cb..114088fa7dace6abd9ef579b48f4737dfc199a8f 100644 (file)
@@ -3,36 +3,44 @@
 if (!defined('UPATH'))
                die("Access denied");
 
-if (!defined('UNREALIRCD_RPC_USER') ||
-               !defined('UNREALIRCD_RPC_PASSWORD') ||
-               !defined('UNREALIRCD_HOST') ||
-               !defined('UNREALIRCD_PORT')
-) die("Unable to find RPC credentials in your config.php");
-
-$tls_verify = (defined('UNREALIRCD_SSL_VERIFY')) ? UNREALIRCD_SSL_VERIFY : true;
-$api_login = UNREALIRCD_RPC_USER.":".UNREALIRCD_RPC_PASSWORD;
-
-/* Connect now */
-try {
-               $rpc = new UnrealIRCd\Connection
-               (
-                       "wss://".UNREALIRCD_HOST.":".UNREALIRCD_PORT,
-                       $api_login,
-                       ["tls_verify" => $tls_verify]
-               );
-}
-catch (Exception $e)
+function connect_to_ircd()
 {
-       echo "Unable to connect to UnrealIRCd: ".$e->getMessage() . "<br><br>";
-       echo "Verify your connection details in config.php (rpc user, rpc password, host) and ".
-            "verify your UnrealIRCd configuration (listen block with listen::options::rpc and ".
-            "an rpc-user block with the correct IP allowed and the correct username and password).";
-       throw $e;
-}
+       GLOBAL $rpc;
 
-$user = unreal_get_current_user();
-if ($user)
-{
-       /* Set issuer for all the RPC commands */
-       $rpc->rpc()->set_issuer($user->username);
+       $host = get_config("unrealircd::host");
+       $port = get_config("unrealircd::port");
+       $rpc_user = get_config("unrealircd::rpc_user");
+       $rpc_password = get_config("unrealircd::rpc_password");
+
+       if (!$host || !$port || !$rpc_user || !$rpc_password)
+               die("Unable to find RPC credentials in your config.php");
+
+       $tls_verify = get_config("unrealircd::tls_verify_cert");
+
+       /* Connect now */
+       try {
+                       $rpc = new UnrealIRCd\Connection
+                       (
+                               "wss://$host:$port",
+                               "$rpc_user:$rpc_password",
+                               ["tls_verify" => $tls_verify]
+                       );
+       }
+       catch (Exception $e)
+       {
+               echo "Unable to connect to UnrealIRCd: ".$e->getMessage() . "<br><br>";
+               echo "Verify your connection details in config.php (rpc user, rpc password, host) and ".
+                    "verify your UnrealIRCd configuration (listen block with listen::options::rpc and ".
+                    "an rpc-user block with the correct IP allowed and the correct username and password).";
+               throw $e;
+       }
+
+       $user = unreal_get_current_user();
+       if ($user)
+       {
+               /* Set issuer for all the RPC commands */
+               $rpc->rpc()->set_issuer($user->username);
+       }
 }
+
+connect_to_ircd();
index ad130dbe8d9074cb2f2e68c055b51fd3f45b61dd..b271c4bb1aaa9aec731fe776d98ef702b0c87c21 100644 (file)
@@ -29,7 +29,7 @@
                                href="https://unrealircd.org"
                                role="button"
                                data-mdb-ripple-color="dark">
-                               <img src="<?php echo BASE_URL; ?>img/unreal.jpg" width="23" height="23" style="margin-right: 25px"></a>
+                               <img src="<?php echo get_config("base_url"); ?>img/unreal.jpg" width="23" height="23" style="margin-right: 25px"></a>
                
                
                <?php
index f025f600f6968b33f3359b92848310cacb0b0e1b..97100c42d39ee6c9a82230556946294aa563f57e 100644 (file)
@@ -2,17 +2,17 @@
 if (is_auth_provided() && !str_ends_with($_SERVER['SCRIPT_FILENAME'], "setup.php"))
 {?>
        <script>
-               var BASE_URL = "<?php echo BASE_URL; ?>";
+               var get_config("base_url") = "<?php echo get_config("base_url"); ?>";
                function timeoutCheck() {
                        var xhttp = new XMLHttpRequest();
                        xhttp.onreadystatechange = function() {
                                if (this.readyState == 4 && this.status == 200) {
                                        var data = JSON.parse(this.responseText);
                                        if (data.session == 'none')
-                                               window.location = BASE_URL + 'login/?timeout=1&redirect=' + encodeURIComponent(window.location.pathname);
+                                               window.location = get_config("base_url") + 'login/?timeout=1&redirect=' + encodeURIComponent(window.location.pathname);
                                }
                        };
-                       xhttp.open("GET", BASE_URL + "api/timeout.php", true);
+                       xhttp.open("GET", get_config("base_url") + "api/timeout.php", true);
                        xhttp.send();
                }
                timeoutCheck();
@@ -28,7 +28,7 @@ $arr = []; Hook::run(HOOKTYPE_PRE_HEADER, $arr); ?>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="HandheldFriendly" content="true">
 
-<link href="<?php echo BASE_URL; ?>css/unrealircd-admin.css" rel="stylesheet">
+<link href="<?php echo get_config("base_url"); ?>css/unrealircd-admin.css" rel="stylesheet">
 
 
  <!-- Latest compiled and minified CSS -->
@@ -41,14 +41,14 @@ $arr = []; Hook::run(HOOKTYPE_PRE_HEADER, $arr); ?>
 <!-- Font Awesome icons -->
 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css">
 <title>UnrealIRCd Panel</title>
-<link rel="icon" type="image/x-icon" href="<?php echo BASE_URL; ?>img/favicon.ico">
+<link rel="icon" type="image/x-icon" href="<?php echo get_config("base_url"); ?>img/favicon.ico">
 </head>
 <body role="document">
 
 <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
 <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
 <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.min.js" integrity="sha384-+sLIOodYLS7CIrQpBjl+C7nPvqq+FbNUBDunl/OZv93DB7Ln/533i8e/mZXLi/P+" crossorigin="anonymous"></script>
-<script src="<?php echo BASE_URL; ?>js/unrealircd-admin.js"></script>
+<script src="<?php echo get_config("base_url"); ?>js/unrealircd-admin.js"></script>
 <style>
        #optionsopen {
                transition: left 0.3s;
@@ -94,7 +94,7 @@ function show_page_item($name, $page, $nestlevel)
        {
                $style = "padding-bottom: 0px;";
        } else {
-               echo "<a href=\"".BASE_URL.$page."\" style=\"text-decoration: none\">\n";
+               echo "<a href=\"".get_config("base_url").$page."\" style=\"text-decoration: none\">\n";
        }
        echo "<div class=\"d-flex justify-content-between align-items-center $class list-group-item-action\" style=\"$style\">$name
                <div class=\"text-right padding-top\">
@@ -122,7 +122,7 @@ foreach($pages as $name=>$page)
        
        <!-- Fixed navbar -->
        <nav class="navbar navbar-expand-sm navbar-dark bg-dark fixed-top z-index padding-top" style="max-height: 50px">
-       <a class="navbar-brand" href="<?php echo BASE_URL; ?>"><img src="<?php echo BASE_URL; ?>img/favicon.ico" height="25" width="25"> UnrealIRCd Admin Panel</a>
+       <a class="navbar-brand" href="<?php echo get_config("base_url"); ?>"><img src="<?php echo get_config("base_url"); ?>img/favicon.ico" height="25" width="25"> UnrealIRCd Admin Panel</a>
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
                        <span class="navbar-toggler-icon"></span>
                </button>
@@ -140,7 +140,7 @@ foreach ($pages as $name => $page)
        if (is_string($page) && strlen($page) == 0) {
                $active_page = "";
        }
-       else if (str_ends_with($script, BASE_URL . "index.php") && BASE_URL != "/" && !strlen($tok[0]))
+       else if (str_ends_with($script, get_config("base_url") . "index.php") && get_config("base_url") != "/" && !strlen($tok[0]))
        {
                $active_page = $tok[0];
        }
index 6384929e931f85540ae84a0dab19ce7e686bc9b3..b5009ce5369b529b78f23bb00d3e0466b3fe5c84 100644 (file)
--- a/index.php
+++ b/index.php
@@ -46,7 +46,7 @@ $num_of_panel_admins = count($userlist);
                                                <div class="col">
                                                        <h6>Users Online</h6>
                                                </div>
-                                               <div class="col"> <a class="btn btn-primary" href="<?php echo BASE_URL; ?>users">View</a></div>
+                                               <div class="col"> <a class="btn btn-primary" href="<?php echo get_config("base_url"); ?>users">View</a></div>
                                        </div>
                                </div>
                        </div>
@@ -70,7 +70,7 @@ $num_of_panel_admins = count($userlist);
                                                <div class="col">
                                                        <h6>Channels</h6>
                                                </div>
-                                               <div class="col"><a class="btn btn-primary" href="<?php echo BASE_URL; ?>channels">View</a></div>
+                                               <div class="col"><a class="btn btn-primary" href="<?php echo get_config("base_url"); ?>channels">View</a></div>
                                        </div>
                                </div>
                        </div>
@@ -92,7 +92,7 @@ $num_of_panel_admins = count($userlist);
                                                <div class="col">
                                                        <h6>Opers</h6>
                                                </div>
-                                               <div class="col"><a class="btn btn-primary" href="<?php echo BASE_URL."users/?operonly"; ?>">View</a></div>
+                                               <div class="col"><a class="btn btn-primary" href="<?php echo get_config("base_url")."users/?operonly"; ?>">View</a></div>
                                        </div>
                                </div>
                        </div>
@@ -115,7 +115,7 @@ $num_of_panel_admins = count($userlist);
                                                <div class="col">
                                                        <h6>Servers</h6>
                                                </div>
-                                               <div class="col"> <a class="btn btn-primary" href="<?php echo BASE_URL; ?>servers">View</a></div>
+                                               <div class="col"> <a class="btn btn-primary" href="<?php echo get_config("base_url"); ?>servers">View</a></div>
                                        </div>
                                </div>
                        </div>
@@ -142,7 +142,7 @@ $num_of_panel_admins = count($userlist);
                                                <div class="col">
                                                        <h6>Server Bans</h6>
                                                </div>
-                                               <div class="col"> <a class="btn btn-primary" href="<?php echo BASE_URL; ?>server-bans">View</a></div>
+                                               <div class="col"> <a class="btn btn-primary" href="<?php echo get_config("base_url"); ?>server-bans">View</a></div>
                                        </div>
                                </div>
                        </div>
@@ -164,7 +164,7 @@ $num_of_panel_admins = count($userlist);
                                                <div class="col">
                                                        <h6>Spamfilter</h6>
                                                </div>
-                                               <div class="col"> <a class="btn btn-primary" href="<?php echo BASE_URL; ?>spamfilter.php">View</a></div>
+                                               <div class="col"> <a class="btn btn-primary" href="<?php echo get_config("base_url"); ?>spamfilter.php">View</a></div>
                                        </div>
                                </div>
                        </div>
@@ -187,7 +187,7 @@ $num_of_panel_admins = count($userlist);
                                                <div class="col">
                                                        <h6>Server Ban Exceptions</h6>
                                                </div>
-                                               <div class="col"> <a class="btn btn-primary" href="<?php echo BASE_URL; ?>server-bans/ban-exceptions.php">View</a></div>
+                                               <div class="col"> <a class="btn btn-primary" href="<?php echo get_config("base_url"); ?>server-bans/ban-exceptions.php">View</a></div>
                                        </div>
                                </div>
                        </div>
@@ -218,7 +218,7 @@ $num_of_panel_admins = count($userlist);
                                                <div class="col">
                                                        <h6>Services Online</h6>
                                                </div>
-                                               <div class="col"> <a class="btn btn-primary" href="<?php echo BASE_URL."users/?servicesonly"; ?>">View</a></div>
+                                               <div class="col"> <a class="btn btn-primary" href="<?php echo get_config("base_url")."users/?servicesonly"; ?>">View</a></div>
                                        </div>
                                </div>
                                
@@ -271,7 +271,7 @@ $num_of_panel_admins = count($userlist);
                                                                <div class="col">
                                                                        <h6>Panel Access</h6>
                                                                </div>
-                                                               <div class="col"> <a class="btn btn-primary" href="<?php echo BASE_URL; ?>settings">View</a></div>
+                                                               <div class="col"> <a class="btn btn-primary" href="<?php echo get_config("base_url"); ?>settings">View</a></div>
                                                        </div>
                                                </div>
                                        </div>
index 1fd14a37ea9ad958b964c76e9202a578364cbcf7..aa5609bbed9ac2a97592bde14d0377784bc20cb7 100644 (file)
@@ -4,15 +4,15 @@ require_once "../common.php";
 
 $logout = false;
 
-$redirect = BASE_URL;
+$redirect = get_config("base_url");
 if (!empty($_GET['redirect']))
 {
        $str = urldecode($_GET['redirect']);
-       if (str_starts_with($str, BASE_URL)) // prevent redirects to like https://othersite/
+       if (str_starts_with($str, get_config("base_url"))) // prevent redirects to like https://othersite/
                $redirect = $_GET['redirect'];
 }
 
-$redirect = (isset($_GET['redirect'])) ? $_GET['redirect'] : BASE_URL;
+$redirect = (isset($_GET['redirect'])) ? $_GET['redirect'] : get_config("base_url");
 if (!empty($_GET['logout']))
 {
        if (!isset($_SESSION['id']))
@@ -63,8 +63,8 @@ if (!empty($_POST))
 
 ?><!DOCTYPE html>
 <head>
-<link href="<?php echo BASE_URL; ?>css/unrealircd-admin.css" rel="stylesheet">
-<script src="<?php echo BASE_URL; ?>js/unrealircd-admin.js"></script>
+<link href="<?php echo get_config("base_url"); ?>css/unrealircd-admin.css" rel="stylesheet">
+<script src="<?php echo get_config("base_url"); ?>js/unrealircd-admin.js"></script>
  <!-- Latest compiled and minified CSS -->
 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">
 
@@ -80,7 +80,7 @@ if (!empty($_POST))
 <!-- Font Awesome icons -->
 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css">
 
-<link rel="icon" type="image/x-icon" href="<?php echo BASE_URL; ?>img/favicon.ico">
+<link rel="icon" type="image/x-icon" href="<?php echo get_config("base_url"); ?>img/favicon.ico">
 <title>UnrealIRCd Panel</title>
 </head>
 <section class="vh-100">
@@ -90,7 +90,7 @@ if (!empty($_POST))
                <div class="card shadow-2-strong" style="border-radius: 1rem;">
                  <div class="card-body p-5 text-center">
                        <form id="login" method="post" action="index.php?redirect=<?php echo $redirect; ?>">
-                               <h3><img src="<?php echo BASE_URL; ?>img/favicon.ico">  Log in to use Admin Panel</h3>
+                               <h3><img src="<?php echo get_config("base_url"); ?>img/favicon.ico">    Log in to use Admin Panel</h3>
                                
                                        <?php 
                                        if (isset($failmsg)) Message::Fail($failmsg);
index 72f096c4b43289bd60b3d7a26e8bf985af0628ed..0ec18720adbbd1a47a8b63db1baa956622887079 100644 (file)
@@ -181,7 +181,7 @@ function generate_chan_occupants_table($channel)
                        $disabled = (current_user_can(PERMISSION_EDIT_CHANNEL_USER)) ? "" : "disabled";
                        $disabledcolor = ($disabled) ? "btn-secondary" : "btn-primary";
                        echo "<td scope=\"row\"><input type=\"checkbox\" value='$member->id' name=\"checkboxes[]\"></td>";
-                       echo "<td><a href=\"".BASE_URL."users/details.php?nick=$member->id\">".htmlspecialchars($member->name)."</a></td>";
+                       echo "<td><a href=\"".get_config("base_url")."users/details.php?nick=$member->id\">".htmlspecialchars($member->name)."</a></td>";
                        echo "<td class='text-right'>$lvlstring</td>";
                        echo "<td><code>".((property_exists($member, 'hostname')) ? htmlspecialchars($member->hostname) : "")."</code></td>";
                        echo "</tr>";
index e11f63ea2c2f0457e6a81c80a022d68c7b266fd0..8902ac76049ff608b4923c8957f50451805bcb4a 100644 (file)
@@ -103,7 +103,7 @@ function generate_html_serverinfo($server)
             </tr><tr>
                 <th>Uplink</th>
                 <?php $serverlkup = (isset($server->server->uplink)) ? $rpc->server()->get($server->server->uplink) : "<span class=\"badge rounded-pill badge-info\">None</span>"; ?>
-                <td colspan="2"><code><?php echo "<a href=\"".BASE_URL."servers/details.php?server=".htmlspecialchars($serverlkup->id)."\">".htmlspecialchars($server->server->uplink)."</a>"; ?></code></td>
+                <td colspan="2"><code><?php echo "<a href=\"".get_config("base_url")."servers/details.php?server=".htmlspecialchars($serverlkup->id)."\">".htmlspecialchars($server->server->uplink)."</a>"; ?></code></td>
             </tr><tr>
                 <th>User count</th>
                 <td colspan="2"><code><?php echo htmlspecialchars($server->server->num_users); ?></code></td>
index 8ab67964fd24fa520fbc729d5b1dcf5d38fdd809..27fc7b1a820dd41dbda4ad55618dd35108f58ca0 100644 (file)
@@ -26,7 +26,7 @@ function generate_html_whois($user)
                             width="20"
                             height="15">
                     <?php } ?>
-                    <a href="<?php echo htmlspecialchars(BASE_URL."tools/ip-whois.php?ip=$user->ip"); ?>"><button class="btn-sm btn-primary">WHOIS IP</button></a>
+                    <a href="<?php echo htmlspecialchars(get_config("base_url")."tools/ip-whois.php?ip=$user->ip"); ?>"><button class="btn-sm btn-primary">WHOIS IP</button></a>
                 </td>
             </tr><tr>
                 <th>Ident</th>
@@ -41,12 +41,12 @@ function generate_html_whois($user)
                 <th>Connected to</th>
                 <?php $serverlkup = $rpc->server()->get($user->user->servername); ?>
                           
-                <td colspan="2"><a href="<?php echo BASE_URL."servers/details.php?server=$serverlkup->id"; ?>"><code><?php echo htmlspecialchars($user->user->servername); ?></code></td>
+                <td colspan="2"><a href="<?php echo get_config("base_url")."servers/details.php?server=$serverlkup->id"; ?>"><code><?php echo htmlspecialchars($user->user->servername); ?></code></td>
 
             </tr>
             <tr>
                 <th>Logged in as</th>
-                <td colspan="2"><code><?php echo (isset($user->user->account)) ? "<a href=\"".BASE_URL."users/?account=".htmlspecialchars($user->user->account)."\">".htmlspecialchars($user->user->account)."</a>" : ""; ?></code></td>
+                <td colspan="2"><code><?php echo (isset($user->user->account)) ? "<a href=\"".get_config("base_url")."users/?account=".htmlspecialchars($user->user->account)."\">".htmlspecialchars($user->user->account)."</a>" : ""; ?></code></td>
             </tr>
                 
 
@@ -323,7 +323,7 @@ function generate_html_userchannels($user)
                 {
                     ?>
                     <tr>
-                        <td><?php echo "<a href=\"".BASE_URL."channels/details.php?chan=".urlencode($chan->name)."\">$chan->name</a>"; ?></td>
+                        <td><?php echo "<a href=\"".get_config("base_url")."channels/details.php?chan=".urlencode($chan->name)."\">$chan->name</a>"; ?></td>
                         <td>
                             
                             <?php
index 3bf8b9a816b20e56f42e1a04f8bc4ff975f8bb9e..c080e1b7ab1353464677a05640304c075581f5f6 100644 (file)
@@ -1,9 +1,5 @@
 <?php
-
-require_once "config.php";
-
 require_once "common.php";
-
 require_once "Classes/class-message.php";
 
 
@@ -110,9 +106,9 @@ class Plugin
        }
 }
 
-if (defined('PLUGINS'))
+if (get_config("plugins"))
 {
-       foreach(PLUGINS as $plugin)
+       foreach(get_config("plugins") as $plugin)
                Plugins::load($plugin);
 }
 
index cf9d91fc80baedec456bf0ff9a18c9a9f64ea9bc..7d8099d39d6ec60d0ae853ee70e5fb07ba66e917 100644 (file)
@@ -46,7 +46,7 @@ class config_blocks
        public static function create_sql_table()
        {
                $conn = sqlnew();
-               $conn->query("CREATE TABLE IF NOT EXISTS " . SQL_PREFIX . "configblocks (
+               $conn->query("CREATE TABLE IF NOT EXISTS " . get_config("mysql::table_prefix") . "configblocks (
                        block_id int AUTO_INCREMENT NOT NULL,
                        block_name VARCHAR(255) NOT NULL,
                        block_value VARCHAR(255) NOT NULL,
index b475a60f389bdfbe5b3a113f6a1e30fe401ac4b0..34e9d03445439231dfeafea84890b36f6e8fc923 100644 (file)
@@ -3,7 +3,7 @@
 require_once "../../common.php";
 if (!current_user_can(PERMISSION_CONFIG_BLOCKS))
 {
-    header("Location: ".BASE_URL);
+    header("Location: ".get_config("base_url"));
     die();
 }
 require_once "../../header.php";
index e0ab011bf973ad7b60c7f10924618a21ada62db3..e2ac322d554d2eba57ad290ca9aabb47b3a7b244 100644 (file)
@@ -8,7 +8,7 @@ class AuthSettings {
     function __construct()
     {
         $conn = sqlnew();
-        $query = "SELECT * FROM " . SQL_PREFIX . "auth_settings";
+        $query = "SELECT * FROM " . get_config("mysql::table_prefix") . "auth_settings";
         $result = $conn->query($query);
         while ($row = $result->fetch())
         {
index a9b0a556cf5ec490b67fc348618eaa6b51e025e5..b325c96bc4610ba5a5fda9a6386db797d85bffe7 100644 (file)
@@ -2,10 +2,10 @@
 
 function sqlnew()
 {
-       $host = SQL_IP;
-       $user = SQL_USERNAME;
-       $pass = SQL_PASSWORD;
-       $db = SQL_DATABASE;
+       $host = get_config("mysql::host");
+       $user = get_config("mysql::username");
+       $pass = get_config("mysql::password");
+       $db = get_config("mysql::database");
        $charset = 'utf8mb4';
 
        if ($host[0] == "/")
index 59600afe7e6597090f9a68c6aee60f6f735be010..09083188b4048156c1153f8fd4f5ca360eca1dd6 100644 (file)
@@ -10,7 +10,7 @@ require_once "../../common.php";
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="HandheldFriendly" content="true">
 
-<link href="<?php echo BASE_URL; ?>css/unrealircd-admin.css" rel="stylesheet">
+<link href="<?php echo get_config("base_url"); ?>css/unrealircd-admin.css" rel="stylesheet">
 
 
  <!-- Latest compiled and minified CSS -->
@@ -22,9 +22,9 @@ require_once "../../common.php";
 
 <!-- Font Awesome icons -->
 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css">
-<script src="<?php echo BASE_URL; ?>js/unrealircd-admin.js"></script>
+<script src="<?php echo get_config("base_url"); ?>js/unrealircd-admin.js"></script>
 <title>UnrealIRCd Panel</title>
-<link rel="icon" type="image/x-icon" href="<?php echo BASE_URL; ?>img/favicon.ico">
+<link rel="icon" type="image/x-icon" href="<?php echo get_config("base_url"); ?>img/favicon.ico">
 </head>
 <body role="document">
 
@@ -54,7 +54,7 @@ if (!isset($_POST) || empty($_POST))
 elseif (isset($_POST['createbtn']))
 {
     $conn = sqlnew();
-    $conn->query("CREATE TABLE IF NOT EXISTS " . SQL_PREFIX . "users (
+    $conn->query("CREATE TABLE IF NOT EXISTS " . get_config("mysql::table_prefix") . "users (
         user_id int AUTO_INCREMENT NOT NULL,
         user_name VARCHAR(255) NOT NULL,
         user_pass VARCHAR(255) NOT NULL,
@@ -70,7 +70,7 @@ elseif (isset($_POST['createbtn']))
      * Patch for beta users
      * This adds the email column to existing tables without it
     */
-    $columns = $conn->query("SHOW COLUMNS FROM " . SQL_PREFIX . "users");
+    $columns = $conn->query("SHOW COLUMNS FROM " . get_config("mysql::table_prefix") . "users");
     $column_names = array();
     $c = $columns->fetchAll();
 
@@ -79,7 +79,7 @@ elseif (isset($_POST['createbtn']))
     }
     $column_exists = in_array("user_email", $column_names);
     if (!$column_exists) {
-        $conn->query("ALTER TABLE " . SQL_PREFIX . "users ADD COLUMN user_email varchar(255)");
+        $conn->query("ALTER TABLE " . get_config("mysql::table_prefix") . "users ADD COLUMN user_email varchar(255)");
     }
 
     /**
@@ -87,38 +87,38 @@ elseif (isset($_POST['createbtn']))
      * This changes the size of the meta_value so we can store more
      */
     
-    $conn->query("CREATE TABLE IF NOT EXISTS " . SQL_PREFIX . "user_meta (
+    $conn->query("CREATE TABLE IF NOT EXISTS " . get_config("mysql::table_prefix") . "user_meta (
         meta_id int AUTO_INCREMENT NOT NULL,
         user_id int NOT NULL,
         meta_key VARCHAR(255) NOT NULL,
         meta_value VARCHAR(255),
         PRIMARY KEY (meta_id)
     )");
-    $conn->query("CREATE TABLE IF NOT EXISTS " . SQL_PREFIX . "auth_settings (
+    $conn->query("CREATE TABLE IF NOT EXISTS " . get_config("mysql::table_prefix") . "auth_settings (
         id int AUTO_INCREMENT NOT NULL,
         setting_key VARCHAR(255) NOT NULL,
         setting_value VARCHAR(255),
         PRIMARY KEY (id)
     )");
-    $conn->query("CREATE TABLE IF NOT EXISTS " . SQL_PREFIX . "fail2ban (
+    $conn->query("CREATE TABLE IF NOT EXISTS " . get_config("mysql::table_prefix") . "fail2ban (
         id int AUTO_INCREMENT NOT NULL,
         ip VARCHAR(255) NOT NULL,
         count VARCHAR(255),
         PRIMARY KEY (id)
     )");
     $c = [];
-    if (($columns = $conn->query("SHOW COLUMNS FROM ".SQL_PREFIX."user_meta")));
+    if (($columns = $conn->query("SHOW COLUMNS FROM ".get_config("mysql::table_prefix")."user_meta")));
         $c = $columns->fetchAll();
     if (!empty($c))
-        $conn->query("ALTER TABLE `".SQL_PREFIX."user_meta` CHANGE `meta_value` `meta_value` VARCHAR(5000) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL");
+        $conn->query("ALTER TABLE `".get_config("mysql::table_prefix")."user_meta` CHANGE `meta_value` `meta_value` VARCHAR(5000) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL");
 
 
     new AuthSettings();
 
     Message::Success("Congratulations, you're all ready to go!");
     ?>
-    <a class="btn btn-primary" href="<?php echo BASE_URL; ?>">Take me home!</a>
-    <a class="btn btn-warning" href="<?php echo BASE_URL."settings"; ?>">Settings</a>
+    <a class="btn btn-primary" href="<?php echo get_config("base_url"); ?>">Take me home!</a>
+    <a class="btn btn-warning" href="<?php echo get_config("base_url")."settings"; ?>">Settings</a>
     <?php
 }
 require_once "../../footer.php";
\ No newline at end of file
index eac438ec751b5d6dd940bb5d2d0492f502616006..16b1a9addc5a04255017db02afe0ed116fd40fbf 100644 (file)
@@ -79,10 +79,10 @@ class sql_auth
                        
                        $tok = split($_SERVER['SCRIPT_FILENAME'], "/");
                        if ($check = security_check() && $tok[count($tok) - 1] !== "error.php") {
-                               header("Location: " . BASE_URL . "plugins/sql_auth/error.php");
+                               header("Location: " . get_config("base_url") . "plugins/sql_auth/error.php");
                                die();
                        }
-                       header("Location: ".BASE_URL."login/?redirect=".urlencode($current_page));
+                       header("Location: ".get_config("base_url")."login/?redirect=".urlencode($current_page));
                        die();
                }
                else
@@ -90,7 +90,7 @@ class sql_auth
                        if (!unreal_get_current_user()) // user no longer exists
                        {
                                session_destroy();
-                               header("Location: ".BASE_URL."login");
+                               header("Location: ".get_config("base_url")."login");
                                die();
                        }
                        // you'll be automatically logged out after one hour of inactivity
@@ -109,10 +109,10 @@ class sql_auth
                if (str_ends_with($script,"setup.php"))
                        return;
                $conn = sqlnew();
-               $stmt = $conn->query("SHOW TABLES LIKE '".SQL_PREFIX."%'");
+               $stmt = $conn->query("SHOW TABLES LIKE '".get_config("mysql::table_prefix")."%'");
                if ($stmt->rowCount() < 4)
                {
-                       header("Location: ".BASE_URL."plugins/sql_auth/setup.php");
+                       header("Location: ".get_config("base_url")."plugins/sql_auth/setup.php");
                        die();
                }
        }
@@ -126,12 +126,12 @@ class sql_auth
 
                if ($id)
                {
-                       $prep = $conn->prepare("SELECT * FROM " . SQL_PREFIX . "users WHERE user_id = :id LIMIT 1");
+                       $prep = $conn->prepare("SELECT * FROM " . get_config("mysql::table_prefix") . "users WHERE user_id = :id LIMIT 1");
                        $prep->execute(["id" => strtolower($id)]);
                }
                elseif ($name)
                {
-                       $prep = $conn->prepare("SELECT * FROM " . SQL_PREFIX . "users WHERE LOWER(user_name) = :name LIMIT 1");
+                       $prep = $conn->prepare("SELECT * FROM " . get_config("mysql::table_prefix") . "users WHERE LOWER(user_name) = :name LIMIT 1");
                        $prep->execute(["name" => strtolower($name)]);
                }
                $data = NULL;
@@ -160,7 +160,7 @@ class sql_auth
                $conn = sqlnew();
                if (isset($id))
                {
-                       $prep = $conn->prepare("SELECT * FROM " . SQL_PREFIX . "user_meta WHERE user_id = :id");
+                       $prep = $conn->prepare("SELECT * FROM " . get_config("mysql::table_prefix") . "user_meta WHERE user_id = :id");
                        $prep->execute(["id" => $id]);
                }
                foreach ($prep->fetchAll() as $row)
@@ -174,12 +174,12 @@ class sql_auth
                $meta = $meta['meta'];
                $conn = sqlnew();
                /* check if it exists first, update it if it does */
-               $query = "SELECT * FROM " . SQL_PREFIX . "user_meta WHERE user_id = :id AND meta_key = :key";
+               $query = "SELECT * FROM " . get_config("mysql::table_prefix") . "user_meta WHERE user_id = :id AND meta_key = :key";
                $stmt = $conn->prepare($query);
                $stmt->execute(["id" => $meta['id'], "key" => $meta['key']]);
                if ($stmt->rowCount()) // it exists, update instead of insert
                {
-                       $query = "UPDATE " . SQL_PREFIX . "user_meta SET meta_value = :value WHERE user_id = :id AND meta_key = :key";
+                       $query = "UPDATE " . get_config("mysql::table_prefix") . "user_meta SET meta_value = :value WHERE user_id = :id AND meta_key = :key";
                        $stmt = $conn->prepare($query);
                        $stmt->execute($meta);
                        if ($stmt->rowCount())
@@ -189,7 +189,7 @@ class sql_auth
 
                else
                {
-                       $query = "INSERT INTO " . SQL_PREFIX . "user_meta (user_id, meta_key, meta_value) VALUES (:id, :key, :value)";
+                       $query = "INSERT INTO " . get_config("mysql::table_prefix") . "user_meta (user_id, meta_key, meta_value) VALUES (:id, :key, :value)";
                        $stmt = $conn->prepare($query);
                        $stmt->execute($meta);
                        if ($stmt->rowCount())
@@ -200,7 +200,7 @@ class sql_auth
        public static function del_usermeta(&$u)
        {
                $conn = sqlnew();
-               $query = "DELETE FROM " . SQL_PREFIX . "user_meta WHERE user_id = :id AND meta_key = :key";
+               $query = "DELETE FROM " . get_config("mysql::table_prefix") . "user_meta WHERE user_id = :id AND meta_key = :key";
                $stmt = $conn->prepare($query);
                $stmt->execute($u['meta']);
                if ($stmt->rowCount())
@@ -216,7 +216,7 @@ class sql_auth
                $user_bio = $u['user_bio'] ?? NULL;
                $user_email = $u['user_email'] ?? NULL;
                $conn = sqlnew();
-               $prep = $conn->prepare("INSERT INTO " . SQL_PREFIX . "users (user_name, user_pass, user_fname, user_lname, user_bio, user_email, created) VALUES (:name, :pass, :fname, :lname, :user_bio, :user_email, :created)");
+               $prep = $conn->prepare("INSERT INTO " . get_config("mysql::table_prefix") . "users (user_name, user_pass, user_fname, user_lname, user_bio, user_email, created) VALUES (:name, :pass, :fname, :lname, :user_bio, :user_email, :created)");
                $prep->execute(["name" => $username, "pass" => $password, "fname" => $first_name, "lname" => $last_name, "user_bio" => $user_bio, "user_email" => $user_email, "created" => date("Y-m-d H:i:s")]);
                if ($prep->rowCount())
                        $u['success'] = true;
@@ -227,7 +227,7 @@ class sql_auth
        public static function get_user_list(&$list)
        {
                $conn = sqlnew();
-               $result = $conn->query("SELECT user_id FROM " . SQL_PREFIX . "users");
+               $result = $conn->query("SELECT user_id FROM " . get_config("mysql::table_prefix") . "users");
                if (!$result) // impossible
                {
                        die("Something went wrong.");
@@ -244,7 +244,7 @@ class sql_auth
        public static function user_delete(&$u)
        {
                $user = $u['user'];
-               $query = "DELETE FROM " . SQL_PREFIX . "users WHERE user_id = :id";
+               $query = "DELETE FROM " . get_config("mysql::table_prefix") . "users WHERE user_id = :id";
                $conn = sqlnew();
                $stmt = $conn->prepare($query);
                $stmt->execute(["id" => $user->id]);
@@ -297,7 +297,7 @@ class sql_auth
                        
                        if (!$value)
                                continue;
-                       $query = "UPDATE " . SQL_PREFIX . "users SET $value=:value WHERE user_id = :id";
+                       $query = "UPDATE " . get_config("mysql::table_prefix") . "users SET $value=:value WHERE user_id = :id";
                        $stmt = $conn->prepare($query);
                        $stmt->execute(["value" => $val, "id" => $user->id]);
 
index 001120a5d55402f83533703aa52474ac4d339b21..c501ab2cfbef0baf6770b75f9080d71e2d468638 100644 (file)
@@ -27,7 +27,7 @@ if (isset($_POST))
                        if ($us->id == $user->id) // if it's the current user
                        {
                                session_destroy();
-                               header("Location: " . BASE_URL . "plugins/sql_auth/login.php");
+                               header("Location: " . get_config("base_url") . "plugins/sql_auth/login.php");
                                die();
                        }
                        $msg = ($deleted = 1) ? "Message::Success" : "Message::Fail";
@@ -146,7 +146,7 @@ Click on a username to view more information.
                {
                        
                        echo "<td scope=\"col\"><input type=\"checkbox\" value='" .$user->id . "' name=\"userch[]\"></td>";
-                       echo "<td scope=\"col\"><a href=\"".BASE_URL."settings/user-edit.php?id=$user->id\">$user->username</a></td>";
+                       echo "<td scope=\"col\"><a href=\"".get_config("base_url")."settings/user-edit.php?id=$user->id\">$user->username</a></td>";
                        echo "<td scope=\"col\">".$user->first_name."</td>";
                        echo "<td scope=\"col\">".$user->last_name."</td>";
                        echo "<td scope=\"col\"><a href=\"mailto:$user->email\">$user->email</a></td>";
index ac574aa74c3f9120faf40ec3261ff5d48ef53287..aa94958ba2b5422fd76cc300d0c1daa39398b36b 100644 (file)
@@ -8,7 +8,7 @@ require_once "../header.php";
 
 <h2>Active Plugins</h2>
 <br>
-To load and unload plugins, see the <code>PLUGINS</code> section of your <code>config.php</code><br>
+To load and unload plugins, see the plugins section of your <code>config.php</code><br>
 <br>
 <table class="container-xxl table table-sm table-responsive caption-top table-striped">
        <thead class="table-primary">
index 1026cfcf9a8afe6b5c84eabadb8ba2adaa0fe00e..562aed386d4bb9e74d8738bee9412651b71560b4 100644 (file)
@@ -148,7 +148,7 @@ new Chart("myChart", {
 <script>
     function updateStats() {
         var xhttp = new XMLHttpRequest();
-        var BASE_URL = "<?php echo BASE_URL; ?>";
+        var get_config("base_url") = "<?php echo get_config("base_url"); ?>";
         xhttp.onreadystatechange = function() {
             if (this.readyState == 4 && this.status == 200) {
                 var data = JSON.parse(this.responseText);
@@ -156,7 +156,7 @@ new Chart("myChart", {
                 document.getElementById("memory-usage").innerHTML = "Memory Usage: <code>" + data.memory + "</code>";
             }
         };
-        xhttp.open("GET", BASE_URL + "api/data.php", true);
+        xhttp.open("GET", get_config("base_url") + "api/data.php", true);
         xhttp.send();
     }
     updateStats();
index 71cf596473da1d379ea9500a2bf748b0cd68fe87..dae4041d39ceca1e625e97a35d7d54fd642b270f 100644 (file)
@@ -202,7 +202,7 @@ Click on a username to view more information.
                        echo "<td><a href=\"details.php?nick=".$user->id."\">$user->name$isBot</a></td>";
                        echo "<td>".(isset($user->geoip->country_code) ? '<img src="https://flagcdn.com/48x36/'.htmlspecialchars(strtolower($user->geoip->country_code)).'.png" width="20" height="15"> '.$user->geoip->country_code : "")."</td>";
                        echo "<td class=\"hostname\">".htmlspecialchars($user->hostname)." (".($user->hostname == $user->ip ? 'the same' : htmlspecialchars($user->ip ?? "None")).")</td>";
-                       $account = (isset($user->user->account)) ? "<a href=\"".BASE_URL."users/?account=".$user->user->account."\">".htmlspecialchars($user->user->account)."</a>" : '<span class="badge rounded-pill badge-primary">None</span>';
+                       $account = (isset($user->user->account)) ? "<a href=\"".get_config("base_url")."users/?account=".$user->user->account."\">".htmlspecialchars($user->user->account)."</a>" : '<span class="badge rounded-pill badge-primary">None</span>';
                        echo "<td>".$account."</td>";
                        $modes = (isset($user->user->modes)) ? "+" . $user->user->modes : "<none>";
                        echo "<td>".$modes."</td>";
@@ -215,7 +215,7 @@ Click on a username to view more information.
                        if (strpos($user->user->modes, "S") !== false)
                                $secure = "";
                        echo "<td class=\"securecol\">".$secure."</td>";
-                       echo "<td class=\"uplinkcol\"><a href=\"".BASE_URL."servers/details.php?server=".substr($user->id, 0, 3)."\">".$user->user->servername."</a></td>";
+                       echo "<td class=\"uplinkcol\"><a href=\"".get_config("base_url")."servers/details.php?server=".substr($user->id, 0, 3)."\">".$user->user->servername."</a></td>";
                        echo "<td>".$user->user->reputation."</td>";
                        echo "</tr>";
                        $currentNumberUsers++;