]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - plugins/php_mailer/php_mailer.php
Not important but set example SQL database name to unrealircdwebpanel.
[irc/unrealircd/unrealircd-webpanel.git] / plugins / php_mailer / php_mailer.php
index 24f5de4fb37ada03ce239c5667524043fc39d1fd..f8a0d7fb954a96a86b2f3d882424bf9b87c2de23 100644 (file)
@@ -9,6 +9,7 @@ class php_mailer
        public $author = "Valware";
        public $version = "1.0";
        public $description = "Send mail using PHPMailer()";
+       public $email = "v.a.pond@outlook.com";
 
        function __construct()
        {
@@ -41,9 +42,8 @@ class php_mailer
                        $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
 
                        $mail->send();
-                       echo 'Message has been sent';
                } catch (Exception $e) {
-                       echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
+                       die("Could not send mail:". $e);
                }
        }
 
@@ -57,8 +57,21 @@ class php_mailer
                self::send_mail(
                        ["email" => EMAIL_SETTINGS['username'], "name" => EMAIL_SETTINGS['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']."\""
+                       "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)
        {
@@ -67,5 +80,17 @@ class php_mailer
                        "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