[BETA] FreeCap Visual Confirmation 0.0.3

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.
User avatar
aronchav
Registered User
Posts: 10
Joined: Mon Nov 21, 2005 8:21 am
Contact:

Post by aronchav »

I uploaded everything and changed all the files in the "include" folder per instructions for freecap 002. Then I changed all files in the template folder according to instructions here: How to add Visual Confirmation to outdated templates.

I get the option in my admin panel to turn on VC. When I try to register, the images and VC text field comes up, but it doesn't actually do anything. I enter wrong letters on purpode to test and it still lets me register. Also, the background never changes. I saw there were 5 or so background images for freecap, but only one ever shows when I test. So I'm wondering if freecap is conflicting with phpBB's built in VC?

***edit: Actually, I tried reloading the page several times and the background behind the letters does change, but it does not appear to be any of the images from freecap.***

And after entering the VC and registration info, I get these error messages at the top of my screen before my logo and everything (this is the screen that says, "you have sucessfully registered but you have to check your email to be confirmed" or whatever.)


Parse error: parse error, unexpected ')' in c:\...\phpBB2\includes\usercp_register.php(307) : eval()'d code on line 1

Warning: Cannot modify header information - headers already sent by (output started at c:\...\phpBB2\includes\usercp_register.php(307) : eval()'d code:1) in c:\...\phpBB2\includes\page_header.php on line 483

Warning: Cannot modify header information - headers already sent by (output started at c:\...\phpBB2\includes\usercp_register.php(307) : eval()'d code:1) in c:\...\phpBB2\includes\page_header.php on line 485

Warning: Cannot modify header information - headers already sent by (output started at c:\...\phpBB2\includes\usercp_register.php(307) : eval()'d code:1) in c:\...\phpBB2\includes\page_header.php on line 486




If anyone has a second and wants to see for yourself, the site is http://www.roguemoon.us/ravings/phpBB2/index.php

And if I'm asking in the wrong forum/thread, just let me know :)


Thx
User avatar
A_Jelly_Doughnut
Former Team Member
Posts: 34457
Joined: Sat Jan 18, 2003 1:26 am
Location: Where the Rivers Run
Contact:

Post by A_Jelly_Doughnut »

That error means your profile_add_body.tpl has mismatches in BEGIN and END commands, most probably near the beginning of the file.

Feel free to post the first ten lines or so of the file and I'll have a look :)
A Donut's Blog
"Bach's Prelude (Cello Suite No. 1) is driving Indiana country roads in Autumn" - Ann Kish
User avatar
aronchav
Registered User
Posts: 10
Joined: Mon Nov 21, 2005 8:21 am
Contact:

Post by aronchav »

Seemed like a lot of the stuff at the beginning was just formatting stuff, so I'l paste a bit more than the first 10 lines. Hope this is what you need. Thx for the help. :D

Code: Select all

<form action="{S_PROFILE_ACTION}" {S_FORM_ENCTYPE} method="post"><center>

{ERROR_BOX}

<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
<tr> 
	<td align="left"><span class="small"><a href="{U_INDEX}">{L_INDEX}</a></span></td>
</tr>
</table>

<table width="740" cellpadding="0" cellspacing="0">
<tr>
<td width="41" height="25" background="templates/Galaxian/images/button_1.jpg"></td>
<td width="*" height="25" background="templates/Galaxian/images/button_2.jpg" align="center"><span class="small">{L_REGISTRATION_INFO}</span></td>
<td width="41" height="25" background="templates/Galaxian/images/button_4.jpg"></td>
</tr>
</table>

<table width="670" bgcolor="#000000" cellspacing="0">
<tr><td background="templates/Galaxian/images/announce_2.gif" height="15"></td></tr>
</table>

<table width="670" cellpadding="2" cellspacing="1" border="0" bgcolor="#636363">
<tr> 
	<td colspan="2" height="25" bgcolor="#0F0F0F" align="center"><span class="medium">{L_ITEMS_REQUIRED}</span></td>
</tr>

<tr><td bgcolor="#000000" colspan="2" background="templates/Galaxian/images/announce_2a.gif" height="10"></td></tr>

<!-- BEGIN switch_namechange_disallowed --> 
<tr> 
	<td bgcolor="#0F0F0F" width="38%"><span class="medium">{L_USERNAME}: *</span></td>
	<td bgcolor="#0F0F0F" width="62%"><input type="hidden" name="username" value="{USERNAME}" /><span class="small">{USERNAME}</span></td>
</tr> 
<!-- END switch_namechange_disallowed --> 
<!-- BEGIN switch_namechange_allowed --> 
<tr> 
	<td bgcolor="#0F0F0F" width="38%"><span class="medium">{L_USERNAME}: *</span></td>
	<td bgcolor="#0F0F0F" width="62%"><input type="text" style="width:200px" name="username" size="25" maxlength="25" value="{USERNAME}" /></td>
</tr> 
<!-- END switch_namechange_allowed -->

<tr><td bgcolor="#000000" colspan="2" background="templates/Galaxian/images/announce_2a.gif" height="10"></td></tr>

<tr> 
	<td bgcolor="#0F0F0F"><span class="medium">{L_EMAIL_ADDRESS}: *</span></td>
	<td bgcolor="#0F0F0F"><input type="text" style="width:200px" name="email" size="25" maxlength="255" value="{EMAIL}" /></td>
</tr>

<tr><td bgcolor="#000000" colspan="2" background="templates/Galaxian/images/announce_2a.gif" height="10"></td></tr>

<!-- BEGIN switch_edit_profile -->
<tr> 
	<td bgcolor="#0F0F0F"><span class="medium">{L_CURRENT_PASSWORD}: *</span><br />
		<span class="small">{L_CONFIRM_PASSWORD_EXPLAIN}</span></td>
	<td bgcolor="#0F0F0F"> 
		<input type="password" style="width: 200px" name="cur_password" size="25" maxlength="32" value="{CUR_PASSWORD}" />
	</td>
</tr>

<tr><td bgcolor="#000000" colspan="2" background="templates/Galaxian/images/announce_2a.gif" height="10"></td></tr>
<!-- END switch_edit_profile -->
User avatar
A_Jelly_Doughnut
Former Team Member
Posts: 34457
Joined: Sat Jan 18, 2003 1:26 am
Location: Where the Rivers Run
Contact:

Post by A_Jelly_Doughnut »

Nope, not there...looking again, if it was what I had said first, the error would be in template.php.

The actual error is in usercp_register.php, probably with the lines you pasted in from this MOD...the part where you take one line and replace it with about 15. Double-check that edit please.
A Donut's Blog
"Bach's Prelude (Cello Suite No. 1) is driving Indiana country roads in Autumn" - Ann Kish
Swizec
Former Team Member
Posts: 1701
Joined: Mon Mar 10, 2003 9:42 pm
Location: Slovenia
Contact:

Post by Swizec »

I think that kind of CAPTCHA has been broken too.

You need something like gimpy, except you should also cut up the image into pieces so that bots can't get ahold of the image to OCR.

I have a function made that does that if you're interested :P (it's not perfect gimpy, but it comes close)
User avatar
A_Jelly_Doughnut
Former Team Member
Posts: 34457
Joined: Sat Jan 18, 2003 1:26 am
Location: Where the Rivers Run
Contact:

Post by A_Jelly_Doughnut »

If you can find evidence, I'm listening. This style captcha was designed in part by the guy who broke phpBB's and vBulletin's, so it should last at least as long at phpBB's did (2 years?).
A Donut's Blog
"Bach's Prelude (Cello Suite No. 1) is driving Indiana country roads in Autumn" - Ann Kish
User avatar
aronchav
Registered User
Posts: 10
Joined: Mon Nov 21, 2005 8:21 am
Contact:

Post by aronchav »

(Sry, I tried to bold the changes to make it easier to read, but the tags didn't take for some reason.)

your instructions

Code: Select all

#
#----[ OPEN ]---------------------
#
includes/usercp_register.php

#
#----[ FIND ]---------------------
#
				if ($row['code'] == $confirm_code)
#
#----[ REPLACE WITH ]-------------
#

				if (@extension_loaded('gd') || @extension_loaded('gd2'))
				{
					$logic = 'return strtolower($row[\'code\'])) != strtolower($confirm_code);';
				}
				else
				{
					$logic = 'return $row[\'code\'] != $confirm_code;';
				}

				if (eval($logic))

#
#----[ FIND ]---------------------
#
			$code .= $confirm_chars[mt_rand(0, $max_chars)];
		}

#
#----[ AFTER, ADD ]---------------
#
		$code = strtolower(preg_replace('#(\d)#e', 'chr($1 + 96)', $code));

#
#----[ FIND ]---------------------
#
		$confirm_image = (@extension_loaded('zlib')) ? '<img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id") . '" alt="" title="" />' : '<img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=1") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=2") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=3") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=4") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=5") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=6") . '" alt="" title="" />';

#
#----[ REPLACE WITH ]-------------
#
		$confirm_image = (@extension_loaded('gd') || @extension_loaded('gd2')) ? "<img src=\"" . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id") . '" alt="" title="" />' : ((@extension_loaded('zlib')) ? '<img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id") . '" alt="" title="" />' : '<img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=1") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=2") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=3") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=4") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=5") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=6") . '" alt="" title="" />');




Problem with first edit -- there is no line if ($row['code'] == $confirm_code) in original file. Closest match is if ($row['code'] != $confirm_code). There is != instead of ==, but I ran a "find..." on Wordpad and there is no other line.


First edit,replace:


Code: Select all

if (!($result = $db->sql_query($sql)))
			{
				message_die(GENERAL_ERROR, 'Could not obtain confirmation code', __LINE__, __FILE__, $sql);
			}

			if ($row = $db->sql_fetchrow($result))
			{
				if ($row['code'] != $confirm_code)
				{
					$error = TRUE;
					$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Confirm_code_wrong'];
				}
				else
				{
					$sql = 'DELETE FROM ' . CONFIRM_TABLE . " 
						WHERE confirm_id = '$confirm_id' 
							AND session_id = '" . $userdata['session_id'] . "'";
					if (!$db->sql_query($sql))
					{
with

Code: Select all

if (!($result = $db->sql_query($sql)))
			{
				message_die(GENERAL_ERROR, 'Could not obtain confirmation code', __LINE__, __FILE__, $sql);
			}

			if ($row = $db->sql_fetchrow($result))
			{
				if (@extension_loaded('gd') || @extension_loaded('gd2'))
				{
					$logic = 'return strtolower($row[\'code\'])) != strtolower($confirm_code);';
				}
				else
				{
					$logic = 'return $row[\'code\'] != $confirm_code;';
				}

				if (eval($logic))

				{
					$error = TRUE;
					$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Confirm_code_wrong'];
				}
				else
				{
					$sql = 'DELETE FROM ' . CONFIRM_TABLE . " 
						WHERE confirm_id = '$confirm_id' 
							AND session_id = '" . $userdata['session_id'] . "'";
					if (!$db->sql_query($sql))
					{

Second edit, add after:

Code: Select all

list($usec, $sec) = explode(' ', microtime()); 
		mt_srand($sec * $usec); 

		$max_chars = count($confirm_chars) - 1;
		$code = '';
		for ($i = 0; $i < 6; $i++)
		{
			$code .= $confirm_chars[mt_rand(0, $max_chars)];
		}

		$code = strtolower(preg_replace('#(\d)#e', 'chr($1 + 96)', $code));

		$confirm_id = md5(uniqid($user_ip));

		$sql = 'INSERT INTO ' . CONFIRM_TABLE . " (confirm_id, session_id, code) 
			VALUES ('$confirm_id', '". $userdata['session_id'] . "', '$code')";
		if (!$db->sql_query($sql))
		{

Third edit, replace:

Code: Select all

		if (!$db->sql_query($sql))
		{
			message_die(GENERAL_ERROR, 'Could not insert new confirm code information', '', __LINE__, __FILE__, $sql);
		}

		unset($code);
		
		$confirm_image = (@extension_loaded('zlib')) ? '<img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id") . '" alt="" title="" />' : '<img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=1") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=2") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=3") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=4") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=5") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=6") . '" alt="" title="" />';
		$s_hidden_fields .= '<input type="hidden" name="confirm_id" value="' . $confirm_id . '" />';

		$template->assign_block_vars('switch_confirm', array());
	}

with

Code: Select all

		if (!$db->sql_query($sql))
		{
			message_die(GENERAL_ERROR, 'Could not insert new confirm code information', '', __LINE__, __FILE__, $sql);
		}

		unset($code);
		
		$confirm_image = (@extension_loaded('gd') || @extension_loaded('gd2')) ? "<img src=\"" . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id") . '" alt="" title="" />' : ((@extension_loaded('zlib')) ? '<img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id") . '" alt="" title="" />' : '<img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=1") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=2") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=3") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=4") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=5") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=6") . '" alt="" title="" />');
		$s_hidden_fields .= '<input type="hidden" name="confirm_id" value="' . $confirm_id . '" />';

		$template->assign_block_vars('switch_confirm', array());
	}
User avatar
aronchav
Registered User
Posts: 10
Joined: Mon Nov 21, 2005 8:21 am
Contact:

Post by aronchav »

Swizec wrote: I think that kind of CAPTCHA has been broken too.

You need something like gimpy, except you should also cut up the image into pieces so that bots can't get ahold of the image to OCR.

I have a function made that does that if you're interested :P (it's not perfect gimpy, but it comes close)


Thx, Swiz, I'll take a look once I get this one figured out.
Swizec
Former Team Member
Posts: 1701
Joined: Mon Mar 10, 2003 9:42 pm
Location: Slovenia
Contact:

Post by Swizec »

A_Jelly_Doughnut wrote: If you can find evidence, I'm listening. This style captcha was designed in part by the guy who broke phpBB's and vBulletin's, so it should last at least as long at phpBB's did (2 years?).


Naw, I can't, that's why the I think, new captchas die every day, but I think "my idea" will last quite some time :)
(the idea about splitting the image)

anyways, I include my function if ever it is needed

Code: Select all

// makes text on the image somewhat arced
	function arctext( $x, $y, $size, $font, &$img, $str, $col, $w, $ang )
	{
		// a few basic things that we'll need
		$msize = ceil( $size/2 );
		$delta = ceil( $msize/strlen( $str ) );
		$xx = $x;
		$yy = $y;
		$sz = $size;
		
		// now print the text
		for ( $i = 0; $i < strlen( $str ); $i++ )
		{
			$s = imagettftext( $img, $sz, $ang, $xx, $yy, $col, $font, $str{$i} );
			$xx = $s[ 2 ];
			$ang = ( $w == 'd' ) ? $ang - 5 : $ang + 5;
			$sz -= $delta;
		}
	}

	// this creates the captcha for registration
	function captcha()
	{
		global $cache, $security, $encryption, $Cl_root_path, $userdata, $Cl_root_path4template;
		
		// first delete the images
		$this->cleancaptcha();
		
		// create an empty image
		$maxx = 400;
		$maxy = 300;
		$img = imagecreatetruecolor( $maxx, $maxy );
		
		// now put in a background
		$b = rand( 0, 2 );
		$bck = imagecreatefromjpeg( $Cl_root_path . 'includes/captcha/back' . $b . '.jpg' );
		$size = getimagesize( $Cl_root_path . 'includes/captcha/back' . $b . '.jpg' );
		imagecopy( $img, $bck, 0, 0, rand( 0, $size[ 0 ]-$maxx ), rand( 0, $size[ 1 ]-$maxy ), $maxx, $maxy );
		imagedestroy( $bck );
		
		// array of available fonts
		$fonts = array( 'times', 'tahoma', 'lsans' );
		// the font we'll be using
		$col = imagecolorallocatealpha( $img, 0, 0, 0, 50 ); // and the colour
		
		// make the array of strings
		include( $Cl_root_path . 'includes/captcha/wordlist' . phpEx ); // get the word list
		$words = array();
		for ( $i = 0; $i < 10; $i++ )
		{
			$words[] = strtoupper( $list[ rand( 0, count( $list ) ) ] );
		}
		
		$x = 40;
		$y = 50;
		$size = 22;
		$wordlist = array(); // this will later be used to determine the shortest and longest word
		
		// print text to image
		for ( $i = 0; $i < 4; $i++ )
		{
			// choose font for each line
			$font1 = $Cl_root_path . 'includes/captcha/' . $fonts[ rand( 0, count( $fonts )-1 ) ] . '.ttf';
			$font2 = $Cl_root_path . 'includes/captcha/' . $fonts[ rand( 0, count( $fonts )-1 ) ] . '.ttf';
			// choose word for each line
			$w1 = $words[ rand( 0, 9 ) ];
			$w2 = $words[ rand( 0, 9 ) ];
			// add words to list
			$wordlist[] = $w1;
			$wordlist[] = $w2;
			// write text to image
			$this->arctext( $x + 10, $y + 10, $size, $font1, $img, $w1, $col, 'd', 10 );
			$this->arctext( $x, $y, $size, $font2, $img, $w2, $col, 'd', 10 );
			// change position for next word
			$dx = ( strlen( $w1 ) < strlen( $w2 ) ) ? strlen( $w1 ) * $size : strlen( $w2 ) * $size;
			$x += $dx - 50;
			$y += $size + 40;
		}
		
		// now we chop up the image into smaller entities
		
		// first calculate the parts
		$nrows = rand( 2, 10 );
		$ncols = rand( 2, 10 );
		$rows = array( 0 );
		$cols = array( 0 );
		// y borders
		for ( $i = 1; $i < $nrows; $i++ )
		{
			$rows[ $i ] = rand( $rows[ $i - 1 ], $maxy );
			if ( $rows[ $i ] == $maxy )
			{ // break because we found the end
				$nrows = $i;
				break;
			}
		}
		// x borders
		for ( $i = 1; $i < $ncols; $i++ )
		{
			$cols[ $i ] = rand( $cols[ $i - 1 ], $maxx );
			if ( $cols[ $i ] == $maxx )
			{ // break because we found the end
				$ncols = $i;
				break;
			}
		}
		if ( $rows[ $i ] != $maxy )
		{ // we didn't have border yet
			$rows[] = $maxy;
		}
		if ( $cols[ $i ] != $maxx )
		{ // we didn't have border yet
			$cols[] = $maxx;
		}
		
		$tosave = $Cl_root_path . 'cache/captcha_' . $userdata[ 'sid' ] . '_' . time();
		$filelist = array(); // this will be the array of files that will later need deletion
		
		// now do chopping and create the table as we go
		$out = '<table cellspacing="0" cellpadding="0" border="0">';
		for ( $i = 1; $i <= $nrows; $i++ )
		{ // the rows
			$y1 = $rows[ $i -1 ];
			$y2 = $rows[ $i ];
			if ( $y1 == $y2 )
			{ // if the row is 0px big it can be skipped
				continue;
			}
			$out .= '<tr>';
			for ( $ii = 1; $ii <= $ncols; $ii++ )
			{ // the cols
				$x1 = $cols[ $ii - 1 ];
				$x2 = $cols[ $ii ];
				
				if ( $x1 == $x2 )
				{ // if the col is 0px big it can be skipped
					continue;
				}
				
				// make empty image
				$im = imagecreatetruecolor( $x2-$x1, $y2-$y1 );
				// paste part of the captcha onto it
				imagecopy( $im, $img, 0, 0, $x1, $y1, $x2, $y2 );
				// save it to cache
				imagejpeg( $im, $tosave . "_$i:$ii.jpg" );
				// don't need it anymore
				imagedestroy( $im );
				// add to table
				$out .= "<td><img src=\"$Cl_root_path4template$tosave" . "_$i:$ii.jpg\"/></td>";
				// add to filelist
				$filelist[] = $tosave . "_$i:$ii.jpg";
			}
			$out .= '</tr>';
		}
		$out .= '</table>';
		imagedestroy( $img );
		
		// now store the filelist to cache
		$cache->push( $userdata[ 'sid' ] . 'captchalist', $filelist, TRUE, ESSENTIAL );
		// find the shortest and longest used word
		$sh = array( 200, 0 );
		$lng = array( 0, 0 );
		for ( $i = 0; $i < count( $wordlist ); $i++ )
		{
			$l = strlen( $wordlist[ $i ] );
			if ( $l < $sh[ 0 ] )
			{ // shorter than the "shortest"
				$sh[ 0 ] = $l;
				$sh[ 1 ] = $i;
			}
			if ( $l > $lng[ 0 ] )
			{ // longer than the "longest"
				$lng[ 0 ] = $l;
				$lng[ 1 ] = $i;
			}
		}
		// save this too, but encrypted so it cannot be abused
		$w1 = $encryption->encrypt( $security->make_key( 'short' ), $wordlist[ $sh[ 1 ] ], 15 );
		$w2 = $encryption->encrypt( $security->make_key( 'long' ), $wordlist[ $lng[ 1 ] ], 15 );
		$cache->push( $userdata[ 'sid' ] . 'captchawords', array( $w1, $w2 ), TRUE, ESSENTIAL );
		
		return $out;
	}
	
	// this cleans the captcha images from cache
	function cleancaptcha()
	{
		global $cache, $userdata;
		
		// get filelist
		$list = $cache->pull( $userdata[ 'sid' ] . 'captchalist', ESSENTIAL );
		
		if ( empty( $list ) )
		{ // nothing to do
			return;
		}
		
		foreach( $list as $file )
		{ // delete each one
			@unlink( $file );
		}
	}
It's been coded for chlorine boards so yeah, changes will be needed for it to work.

A live example can be found here

The only problem this actually has atm is that sometimes it is hard to tell which word exactly to input, and that sometimes trash is left behind in the cache, everything else is mmkay I think.

If anyone can break it, please please pleas tell me :)
rcardona
Registered User
Posts: 41
Joined: Fri Mar 26, 2004 3:57 am
Location: Austin, TX, USA

Post by rcardona »

Thanks for the mod A_Jelly_Doughnut.

What font is the mod supposed be using? All I'm getting are backgrounds with no foreground sequence.

Any ideas? I'll see if can dig it up myself...
User avatar
A_Jelly_Doughnut
Former Team Member
Posts: 34457
Joined: Sat Jan 18, 2003 1:26 am
Location: Where the Rivers Run
Contact:

Post by A_Jelly_Doughnut »

The fonts are included in the package -- the 5 .gdf files are fonts.
A Donut's Blog
"Bach's Prelude (Cello Suite No. 1) is driving Indiana country roads in Autumn" - Ann Kish
rcardona
Registered User
Posts: 41
Joined: Fri Mar 26, 2004 3:57 am
Location: Austin, TX, USA

Post by rcardona »

I found the problem in freecap's usage of imageloadfont():

Code: Select all

int imageloadfont ( string file )
...
The font file format is currently binary and architecture dependent. This means you should generate the font files on the same type of CPU as the machine you are running PHP on.
The fonts included in freecap are for a little-endian processor architecture such as x86. I'm running on a big-endian processor. I'll have to convert my own fonts.
rcardona
Registered User
Posts: 41
Joined: Fri Mar 26, 2004 3:57 am
Location: Austin, TX, USA

Post by rcardona »

A_Jelly_Doughnut,
After some intense debugging I finally got your freecap port to work. Fixing the fonts for big-endian only involved modifying the first 16 bytes of the font file.

Then I spent a few more hours debugging a bug in freecap()...
In this block of code

Code: Select all

// read each font and get font character widths
$font_widths = array();
for ($i = 0; $i < sizeof($font_locations); $i++)
{
	$handle = fopen($font_locations[$i], 'r');
	// read header of GD font, up to char width
	$c_wid = fread($handle,11);
	$font_widths[$i] = ord($c_wid{8}) + ord($c_wid{9}) + ord($c_wid{10}) + ord($c_wid{11});
	fclose($handle);
}
On the fread() statement, it really needs to read in 12 bytes. The array offsets are zero-based but the absolute count is not. So on my system all font widths were 0! :(

I changed the fread() to 12 and then everything worked.

There's another very unlikely bug: the font width is not the sum of the ords. Each width byte must be shifted by its bit position or multiplied by 2^(bit position). It won't matter since any font with a width over 255 probably won't work here anyway. I just thought I'd point it out. The problem is you have to know the proc architecure order to know which bytes to multiply or shift. It doesn't matter for now.

Thanks again for the mod and port.
rcardona
Registered User
Posts: 41
Joined: Fri Mar 26, 2004 3:57 am
Location: Austin, TX, USA

Post by rcardona »

I found aronchav's eval() bug:

Code: Select all

					$logic = 'return strtolower($row[\'code\'])) != strtolower($confirm_code);';

Has one too many )'s for the first strtolower(). This is from the latest zip, enhanced_002.zip.

I had to fix that too to get registration to work.
User avatar
A_Jelly_Doughnut
Former Team Member
Posts: 34457
Joined: Sat Jan 18, 2003 1:26 am
Location: Where the Rivers Run
Contact:

Post by A_Jelly_Doughnut »

Both are noted, I'll probably put out 0.0.3 soon. I'll also forward them to the author of Freecap itself.

Big-endian means Sun UltraSparc or IBM Power, and maybe PowerPC, correct? I'm going to include the font-building note in the author notes.
A Donut's Blog
"Bach's Prelude (Cello Suite No. 1) is driving Indiana country roads in Autumn" - Ann Kish
Post Reply

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