| 1 |
<?php |
<?php |
| 2 |
// $Id: captcha.module,v 1.16 2006/01/10 21:50:36 arnabdotorg Exp $ |
// $Id: captcha.module,v 1.17 2006/01/11 17:41:40 arnabdotorg Exp $ |
| 3 |
|
|
| 4 |
function captcha_help($section = "admin/help#captcha") { |
function captcha_help($section = "admin/help#captcha") { |
| 5 |
$output = ""; |
$output = ""; |
| 54 |
|
|
| 55 |
//check for TTF support |
//check for TTF support |
| 56 |
if (!function_exists(imagettftext)) |
if (!function_exists(imagettftext)) |
| 57 |
form_set_error('No TTF support', t('Your image library does not seem to have TrueType font support. Captcha will work, but will use the default inbuilt font.')); |
|
| 58 |
|
drupal_set_message(t('Your image library does not seem to have TrueType font support. Captcha will work, but will use the default inbuilt font.'),'status'); |
| 59 |
|
|
| 60 |
else { |
else { |
| 61 |
|
|
| 153 |
* Comment callback; adds captcha field to new comment form. |
* Comment callback; adds captcha field to new comment form. |
| 154 |
*/ |
*/ |
| 155 |
function captcha_comment($edit, $op) { |
function captcha_comment($edit, $op) { |
|
global $user; |
|
| 156 |
|
|
|
// check if captcha is enabled for form type |
|
|
//if ($user->uid == 0 && !_captcha_istrue("captcha_comment_anonymous")) return; |
|
|
//if ($user->uid != 0 && !_captcha_istrue("captcha_comment_registered")) return; |
|
| 157 |
switch ($op) { |
switch ($op) { |
| 158 |
case 'validate': //this is redundant, not followed |
case 'validate': //this is redundant, not followed |
| 159 |
// only validate captcha once for a comment. |
// only validate captcha once for a comment. |
| 198 |
|
|
| 199 |
|
|
| 200 |
function captcha_form_alter($formid, &$form) { |
function captcha_form_alter($formid, &$form) { |
| 201 |
|
|
| 202 |
|
global $user; |
| 203 |
|
|
| 204 |
switch($formid) { |
switch($formid) { |
| 205 |
case 'comment_form': |
case 'comment_form': |
| 206 |
|
|
| 207 |
|
// check if captcha is enabled for form type |
| 208 |
|
if ($user->uid == 0 && !_captcha_istrue("captcha_comment_anonymous")) return; |
| 209 |
|
if ($user->uid != 0 && !_captcha_istrue("captcha_comment_registered")) return; |
| 210 |
|
|
| 211 |
// include logic to remove captcha if the current entry is a valid captcha |
// include logic to remove captcha if the current entry is a valid captcha |
| 212 |
if (!$_SESSION['captcha_comment_correct'] && !($_POST['edit']['captcha_word'] != '' && _captcha_validate($_POST['edit']['captcha_word']))) { |
if (!$_SESSION['captcha_comment_correct'] && !($_POST['edit']['captcha_word'] != '' && _captcha_validate($_POST['edit']['captcha_word']))) { |
| 213 |
$form['captcha'] = _captcha_form(); |
$form['captcha'] = _captcha_form(); |