|
|
@ -27,6 +27,7 @@ |
|
|
# Initiate vars
|
|
|
# Initiate vars
|
|
|
$result = ""; |
|
|
$result = ""; |
|
|
$login = $presetLogin; |
|
|
$login = $presetLogin; |
|
|
|
|
|
$email = ""; |
|
|
$mail = ""; |
|
|
$mail = ""; |
|
|
$ldap = ""; |
|
|
$ldap = ""; |
|
|
$userdn = ""; |
|
|
$userdn = ""; |
|
|
@ -34,6 +35,7 @@ $token = ""; |
|
|
$usermail = ""; |
|
|
$usermail = ""; |
|
|
$captchaphrase = ""; |
|
|
$captchaphrase = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$mail_address_use_ldap) { |
|
|
if (!$mail_address_use_ldap) { |
|
|
if (isset($_POST["mail"]) and $_POST["mail"]) { |
|
|
if (isset($_POST["mail"]) and $_POST["mail"]) { |
|
|
$mail = strval($_POST["mail"]); |
|
|
$mail = strval($_POST["mail"]); |
|
|
@ -49,9 +51,10 @@ if ($use_captcha) { |
|
|
if (isset($_POST["captchaphrase"]) and $_POST["captchaphrase"]) { $captchaphrase = strval($_POST["captchaphrase"]); } |
|
|
if (isset($_POST["captchaphrase"]) and $_POST["captchaphrase"]) { $captchaphrase = strval($_POST["captchaphrase"]); } |
|
|
else { $result = "captcharequired"; } |
|
|
else { $result = "captcharequired"; } |
|
|
} |
|
|
} |
|
|
if (isset($_REQUEST["login"]) and $_REQUEST["login"]) { $login = strval($_REQUEST["login"]); } |
|
|
|
|
|
else { $result = "loginrequired"; } |
|
|
|
|
|
if (! isset($_POST["mail"]) and ! isset($_REQUEST["login"])) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($_REQUEST["email"]) and $_REQUEST["email"]) { $email = strval($_REQUEST["email"]); } |
|
|
|
|
|
else { $result = "emailrequired"; } |
|
|
|
|
|
if (! isset($_POST["mail"]) and ! isset($_REQUEST["email"])) |
|
|
{ $result = "emptysendtokenform"; } |
|
|
{ $result = "emptysendtokenform"; } |
|
|
|
|
|
|
|
|
# Check the entered username for characters that our installation doesn't support
|
|
|
# Check the entered username for characters that our installation doesn't support
|
|
|
@ -100,7 +103,7 @@ if ( $result === "" ) { |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
|
|
|
# Search for user
|
|
|
# Search for user
|
|
|
$ldap_filter = str_replace("{login}", $login, $ldap_filter); |
|
|
|
|
|
|
|
|
$ldap_filter = str_replace("{email}", $email, $ldap_filter); |
|
|
$search = ldap_search($ldap, $ldap_base, $ldap_filter); |
|
|
$search = ldap_search($ldap, $ldap_base, $ldap_filter); |
|
|
|
|
|
|
|
|
$errno = ldap_errno($ldap); |
|
|
$errno = ldap_errno($ldap); |
|
|
@ -117,50 +120,8 @@ if ( $result === "" ) { |
|
|
$result = "badcredentials"; |
|
|
$result = "badcredentials"; |
|
|
error_log("LDAP - User $login not found"); |
|
|
error_log("LDAP - User $login not found"); |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
|
|
|
# Compare mail values
|
|
|
# Compare mail values
|
|
|
$mailValues = ldap_get_values($ldap, $entry, $mail_attribute); |
|
|
|
|
|
unset($mailValues["count"]); |
|
|
|
|
|
$match = 0; |
|
|
|
|
|
|
|
|
|
|
|
if (!$mail_address_use_ldap) { |
|
|
|
|
|
# Match with user submitted values
|
|
|
|
|
|
foreach ($mailValues as $mailValue) { |
|
|
|
|
|
if (strcasecmp($mail_attribute, "proxyAddresses") == 0) { |
|
|
|
|
|
$mailValue = str_ireplace("smtp:", "", $mailValue); |
|
|
|
|
|
} |
|
|
|
|
|
if (strcasecmp($mail, $mailValue) == 0) { |
|
|
|
|
|
$match = 1; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
# Use first available mail adress in ldap
|
|
|
|
|
|
if(count($mailValues) > 0) { |
|
|
|
|
|
$mailValue = $mailValues[0]; |
|
|
|
|
|
if (strcasecmp($mail_attribute, "proxyAddresses") == 0) { |
|
|
|
|
|
$mailValue = str_ireplace("smtp:", "", $mailValue); |
|
|
|
|
|
} |
|
|
|
|
|
$mail = $mailValue; |
|
|
|
|
|
$match = true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!$match) { |
|
|
|
|
|
if (!$mail_address_use_ldap) { |
|
|
|
|
|
$result = "mailnomatch"; |
|
|
|
|
|
error_log("Mail $mail does not match for user $login"); |
|
|
|
|
|
} else { |
|
|
|
|
|
$result = "mailnomatch"; |
|
|
|
|
|
error_log("Mail not found for user $login"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if ( $use_ratelimit ) { |
|
|
|
|
|
if ( ! allowed_rate($login,$_SERVER[$client_ip_header],$rrl_config) ) { |
|
|
|
|
|
$result = "throttle"; |
|
|
|
|
|
error_log("Mail - User $login too fast"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$login = ldap_get_values($ldap, $entry, "uid"); |
|
|
|
|
|
|
|
|
}}}}} |
|
|
}}}}} |
|
|
|
|
|
|
|
|
@ -176,7 +137,7 @@ if ( $result === "" ) { |
|
|
|
|
|
|
|
|
session_name("token"); |
|
|
session_name("token"); |
|
|
session_start(); |
|
|
session_start(); |
|
|
$_SESSION['login'] = $login; |
|
|
|
|
|
|
|
|
$_SESSION['login'] = $login[0]; |
|
|
$_SESSION['time'] = time(); |
|
|
$_SESSION['time'] = time(); |
|
|
|
|
|
|
|
|
if ( $crypt_tokens ) { |
|
|
if ( $crypt_tokens ) { |
|
|
@ -219,13 +180,13 @@ if ( $result === "" ) { |
|
|
error_log("Send reset URL " . ( $debug ? "$reset_url" : "HIDDEN")); |
|
|
error_log("Send reset URL " . ( $debug ? "$reset_url" : "HIDDEN")); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$data = array( "login" => $login, "mail" => $mail, "url" => $reset_url ) ; |
|
|
|
|
|
|
|
|
$data = array( "login" => $login, "mail" => $email, "url" => $reset_url ) ; |
|
|
|
|
|
|
|
|
# Send message
|
|
|
# Send message
|
|
|
if ( send_mail($mailer, $mail, $mail_from, $mail_from_name, $messages["resetsubject"], $messages["resetmessage"].$mail_signature, $data) ) { |
|
|
|
|
|
|
|
|
if ( send_mail($mailer, $email, $mail_from, $mail_from_name, $messages["resetsubject"], $messages["resetmessage"].$mail_signature, $data) ) { |
|
|
$result = "tokensent"; |
|
|
$result = "tokensent"; |
|
|
} else { |
|
|
} else { |
|
|
$result = "tokennotsent"; |
|
|
$result = "tokennotsent"; |
|
|
error_log("Error while sending token to $mail (user $login)"); |
|
|
|
|
|
|
|
|
error_log("Error while sending token to $email (user $login)"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |