]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - common.php
Move to new style config, with config in config/ directory.
[irc/unrealircd/unrealircd-webpanel.git] / common.php
1 <?php
2 if (version_compare(PHP_VERSION, '8.0.0', '<'))
3 die("This webserver is using PHP version ".PHP_VERSION." but we require at least PHP 8.0.0.<br>".
4 "If you already installed PHP8 but are still seeing this error, then it means ".
5 "apache/nginx/.. is loading an older PHP version. Eg. on Debian/Ubuntu you need ".
6 "<code>apt-get install libapache2-mod-php8.2</code> (or a similar version) and ".
7 "<code>apt-get remove libapache2-mod-php7.4</code> (or a similar version). ".
8 "You may also need to choose again the PHP module to load in apache via <code>a2enmod php8.2</code>");
9
10 define('UPATH', dirname(__FILE__));
11
12 function get_config($setting)
13 {
14 GLOBAL $config;
15
16 $item = $config;
17 foreach(explode("::", $setting) as $x)
18 {
19 if (isset($item[$x]))
20 $item = $item[$x];
21 else
22 return NULL;
23 }
24 return $item;
25 }
26
27 /* Load config defaults */
28 $config = Array();
29 require_once UPATH . "/config/config.defaults.php";
30
31 if (!file_exists(UPATH."/config/config.php") && file_exists(UPATH."/config.php"))
32 {
33 require_once UPATH . "/config.php";
34 require_once UPATH . "/config/compat.php";
35 } else {
36 require_once UPATH . "/config/config.php";
37 }
38
39 if (!get_config("base_url")) die("You need to define the base_url in config/config.php");
40 require_once "Classes/class-hook.php";
41 if (!is_dir(UPATH . "/vendor"))
42 die("The vendor/ directory is missing. Most likely the admin forgot to run 'composer install'\n");
43 require_once UPATH . '/vendor/autoload.php';
44 require_once UPATH . "/Classes/class-cmodes.php";
45 require_once UPATH . "/cfg/defines.php";
46 require_once UPATH . "/misc/strings.php";
47 require_once UPATH . "/misc/channel-lookup-misc.php";
48 require_once UPATH . "/misc/user-lookup-misc.php";
49 require_once UPATH . "/misc/server-lookup-misc.php";
50 require_once UPATH . "/misc/ip-whois-misc.php";
51 require_once UPATH . "/Classes/class-log.php";
52 require_once UPATH . "/Classes/class-message.php";
53 require_once UPATH . "/Classes/class-rpc.php";
54 require_once UPATH . "/Classes/class-paneluser.php";
55 require_once UPATH . "/plugins.php";
56
57 $pages = [
58 "Overview" => "",
59 "Users" => "users",
60 "Channels" => "channels",
61 "Servers" => "servers",
62 "Server Bans" => [
63 "Server Bans" => "server-bans",
64 "Name Bans" => "server-bans/name-bans.php",
65 "Ban Exceptions" => "server-bans/ban-exceptions.php"
66 ],
67 "Spamfilter" => "spamfilter.php",
68 "Tools" => [
69 "IP WHOIS" => "tools/ip-whois.php",
70 ],
71 "Settings" => [
72 "Plugins" => "settings/plugins.php",
73 ],
74
75 "News" => "news.php",
76 ];
77
78 if (is_auth_provided())
79 {
80 $pages["Settings"]["Panel Access"] = "settings";
81
82 $user = unreal_get_current_user();
83 if ($user)
84 {
85 /* Add logout page, if logged in */
86 $pages["Logout"] = "login/?logout=true";
87 }
88 }
89 Hook::run(HOOKTYPE_NAVBAR, $pages);
90
91 /* Example to add new menu item:
92 *
93 * class MyPlugin
94 * {
95 *
96 * function __construct()
97 * {
98 * Hook::func(HOOKTYPE_NAVBAR, [$this, 'add_menu'])
99 * }
100 *
101 * function add_menu(&$pages) // this should pass by reference (using the & prefix)
102 * {
103 * $page_name = "My New Page";
104 * $page_link = "link/to/page.php";
105 * $pages[$page_name] = $page_link;
106 * }
107 * }
108 */