version 1.51, 2012/05/18 04:31:05
|
version 1.52, 2012/08/25 04:34:44
|
Line 382 sub print_username_form {
|
Line 382 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>'; |
my $captchaform = &create_captcha(); |
my ($captchaform,$error) = &Apache::loncommon::captcha_display('usercreation',$lonhost); |
if ($captchaform) { |
if ($error) { |
|
my $helpdesk = '/adm/helpdesk?origurl=%2fadm%2fcreateaccount'; |
|
if ($courseid ne '') { |
|
$helpdesk .= '&courseid='.$courseid; |
|
} |
|
$output .= '<span class="LC_error">'.&mt('An error occurred generating the validation code[_1] required for an e-mail address to be used as username.','<br />').'</span><br /><br />'.&mt('[_1]Contact the helpdesk[_2] or [_3]reload[_2] the page and try again.','<a href="'.$helpdesk.'">','</a>','<a href="javascript:window.location.reload()">'); |
|
} else { |
my $submit_text = &mt('Request LON-CAPA account'); |
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})) { |
Line 394 sub print_username_form {
|
Line 400 sub print_username_form {
|
$output .= '<form name="createaccount" method="post" onsubmit="return validate_email()" action="/adm/createaccount">'. |
$output .= '<form name="createaccount" method="post" onsubmit="return validate_email()" action="/adm/createaccount">'. |
&Apache::lonhtmlcommon::start_pick_box()."\n". |
&Apache::lonhtmlcommon::start_pick_box()."\n". |
&Apache::lonhtmlcommon::row_title(&mt('E-mail address'), |
&Apache::lonhtmlcommon::row_title(&mt('E-mail address'), |
'LC_pick_box_title')."\n". |
'LC_pick_box_title')."\n". |
$emailform."\n". |
$emailform."\n"; |
&Apache::lonhtmlcommon::row_closure(1). |
if ($captchaform) { |
&Apache::lonhtmlcommon::row_title(&mt('Validation'), |
$output .= &Apache::lonhtmlcommon::row_closure(1). |
'LC_pick_box_title')."\n". |
&Apache::lonhtmlcommon::row_title(&mt('Validation'), |
$captchaform."\n".'<br /><br />'; |
'LC_pick_box_title')."\n". |
|
$captchaform."\n".'<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 413 sub print_username_form {
|
Line 421 sub print_username_form {
|
$output .= &Apache::lonhtmlcommon::echo_form_input(['courseid']); |
$output .= &Apache::lonhtmlcommon::echo_form_input(['courseid']); |
} |
} |
$output .= '</form>'; |
$output .= '</form>'; |
} else { |
|
my $helpdesk = '/adm/helpdesk?origurl=%2fadm%2fcreateaccount'; |
|
if ($courseid ne '') { |
|
$helpdesk .= '&courseid='.$courseid; |
|
} |
|
$output .= '<span class="LC_error">'.&mt('An error occurred generating the validation code[_1] required for an e-mail address to be used as username.','<br />').'</span><br /><br />'.&mt('[_1]Contact the helpdesk[_2] or [_3]reload[_2] the page and try again.','<a href="'.$helpdesk.'">','</a>','<a href="javascript:window.location.reload()">'); |
|
} |
} |
$output .= '</div>'; |
$output .= '</div>'; |
} |
} |
Line 503 sub process_email_request {
|
Line 505 sub process_email_request {
|
$contact_name,$contact_email); |
$contact_name,$contact_email); |
return $output; |
return $output; |
} else { |
} else { |
my $code = $env{'form.code'}; |
my ($captcha_chk,$captcha_error) = &Apache::loncommon::captcha_response('usercreation',$server); |
my $md5sum = $env{'form.crypt'}; |
|
my %captcha_params = &captcha_settings(); |
|
my $captcha = Authen::Captcha->new( |
|
output_folder => $captcha_params{'output_dir'}, |
|
data_folder => $captcha_params{'db_dir'}, |
|
); |
|
my $captcha_chk = $captcha->check_code($code,$md5sum); |
|
my %captcha_hash = ( |
|
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) { |
if ($captcha_chk != 1) { |
$output = &invalid_state('captcha',$domdesc,$contact_name, |
$output = &invalid_state('captcha',$domdesc,$contact_name, |
$contact_email,$captcha_hash{$captcha_chk}); |
$contact_email,$captcha_error); |
return $output; |
return $output; |
} |
} |
my $uhome=&Apache::lonnet::homeserver($useremail,$domain); |
my $uhome=&Apache::lonnet::homeserver($useremail,$domain); |
Line 1185 sub linkto_email_help {
|
Line 1174 sub linkto_email_help {
|
return $msg; |
return $msg; |
} |
} |
|
|
sub create_captcha { |
|
my ($output_dir,$db_dir) = @_; |
|
my %captcha_params = &captcha_settings(); |
|
my ($output,$maxtries,$tries) = ('',10,0); |
|
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 { |
my ($lkey,$ukey) = @_; |
my ($lkey,$ukey) = @_; |
my $lextkey=hex($lkey); |
my $lextkey=hex($lkey); |