Index: trunk/kernel/frontaction.php =================================================================== diff -u -r6093 -r7391 --- trunk/kernel/frontaction.php (.../frontaction.php) (revision 6093) +++ trunk/kernel/frontaction.php (.../frontaction.php) (revision 7391) @@ -852,27 +852,56 @@ } else { - $Event =& $objMessageList->GetEmailEventObject("USER.SUGGEST"); - if(is_object($Event)) - { - if($Event->Get("Enabled")=="1") - { - $Event->Item = null; - $Event->SendToAddress($email); + $application =& kApplication::Instance(); + $got_string = $application->GetVar('captcha_string'); + if ($objConfig->Get("Suggest_Captcha") && !$application->GetVar('check_captcha')) { + $captcha_helper = $application->recallObject('CaptchaHelper'); + $captcha_code = $captcha_helper->GenerateCaptchaCode(); + $objSession->SetVariable('suggest_captcha_code', $captcha_code); + $application->StoreVar('suggest_email', $email); - $sql = "INSERT INTO ".GetTablePrefix()."SuggestMail (email,sent) VALUES ('".$email."','".adodb_mktime()."')"; - - $rs = $adodbConnection->Execute($sql); - $objSession->SetVariable('suggest_result', language("lu_suggest_success")." ".$email); - } + if ($var_list["DestTemplate"] != $_GET["Captcha"]) { + $var_list["DestTemplate"] = $var_list["t"]; + } + $var_list["t"] = $_GET["Captcha"]; } - $e =& $objMessageList->GetEmailEventObject("USER.SUGGEST",1); + else { + // if no captcha or captcha Ok + if (!$objConfig->Get("Suggest_Captcha") || $got_string == $application->RecallVar('suggest_captcha_code')) { + $Event =& $objMessageList->GetEmailEventObject("USER.SUGGEST"); + if(is_object($Event)) + { + if($Event->Get("Enabled")=="1") + { + $Event->Item = null; + $Event->SendToAddress($email); - if($e->Get("Enabled")==1) - $e->SendAdmin(); + $sql = "INSERT INTO ".GetTablePrefix()."SuggestMail (email,sent) VALUES ('".$email."','".adodb_mktime()."')"; - if(strlen($_GET["Confirm"])>0) - $var_list["t"] = $_GET["Confirm"]; + $rs = $adodbConnection->Execute($sql); + $objSession->SetVariable('suggest_result', language("lu_suggest_success")." ".$email); + } + } + $e =& $objMessageList->GetEmailEventObject("USER.SUGGEST",1); + + if($e->Get("Enabled")==1) + $e->SendAdmin(); + + if(strlen($_GET["Confirm"])>0) + $var_list["t"] = $_GET["Confirm"]; + + $application->RemoveVar('suggest_captcha_code'); + $application->RemoveVar('suggest_email'); + } + elseif ($got_string != $application->RecallVar('suggest_captcha_code')) { + // generate new captcha code in case of error + $captcha_helper = $application->recallObject('CaptchaHelper'); + $captcha_code = $captcha_helper->GenerateCaptchaCode(); + $objSession->SetVariable('suggest_captcha_code', $captcha_code); + + $objSession->SetVariable('suggest_result', language("lu_invalid_captcha")); + } + } } } else