]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/commitdiff
IMPORTANT - Please read
authorValerie Pond <redacted>
Sun, 25 Jun 2023 11:39:16 +0000 (12:39 +0100)
committerValerie Pond <redacted>
Sun, 25 Jun 2023 11:39:16 +0000 (12:39 +0100)
The PHPMailer (and example plugin) are being moved out of source and into the contrib repo. This means when you update past this point, your emails will stop working and you'll have to wait for an update of the plugin in order for it to work.

Classes/class-plugin-git.php
api/plugin.php
plugins/example_plugin/example.php [deleted file]
plugins/example_plugin/example_plugin.php [deleted file]
plugins/php_mailer/php_mailer.php [deleted file]
settings/add-plugin.php

index a4300debe3cff45bcfc4909bed0b9a2743f29eac..f88c7ea8fea6255801dd83df51d116d18936505e 100644 (file)
@@ -72,7 +72,7 @@
         $counter = 0;
 
 
-        foreach($this->data as $p)
+        foreach($this->data->list as $p)
         {
             $installed = in_array($p->name, $config['plugins']) ? true : false;
 
index 11a37108816314cedd7ffdf6731e60b90bd3cde8..0e3e46b22ae0608f44cd3ae2b05cf0fb0179cb26 100644 (file)
@@ -4,7 +4,6 @@ session_start();
 if (!isset($_SESSION['id']))
     die("Access denied");
 require_once('common_api.php');
-
 header("Content-type: application/json; charset=utf-8");
 
 if (!current_user_can(PERMISSION_MANAGE_PLUGINS))
@@ -95,7 +94,8 @@ function install_plugin($name)
 function get_plugin_install_path_from_name($name)
 {
     global $config;
-    foreach($config['third-party-plugins']['data'] as $p)
+    $list = $config['third-party-plugins']['data']->list;
+    foreach($list as $p)
     {
         if (!strcmp($p->name,$name))
             return $p->download_link;
diff --git a/plugins/example_plugin/example.php b/plugins/example_plugin/example.php
deleted file mode 100644 (file)
index 011cdb0..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php
-require_once "../../inc/common.php";
-require_once "../../inc/header.php";
-echo "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
\ No newline at end of file
diff --git a/plugins/example_plugin/example_plugin.php b/plugins/example_plugin/example_plugin.php
deleted file mode 100644 (file)
index 0ae218f..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-
-class example_plugin
-{
-       public $name = "Example plugin";
-       public $author = "Valware";
-       public $version = "1.0";
-       public $description = "An example plugin to show how to make stuff";
-       public $email = "v.a.pond@outlook.com";
-
-       function __construct()
-       {
-               Hook::func(HOOKTYPE_NAVBAR, 'example_plugin::add_navbar'); 
-       }
-
-       public static function add_navbar(&$pages)
-       {
-               $page_name = "Example";
-               $page_link = "plugins/example_plugin/example.php";
-               $pages[$page_name] = $page_link;
-       }
-}
\ No newline at end of file
diff --git a/plugins/php_mailer/php_mailer.php b/plugins/php_mailer/php_mailer.php
deleted file mode 100644 (file)
index 2b50486..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-<?php
-
-use PHPMailer\PHPMailer\PHPMailer;
-use PHPMailer\PHPMailer\SMTP;
-
-class php_mailer
-{
-       public $name = "PHPMailer()";
-       public $author = "Valware";
-       public $version = "1.0";
-       public $description = "Send mail using PHPMailer()";
-       public $email = "v.a.pond@outlook.com";
-
-       function __construct()
-       {
-               Hook::func(HOOKTYPE_USER_LOGIN, 'php_mailer::user_login_notif');
-               Hook::func(HOOKTYPE_USER_LOGIN_FAIL, 'php_mailer::user_login_fail_notif');
-       }
-
-       public static function send_mail($to, $subject, $body)
-       {
-               $mail = new PHPMailer(true);
-               try {
-                       //Server settings
-                       //$mail->SMTPDebug = 2;
-                       $mail->isSMTP();                                    // Send using SMTP
-                       $mail->Host       = get_config("smtp::host");       // Set the SMTP server to send through
-                       $mail->SMTPAuth   = true;                           // Enable SMTP authentication
-                       $mail->Username   = get_config("smtp::username");   // SMTP username
-                       $mail->Password = get_config("smtp::password");     // SMTP password
-                       $mail->SMTPSecure = get_config("smtp::encryption"); // Enable implicit TLS encryption
-                       $mail->Port       = get_config("smtp::port");       // TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
-
-                       //Recipients
-                       $mail->setFrom(get_config("smtp::username"), get_config("smtp::from_name"));
-                       $mail->addAddress($to['email'], $to['name']);       // Add a recipient
-
-                       //Content
-                       $mail->isHTML(true);                                // Set email format to HTML
-                       $mail->Subject = $subject;
-                       $mail->Body    = $body . "<br><br>Thank you for using UnrealIRCd!";
-                       $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
-
-                       $mail->send();
-               } catch (Exception $e) {
-                       die("Could not send mail:". $e);
-               }
-       }
-
-       /**
-        *  Send a login notification to the admin (note-to-self)
-        * @param mixed $user
-        * @return void
-        */
-       public static function user_login_notif($user)
-       {
-               self::send_mail(
-                       ["email" => get_config("smtp::username"), "name" => get_config("smtp::from_name")],
-                       "New login to Unreal Admin Panel",
-                       "There was a new login to the admin panel.<br>User: \"$user->username\"<br>IP: \"".$_SERVER['REMOTE_ADDR']."\" (".$_SERVER['HTTP_CF_IPCOUNTRY'].")<br>".
-                       "User Agent: ".$_SERVER['HTTP_USER_AGENT']
-               );
-
-               if ($user->email)
-                       self::send_mail(
-                               ["email" => $user->email, "name" => $user->first_name . " " . $user->last_name],
-                               "New login to your account",
-                               "Dear $user->first_name, <br><br>".
-                               "There was a new login to account: \"$user->username\"<br><br>".
-                               "Details:<br>".
-                               "IP: ".$_SERVER['REMOTE_ADDR']." (".$_SERVER['HTTP_CF_IPCOUNTRY'].")<br>".
-                               "User Agent: ".$_SERVER['HTTP_USER_AGENT']."<br><br>".
-                               "If this was not you, please contact your Panel Administrator."
-                       );
-       }
-       public static function user_login_fail_notif($fail)
-       {
-               self::send_mail(
-                       ["email" => get_config("smtp::username"), "name" => get_config("smtp::from_name")],
-                       "Failed login attempt - Unreal Admin Panel",
-                       "There was a failed login attempt to the admin panel.<br>User: \"".$fail['login']."\"<br>IP: \"".$fail['IP']."\""
-               );
-               $user = new PanelUser($fail['login']);
-               if ($user->email)
-                       self::send_mail(
-                               ["email" => $user->email, "name" => $user->first_name . " " . $user->last_name],
-                               "Failed login attempt to your account",
-                               "Dear $user->first_name, <br><br>".
-                               "There was failed login attempt to your account: \"$user->username\"<br><br>".
-                               "Details:<br>".
-                               "IP: ".$_SERVER['REMOTE_ADDR']." (".$_SERVER['HTTP_CF_IPCOUNTRY'].")<br>".
-                               "User Agent: ".$_SERVER['HTTP_USER_AGENT']."<br><br>".
-                               "If this was not you, please contact your Panel Administrator."
-                       );
-       }
-}
\ No newline at end of file
index fd265719c4b06784347a61bab4f51d01ca48df5e..adc001696b1d7007365cbb506633b7ccef8ffbf6 100644 (file)
@@ -34,7 +34,6 @@ $p = new PluginRepo();
     const ibtns = document.querySelectorAll(".btn-install-plugin");
     ibtns.forEach((ib) => {
         ib.addEventListener('click', (e) => {
-            console.log("Button clicked! " +ib.innerHTML);
             if (ib.innerHTML !== "Install" && ib.innerHTML !== "Uninstall") // some point between, don't do anything
             {}
             else if (ib.innerHTML == "Install") // install button pressed!
@@ -121,13 +120,13 @@ $p = new PluginRepo();
         fetch(BASE_URL + 'api/plugin.php')
         .then(response => response.json()) // Parse the response as JSON
         .then(data => {
-            for (let i = 0; data[i]; i++)
+            for (let i = 0; data.list[i]; i++)
             {
-                if (data[i].name == modname)
+                if (data.list[i].name == modname)
                 {
                     const modal = bsModal(
-                        "<i>Information about " + data[i].title + "</i>", // title
-                        "<div class=\"" + data[i].name + "_screenshots\"><i class=\"fa fa-spinner\" aria-hidden=\"true\"></i></div><div class=\"" + data[i].name + "_description\"><i class=\"fa fa-spinner\" aria-hidden=\"true\"></i></div>",
+                        "<i>Information about " + data.list[i].title + "</i>", // title
+                        "<div class=\"" + data.list[i].name + "_screenshots\"><i class=\"fa fa-spinner\" aria-hidden=\"true\"></i></div><div class=\"" + data.list[i].name + "_description\"><i class=\"fa fa-spinner\" aria-hidden=\"true\"></i></div>",
                         "<div id=\""+modname+"closebtn\" class=\"btn btn-danger\">Close</div>", null, true, true, false
                     );
                     let modalclose = document.getElementById(modal);
@@ -136,7 +135,7 @@ $p = new PluginRepo();
                     });
                     console.log(modal + '-body');
                     boobs = document.getElementById(modal + '-body');
-                    boobs.innerHTML = data[i].description;
+                    boobs.innerHTML = data.list[i].description;
                 }
             }
         })