]> jfr.im git - irc/unrealircd/unrealircd-webpanel-plugins.git/blobdiff - php_mailer/php_mailer.php
Update README.md
[irc/unrealircd/unrealircd-webpanel-plugins.git] / php_mailer / php_mailer.php
index 6ab51d6a9bd3c772970166f0b1e49210f758653b..27e077a7600ca2b45b35de6e6372ce1feea7ce19 100644 (file)
@@ -4,9 +4,9 @@
   @author Valware
   @contact valerie@valware.co.uk
   @description Provides support for PHPMailer() to send emails you care about
-  @version 1.0
-  @tested 1.0
-  @minver 1.0
+  @version 1.2
+  @tested 0.9
+  @minver 0.9
   @icon https://w7.pngwing.com/pngs/78/575/png-transparent-phpmailer-hd-logo.png
   @maxver *
   @license GPLv3
@@ -18,7 +18,7 @@ class php_mailer
 {
        public $name = "php_mailer";
        public $author = "Valware";
-       public $version = "1.0";
+       public $version = "1.2";
        public $description = "Send mail using PHPMailer()";
        public $email = "v.a.pond@outlook.com";
 
@@ -26,6 +26,7 @@ class php_mailer
        {
                Hook::func(HOOKTYPE_USER_LOGIN, 'php_mailer::user_login_notif');
                Hook::func(HOOKTYPE_USER_LOGIN_FAIL, 'php_mailer::user_login_fail_notif');
+               Hook::func(HOOKTYPE_NAVBAR, 'php_mailer::navbar_hook');
        }
 
        public static function send_mail($to, $subject, $body)
@@ -84,14 +85,22 @@ class php_mailer
                                "If this was not you, please contact your Panel Administrator."
                        );
        }
-       public static function user_login_fail_notif($fail)
+
+       /**
+        * Send a notification about the failed attempt
+        */
+       public static function user_login_fail_notif($user)
        {
                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']."\""
+                       "-- ADMIN NOTIFICATION --, <br><br>".
+                       "There was failed login attempt 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>"
                );
-               $user = new PanelUser($fail['login']);
+               $user = new PanelUser($user['login']);
                if ($user->email)
                        self::send_mail(
                                ["email" => $user->email, "name" => $user->first_name . " " . $user->last_name],
@@ -104,4 +113,11 @@ class php_mailer
                                "If this was not you, please contact your Panel Administrator."
                        );
        }
+
+       public static function navbar_hook(&$pages)
+       {
+               $page_name = "Mail";
+               $page_link = "plugins/php_mailer/mail-settings.php";
+               $pages["Settings"][$page_name] = ["script" => $page_link];
+       }
 }