· 7 years ago · Oct 23, 2018, 12:02 AM
1$captcha_plugin = JFactory::getConfig()->get('captcha');
2if ($captcha_plugin != '0') {
3 $captcha = JCaptcha::getInstance($captcha_plugin);
4 $field_id = 'captcha';
5 print $captcha->display($field_id, $field_id, 'g-recaptcha');
6}
7
8public function _logInUser( $form ){
9 $captcha_plugin = JFactory::getConfig()->get('captcha');
10 $captcha = JCaptcha::getInstance($captcha_plugin);
11 $completed = $captcha->CheckAnswer($form[2]['value']);
12 var_dump($form);
13 echo $form[2]['value'];
14 var_dump($completed);
15 die();
16
17JPluginHelper::importPlugin('captcha');
18$dispatcher = JEventDispatcher::getInstance();
19$res = $dispatcher->trigger('onCheckAnswer',$form[2]['value']);
20if(!$res[0]){
21 var_dump($res);
22 die('Invalid Captcha');
23}
24var_dump($res);
25die();
26
27$secretKey = "my_secret_key";
28$ip = $_SERVER['REMOTE_ADDR'];
29$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$form[2]['value']."&remoteip=".$ip);
30var_dump($response);