Captcha (Visual Confirmation) for adding comments - Page 12 Captcha (Visual Confirmation) for adding comments - Page 12
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Captcha (Visual Confirmation) for adding comments

Started by Abbas Ali, March 25, 2006, 08:39:59 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Sosha

Quote from: Abbas Ali on November 21, 2006, 06:10:46 AM
And for support on that plugin, please post your issue on that thread.
Well actually I posted here because the mod wasnt working, and Hein suggested the plugin which gave the exact same problem, of the captcha image red x'ing

Joachim Müller

Then do as suggested: if you have issues with the plugin, go to the plugin thread. If you have issues, post on the mod thread (this one). Abbas Ali reminded you not to cross-post... Do as he suggested instead of trying to justify what you did before.

Abbas Ali

The thing is that though the issue in both (mod and plugin) might be the same but the way to solve it will be different. So stick to one either mod or plugin and then post your issue on respective thread.
Chief Geek at Ranium Systems

Sosha

Well as you know I originally tried this mod and since you actually wrote it I guess if i had to choose which one to use then it would be this one. I only mentioned the fact that i get the same error with both mod and plugin because I thought that might helpyou 'diagnose'

Sorry if i was perceived to be cross-posting I was just trying to help you guys help me.

Anyway any help would be appreciated as my gallery is still getting spammed badly even with akismet and I know captcha would be perfect if only the damn thing worked :)

Abbas Ali

@Sosha: It seems that you have removed the mod. Re-apply it and then we will debug it and try to solve your issue.

As a starting point just put the captcha.php, captcha.class.php and fonts directory in its place. Do not edit theme file and db_input.php for now. We will first see whether the image is getting created or not. Once the image starts getting created then you can edit theme file.
Chief Geek at Ranium Systems

plathw

I have added this hack to my gallery, and as has been mentioned earlier, everything works great except the fonts aren't showing up, just the input box and the image with lines.  Here is the site for you to look at:

http://photos.coker.com

I have added everything as I should, the fonts directory is on the server in the root directory right where it needs to be....I'm very confused on what could be happening.  We have a working captcha on http://blog.coker.com that uses a wordpress plugin, so I assume that the server supports everything needed for the hack.

Also note I changed the language file so that incorrectly entering the captcha says "comments are disabled" instead of giving an error saying you incorrectly entered the confirmation.

Any help is greatly appreciated!

Joachim Müller


SiamJai

#227
Captcha works like a charm; success at first try - thank you so much for sharing this great mod, Abbas Ali! Spammers now have one less place to infest. :)

I guess the trickiest part of the configuration is to make changes in the theme.php file, since its settings vary from theme to theme. We at the Thaiwonders team use Fruity, and we would like to make the Captcha-config process easier for fellow Fruity-users.  GauGau has posted half of the code already in response to a specific question, but I think it will be useful to see the entire process as a whole.

Please note: this method was tested and found to work with the Fruity theme. It may or may not work with other themes. 

The following two sections of themes/sample/theme.php need to be copied to themes/fruity/theme.php

// Displays comments for a specific picture
function theme_html_comments($pid)
{
    global $CONFIG, $USER, $CURRENT_ALBUM_DATA, $comment_date_fmt, $HTML_SUBST;
    global $template_image_comments, $template_add_your_comment, $lang_display_comments;

    $html = '';

    //report to moderator buttons
    if (!(($CONFIG['report_post']==1) && (USER_CAN_SEND_ECARDS))) {
        template_extract_block($template_image_comments, 'report_comment_button');
    }

    if (!$CONFIG['enable_smilies']) {
        $tmpl_comment_edit_box = template_extract_block($template_image_comments, 'edit_box_no_smilies', '{EDIT}');
        template_extract_block($template_image_comments, 'edit_box_smilies');
        template_extract_block($template_add_your_comment, 'input_box_smilies');
    } else {
        $tmpl_comment_edit_box = template_extract_block($template_image_comments, 'edit_box_smilies', '{EDIT}');
        template_extract_block($template_image_comments, 'edit_box_no_smilies');
        template_extract_block($template_add_your_comment, 'input_box_no_smilies');
    }

    $tmpl_comments_buttons = template_extract_block($template_image_comments, 'buttons', '{BUTTONS}');
    $tmpl_comments_ipinfo = template_extract_block($template_image_comments, 'ipinfo', '{IPINFO}');

    if ($CONFIG['comments_sort_descending'] == 1) {
        $comment_sort_order = 'DESC';
    } else {
        $comment_sort_order = 'ASC';
    }
    $result = cpg_db_query("SELECT msg_id, msg_author, msg_body, UNIX_TIMESTAMP(msg_date) AS msg_date, author_id, author_md5_id, msg_raw_ip, msg_hdr_ip, pid FROM {$CONFIG['TABLE_COMMENTS']} WHERE pid='$pid' ORDER BY msg_id $comment_sort_order");

    while ($row = mysql_fetch_array($result)) {
        $user_can_edit = (GALLERY_ADMIN_MODE) || (USER_ID && USER_ID == $row['author_id'] && USER_CAN_POST_COMMENTS) || (!USER_ID && USER_CAN_POST_COMMENTS && ($USER['ID'] == $row['author_md5_id']));
        $comment_buttons = $user_can_edit ? $tmpl_comments_buttons : '';
        $comment_edit_box = $user_can_edit ? $tmpl_comment_edit_box : '';
        $comment_ipinfo = ($row['msg_raw_ip'] && GALLERY_ADMIN_MODE)?$tmpl_comments_ipinfo : '';

        if ($CONFIG['enable_smilies']) {
            $comment_body = process_smilies(make_clickable($row['msg_body']));
            $smilies = generate_smilies("f{$row['msg_id']}", 'msg_body');
        } else {
            $comment_body = make_clickable($row['msg_body']);
            $smilies = '';
        }

        $ip = $row['msg_hdr_ip'];
        if ($row['msg_hdr_ip'] != $row['msg_raw_ip']) {
            $ip .= ' [' . $row['msg_raw_ip'] . ']';
        }

        $params = array('{EDIT}' => &$comment_edit_box,
            '{BUTTONS}' => &$comment_buttons,
            '{IPINFO}' => &$comment_ipinfo
            );

        $template = template_eval($template_image_comments, $params);

        $params = array('{MSG_AUTHOR}' => stripslashes($row['msg_author']),
            '{MSG_ID}' => $row['msg_id'],
            '{PID}' => $row['pid'],
            '{EDIT_TITLE}' => &$lang_display_comments['edit_title'],
            '{CONFIRM_DELETE}' => &$lang_display_comments['confirm_delete'],
            '{MSG_DATE}' => localised_date($row['msg_date'], $comment_date_fmt),
            '{MSG_BODY}' => bb_decode($comment_body),
            '{MSG_BODY_RAW}' => $row['msg_body'],
            '{OK}' => &$lang_display_comments['OK'],
            '{SMILIES}' => $smilies,
            '{IP}' => $ip,
            '{REPORT_COMMENT_TITLE}' => &$lang_display_comments['report_comment_title'],
            '{WIDTH}' => $CONFIG['picture_table_width']
            );

        $html .= template_eval($template, $params);
    }

    if (USER_CAN_POST_COMMENTS && $CURRENT_ALBUM_DATA['comments'] == 'YES') {
        if (USER_ID) {
            $user_name_input = '<tr><td><input type="hidden" name="msg_author" value="' . stripslashes(USER_NAME) . '" /></td>';
            template_extract_block($template_add_your_comment, 'user_name_input', $user_name_input);
            $user_name = '';
        } else {
            $user_name = isset($USER['name']) ? '"' . strtr($USER['name'], $HTML_SUBST) . '"' : $lang_display_comments['your_name'] . '" onclick="javascript:this.value=\'\';';
        }

        $params = array('{ADD_YOUR_COMMENT}' => $lang_display_comments['add_your_comment'],
            // Modified Name and comment field
            '{NAME}' => $lang_display_comments['name'],
            '{COMMENT}' => $lang_display_comments['comment'],
            '{PIC_ID}' => $pid,
            '{USER_NAME}' => $user_name,
            '{MAX_COM_LENGTH}' => $CONFIG['max_com_size'],
            '{OK}' => $lang_display_comments['OK'],
            '{SMILIES}' => '',
            '{WIDTH}' => $CONFIG['picture_table_width'],
            );

        if ($CONFIG['enable_smilies']){
                        $params['{SMILIES}'] = generate_smilies();
                } else {
                        template_extract_block($template_add_your_comment, 'smilies');
                }

        $html .= template_eval($template_add_your_comment, $params);
    }

    return $html;
}


// HTML template for the form to add comments
$template_add_your_comment = <<<EOT
        <form method="post" name="post" action="db_input.php">
                <table align="center" width="{WIDTH}" cellspacing="1" cellpadding="0" class="maintable">
                        <tr>
                                        <td width="100%" class="tableh2_compact"><b>{ADD_YOUR_COMMENT}</b></td>
                        </tr>
                        <tr>
                <td colspan="1">
                        <table width="100%" cellpadding="0" cellspacing="0">

<!-- BEGIN user_name_input -->
                                                        <tr>
                                                                <td class="tableb_compact">
                                        {NAME}
                                </td>
                                <td class="tableb_compact">
                                        <input type="text" class="textinput" name="msg_author" size="10" maxlength="20" value="{USER_NAME}" />
                                </td>
<!-- END user_name_input -->
<!-- BEGIN input_box_smilies -->
                                <td class="tableb_compact">
                                {COMMENT}
                                                                </td>
                                <td width="100%" class="tableb_compact">
                                <input type="text" class="textinput" id="message" name="msg_body" onselect="storeCaret_post(this);" onclick="storeCaret_post(this);" onkeyup="storeCaret_post(this);" maxlength="{MAX_COM_LENGTH}" style="width: 100%;" />
                                                                </td>
<!-- END input_box_smilies -->
<!-- BEGIN input_box_no_smilies -->
                                <td class="tableb_compact">
                                {COMMENT}
                                                                </td>
                                <td width="100%" class="tableb_compact">
                                <input type="text" class="textinput" id="message" name="msg_body"  maxlength="{MAX_COM_LENGTH}" style="width: 100%;" />
                                </td>
<!-- END input_box_no_smilies -->
                                <td class="tableb_compact">
                                <input type="hidden" name="event" value="comment" />
                                <input type="hidden" name="pid" value="{PIC_ID}" />
                                <input type="submit" class="comment_button" name="submit" value="{OK}" />
                                </td>
                                                        </tr>
                        </table>
                </td>
        </tr>
<!-- BEGIN smilies -->
        <tr>
                <td width="100%" class="tableb_compact">
                        {SMILIES}
                </td>
        </tr>
<!-- END smilies -->
                </table>
        </form>
EOT;


NOTES:
Add these sections before the last ?> in the php file - and don't forget to modify your new themes/fruity/theme.php as described in the first post.

There might be other ways, or less info to copy, but this is a tried-and-true method for the Fruity theme. I hope this will make it a bit easier for fellow Fruity users, and takes care of a few config questions in advance. ;)

Thanks again,

SiamJai from the Thaiwonders Team
Thaiwonders Media Hub - Piano music, Photos and Videos - powered by Coppermine, of course. ;)

SiamJai

Could someone change my "quote" tags to "code" in the above post please? I'd do it myself if post editing were enabled... Sorry for the inconvenience. 
Thaiwonders Media Hub - Piano music, Photos and Videos - powered by Coppermine, of course. ;)

Abbas Ali

Chief Geek at Ranium Systems

Gephri

Installed the mod - simple enough.  But neither the text box nor captcha shows to unregistered visitors.  It must be being blocked by another mod or my own coding.  Can you point me towards where to look to get this mod working?

thanks,

PS I did have to set up the last mod with a body onload tweak because my gallery couldn't pick up the mod as-is.

jeffreybr

Hi,

i'm having a problem installing this.
i have followed all steps, only this one gives me problems:

Edit themes/yourtheme/theme.php

Add

Code:
'{CONFIRM}' => $lang_display_comments['confirm'],

just after

Code:
'{COMMENT}' => $lang_display_comments['comment'],

Add

Code:
<tr>
 <td class="tableb_compact" colspan="2">
   {CONFIRM}
 </td>
 <td class="tableb_compact" colspan="2">
   <input type="text" name="confirmCode" size="5" class="textinput"> <img src="captcha.php" align="middle">
 </td>
</tr>

just after

Code:
<!-- END input_box_no_smilies -->
                               </td>
                               <td class="tableb_compact">
                               <input type="hidden" name="event" value="comment" />
                               <input type="hidden" name="pid" value="{PIC_ID}" />
                               <input type="submit" class="comment_button" name="submit" value="{OK}" />
                               </td></tr>

##################


i have tried this but i can't find the text like the description in my file.
i'm using rainy day as theme.

Could someone help me?

Abbas Ali

@Gephri: Please give the url to your site.

@jeffrybr: You will need to copy that section from themes/sample/theme.php to your theme.php. Read this thread carefully from the begining. You will see that the instructions to copy section from sample theme have been given.
Chief Geek at Ranium Systems

jeffreybr

Hi,

i have done that, but i have a problem.
the image for the confirmation code is not shown.

http://www.watisdeplanning.nl/fotoboek/

Gephri

Hello Abbas Ali
URL to Gephri's site ishttp://www.superstarstudents.com/gallery/index.php

Thanks for taking a look at why unregistered users can't see the captcha and comment area.

Abbas Ali

@Gephri: You will need to allow unregistered users to put comments from groups manager page (in admin mode).
Chief Geek at Ranium Systems

Gephri

thanks  - sometimes we're just looking too deep !

etnies

I need some help.
I followed all instructions carefully, went over them twice,
and thought everything was working great.
Except, the confirmation shows up, but even if I don't type in the code,
it adds the comment, whether I am logged in or out..
Its like its not reading it :S
Please help!

Abbas Ali

You probably didn't modified db_input.php file.
Chief Geek at Ranium Systems

etnies