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']['data'] = NULL;
15 $config['third-party-plugins']['timestamp'] = 0;
17 if (time() - $config['third-party-plugins']['timestamp'] > 200) // Cache for 3.333 minutes lol
19 // come simba it is taem
20 $curl = curl_init($url);
23 curl_setopt($curl, CURLOPT_RETURNTRANSFER
, true); // Return the response instead of printing it
24 curl_setopt($curl, CURLOPT_HTTPHEADER
, ['Content-Type: application/json']); // Set the content type to JSON
25 curl_setopt($curl, CURLOPT_USERAGENT
, "UnrealIRCd Admin Panel"); // This is Secret Agent UnrealIRCd Admin Panel reporting for doody
26 // Execute the request
27 $response = curl_exec($curl);
30 if ($response === false)
31 $this->err
= curl_error($curl);
34 $this->data
= json_decode($response, false);
35 $config['third-party-plugins']['data'] = $this->data
;
36 $config['third-party-plugins']['timestamp'] = time();
37 write_config('third-party-plugins');
41 $this->data
= $config['third-party-plugins']['data'];
47 public function ifInstalledLabel($name, $installed = false)
51 <div style
="margin-left:40px;" class="badge rounded-pill badge-success">✔ Installed
</div
>
53 else if (Plugins
::plugin_exists($name))
56 <div style
="margin-left:40px;" class="badge rounded-pill badge-success">✔ Installed
</div
>
60 public function ifCompatible($plugin)
62 $tok = split(WEBPANEL_VERSION
,"-");
64 if ($plugin->minver
<= $wpversion)
66 <div style
="margin-left:40px;" class="badge rounded-pill badge-info">Compatible
</div
>
70 <div style
="margin-left:40px;" class="badge rounded-pill badge-danger">Incompatible
</div
>
76 public function do_list()
80 die("Could not fetch list.\n");
85 foreach($this->data
->list as $p)
87 $tok = split(WEBPANEL_VERSION
,"-");
88 $upgradeRequired = false;
90 if ($p->minver
> $wpversion)
91 $upgradeRequired = true;
92 $installed = in_array($p->name
, $config['plugins']) ? true : false;
96 // use a default image if there was none
97 $p->icon
= $p->icon
?? get_config("base_url")."img/no-image-available.jpg";
99 <!-- Widget
for plugins
-->
100 <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">
103 <div
class="card-header">
105 <img
class="align-self-start mr-3" src
="<?php echo $p->icon ?>" height
="50" width
="55">
106 <div
class="media-body">
107 <div style
="position:relative;float:inline-end"><?php
echo $this->ifInstalledLabel($p->name
); $this->ifCompatible($p) ?></div
>
108 <h4
class="mb-0 mt-0"><?php
echo $p->title
?></h4
>
109 <small
>By
<a href
="<?php echo "mailto
:$p->contact
" ?>" target
="_blank"><?php
echo $p->author
?></a
></small
>
115 <div
class="card-body">
116 <h6
class="card-title"><?php
echo $p->title
?> <small
><code
>v
<?php
echo $p->version
?></code
></small
></h6
>
117 <p
class="card-text"><?php
echo $p->description
?><br
><br
> </p
>
121 <div
class="card-footer d-flex justify-content-between">
122 <div id
="justALonelyEmptyDivCryEmoji"></div
>
124 <div id
="<?php echo $p->name ?>" class="more-info btn btn-info">More Info
</div
>
125 <?php
if ($upgradeRequired){
127 <div id
="<?php echo $p->name ?>coming-soon" class="btn-coming-soon btn btn-dark disabled">Panel Upgrade Required
</div
>
131 <div id
="<?php echo $p->name ?>install" <?php
if ($upgradeRequired) echo 'style="display:none" '; ?> class="btn-install-plugin btn btn-primary">Install
</div
>
141 <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
>