2 define('DEFAULT_PLUGINS_DIR', 'https://api.valware.uk/plugins.list');
9 function __construct($url = DEFAULT_PLUGINS_DIR
)
12 if (!isset($config['third-party-plugins']))
14 $config['third-party-plugins'] = [];
16 if (empty($config['third-party-plugins']))
18 $config['third-party-plugins']['data'] = NULL;
19 $config['third-party-plugins']['timestamp'] = 0;
21 if (time() - $config['third-party-plugins']['timestamp'] > 200) // Cache for 3.333 minutes lol
23 // come simba it is taem
24 $curl = curl_init($url);
27 curl_setopt($curl, CURLOPT_RETURNTRANSFER
, true); // Return the response instead of printing it
28 curl_setopt($curl, CURLOPT_HTTPHEADER
, ['Content-Type: application/json']); // Set the content type to JSON
29 curl_setopt($curl, CURLOPT_USERAGENT
, "UnrealIRCd Admin Panel"); // This is Secret Agent UnrealIRCd Admin Panel reporting for doody
30 // Execute the request
31 $response = curl_exec($curl);
34 if ($response === false)
35 $this->err
= curl_error($curl);
38 $this->data
= json_decode($response, false);
39 $config['third-party-plugins']['data'] = $this->data
;
40 $config['third-party-plugins']['timestamp'] = time();
41 write_config('third-party-plugins');
45 $this->data
= $config['third-party-plugins']['data'];
51 public function ifInstalledLabel($name, $installed = false)
55 <div style
="margin-left:40px;" class="badge rounded-pill badge-success">✔ Installed
</div
>
57 else if (Plugins
::plugin_exists($name))
60 <div style
="margin-left:40px;" class="badge rounded-pill badge-success">✔ Installed
</div
>
64 public function ifCompatible($plugin)
66 $tok = split(WEBPANEL_VERSION
,"-");
68 if ($plugin->minver
<= $wpversion)
70 <div style
="margin-left:40px;" class="badge rounded-pill badge-info">Compatible
</div
>
74 <div style
="margin-left:40px;" class="badge rounded-pill badge-danger">Incompatible
</div
>
80 public function do_list()
84 die("Could not fetch list.\n");
89 foreach($this->data
->list as $p)
91 $tok = split(WEBPANEL_VERSION
,"-");
92 $upgradeRequired = false;
94 if ($p->minver
> $wpversion)
95 $upgradeRequired = true;
96 $installed = in_array($p->name
, $config['plugins']) ? true : false;
100 // use a default image if there was none
101 $p->icon
= $p->icon
?? get_config("base_url")."img/no-image-available.jpg";
103 <!-- Widget
for plugins
-->
104 <div id
="<?php echo $p->name ?>" class="<?php if ($installed) echo "installed
" ?> plugin-card card text-dark bg-light ml-4 mb-3 w-25" style
="min-width:300px">
107 <div
class="card-header">
109 <img
class="align-self-start mr-3" src
="<?php echo $p->icon ?>" height
="50" width
="55">
110 <div
class="media-body">
111 <div style
="position:relative;float:inline-end"><?php
echo $this->ifInstalledLabel($p->name
); $this->ifCompatible($p) ?></div
>
112 <h4
class="mb-0 mt-0"><?php
echo $p->title
?></h4
>
113 <small
>By
<a href
="<?php echo "mailto
:$p->contact
" ?>" target
="_blank"><?php
echo $p->author
?></a
></small
>
119 <div
class="card-body">
120 <h6
class="card-title"><?php
echo $p->title
?> <small
><code
>v
<?php
echo $p->version
?></code
></small
></h6
>
121 <p
class="card-text"><?php
echo $p->description
?><br
><br
> </p
>
125 <div
class="card-footer d-flex justify-content-between">
126 <div id
="justALonelyEmptyDivCryEmoji"></div
>
128 <div id
="<?php echo $p->name ?>" class="more-info btn btn-info">More Info
</div
>
129 <?php
if ($upgradeRequired){
131 <div id
="<?php echo $p->name ?>coming-soon" class="btn-coming-soon btn btn-dark disabled">Panel Upgrade Required
</div
>
135 <div id
="<?php echo $p->name ?>install" <?php
if ($upgradeRequired) echo 'style="display:none" '; ?> class="btn-install-plugin btn btn-primary">Install
</div
>
145 <i
>Want to see your plugin listed here
? <a href
="https://github.com/unrealircd/unrealircd-webpanel-plugins" target
="__blank">Make a pull request to our GitHub Repository
</a
>!</i
>