version 1.1094, 2012/08/25 04:34:44
|
version 1.1095, 2012/08/27 06:28:06
|
Line 14070 sub captcha_display {
|
Line 14070 sub captcha_display {
|
my ($context,$lonhost) = @_; |
my ($context,$lonhost) = @_; |
my ($output,$error); |
my ($output,$error); |
my ($captcha,$pubkey,$privkey) = &get_captcha_config($context,$lonhost); |
my ($captcha,$pubkey,$privkey) = &get_captcha_config($context,$lonhost); |
if ($captcha eq 'captcha') { |
if ($captcha eq 'original') { |
$output = &create_captcha(); |
$output = &create_captcha(); |
unless ($output) { |
unless ($output) { |
$error = 'captcha'; |
$error = 'captcha'; |
Line 14078 sub captcha_display {
|
Line 14078 sub captcha_display {
|
} elsif ($captcha eq 'recaptcha') { |
} elsif ($captcha eq 'recaptcha') { |
$output = &create_recaptcha($pubkey); |
$output = &create_recaptcha($pubkey); |
unless ($output) { |
unless ($output) { |
$error = 'recpatcha'; |
$error = 'recaptcha'; |
} |
} |
} |
} |
return ($output,$error); |
return ($output,$error); |
Line 14088 sub captcha_response {
|
Line 14088 sub captcha_response {
|
my ($context,$lonhost) = @_; |
my ($context,$lonhost) = @_; |
my ($captcha_chk,$captcha_error); |
my ($captcha_chk,$captcha_error); |
my ($captcha,$pubkey,$privkey) = &get_captcha_config($context,$lonhost); |
my ($captcha,$pubkey,$privkey) = &get_captcha_config($context,$lonhost); |
if ($captcha eq 'captcha') { |
if ($captcha eq 'original') { |
($captcha_chk,$captcha_error) = &check_captcha(); |
($captcha_chk,$captcha_error) = &check_captcha(); |
} elsif ($captcha eq 'recaptcha') { |
} elsif ($captcha eq 'recaptcha') { |
$captcha_chk = &check_recaptcha($privkey); |
$captcha_chk = &check_recaptcha($privkey); |
Line 14100 sub captcha_response {
|
Line 14100 sub captcha_response {
|
|
|
sub get_captcha_config { |
sub get_captcha_config { |
my ($context,$lonhost) = @_; |
my ($context,$lonhost) = @_; |
my ($captcha,$pubkey,$privkey); |
my ($captcha,$pubkey,$privkey,$hashtocheck); |
my $hostname = &Apache::lonnet::hostname($lonhost); |
my $hostname = &Apache::lonnet::hostname($lonhost); |
my $serverhomeID = &Apache::lonnet::get_server_homeID($hostname); |
my $serverhomeID = &Apache::lonnet::get_server_homeID($hostname); |
my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID); |
my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID); |
my %domconfig = &Apache::lonnet::get_dom('configuration',[$context],$serverhomedom); |
if ($context eq 'usercreation') { |
if (ref($domconfig{$context}) eq 'HASH') { |
my %domconfig = &Apache::lonnet::get_dom('configuration',[$context],$serverhomedom); |
if ($domconfig{$context}{'captcha'} eq 'recaptcha') { |
if (ref($domconfig{$context}) eq 'HASH') { |
if (ref($domconfig{$context}{'recaptchakeys'}) eq 'HASH') { |
$hashtocheck = $domconfig{$context}{'cancreate'}; |
$pubkey = $domconfig{$context}{'recaptchakeys'}{'public'}; |
if (ref($hashtocheck) eq 'HASH') { |
$privkey = $domconfig{$context}{'recaptchakeys'}{'private'}; |
if ($hashtocheck->{'captcha'} eq 'recaptcha') { |
|
if (ref($hashtocheck->{'recaptchakeys'}) eq 'HASH') { |
|
$pubkey = $hashtocheck->{'recaptchakeys'}{'public'}; |
|
$privkey = $hashtocheck->{'recaptchakeys'}{'private'}; |
|
} |
|
if ($privkey && $pubkey) { |
|
$captcha = 'recaptcha'; |
|
} else { |
|
$captcha = 'original'; |
|
} |
|
} elsif ($hashtocheck->{'captcha'} ne 'notused') { |
|
$captcha = 'original'; |
|
} |
} |
} |
|
} else { |
|
$captcha = 'captcha'; |
|
} |
|
} elsif ($context eq 'login') { |
|
my %domconfhash = &Apache::loncommon::get_domainconf($serverhomedom); |
|
if ($domconfhash{$serverhomedom.'.login.captcha'} eq 'recaptcha') { |
|
$pubkey = $domconfhash{$serverhomedom.'.login.recaptchakeys_public'}; |
|
$privkey = $domconfhash{$serverhomedom.'.login.recaptchakeys_private'}; |
if ($privkey && $pubkey) { |
if ($privkey && $pubkey) { |
$captcha = 'recaptcha'; |
$captcha = 'recaptcha'; |
|
} else { |
|
$captcha = 'original'; |
} |
} |
} elsif ($domconfig{$context}{'captcha'} eq 'notused') { |
} elsif ($domconfhash{$serverhomedom.'.login.captcha'} eq 'original') { |
$captcha = ''; |
$captcha = 'original'; |
} elsif ($domconfig{$context}{'captcha'} eq 'captcha') { |
|
$captcha = 'captcha'; |
|
} else { |
|
if ($context eq 'usercreation') { |
|
$captcha = 'captcha'; |
|
} |
|
} |
} |
} |
} |
return ($captcha,$pubkey,$privkey); |
return ($captcha,$pubkey,$privkey); |