[MODDB]Better Captcha

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
sonyboy
Registered User
Posts: 2980
Joined: Thu Oct 07, 2004 2:10 am

Post by sonyboy » Sun May 14, 2006 9:44 am

Maybe your host doesn't support it.

Edit: link removed
Last edited by sonyboy on Wed May 17, 2006 8:06 am, edited 1 time in total.

Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 25490
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Post by Paul » Sun May 14, 2006 10:02 am

sonyboy wrote: Maybe your host doesn't support it.

Btw, here's the demo.
I believe thats not my mod.
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development

doneng
Registered User
Posts: 5
Joined: Wed Jul 20, 2005 5:54 am

Post by doneng » Sun May 14, 2006 3:02 pm

Yes, that is different from the one I was trying to install. Any thoughts on how to ge the text to show?

Don

Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 25490
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Post by Paul » Sun May 14, 2006 3:03 pm

Please give a link to your php info, thanks.
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development

doneng
Registered User
Posts: 5
Joined: Wed Jul 20, 2005 5:54 am

Post by doneng » Sun May 14, 2006 4:29 pm


doneng
Registered User
Posts: 5
Joined: Wed Jul 20, 2005 5:54 am

Post by doneng » Mon May 15, 2006 6:08 pm

Seems like the issue must be at my end as I am having the same problem with a different captcha mod. I am running php 4.3.10. Any idea why the bundled fonts are not showing up?

Thanks,

Don

Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 25490
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Post by Paul » Mon May 15, 2006 6:22 pm

I don't know, sorry :(
At my host it works correctly :(
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development

tempered007
Registered User
Posts: 218
Joined: Sun Jun 27, 2004 3:21 am

Post by tempered007 » Mon May 15, 2006 7:02 pm

paul999 wrote: It is self written by the webmaster of mastercode.nl, and modified by me.
Screen:
Image


whoa!

sonyboy
Registered User
Posts: 2980
Joined: Thu Oct 07, 2004 2:10 am

Post by sonyboy » Wed May 17, 2006 8:06 am

paul999 wrote:
sonyboy wrote:Maybe your host doesn't support it.

Btw, here's the demo.
I believe thats not my mod.


Sorry, thought it was yours

kapncrunch
Registered User
Posts: 1
Joined: Fri May 19, 2006 10:43 am

excellent MOD

Post by kapncrunch » Fri May 19, 2006 10:48 am

recently my forum has experienced a sharp surge in spammers, seems like they all suddenly cracked the standard PHPBB captcha and were eager to show it.

in the three days since I installed this MOD, i have had zero spammers.

thumbs up! :D

User avatar
Remix_88
Registered User
Posts: 46
Joined: Wed Apr 23, 2003 12:52 pm
Location: Hampshire, UK

Updated version

Post by Remix_88 » Thu May 25, 2006 2:40 pm

paul999, thanks for contributing a great captcha :-)

I have tweaked it a little and include a copy of my updated 'includes/usercp_captcha.php' below. This is how my update differs from your original code...

1. Scribbles random lines and elipses in the background.
2. The captcha dimensions are randomised, although constrained.
3. The vertical alignment of characters is more random, linked to the captcha height and font size.
4. Horizontal alignment of characters accounts is linked to the captcha width.
5. The font loading/shuffling has been broken up into two functions to reduce file access overhead if you use a large font selection.

Here are some examples...

Image

Image

Image

Feel free to merge my updates into any future version that you might make available :-)

Code: Select all

<?php
/***************************************************************************
 *                            usercp_captcha.php
 *                            -------------------
 *   begin                : Friday, 14 April 2006
 *   copyright            : (C) 2006 paul sohier
 *   email                : webmaster@paulscripts.nl
 *
 *   $Id: usercp_captcha.php,v 1.1 2006/04/14 09:18:17 paulsohier Exp $
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

if ( !defined('IN_PHPBB') )
{
	die('Hacking attempt');
	exit;
} 
// Do we have an id? No, then just exit
if (empty($_GET['id']))
{
	exit;
} 

$confirm_id = htmlspecialchars($_GET['id']);

// Define available charset
$chars = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',  'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',  'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9');

if (!preg_match('/^[A-Za-z0-9]+$/', $confirm_id))
{
	$confirm_id = '';
}
/**
  * Check if GD exisits, otherwise we will use the default phpbb confirm page ;)
  **/
$gd = true;
if(!extension_loaded("gd")){
	//Gd isn't loaded
	//Display error messages always, or not?
	$gd = false;
}
if(!function_exists("gd_info") || !function_exists('imagettftext')){
	//GD function, gd_info don't exists. GD isn't loaded correctly.
	//Freetype function imagettftext doesn't exists. This is required by this mod.
	//print "no gdinfo or imagettftext";
	$gd = false;
}    
if($gd === false){
 	//GD not loaded, or one of the needed functions aren't there. Require usercp_confirm ;)
 	require($phpbb_root_path . 'includes/usercp_confirm.' . $phpEx);
 	die;
}

// Try and grab code for this id and session
$sql = 'SELECT code  
	FROM ' . CONFIRM_TABLE . " 
	WHERE session_id = '" . $userdata['session_id'] . "' 
		AND confirm_id = '$confirm_id'";
$result = $db->sql_query($sql);

// If we have a row then grab data else create a new id
if ($row = $db->sql_fetchrow($result))
{
	$db->sql_freeresult($result);
	$code = $row['code'];
}
else
{
	exit;
}  
/**
  * The next part is orginnaly written by ted from mastercode.nl and modified for using in this mod.
  **/
header("content-type:image/png");
header('Cache-control: no-cache, no-store');

$fonts = get_fonts();

$breedte = rand(256,384);
$hoogte = rand (64,112);

$img = imagecreatetruecolor($breedte,$hoogte);
$achtergrond = imagecolorallocate($img, color("bg"), color("bg"), color("bg")); 			

imagefilledrectangle($img, 0, 0, $breedte-1, $hoogte-1, $achtergrond); 

for($g = 0;$g < 30; $g++)
{
	$t = dss_rand();
	$t = $t[0];
	    
	$ypos = rand(0,$hoogte);
	$xpos = rand(0,$breedte);
	 		
	$kleur = imagecolorallocate($img, color("bgtekst"), color("bgtekst"), color("bgtekst"));
	
	if (!($g % 2))
	{
		$scribx = rand(0,($breedte*2));
		$scriby = rand(0,($hoogte*2));							
		
		$wibblex = rand(0,($breedte*2));
		$wibbley = rand(0,($hoogte*2));
		
		imageline($img, rand(0, $scribx-$xpos), rand(0, $scriby+$ypos), rand(0, $wibblex), rand(0, $wibbley), $kleur+$g);
		imageellipse($img, rand(0, $scribx+$xpos), rand(0, $scriby-$ypos), rand(0, $scriby), rand(0, $scribx), $kleur-$g);		        
	}
	
	imagettftext($img, size(), move(), $xpos, $ypos, $kleur, shuffle_fonts($fonts), $t);
} 			
$stukje = $breedte / (strlen($code) + 3);

for($j = 0;$j < strlen($code); $j++)
{		
	$tek = $code[$j];		
	$ypos = rand(32,$hoogte-8);		
	$xpos = $stukje * ($j+2);
	    
	$kleur2 = imagecolorallocate($img, color("tekst"), color("tekst"), color("tekst"));
	
	imagettftext($img, size(), move(), $xpos, $ypos, $kleur2, shuffle_fonts($fonts) , $tek);
	
}

imagepng($img);
imagedestroy($img); 			
die; 
/**
  * Some functions :)
  * Also orginally written by mastercode.nl
  **/
/**
  * Function to create a random color
  * @auteur mastercode.nl
  * @param $type string Mode for the color
  * @return int
  **/
function color($type)
{
	switch($type)
	{
		case "bg": 
			$kleur = rand(224,255); 
		break;
		case "tekst": 
			$kleur = rand(0,127); 
		break;
		case "bgtekst": 
			$kleur = rand(200,224); 
		break;
		default: 
			$kleur = rand(0,255); 
		break;
	}
	return $kleur;
}
/**
  * Function to ranom the size
  * @auteur mastercode.nl
  * @return int
  **/
function size()
{
	$grootte = rand(18,32);	
	return $grootte;
}
/**
  * Function to random the posistion
  * @auteur mastercode.nl
  * @return int
  **/
function move()
{
	$draai = rand(-25,25);	
	return $draai;
}

/**
  * Function to return a ttf file from fonts array
  * @auteur mastercode.nl
  * @return string
  **/    
function shuffle_fonts($ar)
{
	global $phpbb_root_path;
	
	if(count($ar))
	{
		shuffle($ar);
		$i = rand(0,(count($ar) - 1));
		return $phpbb_root_path . 'includes/fonts/' . $ar[$i];
	}
}	

/**
  * Function to return an array of ttf files
  * @auteur mastercode.nl
  * @return array
  **/    
function get_fonts()
{
	global $phpbb_root_path;
	
	$f = @opendir($phpbb_root_path . 'includes/fonts/');
	$ar = array();
	while(($file = @readdir($f)) !== false)
	{
		if(!in_array($file,array('.','..')) && eregi('.ttf',$file))		
		{
	 		$ar[] = $file;
	 	}
	}
	return $ar;
}    
?>
Regards, Remix_88.

deny
Registered User
Posts: 565
Joined: Wed May 14, 2003 9:14 am
Location: Find-Ip-Address.org
Contact:

Post by deny » Fri May 26, 2006 4:28 pm

It is easy to install and i did use it with remix_88 code but it looks as this captcha is defaced too.Some improving are really needed.
Today i catch again spammer (using trap from another mods with excluding website field and if they use aut. script form to submit it then thier Ip Address will be immediatly banned)

General Error Message:
banned<br /><br /><b><u>DEBUG MODE</u></b><br /><br />Line : 139<br />File :
usercp_register.php


IP: 203.88.152.238
USER: Anonymous

FORM:
Array
(
[website] => http://web-casino.pokersn.com
[mode] => register
[submit] => Submit
[yim] =>
[hideonline] => 0
[msn] =>
[email] => bgnhmkhg@mail.ru
[icq] =>
[agreed] => true
[allowhtml] => 1
[confirm_code] => 181
[password_confirm] => rbterxvcq
[confirm_id] => 69ce471bb1ca584f8ca488047db314a5
[notifypm] => 0
[dateformat] => D M d, Y H:i
[timezone] => -9
[language] => english
[allowbbcode] => 1
[location] =>
[interests] =>
[style] => 1
[popup_pm] => 0
[new_password] => rbterxvcq
[occupation] =>
[viewemail] => 0
[aim] =>
[username] => yrppjxg
[coppa] => 0
[attachsig] => 1
[signature] =>
[notifyreply] => 0
[allowsmilies] => 1
)
Geolocation of any IP address including detection of hostname,
browser, country and country code with ip address range web tool.

IP Address Locator | Email Tracking | IP Address | Check Email

Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 25490
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Post by Paul » Fri May 26, 2006 4:50 pm

I don't think it is already defeated.
Are you sure he registered after install the mod?
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development

deny
Registered User
Posts: 565
Joined: Wed May 14, 2003 9:14 am
Location: Find-Ip-Address.org
Contact:

Post by deny » Fri May 26, 2006 6:43 pm

paul999 wrote: I don't think it is already defeated.
Are you sure he registered after install the mod?


Yep.I'm sure.
2 days a go i did install this mod and today i saw what i show to you above.

Edit
-----------------------
And this is today (27.05.2006 10:00AM).Again spammer caught by trap.
It looks as good mod but need some improvement.
General Error Message:


banned<br /><br /><b><u>DEBUG MODE</u></b><br /><br />Line : 139<br />File :
usercp_register.php


IP: 211.48.37.45
USER: Anonymous

FORM:
Array
(
[website] => http://www.snow-mp3.com
[mode] => register
[submit] => Submit
[yim] =>
[hideonline] => 0
[msn] =>
[email] => jdhuystc@mail.ru
[icq] =>
[agreed] => true
[allowhtml] => 1
[confirm_code] => J11
[password_confirm] => hceupdrfac
[confirm_id] => 3a06c74991bdc91e4b852cb192f911c4
[notifypm] => 0
[dateformat] => D M d, Y H:i
[timezone] => -9
[language] => english
[allowbbcode] => 1
[interests] =>
[location] =>
[style] => 1
[popup_pm] => 0
[viewemail] => 0
[occupation] =>
[new_password] => hceupdrfac
[aim] =>
[username] => neygtqwe
[coppa] => 0
[attachsig] => 1
[notifyreply] => 0
[signature] =>
[allowsmilies] => 1
)
Geolocation of any IP address including detection of hostname,
browser, country and country code with ip address range web tool.

IP Address Locator | Email Tracking | IP Address | Check Email

deny
Registered User
Posts: 565
Joined: Wed May 14, 2003 9:14 am
Location: Find-Ip-Address.org
Contact:

Post by deny » Sat May 27, 2006 3:13 pm

btw

I think that integrating this code with a couple images as background will increase protecting of easy defeacing.
Geolocation of any IP address including detection of hostname,
browser, country and country code with ip address range web tool.

IP Address Locator | Email Tracking | IP Address | Check Email

Locked

Return to “[2.0.x] MODs in Development”