| Author |
Message |
personman


Joined: May 29, 2007 Posts: 152
|
Post subject: CAPTCHA thread Posted: Wed Dec 03, 2008 2:54 pm |
|
I used to have anonymous commenting on my site's news page, but had to disable it to control spam.
Is there a way to turn on captcha for anonymous posting? Should there be? I could investigate modding it, might be over my head though, dunno.
I previously made a patch to allow disabling anonymous news comments without disabling anonymous news submissions. It's floating around here somewhere.
-Andy
_________________ My site
personman's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Linux 2.6.24.5/Apache 2.2.9/MySQL 5.0.67/PHP 5.2.6/DragonflyCMS 9.2.1
Last edited by personman on Tue Apr 14, 2009 3:27 pm; edited 1 time in total |
|
| Back to top |
|
 |
hadi00


Joined: Dec 01, 2004 Posts: 198 Location: Syria
|
Post subject: Re: Captcha for anonymous? Posted: Sun Dec 07, 2008 1:46 am |
|
I guess not! There is no CAPTCHA for news comments..
_________________ The truth is to stop thinking and start living
hadi00 please enter your server specs in your user profile! |
|
| Back to top |
|
 |
personman


Joined: May 29, 2007 Posts: 152
|
Post subject: Re: Captcha for anonymous? Posted: Thu Feb 05, 2009 6:29 pm |
|
Well, I took a whack at it and ended up with nothing but a broken captcha and a headache.
It has such a nice CAPTCHA, but it's a shame so little uses it. Maybe work could be done, or documentation could be written, to make it easier for modders to use the CAPTCHA system? Or maybe I just need to be more patient.
-Andy
_________________ My site
personman's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Linux 2.6.24.5/Apache 2.2.9/MySQL 5.0.67/PHP 5.2.6/DragonflyCMS 9.2.1 |
|
| Back to top |
|
 |
rlgura


Joined: Mar 27, 2006 Posts: 1148 Location: Cleveland, OH USA
|
|
| Back to top |
|
 |
Klas


Joined: Apr 27, 2004 Posts: 37 Location: Oldenburg/Germany
|
Post subject: Re: Captcha for anonymous for News? Posted: Fri Feb 06, 2009 5:17 pm |
|
Try this, copy the comments.php to modules/News/ . But make a backup first.
_________________ Klas
.
My mice Terri & Tracy
Klas's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
 |
|
| Back to top |
|
 |
personman


Joined: May 29, 2007 Posts: 152
|
Post subject: Re: Captcha for anonymous for News? Posted: Fri Feb 06, 2009 5:32 pm |
|
Thanks guys. Once I get re-motivated to take a shot at it, I'd like to go through and CAPTCHA-ize the whole thing. News, blogs, forums, comments, etc. I'd like to eventually re-open my site to anonymous users, without opening a floodgate of spam.
Probably make the changes in to a patch against DF 9.2.1.
I think it would be cool to see it go in to the core (assuming we pull it off.)
Looks like these should be a good starting point, I'll check it out more when I get my hands dirty. 
-Andy
_________________ My site
personman's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Linux 2.6.24.5/Apache 2.2.9/MySQL 5.0.67/PHP 5.2.6/DragonflyCMS 9.2.1 |
|
| Back to top |
|
 |
tkog2004


Joined: May 14, 2006 Posts: 152
|
Post subject: Re: Captcha for anonymous for News? Posted: Sat Feb 07, 2009 11:12 am |
|
just used the Myndworx example as a basis to adding captcha to Guestbook4U and it works no problem so It shouldnt be much hassle to get it in elsewhere.
I dont really use comments much, but if I get chance then I will take a look at it.
_________________

tkog2004 please enter your server specs in your user profile! |
|
| Back to top |
|
 |
personman


Joined: May 29, 2007 Posts: 152
|
Post subject: Re: Captcha for anonymous for News? Posted: Tue Feb 10, 2009 5:40 pm |
|
Here are the changes I've made to add the security code to the news comments form. This should only effect unregistered users, and requires anonymous commenting to be enabled.
Attached is a replacement /modules/News/comments.php for DragonflyCMS 9.2.1, with the changes applied.
Open /modules/News/comments.php
Around line 308, in the function replyform, find this bit of code at the bottom of the function:
Code:
<input type="hidden" name="pid" value="'.$pid.'" />
<input type="hidden" name="sid" value="'.$sid.'" />
<input type="submit" name="preview" value="'._PREVIEW.'" /> <input type="submit" name="postreply" value="'._OK.'" />
</form>';
CloseTable();
and change it to this:
Code:
<input type="hidden" name="pid" value="'.$pid.'" />
<input type="hidden" name="sid" value="'.$sid.'" />';
if (!is_user()) {
echo '
<table border="0">
<tr>
<td class="row1"><span class="gen">'._SECURITYCODE.':</span></td>
<td class="row2">'.generate_secimg().'</td></tr>
<tr>
<td class="row1"><span class="gen">'._TYPESECCODE.':</span></td>
<td class="row2"><input type="text" name="gfx_check" size="7" maxlength="6" /></td>
</tr></table>';}
echo '<input type="submit" name="preview" value="'._PREVIEW.'" /> <input type="submit" name="postreply" value="'._OK.'" />
</form>';
CloseTable();
Around line 384 in the function replypost, you should see this if statement:
Code:
if (is_user()) {
$name = $userinfo['username'];
$email = $userinfo['femail'];
$url = $userinfo['user_website'];
$score = 1;
} else {
$name = $email = $url = '';
$score = 0;
}
We change this to:
Code:
if (is_user()) {
$name = $userinfo['username'];
$email = $userinfo['femail'];
$url = $userinfo['user_website'];
$score = 1;
} else {
$name = $email = $url = '';
$score = 0;
//edited
if (!validate_secimg()) { cpg_error(_SECURITYCODE.' incorrect'); }
//end edit
}
Updated: Forgot the usercheck in the form.
_________________ My site
personman's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Linux 2.6.24.5/Apache 2.2.9/MySQL 5.0.67/PHP 5.2.6/DragonflyCMS 9.2.1
Last edited by personman on Tue Apr 07, 2009 1:56 pm; edited 2 times in total |
|
| Back to top |
|
 |
personman


Joined: May 29, 2007 Posts: 152
|
Post subject: Re: Captcha for anonymous for News? Posted: Tue Feb 10, 2009 6:37 pm |
|
The reDesign theme also has a reply form in it, so here is my attempt at modding in the security code.
I modded version 9.1.2.7 DP I think it was.
Open the file /themes/reDesign/template/news/comments.html
Around line 165 you should see the following:
Code:
<input type="hidden" name="{S_SID_NAME}" value="{S_SID}" />
<div style="text-align: center;padding: 20px;clear: both;">
<input type="submit" name="preview" class="button" value="{S_PREVIEW}" /> <input type="submit" name="postreply" class="button" value="{S_OK}" />
We want to change this to:
Code:
<input type="hidden" name="{S_SID_NAME}" value="{S_SID}" />
<div style="text-align: center;padding: 20px;clear: both;">
<!-- PHP -->
if (!is_user()) {
echo '
<table align="center" border="0">
<tr>
<td class="row1"><span class="gen">'._SECURITYCODE.':</span></td>
<td class="row2">'.generate_secimg().'</td></tr>
<tr>
<td class="row1"><span class="gen">'._TYPESECCODE.':</span></td>
<td class="row2"><input type="text" name="gfx_check" size="7" maxlength="6" /></td>
</tr></table>';
}
<!-- ENDPHP -->
<input type="submit" name="preview" class="button" value="{S_PREVIEW}" /> <input type="submit" name="postreply" class="button" value="{S_OK}" />
_________________ My site
personman's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Linux 2.6.24.5/Apache 2.2.9/MySQL 5.0.67/PHP 5.2.6/DragonflyCMS 9.2.1 |
|
| Back to top |
|
 |
hadi00


Joined: Dec 01, 2004 Posts: 198 Location: Syria
|
Post subject: Re: Captcha for anonymous for News? Posted: Sat Feb 21, 2009 11:01 pm |
|
I think I have just needed that ! thnx a lot !
_________________ The truth is to stop thinking and start living
hadi00 please enter your server specs in your user profile! |
|
| Back to top |
|
 |
DJ Maze


Joined: Apr 19, 2004 Posts: 5668 Location: http://tinyurl.com/5z8dmv
|
Post subject: Re: Captcha for anonymous for News? Posted: Sun Feb 22, 2009 1:38 am |
|
There's no need to manually validate the 'gfxid'
validate_secimg() does it all for you!
dragonflycms.org/cvs/h...play.php?v
DJ Maze's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Fedora 12 / 2.2.15 / 5.1.47 / 5.3.3 / CVS |
|
| Back to top |
|
 |
personman


Joined: May 29, 2007 Posts: 152
|
Post subject: Re: Captcha for anonymous for News? Posted: Sun Feb 22, 2009 1:42 pm |
|
I don't imagine this will block all spam bots, just hoping it raises the bar for them a bit, and makes the moderator's job more reasonable with anonymous commenting. On the other hand, it might just end up attracting bots that crack this particular captcha. Time will tell.
So far, I've had pretty good results. I posted a preview and install guide for Kubuntu Linux 9.04, story ran on a few linux news sites. Got about 5,000 reads, maybe 6 or 7 anonymous comments, and no spam yet. 
-Andy
DJ Maze: If I understand correctly, I can replace this bit:
Code:
//edited
$gfxid = isset($_POST['gfxid']) ? $_POST['gfxid'] : 0;
$code = $CPG_SESS['gfx'][$gfxid];
$gfx_check = isset($_POST['gfx_check']) ? $_POST['gfx_check'] : '';
if (strlen($gfx_check) < 2 || $code != $gfx_check) { cpg_error(_SECURITYCODE.' incorrect'); }
//end edit
simply with: validate_secimg()? or drop it altogether?
Cool, thanks. I'll play around with it next time I'm in there and post any updates.
_________________ My site
personman's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Linux 2.6.24.5/Apache 2.2.9/MySQL 5.0.67/PHP 5.2.6/DragonflyCMS 9.2.1 |
|
| Back to top |
|
 |
DJ Maze


Joined: Apr 19, 2004 Posts: 5668 Location: http://tinyurl.com/5z8dmv
|
|
| Back to top |
|
 |
hadi00


Joined: Dec 01, 2004 Posts: 198 Location: Syria
|
Post subject: Re: Captcha for anonymous for News? Posted: Sun Feb 22, 2009 8:29 pm |
|
Still watching !
keep good work..
_________________ The truth is to stop thinking and start living
hadi00 please enter your server specs in your user profile! |
|
| Back to top |
|
 |
personman


Joined: May 29, 2007 Posts: 152
|
Post subject: Re: Captcha for anonymous for News? Posted: Fri Apr 10, 2009 12:33 pm |
|
I updated the code based on DJ Maze's comments (it should be functionally identical). On a related note, I've added anonymous commenting with CAPTCHA to the newest release of Personal Pages.
Bots seem to have figured out that my survey's comments don't have CAPTCHA yet, so that will probably be one of the next things to remedy.
In the future I'll probably look in to adding CAPTCHA to the blog comments and the forums, maybe the news submission form.
-Andy
_________________ My site
personman's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Linux 2.6.24.5/Apache 2.2.9/MySQL 5.0.67/PHP 5.2.6/DragonflyCMS 9.2.1 |
|
| Back to top |
|
 |