]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/commitdiff
Move hook and fix indentation
authorValerie Pond <redacted>
Mon, 9 Jan 2023 04:28:44 +0000 (04:28 +0000)
committerValerie Pond <redacted>
Mon, 9 Jan 2023 04:28:44 +0000 (04:28 +0000)
Classes/class-hook.php [moved from hook.php with 100% similarity]
common.php
connection.php
header.php
plugins.php
plugins/example_plugin/example_plugin.php

similarity index 100%
rename from hook.php
rename to Classes/class-hook.php
index e51095b0c109a8507bc44313de5611383df9b6c5..e1755a8b2b8d6e84b0ce793274456998abfbc7d3 100644 (file)
@@ -1,41 +1,39 @@
 <?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
index b2a1da04a8492b584439b1fbd49164963b10e03b..985d3fb0af313eae5b15cff1c01fb20c468d54ce 100644 (file)
@@ -1,12 +1,12 @@
 <?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;
@@ -14,9 +14,12 @@ $api_login = UNREALIRCD_RPC_USER.":".UNREALIRCD_RPC_PASSWORD;
 
 /* 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>");
 }
index d6813bf4683eb341ac1bf09b849574236c74d66c..18dd1b460af0f32737c01dfb68b52e56470d7b3e 100644 (file)
@@ -7,16 +7,16 @@
 <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";
 }
 
 ?>
index 39ee1d5b7d04b079ec3e08cad06fbebfe170666f..739c9c918ae00d720fd72512b54d85875d7c099b 100644 (file)
@@ -16,89 +16,89 @@ require_once "Classes/class-message.php";
  * 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
index b21009e0196f0a54b656fe5b2f5d6a35f47cca7f..eeb6e9dd3ab0522ed96705a181d11463675c699d 100644 (file)
@@ -2,20 +2,20 @@
 
 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