X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel-plugins.git/blobdiff_plain/439184a43d1a530b9de56f5853074541b79a43eb..e3842a1cd4ca886cedd9f11ed46ffc525cb9e78c:/php_mailer/php_mailer.php diff --git a/php_mailer/php_mailer.php b/php_mailer/php_mailer.php index b802a22..27e077a 100644 --- a/php_mailer/php_mailer.php +++ b/php_mailer/php_mailer.php @@ -4,7 +4,7 @@ @author Valware @contact valerie@valware.co.uk @description Provides support for PHPMailer() to send emails you care about - @version 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 @@ -16,9 +16,9 @@ use PHPMailer\PHPMailer\SMTP; class php_mailer { - public $name = "PHPMailer()"; + 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.
User: \"".$fail['login']."\"
IP: \"".$fail['IP']."\"" + "-- ADMIN NOTIFICATION --,

". + "There was failed login attempt to account: \"$user->username\"

". + "Details:
". + "IP: ".$_SERVER['REMOTE_ADDR']." (".$_SERVER['HTTP_CF_IPCOUNTRY'].")
". + "User Agent: ".$_SERVER['HTTP_USER_AGENT']."

" ); - $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]; + } }