Commit 56c4f473 authored by Arnab Nandi's avatar Arnab Nandi
Browse files

Fixed anon user check

parent f1b573c6
Captcha Readme
Just to keep track of usage, it would be really cool if you can
send an email to [drupal AT arnab DOT org] telling me you're using it.
##Captcha Readme##
To Install:
Enable the module, and then go to admin/settings/captcha to enable captchas for various actions.
......@@ -113,14 +113,16 @@ function captcha_user($type, &$edit, &$newuser, $category = NULL) {
function captcha_comment($op,$edit) {
global $user;
// check if captcha is enabled for form type
if (!isset($user->uid) && !_captcha_istrue("captcha_comment_anonymous")) return;
if (isset($user->uid) && !_captcha_istrue("captcha_comment_registered")) return;
if ($user->uid == 0 && !_captcha_istrue("captcha_comment_anonymous")) return;
if ($user->uid != 0 && !_captcha_istrue("captcha_comment_registered")) return;
switch ($op) {
case 'validate':
// only validate captcha once for a comment
// only validate captcha once for a comment.
// this implementation basically sets a flag when you've successfully validated a captcha;
// any successive comment inserted uses and invalidates the set flag.
if (sess_read('captcha_comment_correct')!='ok') {
if (strtolower($edit['captchaword']) != '' && strtolower($edit['captchaword']) == strtolower(sess_read('captcha'))) {
......@@ -197,7 +199,10 @@ function _captcha_font_list() {
* Prints an image containing a captcha code.
function _captcha_image() {
//if we don't have GD functions, we can't generate the image
if (!function_exists('imagecreatetruecolor')) return;
// Set headers
header('Expires: Mon, 01 Jan 1997 05:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment