[vhffs-dev] [1344] added an option to enable/disable captcha check while subscribing

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1344
Author:   gradator
Date:     2009-02-18 09:06:59 +0100 (Wed, 18 Feb 2009)

Log Message:
-----------
added an option to enable/disable captcha check while subscribing

Modified Paths:
--------------
    trunk/vhffs-backend/conf/vhffs.conf.dist.in
    trunk/vhffs-panel/subscribe.pl
    trunk/vhffs-panel/templates/user/create.tmpl


Modified: trunk/vhffs-backend/conf/vhffs.conf.dist.in
===================================================================
--- trunk/vhffs-backend/conf/vhffs.conf.dist.in	2009-02-18 07:29:06 UTC (rev 1343)
+++ trunk/vhffs-backend/conf/vhffs.conf.dist.in	2009-02-18 08:06:59 UTC (rev 1344)
@@ -75,6 +75,9 @@
 	# The default theme
 	default_theme		=	vhffs
 
+	# Use captcha ?  Beware, this is going to make subscription impossible by blind users
+	use_captcha		=	no
+
 	# Captcha key, 12 hexadecimal characters [0-9a-f]{12}
 	captchakey		=	a1b2c3d4e5f6
 

Modified: trunk/vhffs-panel/subscribe.pl
===================================================================
--- trunk/vhffs-panel/subscribe.pl	2009-02-18 07:29:06 UTC (rev 1343)
+++ trunk/vhffs-panel/subscribe.pl	2009-02-18 08:06:59 UTC (rev 1344)
@@ -66,6 +66,7 @@
 my $template;
 my $message;
 
+my $usecaptcha = Vhffs::Functions::strtoboolean( $vhffs->get_config->get_panel->{'use_captcha'} );
 my $captchakey = $vhffs->get_config->get_panel->{'captchakey'};
 
 if( $vhffs->get_config->get_allow_subscribe == 0 )
@@ -91,15 +92,19 @@
 	my $zipcode    = Encode::decode_utf8( $cgi->param("ZIPCODE") );
 	my $country    = Encode::decode_utf8( $cgi->param("COUNTRY") );
 	my $address    = Encode::decode_utf8( $cgi->param("ADDRESS") );
-    	my $codeuser   = $cgi->param('CONFIRMATION');
-	my $hexcode    = $cgi->param('CODE');
-	my $code = pack('H12', $hexcode);
-	$code ^= pack('H12', $captchakey) if defined $captchakey;
 
-	if( ( ! defined $code ) || ( $codeuser ne $code ) )
-	{
-		push(@errors, {error => gettext("Codes do not match")});
+	if( $usecaptcha ) {
+	    	my $codeuser   = $cgi->param('CONFIRMATION');
+		my $hexcode    = $cgi->param('CODE');
+		my $code = pack('H12', $hexcode);
+		$code ^= pack('H12', $captchakey) if defined $captchakey;
+
+		if( ( ! defined $code ) || ( $codeuser ne $code ) )
+		{
+			push(@errors, {error => gettext("Codes do not match")});
+		}
 	}
+
 	if( ! defined $username )
 	{
 		push(@errors, {error => gettext("You must declare your username")});
@@ -225,16 +230,20 @@
     $template->param( SEND                  => gettext("Subscribe") );
     $template->param( BACK                  => gettext("Back to Login") );
 
-	my $captcha = Vhffs::Panel::Captcha->new;
-	my $code = $captcha->generate_random_string( 6 );
-	$code ^= pack('H12', $captchakey) if defined $captchakey;
-	my $hex = unpack('H12', $code);
-	$template->param( CODE   => $hex );
+	$template->param( USECAPTCHA            => $usecaptcha );
+	if( $usecaptcha ) {
+		my $captcha = Vhffs::Panel::Captcha->new;
+		my $code = $captcha->generate_random_string( 6 );
+		$code ^= pack('H12', $captchakey) if defined $captchakey;
+		my $hex = unpack('H12', $code);
+		$template->param( CODE   => $hex );
 
-    $template->param( CONFIRMATION_TEXT             => gettext('Code confirmation') );
-    $template->param( REPEAT_CONFIRMATION_TEXT      => gettext('Recopy the code') );
-    $template->param( CONFIRMATION_ALT              => gettext('Confirmation code, contact administrator team if you can\'t read it') );
-    $template->param( CONFIRMATION_SOUND_TEXT    => gettext('Or listen to the code') );
+		$template->param( CONFIRMATION_TEXT             => gettext('Code confirmation') );
+		$template->param( REPEAT_CONFIRMATION_TEXT      => gettext('Recopy the code') );
+		$template->param( CONFIRMATION_ALT              => gettext('Confirmation code, contact administrator team if you can\'t read it') );
+		$template->param( CONFIRMATION_SOUND_TEXT    => gettext('Or listen to the code') );
+	}
+
     $template->param( USERNAME_TIP_TEXT => gettext('Your username. It must contains only alphanumeric characters in lowercase, its length must be between 3 and 12 chars') );
     $template->param( EMAIL_TIP_TEXT => gettext('Your email address. It will be used to contact you when needed and as a destination address if you use our email forwarding service') );
 }

Modified: trunk/vhffs-panel/templates/user/create.tmpl
===================================================================
--- trunk/vhffs-panel/templates/user/create.tmpl	2009-02-18 07:29:06 UTC (rev 1343)
+++ trunk/vhffs-panel/templates/user/create.tmpl	2009-02-18 08:06:59 UTC (rev 1344)
@@ -60,6 +60,7 @@
 					</label>
 					<span><input type="text" name="ZIPCODE" id="ZIPCODE" maxlength="16" value="<TMPL_VAR ESCAPE=1 NAME="ZIPCODE_VALUE">" onkeyup="javascript:check(this.id, validZip);" onchange="javascript:check(this.id, validZip);"/>&nbsp;</span>
 				</p>
+<TMPL_IF NAME="USECAPTCHA">
 				<p>
 					<label for="CONFIRMATION">
 						<TMPL_VAR ESCAPE=1 NAME="CONFIRMATION_TEXT">
@@ -73,6 +74,7 @@
 					<input type="text" name="CONFIRMATION"  id="CONFIRMATION" maxlength="16"/>
 				</p>
 					<input type="hidden" name="CODE" id="CODE" value="<TMPL_VAR ESCAPE=1 NAME="CODE">"/>
+</TMPL_IF>
 				<p class="button">
 					<input type="submit" value="<TMPL_VAR ESCAPE=1 NAME="SEND">" name="CREATE_SUBMIT"/>
 				</p>


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/