diff --git a/public_html/lists/admin/css/app.css b/public_html/lists/admin/css/app.css index 9fa02c9d1..d46acfbfc 100644 --- a/public_html/lists/admin/css/app.css +++ b/public_html/lists/admin/css/app.css @@ -287,3 +287,7 @@ div.plugindetails > div.detail > span.value { font-weight: bold; height: 150px; } + +form#forgotpassword-form input[type="submit"] { + margin-top: 10px; +} diff --git a/public_html/lists/admin/index.php b/public_html/lists/admin/index.php index c747423e7..a7e2e39a3 100644 --- a/public_html/lists/admin/index.php +++ b/public_html/lists/admin/index.php @@ -344,12 +344,22 @@ function mb_strtolower($string) } } //If passwords are encrypted and a password recovery request was made, send mail to the admin of the given email address. - } elseif (isset($_REQUEST['forgotpassword'])) { - $adminId = $GLOBALS['admin_auth']->adminIdForEmail($_REQUEST['forgotpassword']); + } elseif (isset($_REQUEST['forgotpassword']) || isset($_REQUEST['forgotusername'])) { + $addressReminderType = ''; + $addressReminder = ''; + if (isset($_REQUEST['forgotpassword']) && !empty($_REQUEST['forgotpassword'])) { + $addressReminderType = 'password'; + $addressReminder = $_REQUEST['forgotpassword']; + } elseif (isset($_REQUEST['forgotusername']) && !empty($_REQUEST['forgotusername'])) { + $addressReminderType = 'username'; + $addressReminder = $_REQUEST['forgotusername']; + } + $adminId = $GLOBALS['admin_auth']->adminIdForEmail($addressReminder); if ($adminId) { - $msg = sendAdminPasswordToken($adminId); + $msg = ($addressReminderType == 'password') ? sendAdminPasswordToken($adminId) : sendAdminUsernameReminder($adminId); } else { - $msg = $GLOBALS['I18N']->get('Failed sending a change password token'); + if (empty($addressReminderType)) $addressReminderType = 'password'; + $msg = $GLOBALS['I18N']->get('Failed sending a ' . (($addressReminderType == 'password') ? 'change password token' : 'username reminder')); } $page = 'login'; } elseif (!empty($_GET['secret']) diff --git a/public_html/lists/admin/lib.php b/public_html/lists/admin/lib.php index b4236ef0c..c41c267fb 100644 --- a/public_html/lists/admin/lib.php +++ b/public_html/lists/admin/lib.php @@ -417,6 +417,29 @@ function sendAdminPasswordToken($adminId) } } +//Send an email with a username reminder the specified adminId. +function sendAdminUsernameReminder($adminId) +{ + //Retrieve the admin login name and email address + $SQLquery = sprintf('select loginname,email from %s where id=%d;', $GLOBALS['tables']['admin'], $adminId); + $row = Sql_Fetch_Row_Query($SQLquery); + $adminName = $row[0]; + $email = $row[1]; + + $urlroot = getConfig('website').$GLOBALS['adminpages']; + //Build the email body to be sent, and finally send it. + $emailBody = $GLOBALS['I18N']->get('Hello')."\n\n"; + $emailBody .= $GLOBALS['I18N']->get('You have requested a username reminder for phpList.')."\n\n"; + $emailBody .= $GLOBALS['I18N']->get('Your username is:')."\n\n"; + $emailBody .= $adminName; + + if (sendMail($email, $GLOBALS['I18N']->get('Username reminder'), "\n\n".$emailBody, '', '', true)) { + return $GLOBALS['I18N']->get('A username reminder has been sent to the corresponding email address.'); + } else { + return $GLOBALS['I18N']->get('Error sending user reminder'); + } +} + function getTopSmtpServer($domain) { $mx = getmxrr($domain, $mxhosts, $weight); @@ -2522,4 +2545,4 @@ function notifyNewIPLogin($adminId) { sendMail($main_admin_mail, $GLOBALS['installation_name'].' '.s('login from new location'), $msg, system_messageheaders($admin_mail)); } -} \ No newline at end of file +} diff --git a/public_html/lists/admin/login.php b/public_html/lists/admin/login.php index 6affa9e85..515d4812b 100644 --- a/public_html/lists/admin/login.php +++ b/public_html/lists/admin/login.php @@ -40,8 +40,12 @@ function footer() echo '
'; }