]> jfr.im git - irc/unrealircd/unrealircd-webpanel-plugins.git/commitdiff
Work towards making a page for mail settings
authorValerie Pond <redacted>
Tue, 27 Jun 2023 02:23:23 +0000 (03:23 +0100)
committerValerie Pond <redacted>
Tue, 27 Jun 2023 02:23:23 +0000 (03:23 +0100)
example_plugin/README.md
php_mailer/mail-settings.php [new file with mode: 0644]
php_mailer/php_mailer.php

index e1ec867997b2b9c94176f03a527f2609ef24acd9..a225bccbb52fdbeb4acf990c9be1ef90b1915046 100644 (file)
@@ -1,4 +1,4 @@
-This plugin adds a new page which is accessible via the navigation panel on the left.
+    This plugin adds a new page which is accessible via the navigation panel on the left.
 
 The page contains a heading saying "Example Page", followed by some random Latin.
 <br><br>
diff --git a/php_mailer/mail-settings.php b/php_mailer/mail-settings.php
new file mode 100644 (file)
index 0000000..3da8a3b
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+require_once "../../inc/common.php";
+require_once "../../inc/header.php";
+
+if (!current_user_can(PERMISSION_MANAGE_PLUGINS))
+{
+    echo "<h4>Access denied</h4>";
+    require_once "../../inc/footer.php";
+    die();
+}
+
+?>
+
+
+<h4>Mail Settings</h4>
+
+<form method="post" action="mail-settings.php?id=<?php echo $edit_user->id; ?>" autocomplete="off" enctype="multipart/form-data">
+
+
+<br>
+<button type="submit" name="update_user" class="btn btn-primary">Save Changes</button><br>
+</form>
+
+
+<?php
+require_once "../../inc/footer.php";
index 6ab51d6a9bd3c772970166f0b1e49210f758653b..20d673fc9d4ce248663de66db6c819bde2dfa939 100644 (file)
@@ -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,12 +85,20 @@ class php_mailer
                                "If this was not you, please contact your Panel Administrator."
                        );
        }
+
+       /**
+        * Send a notification about the failed attempt
+        */
        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']."\""
+                       "-- 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']);
                if ($user->email)
@@ -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];
+       }
 }