]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/commitdiff
Update with plugins page
authorValerie Pond <redacted>
Thu, 22 Jun 2023 05:32:11 +0000 (06:32 +0100)
committerValerie Pond <redacted>
Thu, 22 Jun 2023 05:32:11 +0000 (06:32 +0100)
Classes/class-plugin-git.php [new file with mode: 0644]
plugins.php
settings/add-plugin.php [new file with mode: 0644]
settings/plugins.php

diff --git a/Classes/class-plugin-git.php b/Classes/class-plugin-git.php
new file mode 100644 (file)
index 0000000..e0610ac
--- /dev/null
@@ -0,0 +1,84 @@
+<?php
+       define('DEFAULT_PLUGINS_DIR', 'https://api.dalek.services/plugins.list');
+       
+       class PluginRepo
+       {
+           public $plugins;
+           public $data;
+           public $err;
+           function __construct($url = DEFAULT_PLUGINS_DIR)
+           {
+       
+           
+               // Initialize curl
+               $curl = curl_init($url);
+       
+               // Set the options
+               curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);  // Return the response instead of printing it
+               curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);  // Set the content type to JSON
+               curl_setopt($curl, CURLOPT_USERAGENT, "UnrealIRCd Admin Panel");
+               // Execute the request
+               $response = curl_exec($curl);
+       
+               // Check for errors
+               if ($response === false)
+                   $this->err = curl_error($curl);
+               else
+                   $this->data = json_decode($response, false);
+           }
+        public function ifInstalledLabel($name)
+        {
+            if (Plugins::plugin_exists($name))
+            {
+                ?>
+                    <div class="badge rounded-pill badge-success">Installed ✅</div>
+                <?php
+            }
+        }
+           public function do_list()
+           {
+               ?>
+<div class="row">
+       <?php     
+               $counter = 0;
+               foreach($this->data as $p)
+               {
+                   if (is_string($p))
+                       continue;
+            
+                   ?>
+       <!-- Widget for plugins -->
+       <div class="card text-dark bg-light ml-4 mb-3 w-25">
+               <div class="card-header">
+                       <div class="font-weight-bold">
+                               <div><img class="mr-3" src="<?php echo $p->icon?>" height="50" width="55">
+                                       <?php echo $p->title; $this->ifInstalledLabel($p->name); ?></div>
+                       </div>
+               </div>
+               <div class="card-body">
+                       <h5 class="card-title"><?php echo $p->title ?></h5>
+                       <p class="card-text"><?php echo $p->description ?> </p>
+               </div>
+               <div class="card-footer">
+                       Author: <a href="<?php echo "mailto:".$p->contact ?? "#" ?>">
+                       <i><?php echo $p->author ?></i></a>
+                       <div class="text-right">
+                               <div class="btn btn-secondary">More Info</div>
+                               <div class="btn btn-primary">Install</div>
+                       </div>
+               </div>
+       </div>
+       <?php
+               $counter++;
+                if ($counter >= 3) // only do three per row. WARNING: untested due to not having more than 2 plugins atm...
+                {
+                    ?>
+</div>
+<div class="row"><?php
+       $counter = 0;
+       }
+       }
+       ?></div>
+<?php
+}
+}
index 2f433cb57e98a25c952988001061ae03cc335139..225d144050226e86fc085166fa9ad10ce00bfa4f 100644 (file)
@@ -45,7 +45,7 @@ class Plugins
        static function plugin_exists($name, $version = NULL)
        {
                foreach(self::$list as $p)
-                       if (!strcasecmp($p->name,$name) && (!$version || ($version >= $p->version)))
+                       if (!strcmp($p->name,$name) && (!$version || ($version >= $p->version)))
                                return true;
 
                return false;
diff --git a/settings/add-plugin.php b/settings/add-plugin.php
new file mode 100644 (file)
index 0000000..21ecf90
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+
+require_once "../inc/common.php";
+require_once "../inc/header.php";
+require_once "../Classes/class-plugin-git.php";
+
+$p = new PluginRepo();
+?>
+
+<h2>Add New Plugin</h2>
+<br>
+
+<?php
+    if ($p) {
+        echo "
+        Welcome to our lively plugins hub, where creativity takes center stage.<br>
+        We've got two fantastic plugins to kick things off (one practical, one for a playful twist).<br>
+        Join us on this exciting journey and unlock new possibilities for your website!<br><br>";   
+        $p->do_list();
+    } else {
+        echo "Oops! Could not find plugins list. This is an upstream error, which means there is nothing wrong<br>
+        on your panel, it just means we can't check the plugins information webpage for some reason.<br>
+        Nothing to worry about! Try again later!";
+    }
+    require_once "../inc/footer.php";
+
+?>
+
+<!-- Remove when page is finished -->
+<script>
+const modal = bsModal("Important", "This is a work in progress.<br><br>Please do not expect anything to work properly on this page",
+"<div class=\"btn btn-primary\" onClick=\"$('#'+modal).modal('hide')\">Ok</div>", size = null, static = true, show = true, closebutton = true);
+</script>
\ No newline at end of file
index a787dd83d1ec1c3d6c477b32fd1055963e14eef6..b6cf5a786356e1769edb96a4a11fbdf585913b53 100644 (file)
@@ -6,9 +6,9 @@ require_once "../inc/header.php";
 
 ?>
 
-<h2>Active Plugins</h2>
+<h2>Active Plugins <a class="btn btn-sm btn-primary" href="add-plugin.php">Add New</a></h2>
 <br>
-To load and unload plugins, see the plugins section of your <code>config.php</code><br>
+Your available plugins. 
 <br>
 <table class="container-xxl table table-sm table-responsive caption-top table-striped">
        <thead class="table-primary">