X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/b98a5822a505991f3ab24d5e07d37d13a9b753b5..47aad98291fb8ad90cb308ba21fe73c7c7ccd843:/inc/common.php
diff --git a/inc/common.php b/inc/common.php
index 3dcfcc1..b168a7c 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -1,11 +1,48 @@
".
- "If you already installed PHP8 but are still seeing this error, then it means ".
- "apache/nginx/.. is loading an older PHP version. Eg. on Debian/Ubuntu you need ".
- "apt-get install libapache2-mod-php8.2
(or a similar version) and ".
- "apt-get remove libapache2-mod-php7.4
(or a similar version). ".
- "You may also need to choose again the PHP module to load in apache via a2enmod php8.2
");
+if (ini_get('output_buffering') == true) {
+ ini_set('output_buffering', 'off');
+}
+if (ini_get('zlib.output_compression') == true) {
+ ini_set('zlib.output_compression', 'off');
+}
+
+function check_requirements()
+{
+ if (version_compare(PHP_VERSION, '8.0.0', '<'))
+ {
+ die("This webserver is using PHP version ".PHP_VERSION." but we require at least PHP 8.0.0.
".
+ "If you already installed PHP8 but are still seeing this error, then it means ".
+ "apache/nginx/.. is loading an older PHP version. Eg. on Debian/Ubuntu you need ".
+ "apt-get install libapache2-mod-php8.2
(or a similar version) and ".
+ "apt-get remove libapache2-mod-php7.4
(or a similar version). ".
+ "You may also need to choose again the PHP module to load in apache via a2enmod php8.2
");
+ }
+
+ $loaded_extensions = get_loaded_extensions();
+ $required_extensions = ["mbstring", "sodium"];
+ $missing_extensions = [];
+ foreach ($required_extensions as $mod)
+ if (!in_array($mod, $loaded_extensions))
+ $missing_extensions[] = $mod;
+
+ if (count($missing_extensions) > 0)
+ {
+ $text = "The following PHP module(s) need to be loaded:
\n
$cmd
".
+ "and restart your webserver (eg: systemctl restart apache2
for apache).";
+ die($text);
+ }
+}
+
+check_requirements(); /* very early !! */
define('UPATH', dirname(__DIR__));
@@ -63,7 +100,7 @@ function get_current_page(&$title)
function page_requires_no_config()
{
if (str_ends_with($_SERVER['SCRIPT_FILENAME'],"install.php") ||
- str_ends_with($_SERVER['SCRIPT_FILENAME'],"installation.php"))
+ str_ends_with($_SERVER['SCRIPT_FILENAME'],"installation.php"))
{
return TRUE;
}
@@ -73,7 +110,7 @@ function page_requires_no_config()
function page_requires_no_login()
{
if (str_ends_with($_SERVER['SCRIPT_FILENAME'],"login/index.php") ||
- page_requires_no_config())
+ page_requires_no_config())
{
return TRUE;
}
@@ -131,9 +168,9 @@ function read_config_db()
function config_is_file_item($name)
{
if (($name == "plugins") ||
- ($name == "mysql") ||
- ($name == "base_url") ||
- ($name == "secrets"))
+ ($name == "mysql") ||
+ ($name == "base_url") ||
+ ($name == "secrets"))
{
return true;
}
@@ -161,10 +198,10 @@ function write_config_file()
if ($str === null)
die("Error while running write_config_file() -- weird!");
if (!fwrite($fd, "");
}
@@ -197,7 +234,7 @@ function write_config($setting = null)
/* Otherwise write the whole config.
* TODO: avoid writing settings file if unneeded,
- * as it is more noisy than db settings.
+ * as it is more noisy than db settings.
*/
$db_settings = [];
@@ -337,8 +374,8 @@ function upgrade_check()
}
/* - encrypting rpc_password */
if (isset($config['unrealircd']) &&
- isset($config['unrealircd']['rpc_password']) &&
- !str_starts_with($config['unrealircd']['rpc_password'], "secret:"))
+ isset($config['unrealircd']['rpc_password']) &&
+ !str_starts_with($config['unrealircd']['rpc_password'], "secret:"))
{
$ret = secret_encrypt($config['unrealircd']['rpc_password']);
if ($ret !== false)
@@ -446,27 +483,27 @@ if (!page_requires_no_config())
}
$pages = [
- "Overview" => ["script"=>""],
- "Users" => ["script"=>"users/index.php"],
- "Channels" => ["script"=>"channels/index.php"],
- "Servers" => ["script"=>"servers/index.php"],
+ "Overview" => ["script"=>""],
+ "Users" => ["script"=>"users/index.php"],
+ "Channels" => ["script"=>"channels/index.php"],
+ "Servers" => ["script"=>"servers/index.php"],
"Server Bans" => [
"Server Bans" => ["script" => "server-bans/index.php"],
"Name Bans" => ["script" => "server-bans/name-bans.php"],
"Ban Exceptions" => ["script" => "server-bans/ban-exceptions.php"],
],
- "Spamfilter" => ["script" => "spamfilter.php"],
+ "Spamfilter" => ["script" => "server-bans/spamfilter.php"],
+ "Logs" => ["script" => "logs/index.php"],
"Tools" => [
"IP WHOIS" => ["script" => "tools/ip-whois.php","no_irc_server_required"=>true],
],
"Settings" => [
- "Plugins" => ["script" => "settings/plugins.php","no_irc_server_required"=>true],
+ "General Settings" => ["script" => "settings/general.php"],
"RPC Servers" => ["script" => "settings/rpc-servers.php","no_irc_server_required"=>true],
],
-
- "News" => ["script" => "news.php","no_irc_server_required"=>true],
];
+
if (!panel_start_session())
{
if (!page_requires_no_login())
@@ -489,6 +526,10 @@ if (!panel_start_session())
"no_irc_server_required"=>true
];
}
+ if (current_user_can(PERMISSION_MANAGE_PLUGINS))
+ {
+ $pages["Settings"]["Plugins"] = ["script" => "settings/plugins.php"];
+ }
$user = unreal_get_current_user();
if ($user)
{
@@ -522,3 +563,21 @@ Hook::run(HOOKTYPE_NAVBAR, $pages);
*/
$current_page = get_current_page($current_page_name);
+
+
+global $rightClickMenu;
+$rightClickMenu = [
+ [
+ "text" => "Copy",
+ "onclick" => "copy_to_clipboard(window.getSelection().toString())",
+ "icon" => "fa-clipboard"
+ ],
+ [
+ "text" => "Paste",
+ "onclick" => "paste_from_clipboard()",
+ "icon" => "fa-paint-brush",
+ ],
+];
+
+// register our menu
+Hook::run(HOOKTYPE_RIGHTCLICK_MENU, $rightClickMenu);