# The LearningOnline Network with CAPA
# Handler to retrieve an old version of a file
#
# (Publication Handler
#
# (TeX Content Handler
#
# 05/29/00,05/30,10/11 Gerd Kortemeyer)
#
# 11/28,11/29,11/30,12/01,12/02,12/04,12/23 Gerd Kortemeyer
# 03/23 Guy Albertelli
# 03/24,03/29 Gerd Kortemeyer)
#
# 03/31 Gerd Kortemeyer
package Apache::lonretrieve;
use strict;
use Apache::File;
use File::Copy;
use Apache::Constants qw(:common :http :methods);
sub handler {
my $r=shift;
my $fn;
if ($ENV{'form.filename'}) {
$fn=$ENV{'form.filename'};
$fn=~s/^http\:\/\/[^\/]+\/\~(\w+)/\/home\/$1\/public_html/;
$fn=~s/\/[^\/]+$//;
} else {
$fn=$r->filename();
}
unless ($fn) {
$r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.
' trying to publish empty directory', $r->filename);
return HTTP_NOT_FOUND;
}
# ----------------------------------------------------------- Start page output
my $uname=$ENV{'user.name'};
my $udom=$ENV{'user.domain'};
$r->content_type('text/html');
$r->send_http_header;
$r->print('<html><head><title>LON-CAPA Construction Space</title></head>');
$r->print(
'<body bgcolor="#FFFFFF"><img align=right src=/adm/lonIcons/lonlogos.gif>');
my $thisdisfn=$fn;
$thisdisfn=~s/^\/home\/$uname\/public_html//;
$r->print('<h1>Construction Space Directory <tt>'.$thisdisfn.'</tt></h1>');
my $docroot=$r->dir_config('lonDocRoot');
my $resdir=$docroot.'/res/'.$udom.'/'.$uname.$thisdisfn;
my $linkdir='/~'.$uname.$thisdisfn;
my $filename;
opendir(DIR,$fn);
while ($filename=readdir(DIR)) {
$filename=~/\.(\w+)$/;
if (($1 ne 'meta') && ($1 ne 'save') && ($1 ne 'log')) {
$r->print($resdir.' - '.$linkdir.' = '.$filename.'<br>');
}
}
closedir(DIR);
$r->print('</body></html>');
return OK;
}
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>