Annotation of loncom/publisher/lonpubdir.pm, revision 1.2
1.1 www 1: # The LearningOnline Network with CAPA
2: #
3: # (Publication Handler
4: #
5: # (TeX Content Handler
6: #
7: # 05/29/00,05/30,10/11 Gerd Kortemeyer)
8: #
9: # 11/28,11/29,11/30,12/01,12/02,12/04,12/23 Gerd Kortemeyer
10: # 03/23 Guy Albertelli
11: # 03/24,03/29 Gerd Kortemeyer)
12: #
1.2 ! www 13: # 03/31,04/03 Gerd Kortemeyer
1.1 www 14:
15: package Apache::lonpubdir;
16:
17: use strict;
18: use Apache::File;
19: use File::Copy;
20: use Apache::Constants qw(:common :http :methods);
21:
22:
23: sub handler {
24:
25: my $r=shift;
26:
27: my $fn;
28:
29: if ($ENV{'form.filename'}) {
30: $fn=$ENV{'form.filename'};
31: $fn=~s/^http\:\/\/[^\/]+\/\~(\w+)/\/home\/$1\/public_html/;
32: $fn=~s/\/[^\/]+$//;
33: } else {
34: $fn=$r->filename();
35: }
36:
37:
38: unless ($fn) {
39: $r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.
1.2 ! www 40: ' trying to list empty directory', $r->filename);
1.1 www 41: return HTTP_NOT_FOUND;
42: }
43:
44: # ----------------------------------------------------------- Start page output
45:
46: my $uname=$ENV{'user.name'};
47: my $udom=$ENV{'user.domain'};
48:
49: $r->content_type('text/html');
50: $r->send_http_header;
51:
52: $r->print('<html><head><title>LON-CAPA Construction Space</title></head>');
53:
54: $r->print(
55: '<body bgcolor="#FFFFFF"><img align=right src=/adm/lonIcons/lonlogos.gif>');
56:
57: my $thisdisfn=$fn;
58: $thisdisfn=~s/^\/home\/$uname\/public_html//;
59:
60: $r->print('<h1>Construction Space Directory <tt>'.$thisdisfn.'</tt></h1>');
61:
62: my $docroot=$r->dir_config('lonDocRoot');
63:
64: my $resdir=$docroot.'/res/'.$udom.'/'.$uname.$thisdisfn;
65: my $linkdir='/~'.$uname.$thisdisfn;
66:
1.2 ! www 67: $r->print('<table border=2>'.
! 68: '<tr><th>Filename</th><th>Modified</th><th>Status</th></tr>');
1.1 www 69:
1.2 ! www 70: my $filename;
! 71: my $dirptr=16384;
1.1 www 72:
1.2 ! www 73: opendir(DIR,$fn);
! 74: while ($filename=readdir(DIR)) {
! 75: my ($cdev,$cino,$cmode,$cnlink,
! 76: $cuid,$cgid,$crdev,$csize,
! 77: $catime,$cmtime,$cctime,
! 78: $cblksize,$cblocks)=stat($fn.'/'.$filename);
! 79: $filename=~/\.(\w+)$/;
! 80: if (($1 ne 'meta') && (&Apache::lonnet::fileembstyle($1))) {
! 81: my $status='Unpublished';
! 82: my $bgcol='#FFBBBB';
! 83: if (-e $resdir.'/'.$filename) {
! 84: my ($rdev,$rino,$rmode,$rnlink,
! 85: $ruid,$rgid,$rrdev,$rsize,
! 86: $ratime,$rmtime,$rctime,
! 87: $rblksize,$rblocks)=stat($resdir.'/'.$filename);
! 88: if ($rmtime>=$cmtime) {
! 89: $status='Published';
! 90: $bgcol='#BBFFBB';
! 91: } else {
! 92: $status='Modified';
! 93: $bgcol='#FFFFBB';
! 94: }
! 95: }
! 96: $r->print('<tr bgcolor='.$bgcol.
! 97: '><td><a href="'.$linkdir.'/'.$filename.'">'.$filename.
! 98: '</a></td><td>'.localtime($cmtime).'</td><td>'.$status.'</td></tr>');
! 99: } elsif ($cmode&$dirptr) {
! 100: $r->print('<tr bgcolor=#BBBBFF'.
! 101: '><td><a href="'.$linkdir.'/'.$filename.'">'.$filename.
! 102: '</a></td><td>'.localtime($cmtime).'</td><td> </td></tr>');
! 103: }
! 104: }
! 105: closedir(DIR);
! 106:
! 107: $r->print('</table></body></html>');
1.1 www 108: return OK;
109: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>