]>
jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - Classes/class-plugin-git.php
2 define('DEFAULT_PLUGINS_DIR', 'https://api.dalek.services/plugins.list');
9 function __construct($url = DEFAULT_PLUGINS_DIR
)
14 $curl = curl_init($url);
17 curl_setopt($curl, CURLOPT_RETURNTRANSFER
, true); // Return the response instead of printing it
18 curl_setopt($curl, CURLOPT_HTTPHEADER
, ['Content-Type: application/json']); // Set the content type to JSON
19 curl_setopt($curl, CURLOPT_USERAGENT
, "UnrealIRCd Admin Panel");
20 // Execute the request
21 $response = curl_exec($curl);
24 if ($response === false)
25 $this->err
= curl_error($curl);
27 $this->data
= json_decode($response, false);
32 public function ifInstalledLabel($name, $installed = false)
36 <div
class="badge rounded-pill badge-success">Installed ✅
</div
>
38 else if (Plugins
::plugin_exists($name))
41 <div
class="badge rounded-pill badge-success">Installed ✅
</div
>
48 public function do_list()
56 foreach($this->data
as $p)
58 $installed = Plugins
::plugin_exists($p->name
) ? true : false;
63 // use a default image if there was none
64 $p->icon
= $p->icon
?? get_config("base_url")."img/no-image-available.jpg";
66 <!-- Widget
for plugins
-->
67 <div id
="<?php echo $p->name ?>" class="<?php if ($installed) echo "installed
" ?>card text-dark bg-light ml-4 mb-3 w-25">
68 <div
class="card-header">
69 <div
class="font-weight-bold">
70 <div
><h5
><img
class="mr-3" src
="<?php echo $p->icon ?>" height
="50" width
="55">
71 <?php
echo $p->title
; $this->ifInstalledLabel($p->name
); ?></h5
></div
>
74 <div
class="card-body">
75 <h5
class="card-title"><?php
echo $p->title
?> <small
><code
>v
<?php
echo $p->version
?></code
></small
></h5
>
76 <p
class="card-text"><?php
echo $p->description
?> </p
>
78 <div
class="card-footer d-flex justify-content-between align-items-center">
79 <ul
class="list-unstyled">
80 <li
class="list-item">Author
: <a href
="<?php echo "mailto
:".$p->contact ?? "#" ?>"></li><i><?php echo $p->author ?></i></a>
82 <div
class="btn-group">
83 <div
class="btn btn-secondary">More Info
</div
>
84 <div id
="<?php echo $p->name ?>install" class="btn btn-primary">Install
</div
>
90 if ($counter >= 3) // only do three per row. WARNING: untested due to not having more than 2 plugins atm...
94 <div
class="row"><?php