<?php
define('UPATH', dirname(__FILE__));
require_once "config.php";
-require_once "hook.php";
-require_once "plugins.php";
+require_once "Classes/class-hook.php";
require_once UPATH . '/vendor/autoload.php';
require_once "connection.php";
require_once "Classes/class-log.php";
require_once "Classes/class-message.php";
require_once "Classes/class-rpc.php";
+require_once "plugins.php";
$pages = Array("Overview" => "index.php",
- "Users" => "users.php",
- "Channels" => "channels.php",
- "Server Bans" => "tkl.php",
- "Spamfilter" => "spamfilter.php",
- "News" => "news.php");
+ "Users" => "users.php",
+ "Channels" => "channels.php",
+ "Server Bans" => "tkl.php",
+ "Spamfilter" => "spamfilter.php",
+ "News" => "news.php");
Hook::run(HOOKTYPE_NAVBAR, $pages);
/* Example to add new menu item:
- *
- * Example to add a navigation bar:
*
* class MyPlugin
* {
*
- * function __construct()
- * {
- * Hook::func(HOOKTYPE_NAVBAR, [$this, 'add_menu'])
- * }
+ * function __construct()
+ * {
+ * Hook::func(HOOKTYPE_NAVBAR, [$this, 'add_menu'])
+ * }
*
- * function add_menu(&$pages) // this should pass by reference (using the & prefix)
- * {
- * $page_name = "My New Page";
- * $page_link = "link/to/page.php";
- * $pages[$page_name] = $page_link;
- * }
+ * function add_menu(&$pages) // this should pass by reference (using the & prefix)
+ * {
+ * $page_name = "My New Page";
+ * $page_link = "link/to/page.php";
+ * $pages[$page_name] = $page_link;
+ * }
* }
*/
\ No newline at end of file
<?php
if (!defined('UPATH'))
- die("Access denied");
+ die("Access denied");
if (!defined('UNREALIRCD_RPC_USER') ||
- !defined('UNREALIRCD_RPC_PASSWORD') ||
- !defined('UNREALIRCD_HOST') ||
- !defined('UNREALIRCD_PORT')
+ !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;
/* Connect now */
try {
- $rpc = new UnrealIRCd\Connection("wss://".UNREALIRCD_HOST.":".UNREALIRCD_PORT,
- $api_login,
- Array("tls_verify"=>$tls_verify));
+ $rpc = new UnrealIRCd\Connection
+ (
+ "wss://".UNREALIRCD_HOST.":".UNREALIRCD_PORT,
+ $api_login,
+ Array("tls_verify"=>$tls_verify)
+ );
} catch (Exception $e) {
- die("Unable to connect to UnreaIRCd<br>");
+ die("Unable to connect to UnreaIRCd<br>");
}
<h2><a href="index.php">UnrealIRCd <small>Administration Panel</small></a></h2></div>
<script src="js/unrealircd-admin.js" defer></script>
<div class="topnav">
-
+
<?php
foreach($pages as $name=>$page)
{
- $active = '';
- if (str_ends_with($_SERVER['SCRIPT_FILENAME'], $page))
- {
- $active = "class=\"active\" ";
- }
- echo "<a ".$active."href=\"$page\">$name</a>\n";
+ $active = '';
+ if (str_ends_with($_SERVER['SCRIPT_FILENAME'], $page))
+ {
+ $active = "class=\"active\" ";
+ }
+ echo "<a ".$active."href=\"$page\">$name</a>\n";
}
?>
* Which contains a class like this:
* ```
* class myplugin {
- * $name = "My plugin";
- * $author = "Joe Bloggs";
- * $version "1.0";
- * $desc = "This is my plugin and it does stuff";
- *
- * // rest of code here...
+ * $name = "My plugin";
+ * $author = "Joe Bloggs";
+ * $version "1.0";
+ * $desc = "This is my plugin and it does stuff";
+ *
+ * // rest of code here...
* }
* ```
* Your plugin class must be constructable and contain the following public variables:
- * $name The name or title of your plugin.
+ * $name The name or title of your plugin.
* $author The name of the author
* $version The version of the plugin
- * $description A short description of the plugin
+ * $description A short description of the plugin
*/
class Plugins
{
- static $list = [];
+ static $list = [];
- static function load($modname)
- {
- $plugin = new Plugin($modname);
- if ($plugin->error)
- {
- Message::Fail("Warning: Plugin \"$modname\" failed to load: $plugin->error");
- }
- else
- {
- self::$list[] = $plugin;
- }
- }
+ static function load($modname)
+ {
+ $plugin = new Plugin($modname);
+ if ($plugin->error)
+ {
+ Message::Fail("Warning: Plugin \"$modname\" failed to load: $plugin->error");
+ }
+ else
+ {
+ self::$list[] = $plugin;
+ }
+ }
}
class Plugin
{
- public $name;
- public $author;
- public $version;
- public $description;
- public $handle;
+ public $name;
+ public $author;
+ public $version;
+ public $description;
+ public $handle;
- public $error = NULL;
- function __construct($handle)
- {
- if (!is_dir("plugins/$handle"))
- $this->error = "Plugin directory \"plugins/$handle\" doesn't exist";
+ public $error = NULL;
+ function __construct($handle)
+ {
+ if (!is_dir("plugins/$handle"))
+ $this->error = "Plugin directory \"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("plugins/$handle/$handle.php"))
+ $this->error = "Plugin file \"plugins/$handle/$handle.php\" doesn't exist";
- else
- {
- require_once "plugins/$handle/$handle.php";
+ else
+ {
+ require_once "plugins/$handle/$handle.php";
- if (!class_exists($handle))
- $this->error = "Class \"$handle\" doesn't exist";
+ if (!class_exists($handle))
+ $this->error = "Class \"$handle\" doesn't exist";
- else
- {
- $plugin = new $handle();
-
- if (!isset($plugin->name))
- $this->error = "Plugin name not defined";
- elseif (!isset($plugin->author))
- $this->error = "Plugin author not defined";
- elseif (!isset($plugin->version))
- $this->error = "Plugin version not defined";
- elseif (!isset($plugin->description))
- $this->error = "Plugin description not defined";
- else
- {
- $this->handle = $handle;
- $this->name = $plugin->name;
- $this->author = $plugin->author;
- $this->version = $plugin->version;
- $this->description = $plugin->description;
- }
- }
- }
- }
+ else
+ {
+ $plugin = new $handle();
+
+ if (!isset($plugin->name))
+ $this->error = "Plugin name not defined";
+ elseif (!isset($plugin->author))
+ $this->error = "Plugin author not defined";
+ elseif (!isset($plugin->version))
+ $this->error = "Plugin version not defined";
+ elseif (!isset($plugin->description))
+ $this->error = "Plugin description not defined";
+ else
+ {
+ $this->handle = $handle;
+ $this->name = $plugin->name;
+ $this->author = $plugin->author;
+ $this->version = $plugin->version;
+ $this->description = $plugin->description;
+ }
+ }
+ }
+ }
}
if (defined('PLUGINS'))
{
- foreach(PLUGINS as $plugin)
- Plugins::load($plugin);
+ foreach(PLUGINS as $plugin)
+ Plugins::load($plugin);
}
\ No newline at end of file
class example_plugin
{
- public $name = "Example plugin";
- public $author = "Valware";
- public $version = "1.0";
- public $description = "An example plugin to show how to make stuff";
+ public $name = "Example plugin";
+ public $author = "Valware";
+ public $version = "1.0";
+ public $description = "An example plugin to show how to make stuff";
- function __construct()
- {
- Hook::func(HOOKTYPE_NAVBAR, 'example_plugin::add_navbar');
- }
+ function __construct()
+ {
+ Hook::func(HOOKTYPE_NAVBAR, 'example_plugin::add_navbar');
+ }
- public static function add_navbar(&$pages)
- {
- $page_name = "Example";
- $page_link = "plugins/example_plugin/example.php";
- $pages[$page_name] = $page_link;
- }
+ public static function add_navbar(&$pages)
+ {
+ $page_name = "Example";
+ $page_link = "plugins/example_plugin/example.php";
+ $pages[$page_name] = $page_link;
+ }
}
\ No newline at end of file