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:
$recaptcha_publickey= "your_public_key_here";
$recaptcha_privatekey="your_private_key_here";
(don't forget to put your keys in the variables above)after:
include_once('lib/Template.class.php');
2.
Add the captcha input box to the registration form
Edit auth.template.php and insert:
$publickey = $GLOBALS['recaptcha_publickey'];
echo recaptcha_get_html($publickey);
echo "<BR>";
after:
$cancelUrl = !empty($memberid) ? "admin.php?tool=users" : "index.php";
3.
Prepare to accept the captcha input
Edit auth.class.php and insert:
require_once($basedir . '/lib/recaptchalib.php');
after:
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:
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:
if ($use_logonname && $this->db->userExists($data['logon_name'], true)) {
$msg .= translate('That logon name is taken already.') . '<br/>';
}
Improvements and suggestions are welcomed.