• Welcome to PHPVIBE Forums. Please log in.

[ Video Sharing CMS v4 ] captcha... for login page.

Started by hunt07777,

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

hunt07777Topic starter

Will we have a captcha for the login page? v 3.3 /login ?
  •  

Marius P.

It should be an easy patch, as it's already done in com/com_register.php
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

hunt07777Topic starter

  •  

sanishan

Quote from: hunt07777 on
not sure what you mean by easy patch. ??

Mario don't give you the 100% working code, he give you the idea how to use captcha for login..

Here is how you could add captcha to login page.

open /com/com_login.php

Find
$error='';


Add After
require_once(INC.'/recaptchalib.php');
$publickey = "6Lc-A84SAAAAAD3btrvWyQUi7MI6EX1fH_RE6p0U"; 
$privatekey = "private captcha key.. find in com_register.php file";
function add_rec($text) {
$text = $text.'<script type="text/javascript">
 var RecaptchaOptions = {     theme : \'clean\'  };
 </script>';
return $text;
}
add_filter( 'filter_extracss', 'add_rec' );
 $captcha =  recaptcha_get_html($publickey);


Find:
global $error;


Replace wiht:
global $error , $captcha;


Find:
<input type="password" name="password" class="validate[required] span12" placeholder="'._lang("Your Password").'">


Add After:
<div class="row-fluid top10 bottom10">      '.$captcha.'</div>

Thanks,
Free PHPVibe Professional Customized Plugin http://phpvibemod.com/
  •  

hunt07777Topic starter

Awesome...
It almost worked...
The captcha shows up...
But it does not require me to validate it.
It will just log me in without having to use it. ???

http://screencast.com/t/YfpRlh0KM
  •  

Marius P.


Well, you can see he forgot to validate it.

/** Actual login **/
if(_post('password') && _post('email')){
if(user::loginbymail(_post('email'),_post('password') )) {
redirect(site_url().me.'/');
} else {
$error = '<div class="msg-warning">'._lang('Wrong username or password.').'<>';
}
}





Should become


  if(_post('password') && _post('email')){
$resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);


  if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
   $error = '<div class="msg-warning">The reCAPTCHA wasn\'t entered correctly. Go back and try it again
         reCAPTCHA error: ' . $resp->error.'<>';
  } else {


if(user::loginbymail(_post('email'),_post('password') )) {
redirect(site_url().me.'/');
} else {
$error = '<div class="msg-warning">'._lang('Wrong username or password.').'<>';
}
}
  
  }
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

sanishan

Quote from: @Mario on
Well, you can see he forgot to validate it.

/** Actual login **/
if(_post('password') && _post('email')){
if(user::loginbymail(_post('email'),_post('password') )) {
redirect(site_url().me.'/');
} else {
$error = '<div class="msg-warning">'._lang('Wrong username or password.').'<>';
}
}





Should become


  if(_post('password') && _post('email')){
$resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);


  if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
   $error = '<div class="msg-warning">The reCAPTCHA wasn\'t entered correctly. Go back and try it again
         reCAPTCHA error: ' . $resp->error.'<>';
  } else {


if(user::loginbymail(_post('email'),_post('password') )) {
redirect(site_url().me.'/');
} else {
$error = '<div class="msg-warning">'._lang('Wrong username or password.').'<>';
}
}
  
  }


Lolz.

I already added the code in my example page, but forgot to add the validate code in this post..

Free PHPVibe Professional Customized Plugin http://phpvibemod.com/
  •  

hunt07777Topic starter

  •  

Similar topics (7)