X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/55fd88eb5bc3006a975800bca93c05e51a1c8e9c..ea90b321a4b3768028d841b307c362af97a5e6e1:/plugins.php diff --git a/plugins.php b/plugins.php index 739c9c9..c080e1b 100644 --- a/plugins.php +++ b/plugins.php @@ -1,9 +1,5 @@ name,$name) && (!$version || ($version >= $p->version))) + return true; + + return false; + } + } class Plugin @@ -55,19 +60,20 @@ class Plugin public $version; public $description; public $handle; + public $email; public $error = NULL; function __construct($handle) { - if (!is_dir("plugins/$handle")) - $this->error = "Plugin directory \"plugins/$handle\" doesn't exist"; + if (!is_dir(UPATH."/plugins/$handle")) + $this->error = "Plugin directory \"".UPATH."/plugins/$handle\" doesn't exist"; - else if (!is_file("plugins/$handle/$handle.php")) - $this->error = "Plugin file \"plugins/$handle/$handle.php\" doesn't exist"; + else if (!is_file(UPATH."/plugins/$handle/$handle.php")) + $this->error = "Plugin file \"".UPATH."/plugins/$handle/$handle.php\" doesn't exist"; else { - require_once "plugins/$handle/$handle.php"; + require_once UPATH."/plugins/$handle/$handle.php"; if (!class_exists($handle)) $this->error = "Class \"$handle\" doesn't exist"; @@ -84,6 +90,8 @@ class Plugin $this->error = "Plugin version not defined"; elseif (!isset($plugin->description)) $this->error = "Plugin description not defined"; + elseif (!isset($plugin->email)) + $this->error = "Plugin email not defined"; else { $this->handle = $handle; @@ -91,14 +99,35 @@ class Plugin $this->author = $plugin->author; $this->version = $plugin->version; $this->description = $plugin->description; + $this->email = $plugin->email; } } } } } -if (defined('PLUGINS')) +if (get_config("plugins")) { - foreach(PLUGINS as $plugin) + foreach(get_config("plugins") as $plugin) Plugins::load($plugin); +} + +/* Requires the plugin */ +function require_plugin($name, $version) +{ + if (!Plugins::plugin_exists($name,$version)) + die("Missing plugin: $name v$version"); +} + + + +/* I'm not a fan of globals */ +class AuthModLoaded +{ + public static $status = 0; +} + +function is_auth_provided() +{ + return AuthModLoaded::$status; } \ No newline at end of file