X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/e47cb29f1f12b3196bd9f7c24b58b0e3a9b440b6..cd26522ba6ff68c18e1504b022ca92f4d01827be:/Classes/class-plugin-git.php diff --git a/Classes/class-plugin-git.php b/Classes/class-plugin-git.php index e0610ac..4bf9dab 100644 --- a/Classes/class-plugin-git.php +++ b/Classes/class-plugin-git.php @@ -1,84 +1,150 @@ err = curl_error($curl); - else - $this->data = json_decode($response, false); - } - public function ifInstalledLabel($name) +class PluginRepo +{ + public $plugins ; + public $data; + public $err; + function __construct($url = DEFAULT_PLUGINS_DIR) + { + global $config; + if (!isset($config['third-party-plugins'])) + { + $config['third-party-plugins'] = []; + } + if (empty($config['third-party-plugins'])) + { + $config['third-party-plugins']['data'] = NULL; + $config['third-party-plugins']['timestamp'] = 0; + } + if (time() - $config['third-party-plugins']['timestamp'] > 200) // Cache for 3.333 minutes lol { - if (Plugins::plugin_exists($name)) + // come simba it is taem + $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"); // This is Secret Agent UnrealIRCd Admin Panel reporting for doody + // Execute the request + $response = curl_exec($curl); + + // Check for errors + if ($response === false) + $this->err = curl_error($curl); + else { - ?> -
Installed ✅
- data = json_decode($response, false); + $config['third-party-plugins']['data'] = $this->data; + $config['third-party-plugins']['timestamp'] = time(); + write_config('third-party-plugins'); } } - public function do_list() - { - ?> -
- data as $p) - { - if (is_string($p)) - continue; + else + $this->data = $config['third-party-plugins']['data']; + + } + + + + public function ifInstalledLabel($name, $installed = false) + { + if ($installed) + { ?> +
✔ Installed
+ +
✔ Installed
+ minver <= $wpversion) + { ?> +
Compatible
+ +
Incompatible
+err) + die("Could not fetch list.\n"); + + ?> +
+ data->list as $p) + { + $tok = split(WEBPANEL_VERSION,"-"); + $upgradeRequired = false; + $wpversion = $tok[0]; + if ($p->minver > $wpversion) + $upgradeRequired = true; + $installed = in_array($p->name, $config['plugins']) ? true : false; + if (is_string($p)) + continue; - ?> - -
-
-
-
- title; $this->ifInstalledLabel($p->name); ?>
-
-
-
-
title ?>
-

description ?>

-
- -
- = 3) // only do three per row. WARNING: untested due to not having more than 2 plugins atm... - { - ?> -
-
-icon = $p->icon ?? get_config("base_url")."img/no-image-available.jpg"; + ?> + +
plugin-card card text-dark bg-light ml-4 mb-3 w-25" style="min-width:300px"> + + +
+
+ +
+
ifInstalledLabel($p->name); $this->ifCompatible($p) ?>
+

title ?>

+ By contact" ?>" target="_blank">author ?> +
+
+
+ + +
+
title ?> vversion ?>
+

description ?>

+
+ + + +
+ +
+ Want to see your plugin listed here? Make a pull request to our GitHub Repository! + \ No newline at end of file