[pmwiki-users] captcha / newgroupbox problem

adam overton a at plus1plus1plus.org
Wed Jul 16 03:19:07 CDT 2008


hi
i've currently got my own implementation of newgroupbox with captcha  
inserted into it.
i thought everything was working alright, until i noticed this:
whenever the user quits and restarts their browser, and then goes to  
the newgroupbox page for the first time [of the session], the captcha  
always fails, even if you've entered in the correct code. however,  
every subsequent use of the newgroupbox + captcha works as expected -  
until you quit & then restart the browser...
wondering if anyone might have any ideas. i've been looking thru the  
captcha.php code, and i'm thinking some part of the captcha recipe  
must not be getting executed, but i can't tell which.

btw, i'm noticing in the resulting source that the captcha only fails  
when the captchakey value is set to 0:
	<input type='hidden' name='captchakey' value='0' />
	anti-spam code: <em class='access'><img src='http:// 
uploaddownloadperform.net/UDP/Upload? 
action=captchaimage&amp;captchakey=0' border='0' align='top' />

below is the code i'm using in newgroupbox
notice anything wrong? is there another function from captcha i need  
to call?
many thanks,
a

. . .

function NewGroupBox($pagename, $opt) {
	global $ScriptUrl,
	/* ao - added captcha global vars */
	$EnablePostCaptchaRequired, $CaptchaKey, $CaptchaName;
	
	$CaptchaImage = CaptchaImage($pagename);    // ao - call captcha  
image func - must call this here in order for $CaptchaKey to get  
loaded with a value
	
	$defaults = array(
		#'size'   => '30',
		'label' => FmtPageName(' $[Create a new group called:] ', $pagename),
		'button' => 'left',
	);
	$opt = array_merge($defaults, ParseArgs($opt));
	
	$buttonHTML = "    <input class='inputbutton newpagebutton'  
type='submit' value='{$opt['label']}' /> \n";
	$onfocusHTML = "
		 onfocus=\"if(this.value=='{$opt['value']}') {this.value=''}\"  
onblur=\"if(this.value=='') {this.value='{$opt['value']}'}\" ";
	$out = "\n  <form class='newgroup' action='$PageUrl' method='post'>
		<input type='hidden' name='n' value='$pagename' />
		<input type='hidden' name='action' value='newgroup' /> \n".
		($opt['value'] ? "    <input type='hidden' name='value' value='{$opt 
['value']}' /> \n" : "").
		($opt['focus'] ? "    <input type='hidden' name='focus' value='{$opt 
['focus']}' /> \n" : "").
		($opt['base'] ? "    <input type='hidden' name='base' value='{$opt 
['base']}' /> \n" : "").
		($opt['save'] ? "    <input type='hidden' name='save' value='{$opt 
['save']}' /> \n" : "").
		($opt['autogroup'] ? "    <input type='hidden' name='autogroup'  
value='{$opt['autogroup']}' /> \n" : "").
		($opt['template'] ? "    <input type='hidden' name='template'  
value='{$opt['template']}' /> \n" : "").
		($opt['autopages'] ? "    <input type='hidden' name='autopages'  
value='{$opt['autopages']}' /> \n" : "").
		"    <input class='inputbox newpagetext' type='text' name='name'  
value='{$opt['value']}' size='{$opt['size']}'" .
		($opt['focus']=="true" ? $onfocusHTML : "").
		"/> \n" .
		/// ao - captcha markup ///
		($EnablePostCaptchaRequired==1 ? "<br /><input type='hidden'  
name='captchakey' value='{$CaptchaKey}' />
		anti-spam code: <em class='access'>".$CaptchaImage."</em> <input  
type='text' name='{$CaptchaName}' size='5' class='inputbox' /> " : "").
		"<br />".
		($opt['button']=="left" ? $buttonHTML : "").
		($opt['button']=="right" ? $buttonHTML : "").
			
		"  </form>";
		return Keep($out);
}

. . .



More information about the pmwiki-users mailing list