version 1.4, 2006/07/21 18:52:32
|
version 1.8, 2009/02/13 17:20:26
|
Line 1
|
Line 1
|
# The LearningOnline Network |
# The LearningOnline Network |
# Passphrase Entry and Validation for Portfolio files |
# Passphrase Entry and Validation for Portfolio files |
# |
# |
|
# $Id$ |
|
# |
# Copyright Michigan State University Board of Trustees |
# Copyright Michigan State University Board of Trustees |
# |
# |
# This file is part of the LearningOnline Network with CAPA (LON-CAPA). |
# This file is part of the LearningOnline Network with CAPA (LON-CAPA). |
Line 45 sub handler {
|
Line 47 sub handler {
|
if (!defined($origurl)) { |
if (!defined($origurl)) { |
$origurl = $r->uri; |
$origurl = $r->uri; |
} |
} |
|
my $msg=''; |
if (exists($env{'form.pass1'})) { |
if (exists($env{'form.pass1'})) { |
my ($result,$end) = &check_pass($r,$origurl); |
my ($result,$end) = &check_pass($r,$origurl); |
if ($result eq 'ok') { |
if ($result eq 'ok') { |
&Apache::lonnet::appenv(('user.passphrase_access_'.$origurl => |
&Apache::lonnet::allowuploaded('/adm/restrictedaccess', |
$end)); |
$origurl); |
$env{'request.state'} = "published"; |
$env{'request.state'} = "published"; |
$env{'request.filename'} = $origurl; |
$env{'request.filename'} = $origurl; |
$r->header_out(Location => 'http://'.$ENV{'HTTP_HOST'}.$origurl); |
$r->header_out(Location => 'http://'.$ENV{'HTTP_HOST'}.$origurl); |
return REDIRECT; |
return REDIRECT; |
} else { |
} else { |
&print_entryform($r,$origurl,"Invalid passphrase"); |
$msg = 'Invalid passphrase'; |
} |
} |
} else { |
|
&print_entryform($r,$origurl); |
|
} |
} |
return OK; |
|
} |
|
|
|
sub print_entryform { |
|
my ($r,$origurl,$msg) = @_; |
|
&Apache::lonlocal::get_language_handle($r); |
|
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
return OK if $r->header_only; |
return OK if $r->header_only; |
|
|
$r->print(&Apache::loncommon::start_page('Passphrase protected file')); |
$r->print(&Apache::loncommon::start_page('Passphrase protected file')); |
|
&print_entryform($r,$origurl,$msg); |
|
|
|
return OK; |
|
} |
|
|
|
sub setup_handler { |
|
my ($r) = @_; |
|
$r->set_handlers('PerlHandler'=> |
|
[\&Apache::restrictedaccess::handler]); |
|
$r->handler('perl-script'); |
|
} |
|
|
|
sub print_entryform { |
|
my ($r,$origurl,$msg) = @_; |
|
|
$r->print('<script type="text/javascript"> |
$r->print('<script type="text/javascript"> |
function verify() { |
function verify() { |
if (document.passform.pass1.value == "") { |
if (document.passform.pass1.value == "") { |
Line 80 function verify() {
|
Line 91 function verify() {
|
document.passform.submit(); |
document.passform.submit(); |
} |
} |
</script>'); |
</script>'); |
$r->print('<span class="LC_error">'.$msg.'</span>'); |
if ($msg ne '') { |
|
$r->print('<span class="LC_error">'.$msg.'</span>'); |
|
} |
$r->print('<div align="center"><form name="passform" method="post" '. |
$r->print('<div align="center"><form name="passform" method="post" '. |
'action="/adm/restrictedaccess">'); |
'action="/adm/restrictedaccess">'); |
$r->print('<br /><br /><br />'); |
$r->print('<br /><br /><br />'); |
$r->print(&Apache::loncommon::start_data_table()); |
$r->print(&Apache::loncommon::start_data_table()); |
$r->print(&Apache::loncommon::start_data_table_row()); |
$r->print(&Apache::loncommon::start_data_table_row()); |
$r->print('<td><nobr>'.&mt('Passphrase: ').'</nobr></td>'. |
$r->print('<td><span class="LC_nobreak">'.&mt('Passphrase: ').'</span></td>'. |
'<td><input type="password" size="20" name="pass1"></td>'); |
'<td><input type="password" size="20" name="pass1" /></td>'); |
$r->print(&Apache::loncommon::end_data_table_row()); |
$r->print(&Apache::loncommon::end_data_table_row()); |
$r->print(&Apache::loncommon::start_data_table_row()); |
$r->print(&Apache::loncommon::start_data_table_row()); |
$r->print('<td align="center" colspan="2"><br />'. |
$r->print('<td align="center" colspan="2"><br />'. |