php forum
php mysql forum
php mysql smarty
 
Topic Options
#313724 - 03/26/07 06:59 PM CAPTCHA newpost & reply
arentzen Offline
Newbie

Registered: 10/05/06
Posts: 18
Loc: Denmark
Hej
This post will describe how to install a captcha in newpost and replies, so its possible to allow anonymous posters, without open your forum for spambots. The capatcha will thus only have effect for anonumous posters. Registrated users can ignore captcha.

Its provided that you have uploaded:
audit.php
button.php

If you havent, you can download them here. You can read about the captcha and test it here http://php.webmaster-kit.com/

Modified files
addpost.php
addpost.php(language file)
newpost.php
newpost.php (language file)
newreply.php
newreply.php (language file)
newpost.tmpl
newreply.tmpl
addpost_prewiev.tmpl


Step 1.
open addpost.php(language file) and add the lines
Code:
$ubbt_lang['NO_CAPTCHA'] = "Wrong digits";
$ubbt_lang['ENTER_DIGITS'] = "Enter digits if you're not logged in";


Step 2.
Open newpost.php( language file) and add the line
Code:
$ubbt_lang['ENTER_DIGITS']  = "Enter digits if you're not logged in";


Step.3
Open newrely.php(language file) and add the line
Code:
$ubbt_lang['ENTER_DIGITS']  = "Enter digits if you're not logged in";


Step.4
Open newpost.tmpl and newreply.tmpl and add the captcha and digit input box
Code:

<br/>
<img width="120" height="30" src="button.php" border="1" />




<b>
{$ubbt_lang['ENTER_DIGITS']}
</b>


<input type="text" maxlenght="5" size="5" name="userdigit" class="formboxes" value="" />





Step.5
NOTE!In addpost_prewiev.tmpl, the captcha has to be put into 2 places, because you have 2 options. One option to send the post, and a option to edit the post. You may not exclude one of them, otherwise it will not work!
Code:
<?  //UBBTREMARK
echo <<<UBBTPRINT

<table width="{$theme['tablewidth']}" align="center" cellpadding="1" cellspacing="1" class="tablesurround">
<tr>
<td>
<table cellpadding="{$theme['cellpadding']}" cellspacing="{$theme['cellspacing']}" width="100%" class="tableborders">
<tr>
<td class="tdheader">
{$ubbt_lang['PREV_POST']}
</td>
</tr>
</table>
</td>
</tr>
</table>

<table width="{$theme['tablewidth']}" align="center" cellpadding="1" cellspacing="1" class="tablesurround">
<tr>
<td>
{$template['form1']}
<table cellpadding="{$theme['cellpadding']}" cellspacing="{$theme['cellspacing']}" width="100%" class="tableborders">
<tr class="darktable">
<td>
{$ubbt_lang['POST_BODY']}
</td>
</tr>
<tr class="lighttable">
<td>





<table width="100%" align="center" cellpadding="1" cellspacing="1" class="tablesurround">
<tr>
<td>
<table cellpadding="{$theme['cellpadding']}" cellspacing="{$theme['cellspacing']}" width="100%" class="tableborders">
<tr>
<td class="subjecttable">
$iconurl $PrintSubject
</td>
</tr>
<tr class="lighttable">
<td>


$PrintBody

</td>
</tr>
</table>
</td>
</tr>
</table>

<input type="hidden" name="Subject" value="$FormSubject" />
<input type="hidden" name="Body" value="$FormBody" />
<input type="hidden" name="Parent" value="$Parent" />
<input type="hidden" name="Main" value="$Main" />
<input type="hidden" name="postername" value="$postername" />
<input type="hidden" name="Cat" value="$Cat" />
<input type="hidden" name="Reged" value="$Reged" />
<input type="hidden" name="Board" value="$Board" />
<input type="hidden" name="IP" value="$IP" />
<input type="hidden" name="what" value="$what" />
<input type="hidden" name="page" value="$page" />
<input type="hidden" name="view" value="$view" />
<input type="hidden" name="oldnumber" value="$oldnumber" />
<input type="hidden" name="sb" value="$sb" />
<input type="hidden" name="o" value="$o" />
<input type="hidden" name="mail" value="$mail" />
<input type="hidden" name="PStatus" value="$PStatus" />
<input type="hidden" name="Sticky" value="$Sticky" />
<input type="hidden" name="Icon" value="$Icon" />
<input type="hidden" name="frompreview" value="0" />
<input type="hidden" name="vc" value="$vc" />
<input type="hidden" name="fpart" value="$fpart" />
<input type="hidden" name="replyto" value="$replyto" />
<input type="hidden" name="convert" value="$convert" />
{$template['attachfile']}
{$template['fileinput']}




<img width="120" height="30" src="button.php" border="1" />




<b>
{$ubbt_lang['ENTER_DIGITS']}
</b>


<input type="text" maxlenght="5" size="5" name="userdigit" class="formboxes" value="" />



<input type="submit" value="{$ubbt_lang['TEXT_CONT']}" class="buttons" />

</td>
</tr>
</table>
</form>
</td>
</tr>
</table>







<table width="{$theme['tablewidth']}" align="center" cellpadding="1" cellspacing="1" class="tablesurround">
<tr>
<td>
<table cellpadding="{$theme['cellpadding']}" cellspacing="{$theme['cellspacing']}" width="100%" class="tableborders">
<tr class="darktable">
<td>
{$ubbt_lang['EDIT_MORE']}
</td>
</tr>
<tr class="lighttable">
<td>
{$template['form2']}
{$ubbt_lang['SUBJECT_TEXT']}


<input type="text" name="Subject" value="$Subject" class="formboxes" />


<!-- The following 2 template vars are defined in addpost.php -->
<!-- This is necessary because post icons are a config option -->

{$ubbt_lang['POST_TEXT']}


<textarea cols="$TextCols" rows="$TextRows" class="formboxes" wrap="soft" name="Body">$Body</textarea>







<input type="hidden" name="postername" value="$postername" />
<input type="hidden" name="Cat" value="$Cat" />
<input type="hidden" name="Reged" value="$Reged" />
<input type="hidden" name="Board" value="$Board" />
<input type="hidden" name="what" value="$what" />
<input type="hidden" name="page" value="$page" />
<input type="hidden" name="view" value="$view" />
<input type="hidden" name="Main" value="$Main" />
<input type="hidden" name="Parent" value="$Parent" />
<input type="hidden" name="sb" value="$sb" />
<input type="hidden" name="o" value="$o" />
<input type="hidden" name="fpart" value="$fpart" />
<input type="hidden" name="vc" value="$vc" />
<input type="hidden" name="replyto" value="$replyto" />
<input type="hidden" name="oldnumber" value="$oldnumber" />
<input type="hidden" name="convert" value="$convert" />

<!-- The following template var is defined in addpost.php -->
<!-- This is necessary because it is not always displayed -->
{$template['emailoption']}
<input type="checkbox" name="preview" value="1" $Pselected class="formboxes" />
{$ubbt_lang['DO_PREVIEW']}
{$template['canattach']}
.



<img width="120" height="30" src="button.php" border="1" />




<b>
{$ubbt_lang['ENTER_DIGITS']}
</b>


<input type="text" maxlenght="5" size="5" name="userdigit" class="formboxes" value="" />




<input type="submit" value="{$ubbt_lang['TEXT_CONT']}" class="buttons" />
</form>


</td>
</tr>
</table>
</td>
</tr>
</table>
UBBTPRINT;
/* UBBTREMARK */ ?>


Step.6
Open addpost.php and add the code just before these lines
// -----------------------------------------------------
// Now if we are doing a preview of the post, we do this


Code:
//------------------------------------------------------------	
// Captcha - af Arentzen
	if( ($config['anonnames']) && (!$Username) ) {
	include "audit.php";
	if(audit()){
	}
	else {
		$html -> not_right($ubbt_lang['NO_CAPTCHA'],$Cat);
	}
	}


Step.7
Open newpost.php and newreply.php and put in a "dummy code" in the middle of the scripts, so you dont get error message when executing the scripts.
Code:
//---------------------------------------------------------------------------
// Reset captcha ved besvarelse - af Arentzen	
	if( ($config['anonnames']) && (!$Username) ){
	include "audit.php";
	if(!audit()){
	}
	}


Then we are finish. You should now be able to open your forum for anonymous without collecting spamposts from spambots...
Please leave a comment if you have trouble understanding or further modifications to this guide.

Enjoy!
_________________________
Peter Arentzen
trosfrihed.dk

Top
#313726 - 03/26/07 07:57 PM Re: CAPTCHA newpost & reply [Re: arentzen]
Gizmo Administrator Online   shocked
Wizard

Registered: 01/10/00
Posts: 5094
Loc: Portland, OR, USA
Looks great, good job smile
_________________________
UBB.Dev - Where you too can render your UBB install completely useless...
UGN Security, Elite Web Gamers & VNC Web Design Owner

Top


Moderator:  Ian_W 
Top Posters Last 30 Days
AllenAyres 83
Gizmo 29
sirdude 25
Zarzal 23
blaaskaak 12
swebs 6
willing 5
Who's Online
2 Registered (Djuma, Gizmo), 47 Guests and 11 Spiders online.
Key: Admin, Global Mod, Mod
Shout Box

Latest Posts
User Authentication Class
by sirdude
54 minutes 29 seconds ago
Multiple Identity Detector
by Myke
Today at 05:45 AM
FlashChat with UBB.Threads 7.0.2
by Gizmo
Today at 12:30 AM
Nice Ajax Chat
by Thelockman
07/06/08 09:07 AM
[7.x] UBB.Post Templates v0.1
by sirdude
07/05/08 12:48 PM
Team UBBDev Rides Again!
by AllenAyres
07/04/08 10:56 PM
[7.3.x] ubb.links
by AllenAyres
07/03/08 06:15 PM
New Mods
Protect users emails
by Basil Fawlty
06/29/08 08:44 AM
[7.3.x] Scheduled board close for backup
by blaaskaak
06/26/08 04:01 AM
[7.3+] CustomTag - Audo Embedding
by Gizmo
06/24/08 07:52 PM
[7.3.x] ubb.links
by AllenAyres
06/20/08 11:50 PM
[7.3] Dissallow quotes more then 3 levels deep
by blaaskaak
06/09/08 09:01 AM
Newest Members
nunny, lpzie, DoubleDutch, ryzilla, M4D
13305 Registered Users

 

 

 
fusionbb message board php hacks