--- loncom/interface/createaccount.pm 2012/02/13 05:24:22 1.40.2.5.2.5 +++ loncom/interface/createaccount.pm 2012/02/13 17:22:56 1.40.2.5.2.6 @@ -3,7 +3,7 @@ # institutional log-in ID (institutional authentication required - localauth # or kerberos) or an e-mail address. # -# $Id: createaccount.pm,v 1.40.2.5.2.5 2012/02/13 05:24:22 raeburn Exp $ +# $Id: createaccount.pm,v 1.40.2.5.2.6 2012/02/13 17:22:56 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -57,6 +57,8 @@ sub handler { my $sso_username = $r->subprocess_env->get('REDIRECT_SSOUserUnknown'); my $sso_domain = $r->subprocess_env->get('REDIRECT_SSOUserDomain'); + my $privkey = $r->subprocess_env->get('reCAPTCHA_PRIVATE'); + my $pubkey = $r->subprocess_env->get('reCAPTCHA_PUBLIC') &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['token','courseid']); &Apache::lonacc::get_posted_cgi($r); @@ -225,7 +227,7 @@ sub handler { $output = &process_email_request($env{'form.useremail'},$domain,$domdesc, $contact_name,$contact_email,$cancreate, $lonhost,$domconfig{'usercreation'}, - $courseid); + $courseid,$privkey); } elsif (!$token) { &print_header($r,$start_page,$courseid); my $now=time; @@ -238,7 +240,7 @@ sub handler { $r->print(&javascript_validmail()); } $output = &print_username_form($domain,$domdesc,$cancreate,$now,$lonhost, - $courseid); + $courseid,$pubkey); } $r->print($output); &print_footer($r); @@ -398,7 +400,7 @@ ENDSCRIPT } sub print_username_form { - my ($domain,$domdesc,$cancreate,$now,$lonhost,$courseid) = @_; + my ($domain,$domdesc,$cancreate,$now,$lonhost,$courseid,$pubkey) = @_; my %lt = &Apache::lonlocal::texthash ( unam => 'username', udom => 'domain', @@ -433,7 +435,7 @@ sub print_username_form { $lt{'inst'}.'
'. $lt{'aftr'}.'
'. $lt{'thes'}.'
'; - my $captchaform = &create_recaptcha(); + my $captchaform = &create_recaptcha($pubkey); if ($captchaform) { my $submit_text = &mt('Sign-up'); my $emailform = ''; @@ -527,7 +529,7 @@ sub login_box { sub process_email_request { my ($useremail,$domain,$domdesc,$contact_name,$contact_email,$cancreate, - $server,$settings,$courseid) = @_; + $server,$settings,$courseid,$privkey) = @_; $useremail = lc($env{'form.useremail'}); my $output; if (ref($cancreate) eq 'ARRAY') { @@ -549,7 +551,7 @@ sub process_email_request { my $captcha = Captcha::reCAPTCHA->new; my $captcha_result = $captcha->check_answer( - 'PRIVATEKEY', + $privkey, $ENV{'REMOTE_ADDR'}, $env{'form.recaptcha_challenge_field'}, $env{'form.recaptcha_response_field'}, @@ -1210,10 +1212,11 @@ sub linkto_email_help { } sub create_recaptcha { + my ($pubkey) = @_; my $captcha = Captcha::reCAPTCHA->new; # generate PUBLICKEY from https://www.google.com/recaptcha return $captcha->get_options_setter({theme => 'white'})."\n". - $captcha->get_html('PUBLICKEY'); + $captcha->get_html($pubkey); } sub getkeys {