|
28 | 28 | $Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/forgotpassword','Invalid e-mail address!'); |
29 | 29 | } |
30 | 30 |
|
| 31 | + $recaptchaData = erLhcoreClassModelChatConfig::fetch('recaptcha_data')->data_value; |
| 32 | + |
| 33 | + if (is_array($recaptchaData) && isset($recaptchaData['enabled']) && $recaptchaData['enabled'] == 1) { |
| 34 | + $params = [ |
| 35 | + 'secret' => $recaptchaData['secret_key'], |
| 36 | + 'response' => $_POST['g-recaptcha'] |
| 37 | + ]; |
| 38 | + |
| 39 | + $ch = curl_init(); |
| 40 | + curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/recaptcha/api/siteverify'); |
| 41 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 42 | + curl_setopt($ch, CURLOPT_TIMEOUT, 5); |
| 43 | + curl_setopt($ch,CURLOPT_POST,1); |
| 44 | + curl_setopt($ch,CURLOPT_POSTFIELDS,$params); |
| 45 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT , 5); |
| 46 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
| 47 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
| 48 | + @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Some hostings produces warning... |
| 49 | + $res = curl_exec($ch); |
| 50 | + |
| 51 | + $res = json_decode($res,true); |
| 52 | + |
| 53 | + if (!(isset($res['success']) && $res['success'] == 1 && isset($res['score']) && $res['score'] >= 0.1 && $res['action'] == 'login_action')) { |
| 54 | + $Errors[] = 'Invalid recaptcha!'; |
| 55 | + } |
| 56 | + } |
| 57 | + |
31 | 58 | if (count($Errors) == 0) { |
32 | 59 |
|
33 | 60 | if (($userID = erLhcoreClassModelUser::fetchUserByEmail($form->Email)) !== false) { |
|
0 commit comments