Gossamer Forum
Home : Products : Links 2.0 : Customization :

comments verification?

Quote Reply
comments verification?
i've had Links 2 running for years trouble free (an extremely small site, mainly personal use and used really just for affiliated links for myself), however, i'm now being troubled by comment spammers on a daily basis (i've got less than 10 genuine comments and now getting about 40 extra a day.
It's easy enough to ban the IPs but is there an easy enough way to add some sort of verification to the Comments 4lite mod i've currently got installed
(my perl knowledge is rusty and knowing my way around Links 2 even worse - as it's been perfectly stable and fine i've not tinkered with it for ages).
Thanks in advance
Quote Reply
Re: [bs7] comments verification? In reply to
Hello bs7,

Chat Andy up as he has a captcha developed and can custom develop something to fit your needs. His site is Ultranerds or you can find a bazzillion comments on this forum from him.


Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Quote Reply
Re: [SandraR] comments verification? In reply to
Hi Sandra,

This is on Links 2 :) (I don't tend to really do much work on Links2, as its a bugger to work with ;))

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: Oct 10, 2008, 7:54 AM
Quote Reply
Re: [bs7] comments verification? In reply to
thanks for the replies.

any idea with regards to even a crude 'please enter the code displayed to your right' type verification (even if the code is only changed manual) - where would i look to add that to the script?

any ideas at all would be very gratefully received OR any ideas that would allow me to waste their time and resources would be just as good

tia
Quote Reply
Re: [bs7] comments verification? In reply to
The captcha code would be easy to modify to work with comments.

Here it is for add.cgi:
http://www.gossamer-threads.com/...ring=captcha;#288271

And for rate.cgi:
http://www.gossamer-threads.com/...ring=captcha;#301076


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] comments verification? In reply to
hi again

it took me a while to get captcha working

the only problem now is i keep messing up the comments.cgi script - every possible option i try ends up with it displaying a blank page.

where should i be adding the captcha code into 'sub main'
and where should i add 'sub captcha'

any advise would be great

thanks again
Quote Reply
Re: [bs7] comments verification? In reply to
(it's the "Comments 4lite mod" i'm trying to modify)
Quote Reply
Re: [bs7] comments verification? In reply to
Okay, here is my guess at what it needs. NOT TESTED! The error page may not work, either. Let me know how it goes...

Still need to do steps 1 & 5 from the post about adding to add.cgi. Then, in comments4l.cgi:

A. Change sub_main:
Code:
sub main {
#-------------------------------------------------------------------
local (%in) = &parse_form;
if ($in{'function'} eq 'post_comment'){
#&post_comment;
$in{'captcha'} ? &captcha : &site_error("You are attempting to bypass our security.") and return;
}
elsif ($in{'function'} eq 'display'){
&display;
}
else {
&site_error;
}
}

B. Add new sub after it:
Code:
sub captcha {
#------------------------------------------
require "admin/captcha/captcha.pl";
$code = ($in{'code'});
$crypt = ($in{'crypt'});
if ($code && $crypt){
# check code
$result = &checkCode($code,$crypt);
if ($result == 1){
&post comment;
}
elsif ($result == -1){
&site_error("<b>Failed!</b> Reason: code expired. Possible cause: code was issued too long ago. Try the new code below.") and return;
}
elsif ($result == -2){
&site_error("<b>Failed!</b> Reason: invalid code (not in database). Possible causes: code already used or expired. Try the new code below.") and return;
}
elsif ($result == -3){
&site_error("<b>Failed!</b> Reason: invalid code (code does not match crypt). Possible cause: characters not entered correctly. Try the new code below.") and return;
# note - once a solution is tried it is expired, even if it failed
}
else {
&site_error("You did not enter the security code.") and return;
}
}
}
# end sub

C. In sub_display, add this:
Code:
<td><textarea wrap="virtual" name="Comment" value="" rows="6" cols="15" ></textarea></td>
</tr> <tr><td>|;
$comments = &create_captcha_form; #in db_utils.pl
$comments = qq| </td></tr>
<tr>
<td><font face="Verdana"><font size=-1>Click once:</font></font></td>


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] comments verification? In reply to
thanks a million for your help

this bit is giving me a little trouble because it seems i've previously edited sub_display on my own

PerlFlunkie wrote:

C. In sub_display, add this:
Code:
<td><textarea wrap="virtual" name="Comment" value="" rows="6" cols="15" ></textarea></td>
</tr> <tr><td>|;
$comments = &create_captcha_form; #in db_utils.pl
$comments = qq| </td></tr>
<tr>
<td><font face="Verdana"><font size=-1>Click once:</font></font></td>

as you'll see from my code (below) the tricky bit for me is working out how to use the "|" bit in with my code (you're a perl genius so you'll know what i mean):
Code:
<script language="JavaScript">
<!--
function open_new_window()
{
new_window = open("","displayWindow","width=280,height=360,left=30,top=30");

// open new document
new_window.document.open();

new_window.document.write("<html><head><title>Leave Comment</title></head><body>");
new_window.document.write("<table BORDER=1 CELLPADDING=2 COLS=1 WIDTH='260' bordercolor='#C0C0C0' cellspacing='0'><tr>");
new_window.document.write("<td BGCOLOR='#C0C0C0'><b><font size=-1 face='Verdana'>Add your comment:</font></b></td></tr>");
new_window.document.write("<tr><td BGCOLOR='#FFFFFF'><font size=-1 face='Verdana'>");
new_window.document.write("Fill out the form below to add your rating and/or comment.&nbsp; Please note that all Ip's are logged and any abusers will be banned from posting.");
new_window.document.write("</font><form action='comments.cgi' method='POST'>");
new_window.document.write("<input type='HIDDEN' NAME='LID' VALUE='$rec{'ID'}'><input type='HIDDEN' NAME='Title' VALUE='$rec{'Title'}'>");
new_window.document.write("<input type='HIDDEN' NAME='function' VALUE='post_comment'>");
new_window.document.write("<table BORDER=0 CELLSPACING=0 CELLPADDING=0 COLS=2 WIDTH='100%'>");
new_window.document.write("<tr><td WIDTH='100'><font size=-1 face='Verdana'>Your name:</font></td>");
new_window.document.write("<td><input name='Contact Name' size='18' ></td></tr><tr>");
new_window.document.write("<td><font size=-1 face='Verdana'>Your email:</font></td>");
new_window.document.write("<td><input name='Email' size='18' ></td></tr><tr>");
new_window.document.write("<td><font size=-1 face='Verdana'>Your verdict:</font></td><td>");
new_window.document.write("<INPUT type='radio' name=Rating value = 2><IMG SRC='$db_images/up.gif' ALT='Great site'>");
new_window.document.write("<INPUT type='radio' name=Rating value = 1><IMG SRC='$db_images/okay.gif' ALT='Okay site'>");
new_window.document.write("<INPUT type='radio' name=Rating value = 0><IMG SRC='$db_images/down.gif' ALT='Terrible site'>");
new_window.document.write("</td></tr><tr><td><font size=-1 face='Verdana'>Your comment:</font></td>");
new_window.document.write("<td><textarea wrap='virtual' name='Comment' rows='6' cols='15' ></textarea></td>");
new_window.document.write("</tr><tr><td><font size=-1 face='Verdana'>Click once:</font></td>");
new_window.document.write("<td><input type='SUBMIT' value='Add Comment'></form></td></tr></table></td></tr></table>");
new_window.document.write("</body></html>");

// close the document
new_window.document.close();
}

// -->
</script>

any ideas - again thank you
Quote Reply
Re: [bs7] comments verification? In reply to
I have not worked with javascript much... once you leave perl, I'm lost.
Can you close the write without closing the document? Or put it in line:

new_window.document &create_captcha_form;

The pipe "|" is just stopping the html, so the subroutine can run and insert its content, then the html continues after "qq|".


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] comments verification? In reply to
sorted it - thanks

i only ever seem to get the response: "Error You are attempting to bypass our security."

any more ideas

again - thanks
Quote Reply
Re: [bs7] comments verification? In reply to
Forgot step six, where you add a name to the submit button:

<input type="submit" value="Add Comment" name="captcha">


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] comments verification? In reply to
sorry about this:

if the right code is entered i get: "Error Message : fatal error: Undefined subroutine &main::process_form called at comments.cgi line 69."

(if wrong code, or wrong data - just a blank page - but that's not a problem really)


thanks again
Quote Reply
Re: [bs7] comments verification? In reply to
Check item B above...


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] comments verification? In reply to
thanks for all the help