- 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);
- }
+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']['data'] = NULL;
+ $config['third-party-plugins']['timestamp'] = 0;
+ }
+ if (time() - $config['third-party-plugins']['timestamp'] > 200) // Cache for 3.333 minutes lol
+ {
+ // 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
+ {
+ $this->data = json_decode($response, false);
+ $config['third-party-plugins']['data'] = $this->data;
+ $config['third-party-plugins']['timestamp'] = time();
+ write_config('third-party-plugins');
+ }
+ }
+ else
+ $this->data = $config['third-party-plugins']['data'];
+
+ }