phpScheduleIt
May 26, 2013, 03:17:19 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: phpScheduleIt 2.4.2 has been released!
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Adding re-captcha to Registration form  (Read 2895 times)
pbechard
Newbie
*

Karma: 0
Posts: 1


« on: August 25, 2011, 08:18:38 PM »

This applies to phpScheduleIt v.1.2.x

Our site was getting spammed with bogus registrations, so I integrated the re-Captcha product into the registration process.  Learn more about it here:  http://www.captcha.net/

First off, kudos to franky4fingers for his post about a different captcha.  That got me off to a great start for where to integrate this code.

  • Register at www.captcha.net to get your private and public keys
  • Download the zip file, and extract recaptchalib.php.  Copy to /lib/ of the phpScheduleIt program

1.
Set the captcha variables for use in the site.
Edit register.php and insert:
Code:
$recaptcha_publickey= "your_public_key_here";
$recaptcha_privatekey="your_private_key_here";
(don't forget to put your keys in the variables above)

after:
Code:
include_once('lib/Template.class.php');


2.
Add the captcha input box to the registration form
Edit auth.template.php and insert:
Code:
$publickey = $GLOBALS['recaptcha_publickey'];
echo recaptcha_get_html($publickey);
echo "<BR>";

after:
Code:
$cancelUrl = !empty($memberid) ? "admin.php?tool=users" : "index.php";

3.
Prepare to accept the captcha input
Edit auth.class.php and insert:
Code:
require_once($basedir . '/lib/recaptchalib.php'); 

after:
Code:
include_once($basedir . '/templates/auth.template.php');


4.
Evaluate the captcha input and reject with a message if incorrect
Edit auth.class.php and insert:
Code:
if (!$is_edit) {
$privatekey=$GLOBALS['recaptcha_privatekey'];
if ($_POST["recaptcha_response_field"]) {
$resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$msg.="The reCAPTCHA wasn't entered correctly. Go back and try it again. (Error: ".$resp->error.")";
}
}
}

after:
Code:
if ($use_logonname && $this->db->userExists($data['logon_name'], true)) {
$msg .= translate('That logon name is taken already.') . '<br/>';
}




Improvements and suggestions are welcomed.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2006-2007, Simple Machines Valid XHTML 1.0! Valid CSS!