$skindata['pagename'] = 'forgot';
require_once("include.html");
if($otherconfig["DISABLEFORGOTPASS"]){ header("Location: index.html"); exit;}
require_once("inc/function.accounts.php");
unset($message2,$message,$ffile,$ddomain,$apipass);
if($integrate && !$otherconfig["DISABLEVERIFICATION"])
{
unset($cook);
if($_COOKIE[webmailsignup]!="")
{
$wordtest = str_replace(' ','',$wordtest);
//$wordtest = substr($wordtest,0,5).' '.substr($wordtest,5);
ereg("(.+)-([0-9]+)",$_COOKIE[webmailsignup],$cook);
setcookie(webmailsignup,"", -3600);
}
if($integrate && (!is_array($cook) || !$cook[2] || strcmp(md5(strtoupper($wordtest).$cook[2]),$cook[1])))
$message2 = $lang[MSG_VERIFICATIONERR]."
";
}
if(trim($accountname)=="") $message = ", \"$lang[MSG_USERNAME]\"";
$accountname=trim($accountname);
$accountname=strtolower($accountname);
if(ereg("([a-z0-9\_\.-]+)@([a-z0-9\_\.-]+)",$accountname,$arr))
{
$name=$arr[1];
$ddomain=$arr[2];
}
else
$message2 .= $lang[MSG_INCORECTAEMAIL]."
";
if ($message2.$message !== "")
{
$message = $message2.($message?$emptyfields["MESSAGE"] . substr($message, 2, strlen($message) - 2):'');
$skindata['message'] = showmessage($message,'','', true, $showmessage_errorcolor, true);
include_once("forgot.html");
exit;
}
$apipass = $altmail = $name2 = '';
if ($otherconfig['FULLMERAK']) {
require_once("integrateinclude.html");
$apipass = integrateuserpass($accountname);
$altmail = integrateuseraltmail($accountname);
$name2 = integrateusername($accountname);
$name = $name2?$name2:$name;
}
// get email from Merak API
$ffile = null;
$val = array();
// get email from user's folder
$path = validatefolder(usersdir .$ddomain."/".$name."/". userfile);
if (@file_exists($path)) {
$ffile = @file($path);
if(!is_array($ffile)){
$path=validatefolder(usersdir . $ddomain."/".$name."@".$ddomain."/". userfile);
$ffile = @file($path);
}
if(!is_array($ffile)){
$path=validatefolder(usersdir .$name."@".$ddomain."/". userfile);
$ffile = @file($path);
}
if(!is_array($ffile)){
$path=validatefolder(usersdir .$name."/". userfile);
$ffile = @file($path);
}
if(!is_array($ffile) && !$otherconfig['FULLMERAK']){
$skindata['message'] = showmessage($forgotpass['NOUSER'],'','', true, $showmessage_errorcolor, true);
include_once("forgot.html");
exit;
}
if(is_array($ffile)) $val = convertuser(trim($ffile[0]));
}
if ($otherconfig['FULLMERAK']) {
if(!$val['EMAIL']) $val['EMAIL'] = $accountname;
if(!$val['FULLNAME']) $val['FULLNAME'] = $name;
if($altmail) $val['ALTEMAIL'] = $altmail;
if($apipass) $val['PASS'] = $apipass;
}
/*
if($ddomain && !ereg("@".$ddomain."$",$val['EMAIL'])){
$skindata['message'] = showmessage($forgotpass['NOUSER'],'','', true, $showmessage_errorcolor, true);
include_once("forgot.html");
exit;
}
*/
if(!$val['PASS']){
$skindata['message'] = showmessage($forgotpass['NOPASS'],'','', true, $showmessage_errorcolor, true);
include_once("forgot.html");
exit;
}
include_once("smtppop3.html");
if ($smtphost)
{
$smtp = new smtp($smtphost, $smtpport, $connected);
$body= sprintf ($forgotpass['BODY'],$val['EMAIL'],$val['PASS']);
$message = "Date: ".Date("r")."\r\n";
$message .= "From: ".putheader($val['FULLNAME'].' <'.$val['EMAIL'].">")."\r\n";
$message .= "To: ".putheader($val['ALTEMAIL']?$val['ALTEMAIL']:$val['EMAIL'])."\r\n";
$message .= "Subject: " . putheader(sprintf($forgotpass['SUBJECT'],$name)) . "\r\n";
$message .= "Message-ID: <" . md5(uniqid("")) . strstr($val['EMAIL'],"@"). ">\r\n";
$message .= "X-Mailer: " . webmail . "\r\n";
$message .= "X-Originating-IP: " . $REMOTE_ADDR . "\r\n";
$message .= "\r\n";
$message.= dotconvert($body);
unset($to2);
if($val['ALTEMAIL']){
$to2[]=$val['ALTEMAIL'];
$skindata['message'] = showmessage(sprintf($forgotpass['SEND1'],htmlspecialchars($val['EMAIL']),htmlspecialchars($val['ALTEMAIL'])),'','', true, $showmessage_errorcolor, true);
}
else
$skindata['message'] = showmessage(sprintf($forgotpass['SEND2'],htmlspecialchars($val['EMAIL'])),'','', true, $showmessage_errorcolor, true);
$to2[]=$val['EMAIL'];
$smtp->smtpmail($val['EMAIL'], $to2, $message);
$smtp->status["LASTRESULTTXT"];
$smtp->close();
$smtp = null;
}
else
$skindata['message'] = showmessage($forgotpass['SMTPHOSTERR'],'','', true, $showmessage_errorcolor, true);
include_once("index.html");
?>