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

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 3 Guests are viewing this topic.

Hein Traag

jenkinl1302 i tried it but it did not work. Thanks for the input though :)

ceesjoore

Quote from: jenkinl1302 on October 25, 2006, 02:07:47 PM
I originally had the same problems as some on this board with the captcha image not showing up.  Something with GD.  Actually, it prevented me from using any gallery software until I figured it out.  GD wasn't available until I asked for it (in code).  On captcha.php, try adding dl("gd.so"); immediately before define("IN_COPPERMINE", true);

I'm not sure if there's a better way to do this, or if it will work for everyone, but it seemed to make things work for me.

jenkinl1302 i tried it but it did not work for me thanks anyway !

Abbas Ali

Hein & ceesjoore: If both of you are happy to PM me your ftp details then i will look into it.
Chief Geek at Ranium Systems

niks_007

Hi...
        Mr. Abbas I did what is written here followed all the instructions. but can not see any changes to my gallery the url is http://www.lakesparadise.com/wallpapers/index.php here hundreds of people post comments daily and since last few days i am reciving so many spams so i tried it here i am attaching all the files needed to be modified take a look and let me know what is the problem.

             i have added few more words to ban list but it replaced those words with (...) when a comment is posted how can i change it to some smile simbol like :lol: so instead of ban word a smile can be viewed.


waiting for reply.
Nishant

Abbas Ali

@ceesjoore: Your server doesn't have one of the functions ( imageftbbox() )required by this mod. You need to ask your webhost for this. That function is generally present if freetype is enabled.

@Hein: Today when i tried to browser your site, it is giving 403 forbidden error. Please ask your webhost to sort this out so that i can look at captcha issue. ( http://fototest.scouting.nl/ is giving 403)
Chief Geek at Ranium Systems

niks_007

Dear Mr. Abbas Ali,
                 I am very much fed up with spam and want to sort out the issue as soon as posible i know you are very busy but please take a look at my problem.

Quote from: niks_007 on October 29, 2006, 07:29:27 PM
Hi...
        Mr. Abbas I did what is written here followed all the instructions. but can not see any changes to my gallery the url is http://www.lakesparadise.com/wallpapers/index.php here hundreds of people post comments daily and since last few days i am reciving so many spams so i tried it here i am attaching all the files needed to be modified take a look and let me know what is the problem.

             i have added few more words to ban list but it replaced those words with (...) when a comment is posted how can i change it to some smile simbol like :lol: so instead of ban word a smile can be viewed.


waiting for reply.
Nishant

Hein Traag

#186
Quote from: niks_007 on October 30, 2006, 02:27:06 PM
Dear Mr. Abbas Ali,
                 I am very much fed up with spam and want to sort out the issue as soon as posible i know you are very busy but please take a look at my problem.


Patience is the keyword here. Do not expect that the people who develop Coppermine are online 24/7 on the look out for any new question. They do not get paid for helping those who need it. Be aware of that fact before you loose patience and start spamming the forum.

Your first question is concerining the implementation of the Captcha mod to your gallery. Enable debugging, it's in the config panel, and also provide a description of any error messages you get etc.. Or if you are in a hurry try one of the other anti-spam methods, use the search of the forum.

Your second question is about the swear list of Coppermine. I suggest you make a new ticket for that question. This is not the correct place to place that question.

Cheers
Hein

Joachim Müller

@Hein: thanks for taking the time to explain to niks_007 how a support board works. Sadly, this has been done many times before, niks_007 has been told to behave many times. He/she doesn't (as his negative karma record clearly shows).

@niks_007: this is the ultimatively last warning, next step even for the slightest misbehaviour will be a permanent ban.

Abbas Ali

@Hein: The captcha image is coming fine now. There was a parse error in captcha.php which i rectified (http://fototest.scouting.nl/captcha.php ). Modify the theme file now to apply the mod.

@niks_007: Try removing the below mentioned code from captcha.php file


require("include/init.inc.php");
Chief Geek at Ranium Systems

Hein Traag

#189
Thanks Abbas for looking into this. I'll see what needs modifying in the theme.php file for displaying the Captcha image. Again, thanks for your time!

Kind regards,
Hein

Update 11:03
When i visit the captcha.php directly i get a red cross with IE and the line "http://fototest.scouting.nl/captcha.php" with Firefox. Is it a browser setting ?

Sami

Do you have any internet security software like Norton internet security
if you have disable it and try again
‍I don't answer to PM with support question
Please post your issue to related board

Hein Traag

Quote from: Sami on October 31, 2006, 11:09:26 AM
Do you have any internet security software like Norton internet security
if you have disable it and try again

No i do not have that on my pc as it tends to slow everything down ;)
But if that would be a possible cause then wouldn't that mean all who use such a program have no picture showing up ?

jakejammin

Could help me out with this mod which I installed for a client?

I installed this mod on a client's gallery which is hosted with us and it did not show the visual confirmation box.
So I read the thread here and seen it needed GD Support to run.  I went into the server and recompiled PHP with GD Support. Checked the gallery and the visiual confirmation still does not show and in IE is the old red X broken symbol.
Then I rechecked and the PHP info is now showing the GD Support.

The gallery is at:
http://www.billyelliotthemusical.me.uk/gallery/displayimage.php?album=67&pos=1

As per the install description, I put the captcha.php and fonts folder in the root of the gallery, and then the captcha.class.php in includes folder of the gallery.

I had to mod the themes/eyeball/theme.php to get the code in of course. 

Is there anything I can check?  I do have full administration access to the server which this gallery is hosted on.


Nibbler

Enable display of errors in php - then you will be able to see what the error is at http://www.billyelliotthemusical.me.uk/gallery/captcha.php. You probably missed something when adding GD support like freetype.

niks_007

hi Hein...
        I have enabled the debugging mode for admin only but i am not getting any error at all and comments can be posted but no visual confirmation is required i have followed all the instructions which are needed to be followed. but if i edit the same comment it shows a text {CONFIRM} in the left side and a cross in the right (No Image) and when you press ok button to edit it it says "Confirmation code didn't matched" but only when we edit the comment else it does not show any thing. in the previous message i have attached all three files needed to be edited so one can get the idea what and where is the problem.

Quote from: niks_007 on October 29, 2006, 07:29:27 PM
Hi...
        Mr. Abbas I did what is written here followed all the instructions. but can not see any changes to my gallery the url is http://www.lakesparadise.com/wallpapers/index.php here hundreds of people post comments daily and since last few days i am reciving so many spams so i tried it here i am attaching all the files needed to be modified take a look and let me know what is the problem.

waiting for reply.
Nishant

if any one can help me please do so.

Thanks
Nishant

jakejammin

Quote from: Nibbler on October 31, 2006, 04:50:52 PM
Enable display of errors in php - then you will be able to see what the error is at http://www.billyelliotthemusical.me.uk/gallery/captcha.php. You probably missed something when adding GD support like freetype.

Yep you're correct...... Fixed now.... Thanks for the help!

jakejammin

Quote from: niks_007 on October 31, 2006, 05:55:04 PMif any one can help me please do so.
Thanks
Nishant

It looks like you did not edit the themes/yours/theme.php correctly.


jakejammin

I think there is some confusion in adding this mod for the average user which does not know PHP or how it is coded.

So I'm going to post a clear how to:

I will do this in steps for everyone.

1) Check to make sure your host has GD Support with FreeType Support.  If not then this will not work for you.  You can check this by making a php page with phpinfo(); in it and uploading it to your site. Under gd you will see the above if it is installed on their server.

2) Now upload captcha.php and fonts directory in your coppermine root directory and then upload captcha.class.php in include directory.

3) Open lang/english.php
Find:
'non_exist_comment' => 'The selected comment does not exist', //cpg1.4

Just under that add:
'captcha_error' => 'The confirmation code didn\'t matched',

Find:
'report_comment_title' => 'Report this comment to the administrator', //cpg1.4

Just under that add:
'confirm' => 'Confirmation',

Save and close.

4) This is where is gets some what confusing.
We now want to open themes/yourtheme/theme.php (for an example we will do eyeball).

Now we want to also open themes/sample/theme.php

In themes/sample/theme.php Find & Copy:

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'],
'{CONFIRM}' => $lang_display_comments['confirm'],
            '{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;
}


Now we want to paste that copy in your theme (again in this case the eyeball theme) just above the PHP close ?>.

Now that is done go back to themes/sample/theme.php then
Find & Copy:

$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;


Now we want to paste that copy in your theme (again in this case the eyeball theme) just above the PHP close ?> again.

5) Now we want to search your theme file (again in this caes eyeball) for:
<!-- 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>


Just after that add:

<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>


Save and close.

6) Open db_input.php
Find:

case 'comment':
        if (!(USER_CAN_POST_COMMENTS)) cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);


Just after that add:

require("include/captcha.class.php");
        if (!PhpCaptcha::Validate($_POST['confirmCode'])) {
          cpg_die(ERROR, "Confirmation code didn't matched", __FILE__, __LINE__);
        }


Save and Close.

Thats it..... You're done.....


I hope this helps out some people having problems.  I also hope this is not looked at as a double post to Abbas Ali first post, I just thought it would help some with how to add it to their theme as his post was not clear on that part.


Thanks for the great mod and the time it took!


Jake

darktea

This looks like a great mod especially as my site was hit for the first time by spammers today. 

I followed the initial instructions and seem to have got most of the way there as I have the confirmation box, but I do not see the image.  I have looked through the previous comments and there is a suggest this maybe because I don't have freetype support; I checked this and it is enabled http://www.darktea.co.uk/phpinfo.php

I have followed the instructions posted by jakejammin as a check and picked up one error (I had duplicated some code so had two confirmation boxes previously), but I guess there is still something which my non php code eyes don't see

Any suggestions you could make would be wonderful and I have enabled the debug info just in case it is helpful.  www.darktea.co.uk

Thank you