--- drupal-4.6.2/modules/comment.module 2005-06-29 12:53:35.000000000 -0700
+++ testdrup/modules/comment.module 2005-07-18 15:01:11.000000000 -0700
@@ -315,6 +315,8 @@ function comment_configure() {
$output = form_group(t('Comment viewing options'), $group);
$group = form_radios(t('Anonymous poster settings'), 'comment_anonymous', variable_get('comment_anonymous', 0), array(t('Anonymous posters may not enter their contact information'), t('Anonymous posters may leave their contact information'), t('Anonymous posters must leave their contact information')), t('This feature is only useful if you allow anonymous users to post comments. See the permissions page.', array('%url' => url('admin/access/permissions'))));
+ $group .= form_textfield(t('Anonymous commenter challenge question'), 'comment_question', variable_get( 'comment_question', ''), 70, 99, t('Invent a simple, unambiguous, easy to answer question that will be asked of anonymous commenters, as a means to foil spam-bots. You must enable anonymous comments.'));
+ $group .= form_textfield(t('Anonymous commenter answer'), 'comment_answer', variable_get( 'comment_answer', ''), 20, 20, t('Provide a short string which must appear within the answer to the question asked anonymous commenters. Leave blank to disable the anonymous commenter challenge question.'));
$group .= form_radios(t('Comment subject field'), 'comment_subject_field', variable_get('comment_subject_field', 1), array(t('Disabled'), t('Enabled')), t('Can users provide a unique subject for their comments?'));
$group .= form_radios(t('Preview comment'), 'comment_preview', variable_get('comment_preview', 1), array(t('Optional'), t('Required')));
$group .= form_radios(t('Location of comment submission form'), 'comment_form_location', variable_get('comment_form_location', 0), array(t('Display on separate page'), t('Display below post or comments')));
@@ -479,6 +481,10 @@ function comment_validate_form($edit) {
form_set_error('homepage', t('The URL of your homepage is not valid. Remember that it must be fully qualified, i.e. of the form http://example.com/directory.'));
}
}
+ $questAnswer = variable_get( 'comment_answer', NULL );
+ if( $questAnswer && stristr( $edit['comm_question'], $questAnswer ) == FALSE) {
+ form_set_error( 'comm_question', t("You didn't properly fill in the answer to the question to show you aren't a spamming robot.") );
+ }
}
}
@@ -1385,17 +1391,24 @@ function theme_comment_form($edit, $titl
$form .= "\n";
+ $comQuest = variable_get( 'comment_question', NULL );
// contact information:
if ($user->uid) {
$form .= form_item(t('Your name'), format_name($user));
}
else if (variable_get('comment_anonymous', 0) == 1) {
$form .= form_textfield(t('Your name'), 'name', $edit['name'] ? $edit['name'] : variable_get('anonymous', 'Anonymous') , 20, 60);
+ if( $comQuest ) {
+ $form .= form_textfield(t('Robot-blocking question'), 'comm_question', $edit['comm_question'], 20, 20, $comQuest );
+ }
$form .= form_textfield(t('E-mail'), 'mail', $edit['mail'], 20, 64, t('The content of this field is kept private and will not be shown publicly.'));
$form .= form_textfield(t('Homepage'), 'homepage', $edit['homepage'], 20, 255);
}
else if (variable_get('comment_anonymous', 0) == 2) {
$form .= form_textfield(t('Your name'), 'name', $edit['name'] ? $edit['name'] : variable_get('anonymous', 'Anonymous') , 20, 60, NULL, NULL, TRUE);
+ if( $comQuest ) {
+ $form .= form_textfield(t('Robot-blocking question'), 'comm_question', $edit['comm_question'], 20, 20, $comQuest );
+ }
$form .= form_textfield(t('E-mail'), 'mail', $edit['mail'], 20, 64, t('The content of this field is kept private and will not be shown publicly.'), NULL, TRUE);
$form .= form_textfield(t('Homepage'), 'homepage', $edit['homepage'], 20, 255);
}