version 1.40.2.5.2.3, 2012/02/11 23:30:16
|
version 1.48, 2012/05/16 21:19:39
|
Line 39 use Apache::lonhtmlcommon;
|
Line 39 use Apache::lonhtmlcommon;
|
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonauth; |
use Apache::lonauth; |
use Apache::resetpw; |
use Apache::resetpw; |
use Captcha::reCAPTCHA; |
use Authen::Captcha; |
use DynaLoader; # for Crypt::DES version |
use DynaLoader; # for Crypt::DES version |
use Crypt::DES; |
use Crypt::DES; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
use HTML::Entities; |
use HTML::Entities; |
|
|
|
#TODO this module needs documentation |
|
|
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
Line 65 sub handler {
|
Line 67 sub handler {
|
if ($sso_username ne '' && $sso_domain ne '') { |
if ($sso_username ne '' && $sso_domain ne '') { |
$domain = $sso_domain; |
$domain = $sso_domain; |
} else { |
} else { |
$domain = &Apache::lonnet::default_login_domain(); |
($domain, undef) = Apache::lonnet::is_course($env{'form.courseid'}); |
if (defined($env{'form.courseid'})) { |
$domain ||= &Apache::lonnet::default_login_domain(); |
if (&validate_course($env{'form.courseid'})) { |
|
if ($env{'form.courseid'} =~ /^($match_domain)_($match_courseid)$/) { |
|
$domain = $1; |
|
} |
|
} |
|
} |
|
} |
} |
my $domdesc = &Apache::lonnet::domain($domain,'description'); |
my $domdesc = &Apache::lonnet::domain($domain,'description'); |
my $contact_name = &mt('LON-CAPA helpdesk'); |
my $contact_name = &mt('LON-CAPA helpdesk'); |
Line 98 sub handler {
|
Line 94 sub handler {
|
} |
} |
|
|
my ($js,$courseid,$title); |
my ($js,$courseid,$title); |
if (defined($env{'form.courseid'})) { |
$courseid = Apache::lonnet::is_course($env{'form.courseid'}); |
$courseid = &validate_course($env{'form.courseid'}); |
|
} |
|
if ($courseid ne '') { |
if ($courseid ne '') { |
$js = &catreturn_js(); |
$js = &catreturn_js(); |
$title = 'Self-enroll in a LON-CAPA course'; |
$title = 'Self-enroll in a LON-CAPA course'; |
Line 128 sub handler {
|
Line 122 sub handler {
|
return OK; |
return OK; |
} else { |
} else { |
$start_page = |
$start_page = |
&Apache::loncommon::start_page($title,$js, |
&Apache::loncommon::start_page($title,$js); |
{'no_inline_link' => 1,}); |
|
&print_header($r,$start_page,$courseid); |
&print_header($r,$start_page,$courseid); |
$r->print($output); |
$r->print($output); |
&print_footer($r); |
&print_footer($r); |
Line 137 sub handler {
|
Line 130 sub handler {
|
} |
} |
} |
} |
$start_page = |
$start_page = |
&Apache::loncommon::start_page($title,$js, |
&Apache::loncommon::start_page($title,$js); |
{'no_inline_link' => 1,}); |
|
my %domconfig = |
my %domconfig = |
&Apache::lonnet::get_dom('configuration',['usercreation'],$domain); |
&Apache::lonnet::get_dom('configuration',['usercreation'],$domain); |
my ($cancreate,$statustocreate) = &get_creation_controls($domain,$domconfig{'usercreation'}); |
my ($cancreate,$statustocreate) = &get_creation_controls($domain,$domconfig{'usercreation'}); |
Line 146 sub handler {
|
Line 139 sub handler {
|
&print_header($r,$start_page,$courseid); |
&print_header($r,$start_page,$courseid); |
my $output = '<h3>'.&mt('Account creation unavailable').'</h3>'. |
my $output = '<h3>'.&mt('Account creation unavailable').'</h3>'. |
'<span class="LC_warning">'. |
'<span class="LC_warning">'. |
&mt('Creation of a new user account using an e-mail address or an institutional log-in ID as username is not permitted for [_1].',$domdesc).'</span><br /><br />'; |
&mt('Creation of a new user account using an e-mail address or an institutional log-in ID as username is not permitted at this institution ([_1]).',$domdesc).'</span><br /><br />'; |
$r->print($output); |
$r->print($output); |
&print_footer($r); |
&print_footer($r); |
return OK; |
return OK; |
Line 245 sub handler {
|
Line 238 sub handler {
|
return OK; |
return OK; |
} |
} |
|
|
sub get_custom_name { |
|
my ($domain) = @_; |
|
if ($domain eq 'relate') { |
|
return 'Learn-Physics'; |
|
} else { |
|
return lc($domain); |
|
} |
|
} |
|
|
|
sub print_header { |
sub print_header { |
my ($r,$start_page,$courseid) = @_; |
my ($r,$start_page,$courseid) = @_; |
$r->print($start_page); |
$r->print($start_page); |
Line 305 sub selfenroll_crumbs {
|
Line 289 sub selfenroll_crumbs {
|
return; |
return; |
} |
} |
|
|
sub validate_course { |
|
my ($courseid) = @_; |
|
my ($cdom,$cnum) = ($courseid =~ /^($match_domain)_($match_courseid)$/); |
|
if (($cdom ne '') && ($cnum ne '')) { |
|
if (&Apache::lonnet::is_course($cdom,$cnum)) { |
|
return ($courseid); |
|
} |
|
} |
|
return; |
|
} |
|
|
|
sub javascript_setforms { |
sub javascript_setforms { |
my ($now) = @_; |
my ($now) = @_; |
my $js = <<ENDSCRIPT; |
my $js = <<ENDSCRIPT; |
Line 382 function validate_email() {
|
Line 355 function validate_email() {
|
if (validmail(field) == false) { |
if (validmail(field) == false) { |
alert("$lt{'email'}: "+field.value+" $lt{'notv'}."); |
alert("$lt{'email'}: "+field.value+" $lt{'notv'}."); |
return false; |
return false; |
} else { |
|
var emailaddr = field.value; |
|
var lcemail = emailaddr.toLowerCase(); |
|
if (emailaddr != lcemail) { |
|
field.value = lcemail; |
|
alert("Learn-Physics usernames are all lower case.\\nAccordingly your username will be "+lcemail+" once activated."); |
|
} |
|
} |
} |
return true; |
return true; |
} |
} |
Line 417 sub print_username_form {
|
Line 383 sub print_username_form {
|
} |
} |
} |
} |
if (grep(/^email$/,@{$cancreate})) { |
if (grep(/^email$/,@{$cancreate})) { |
$output .= '<div class="LC_left_float"><h3>'.&mt('Create account with an e-mail address as your username').'</h3>'. |
$output .= '<div class="LC_left_float"><h3>'.&mt('Create account with an e-mail address as your username').'</h3>'; |
&mt('You are about to sign-up for a Learn Physics account so you can take the pre-requisite test for enrollment in the online course.').'<br />'. |
my $captchaform = &create_captcha(); |
&mt('Your performance on the test will help both you and us gauge your readiness to take the course.').'<br />'. |
|
&mt('Although the pre-test exam will be the basis for admitting people into the course, we can only accommodate a limited number of students.').'<br />'. |
|
&mt('We will e-mail you with instructions on how to access the course by the end of February, if we are able to accommodate you.').'<br />'; |
|
my $captchaform = &create_recaptcha(); |
|
if ($captchaform) { |
if ($captchaform) { |
my $submit_text = &mt('Sign-up'); |
my $submit_text = &mt('Request LON-CAPA account'); |
my $emailform = '<input type="text" name="useremail" size="25" value="" />'; |
my $emailform = '<input type="text" name="useremail" size="25" value="" />'; |
if (grep(/^login$/,@{$cancreate})) { |
if (grep(/^login$/,@{$cancreate})) { |
$output .= &mt('Provide your e-mail address to sign up for a Learn Physics account if you do not have a log-in ID at your institution.','<br />').'<br /><br />'; |
$output .= &mt('Provide your e-mail address to request a LON-CAPA account,[_1] if you do not have a log-in ID at your institution.','<br />').'<br /><br />'; |
} else { |
} else { |
$output .= '<br />'; |
$output .= '<br />'; |
} |
} |
Line 439 sub print_username_form {
|
Line 401 sub print_username_form {
|
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_title(&mt('Validation'), |
&Apache::lonhtmlcommon::row_title(&mt('Validation'), |
'LC_pick_box_title')."\n". |
'LC_pick_box_title')."\n". |
$captchaform."\n". |
$captchaform."\n".'<br /><br />'; |
&mt('If either word is hard to read, [_1] will replace them.','<image src="/res/adm/pages/refresh.gif" alt="reCAPTCHA refresh" />').'<br /><br />'; |
|
if ($courseid ne '') { |
if ($courseid ne '') { |
$output .= '<input type="hidden" name="courseid" value="'.$courseid.'"/>'."\n"; |
$output .= '<input type="hidden" name="courseid" value="'.$courseid.'"/>'."\n"; |
} |
} |
Line 487 sub login_box {
|
Line 448 sub login_box {
|
my $unameform = '<input type="text" name="uname" size="20" value="" />'; |
my $unameform = '<input type="text" name="uname" size="20" value="" />'; |
my $upassform = '<input type="password" name="upass'.$now.'" size="20" />'; |
my $upassform = '<input type="password" name="upass'.$now.'" size="20" />'; |
$output .= '<form name="client" method="post" action="" onsubmit="return(send());">'."\n". |
$output .= '<form name="client" method="post" action="" onsubmit="return(send());">'."\n". |
'<input type="hidden" name="udom" value="'.$domain.'" />'. |
|
&Apache::lonhtmlcommon::start_pick_box()."\n". |
&Apache::lonhtmlcommon::start_pick_box()."\n". |
&Apache::lonhtmlcommon::row_title($titles{$context}, |
&Apache::lonhtmlcommon::row_title($titles{$context}, |
'LC_pick_box_title')."\n". |
'LC_pick_box_title')."\n". |
Line 495 sub login_box {
|
Line 455 sub login_box {
|
&Apache::lonhtmlcommon::row_closure(1)."\n". |
&Apache::lonhtmlcommon::row_closure(1)."\n". |
&Apache::lonhtmlcommon::row_title(&mt('Password'), |
&Apache::lonhtmlcommon::row_title(&mt('Password'), |
'LC_pick_box_title')."\n". |
'LC_pick_box_title')."\n". |
$upassform. |
$upassform; |
&Apache::lonhtmlcommon::row_closure(1). |
if ($context eq 'selfenroll') { |
|
my $udomform = '<input type="text" name="udom" size="10" value="'. |
|
$domain.'" />'; |
|
$output .= &Apache::lonhtmlcommon::row_closure(1)."\n". |
|
&Apache::lonhtmlcommon::row_title(&mt('Domain'), |
|
'LC_pick_box_title')."\n". |
|
$udomform."\n"; |
|
} else { |
|
$output .= '<input type="hidden" name="udom" value="'.$domain.'" />'; |
|
} |
|
$output .= &Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_title(). |
&Apache::lonhtmlcommon::row_title(). |
'<br /><input type="submit" name="username_validation" value="'. |
'<br /><input type="submit" name="username_validation" value="'. |
$submit_text.'" />'."\n"; |
$submit_text.'" />'."\n"; |
Line 517 sub login_box {
|
Line 487 sub login_box {
|
sub process_email_request { |
sub process_email_request { |
my ($useremail,$domain,$domdesc,$contact_name,$contact_email,$cancreate, |
my ($useremail,$domain,$domdesc,$contact_name,$contact_email,$cancreate, |
$server,$settings,$courseid) = @_; |
$server,$settings,$courseid) = @_; |
$useremail = lc($env{'form.useremail'}); |
$useremail = $env{'form.useremail'}; |
my $output; |
my $output; |
if (ref($cancreate) eq 'ARRAY') { |
if (ref($cancreate) eq 'ARRAY') { |
if (!grep(/^email$/,@{$cancreate})) { |
if (!grep(/^email$/,@{$cancreate})) { |
Line 532 sub process_email_request {
|
Line 502 sub process_email_request {
|
my $uhome = &Apache::lonnet::homeserver($useremail,$domain); |
my $uhome = &Apache::lonnet::homeserver($useremail,$domain); |
if ($uhome ne 'no_host') { |
if ($uhome ne 'no_host') { |
$output = &invalid_state('existinguser',$domdesc, |
$output = &invalid_state('existinguser',$domdesc, |
$contact_name,$contact_email,'',$useremail); |
$contact_name,$contact_email); |
return $output; |
return $output; |
} else { |
} else { |
my $captcha = Captcha::reCAPTCHA->new; |
my $code = $env{'form.code'}; |
my $captcha_result = |
my $md5sum = $env{'form.crypt'}; |
$captcha->check_answer( |
my %captcha_params = &captcha_settings(); |
'PRIVATEKEY', |
my $captcha = Authen::Captcha->new( |
$ENV{'REMOTE_ADDR'}, |
output_folder => $captcha_params{'output_dir'}, |
$env{'form.recaptcha_challenge_field'}, |
data_folder => $captcha_params{'db_dir'}, |
$env{'form.recaptcha_response_field'}, |
); |
); |
my $captcha_chk = $captcha->check_code($code,$md5sum); |
# PRIVATE key from https://www.google.com/recaptcha |
my %captcha_hash = ( |
if (!$captcha_result->{is_valid}) { |
0 => 'Code not checked (file error)', |
|
-1 => 'Failed: code expired', |
|
-2 => 'Failed: invalid code (not in database)', |
|
-3 => 'Failed: invalid code (code does not match crypt)', |
|
); |
|
if ($captcha_chk != 1) { |
$output = &invalid_state('captcha',$domdesc,$contact_name, |
$output = &invalid_state('captcha',$domdesc,$contact_name, |
$contact_email); |
$contact_email,$captcha_hash{$captcha_chk}); |
|
|
return $output; |
return $output; |
} |
} |
my $uhome=&Apache::lonnet::homeserver($useremail,$domain); |
my $uhome=&Apache::lonnet::homeserver($useremail,$domain); |
Line 610 sub send_token {
|
Line 584 sub send_token {
|
if ($token !~ /^error/ && $token ne 'no_such_host') { |
if ($token !~ /^error/ && $token ne 'no_such_host') { |
my $esc_token = &escape($token); |
my $esc_token = &escape($token); |
my $showtime = localtime(time); |
my $showtime = localtime(time); |
my $mailmsg = &mt('A request was submitted on [_1] for creation of a [_1] account.',$showtime,$domdesc)."\n". |
my $mailmsg = &mt('A request was submitted on [_1] for creation of a LON-CAPA account at the following institution: [_2].',$showtime,$domdesc).' '. |
&mt('To complete this process please open a web browser and enter the following URL in the address/location box: [_1]', |
&mt('To complete this process please open a web browser and enter the following URL in the address/location box: [_1]', |
"\n\n".&Apache::lonnet::absolute_url().'/adm/createaccount?token='.$esc_token); |
&Apache::lonnet::absolute_url().'/adm/createaccount?token='.$esc_token); |
my $result = &Apache::resetpw::send_mail($domdesc,$email,$mailmsg,$contact_name, |
my $result = &Apache::resetpw::send_mail($domdesc,$email,$mailmsg,$contact_name, |
$contact_email); |
$contact_email); |
if ($result eq 'ok') { |
if ($result eq 'ok') { |
$msg .= &mt('A message has been sent to the e-mail address you provided.').'<br />'.&mt('The message includes the web address for the link you will use to complete the sign-up process.').'<br />'.&mt("The link included in the message will be valid for the next [_1]two[_2] hours.",'<b>','</b>'); |
$msg .= &mt('A message has been sent to the e-mail address you provided.').'<br />'.&mt('The message includes the web address for the link you will use to complete the account creation process.').'<br />'.&mt("The link included in the message will be valid for the next [_1]two[_2] hours.",'<b>','</b>'); |
} else { |
} else { |
$msg .= '<span class="LC_error">'. |
$msg .= '<span class="LC_error">'. |
&mt('An error occurred when sending a message to the e-mail address you provided.').'</span><br />'. |
&mt('An error occurred when sending a message to the e-mail address you provided.').'</span><br />'. |
Line 652 sub process_mailtoken {
|
Line 626 sub process_mailtoken {
|
if ($result eq 'ok') { |
if ($result eq 'ok') { |
$msg = $output; |
$msg = $output; |
my $shownow = &Apache::lonlocal::locallocaltime($now); |
my $shownow = &Apache::lonlocal::locallocaltime($now); |
my $mailmsg = &mt('A [_1] account has been created [_2] from IP address: [_3]. If you did not perform this action or authorize it, please contact the [_4] ([_5]).',$domdesc,$shownow,$ENV{'REMOTE_ADDR'},$contact_name,$contact_email)."\n"; |
my $mailmsg = &mt('A LON-CAPA account for the institution: [_1] has been created [_2] from IP address: [_3]. If you did not perform this action or authorize it, please contact the [_4] ([_5]).',$domdesc,$shownow,$ENV{'REMOTE_ADDR'},$contact_name,$contact_email)."\n"; |
my $mailresult = &Apache::resetpw::send_mail($domdesc,$data{'email'}, |
my $mailresult = &Apache::resetpw::send_mail($domdesc,$data{'email'}, |
$mailmsg,$contact_name, |
$mailmsg,$contact_name, |
$contact_email); |
$contact_email); |
Line 661 sub process_mailtoken {
|
Line 635 sub process_mailtoken {
|
} else { |
} else { |
$msg .= &mt('An error occurred when sending e-mail to [_1] confirming creation of your LON-CAPA account.',$data{'username'}); |
$msg .= &mt('An error occurred when sending e-mail to [_1] confirming creation of your LON-CAPA account.',$data{'username'}); |
} |
} |
my %form = &start_session($r,$data{'username'},$domain, |
&start_session($r, $data{'username'}, $domain, $lonhost, |
$lonhost,$data{'courseid'}, |
$data{'courseid'}, $token); |
$token); |
|
$nostart = 1; |
$nostart = 1; |
$noend = 1; |
$noend = 1; |
} else { |
} else { |
Line 690 sub process_mailtoken {
|
Line 663 sub process_mailtoken {
|
} |
} |
|
|
sub start_session { |
sub start_session { |
my ($r,$username,$domain,$lonhost,$courseid,$token) = @_; |
my ($r, $username, $domain, $lonhost, $courseid, $token) = @_; |
my %form = ( |
|
uname => $username, |
|
udom => $domain, |
|
); |
|
my $firsturl = '/adm/roles'; |
|
if (defined($courseid)) { |
|
$courseid = &validate_course($courseid); |
|
if ($courseid ne '') { |
|
$form{'courseid'} = $courseid; |
|
$firsturl = '/adm/selfenroll?courseid='.$courseid; |
|
} |
|
} |
|
if ($r->dir_config('lonBalancer') eq 'yes') { |
if ($r->dir_config('lonBalancer') eq 'yes') { |
&Apache::lonauth::success($r,$form{'uname'},$form{'udom'}, |
Apache::lonauth::success($r, $username, $domain, $lonhost, |
$lonhost,'noredirect',undef,\%form); |
'noredirect', undef, {}); |
if ($token ne '') { |
|
my $delete = &Apache::lonnet::tmpdel($token); |
Apache::lonnet::tmpdel($token) if $token; |
} |
|
$r->internal_redirect('/adm/switchserver'); |
$r->internal_redirect('/adm/switchserver'); |
} else { |
} else { |
&Apache::lonauth::success($r,$form{'uname'},$form{'udom'}, |
$courseid = Apache::lonnet::is_course($courseid); |
$lonhost,$firsturl,undef,\%form); |
|
|
Apache::lonauth::success($r, $username, $domain, $lonhost, |
|
($courseid ? "/adm/selfenroll?courseid=$courseid" : '/adm/roles'), |
|
undef, {}); |
} |
} |
return %form; |
|
|
return; |
} |
} |
|
|
|
|
Line 886 sub username_validation {
|
Line 852 sub username_validation {
|
if ($uhome ne 'no_host') { |
if ($uhome ne 'no_host') { |
my $result = &Apache::lonnet::authenticate($username,$upass,$domain); |
my $result = &Apache::lonnet::authenticate($username,$upass,$domain); |
if ($result ne 'no_host') { |
if ($result ne 'no_host') { |
my %form = &start_session($r,$username,$domain,$lonhost,$courseid); |
&start_session($r, $username, $domain, $lonhost, $courseid); |
$output = '<br /><br />'.&mt('A LON-CAPA account already exists for username [_1] at this institution ([_2]).','<tt>'.$username.'</tt>',$domdesc).'<br />'.&mt('The password entered was also correct so you have been logged in.'); |
$output = '<br /><br />'.&mt('A LON-CAPA account already exists for username [_1] at this institution ([_2]).','<tt>'.$username.'</tt>',$domdesc).'<br />'.&mt('The password entered was also correct so you have been logged in.'); |
return ('existingaccount',$output); |
return ('existingaccount',$output); |
} else { |
} else { |
Line 1110 sub username_activation {
|
Line 1076 sub username_activation {
|
if ($result eq 'ok') { |
if ($result eq 'ok') { |
my $delete = &Apache::lonnet::tmpdel($env{'form.authtoken'}); |
my $delete = &Apache::lonnet::tmpdel($env{'form.authtoken'}); |
$output = &mt('A LON-CAPA account has been created for username: [_1] in domain: [_2].',$username,$domain); |
$output = &mt('A LON-CAPA account has been created for username: [_1] in domain: [_2].',$username,$domain); |
my %form = &start_session($r,$username,$domain,$lonhost,$courseid); |
&start_session($r, $username, $domain, $lonhost, $courseid); |
my $nostart = 1; |
my $nostart = 1; |
return ('ok',$output,$nostart); |
return ('ok',$output,$nostart); |
} else { |
} else { |
Line 1153 sub check_id {
|
Line 1119 sub check_id {
|
} |
} |
|
|
sub invalid_state { |
sub invalid_state { |
my ($error,$domdesc,$contact_name,$contact_email,$msgtext,$useremail) = @_; |
my ($error,$domdesc,$contact_name,$contact_email,$msgtext) = @_; |
my $msg = '<h3>'.&mt('Account creation unavailable').'</h3><span class="LC_error">'; |
my $msg = '<h3>'.&mt('Account creation unavailable').'</h3><span class="LC_error">'; |
if ($error eq 'baduseremail') { |
if ($error eq 'baduseremail') { |
$msg .= &mt('The e-mail address you provided does not appear to be a valid address.'); |
$msg .= &mt('The e-mail address you provided does not appear to be a valid address.'); |
} elsif ($error eq 'existinguser') { |
} elsif ($error eq 'existinguser') { |
my $uname = &HTML::Entities::encode($useremail); |
$msg .= &mt('The e-mail address you provided is already in use as a username in LON-CAPA at this institution.'); |
$msg .= &mt('The e-mail address you provided is already in use as a username in LON-CAPA at this institution.').'</span><br /><br /><span class="LC_warning">'.&mt('You can either:').'<ul>'. |
|
'<li>'.&mt('Return to the [_1]log-in page[_2] and enter your password.','<a href="/adm/login?username='.$uname.'">','</a>').'</li>'. |
|
'<li>'.&mt('or, if you do not remember your password, visit the "[_1]Forgot your password?[_2]" page.','<a href="/adm/resetpw?uname='.$uname.'&useremail='.$uname.'&referrer=createaccount">','</a>'). |
|
'</li></ul>'; |
|
} elsif ($error eq 'userrules') { |
} elsif ($error eq 'userrules') { |
$msg .= &mt('Username rules at this institution do not allow the e-mail address you provided to be used as a username.'); |
$msg .= &mt('Username rules at this institution do not allow the e-mail address you provided to be used as a username.'); |
} elsif ($error eq 'userformat') { |
} elsif ($error eq 'userformat') { |
Line 1198 sub linkto_email_help {
|
Line 1160 sub linkto_email_help {
|
return $msg; |
return $msg; |
} |
} |
|
|
sub create_recaptcha { |
sub create_captcha { |
my $captcha = Captcha::reCAPTCHA->new; |
my ($output_dir,$db_dir) = @_; |
# generate PUBLICKEY from https://www.google.com/recaptcha |
my %captcha_params = &captcha_settings(); |
return $captcha->get_options_setter({theme => 'white'})."\n". |
my ($output,$maxtries,$tries) = ('',10,0); |
$captcha->get_html('PUBLICKEY'); |
while ($tries < $maxtries) { |
|
$tries ++; |
|
my $captcha = Authen::Captcha->new ( |
|
output_folder => $captcha_params{'output_dir'}, |
|
data_folder => $captcha_params{'db_dir'}, |
|
); |
|
my $md5sum = $captcha->generate_code($captcha_params{'numchars'}); |
|
|
|
if (-e $Apache::lonnet::perlvar{'lonCaptchaDir'}.'/'.$md5sum.'.png') { |
|
$output = '<input type="hidden" name="crypt" value="'.$md5sum.'" />'."\n". |
|
&mt('Type in the letters/numbers shown below').' '. |
|
'<input type="text" size="5" name="code" value="" /><br />'. |
|
'<img src="'.$captcha_params{'www_output_dir'}.'/'.$md5sum.'.png" />'; |
|
last; |
|
} |
|
} |
|
return $output; |
|
} |
|
|
|
sub captcha_settings { |
|
my %captcha_params = ( |
|
output_dir => $Apache::lonnet::perlvar{'lonCaptchaDir'}, |
|
www_output_dir => "/captchaspool", |
|
db_dir => $Apache::lonnet::perlvar{'lonCaptchaDb'}, |
|
numchars => '5', |
|
); |
|
return %captcha_params; |
} |
} |
|
|
sub getkeys { |
sub getkeys { |