]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - common.php
Rename "Panel Access" menu item to "Accounts"
[irc/unrealircd/unrealircd-webpanel.git] / common.php
index 08662f10a8ec08916edd8312caefbeb0f0525cd7..2caa5ca3c7301b020610fc001e844489c9312a78 100644 (file)
@@ -8,8 +8,51 @@ 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;
+}
+
+function page_requires_no_config()
+{
+       if (str_ends_with($_SERVER['SCRIPT_FILENAME'],"install.php") ||
+           str_ends_with($_SERVER['SCRIPT_FILENAME'],"test_connection.php"))
+       {
+               return TRUE;
+       }
+       return FALSE;
+}
+
+
+/* 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
+if (page_requires_no_config())
+{
+       /* Allow empty conf */
+} 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");
@@ -32,20 +75,25 @@ $pages = [
        "Users"        => "users",
        "Channels"     => "channels",
        "Servers"      => "servers",
-       "Server Bans" => "server-bans",
-       "Name Bans" => "server-bans/name-bans.php",
-       "Ban Exceptions" => "server-bans/ban-exceptions.php",
+       "Server Bans"  => [
+               "Server Bans" => "server-bans",
+               "Name Bans" => "server-bans/name-bans.php",
+               "Ban Exceptions" => "server-bans/ban-exceptions.php"
+       ],
        "Spamfilter"   => "spamfilter.php",
-       "IP WHOIS" => "tools/ip-whois.php",
-       "Network Checkup" => "tools/checkup.php",
-       "Plugins" => "settings/plugins.php",
+       "Tools" => [
+               "IP WHOIS" => "tools/ip-whois.php",
+       ],
+       "Settings" => [
+               "Plugins" => "settings/plugins.php",
+       ],
        
        "News" => "news.php",
 ];
 
 if (is_auth_provided())
 {
-       $pages["Panel Access"] = "settings";
+       $pages["Settings"]["Accounts"] = "settings";
 
        $user = unreal_get_current_user();
        if ($user)