CAPTCHA thread
Post new topic   Reply to topic   Printer Friendly Page     Forum IndexAdd-Ons & Blocks
Author Message
personman
Heavy poster


Joined: May 29, 2007
Posts: 152

PostPost subject: CAPTCHA thread
Posted: Wed Dec 03, 2008 2:54 pm
Reply with quote

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
View user's profile Visit poster's website
hadi00
Translator


Joined: Dec 01, 2004
Posts: 198
Location: Syria

PostPost subject: Re: Captcha for anonymous?
Posted: Sun Dec 07, 2008 1:46 am
Reply with quote

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! Crying or Very sad
Back to top
View user's profile Send e-mail
personman
Heavy poster


Joined: May 29, 2007
Posts: 152

PostPost subject: Re: Captcha for anonymous?
Posted: Thu Feb 05, 2009 6:29 pm
Reply with quote

Well, I took a whack at it and ended up with nothing but a broken captcha and a headache. Sad

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
View user's profile Visit poster's website
rlgura
1000+ Posts Club


Joined: Mar 27, 2006
Posts: 1148
Location: Cleveland, OH USA

PostPost subject: Re: Captcha for anonymous for News?
Posted: Fri Feb 06, 2009 4:47 pm
Reply with quote

Might want to take a look at this post and see if it's helpful for what you're doing: myndworx.com/ForumsPro...t=709.html
_________________
Admin - Great Lakes Web Designs
Theme Designer - WebSite Guru Designs
Site Admin - Families with Food Allergies

rlgura's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux 2.6.27-grsec/Apache 2.2.11/MySQL 5.0.67-community-log/PHP 5.2.8/DF 9.2.1
Back to top
View user's profile Visit poster's website
Klas
Newbie


Joined: Apr 27, 2004
Posts: 37
Location: Oldenburg/Germany

PostPost subject: Re: Captcha for anonymous for News?
Posted: Fri Feb 06, 2009 5:17 pm
Reply with quote

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
View user's profile Visit poster's website
personman
Heavy poster


Joined: May 29, 2007
Posts: 152

PostPost subject: Re: Captcha for anonymous for News?
Posted: Fri Feb 06, 2009 5:32 pm
Reply with quote

Thanks guys. Smile 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. Smile

-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
View user's profile Visit poster's website
tkog2004
Heavy poster


Joined: May 14, 2006
Posts: 152

PostPost subject: Re: Captcha for anonymous for News?
Posted: Sat Feb 07, 2009 11:12 am
Reply with quote

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! Crying or Very sad
Back to top
View user's profile Visit poster's website
personman
Heavy poster


Joined: May 29, 2007
Posts: 152

PostPost subject: Re: Captcha for anonymous for News?
Posted: Tue Feb 10, 2009 5:40 pm
Reply with quote

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
View user's profile Visit poster's website
personman
Heavy poster


Joined: May 29, 2007
Posts: 152

PostPost subject: Re: Captcha for anonymous for News?
Posted: Tue Feb 10, 2009 6:37 pm
Reply with quote

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
View user's profile Visit poster's website
hadi00
Translator


Joined: Dec 01, 2004
Posts: 198
Location: Syria

PostPost subject: Re: Captcha for anonymous for News?
Posted: Sat Feb 21, 2009 11:01 pm
Reply with quote

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! Crying or Very sad
Back to top
View user's profile Send e-mail
DJ Maze
Developer


Joined: Apr 19, 2004
Posts: 5668
Location: http://tinyurl.com/5z8dmv

PostPost subject: Re: Captcha for anonymous for News?
Posted: Sun Feb 22, 2009 1:38 am
Reply with quote

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
View user's profile Visit poster's website Yahoo Messenger
personman
Heavy poster


Joined: May 29, 2007
Posts: 152

PostPost subject: Re: Captcha for anonymous for News?
Posted: Sun Feb 22, 2009 1:42 pm
Reply with quote

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

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

_________________
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
View user's profile Visit poster's website
DJ Maze
Developer


Joined: Apr 19, 2004
Posts: 5668
Location: http://tinyurl.com/5z8dmv

PostPost subject: Re: Captcha for anonymous for News?
Posted: Sun Feb 22, 2009 5:37 pm
Reply with quote

You're correct just use:
Code:
if (!validate_secimg()) { cpg_error(_SECURITYCODE.' incorrect'); }

You could even make the code harder.
By default it uses 6 characters but can modify that to your liking.

generate_secimg(12)
validate_secimg(12)

Ofcourse the background image should be big enough to fit all characters Wink


Tip regarding you news item: Use VirtualBox!
When running a VM you can make nice screenshots instead of the horrible "shoot the monitor" pictures Very Happy
VirtualBox is available in your Ubuntu repo or at www.virtualbox.org/

I use it all the time to test new OS's
  1. download an ISO of the desired OS
  2. run virtualbox and mount the ISO as CD/DVD


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
View user's profile Visit poster's website Yahoo Messenger
hadi00
Translator


Joined: Dec 01, 2004
Posts: 198
Location: Syria

PostPost subject: Re: Captcha for anonymous for News?
Posted: Sun Feb 22, 2009 8:29 pm
Reply with quote

Still watching !
keep good work..

_________________
The truth is to stop thinking and start living

hadi00 please enter your server specs in your user profile! Crying or Very sad
Back to top
View user's profile Send e-mail
personman
Heavy poster


Joined: May 29, 2007
Posts: 152

PostPost subject: Re: Captcha for anonymous for News?
Posted: Fri Apr 10, 2009 12:33 pm
Reply with quote

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
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   Printer Friendly Page     Forum IndexAdd-Ons & Blocks All times are GMT
Go to page 1, 2  Next
Page 1 of 2


Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

stopsoftwarepatents.eu petition banner
User Info [x]

Welcome Anonymous

Nickname
Password
(Register)

Last CVS commits [x]

Languages [x]

Community [x]

Support for DragonflyCMS in a other languages:

Deutsch
Español

X-links [x]
UltraEdit Browse Happy logo Firefox MySQL PostgreSQL Valid CSS! Valid XHTML 1.0! Unicode Encoded Badge NukeBiz Resources Raven DragonflyCMS Dedicated Now InsideSupport Lampe Berger

Preview theme [x]
Each user can view the site with a different theme.
Themes marked with a * also change the forum look.


You are seeing squares or questionmarks on this page?

All content of this website is copyrighted by the Creative Commons NC-SA
The logos and trademarks used on this site are the property of their respective owners
We are not responsible for comments posted by our users, as they are the property of the poster.
Our server runs on a P3 1.2GHz with 512MB RAM with no accelerators
Support GoPHP5.org
This page generated in 1.3307 seconds with 17 DB Queries in 0.0528 seconds
Memory Usage: 3.13 MB
Interactive software released under GNU GPL, Code Credits, Privacy Policy