--- loncom/publisher/lonpubdir.pm 2001/04/01 02:58:51 1.1
+++ loncom/publisher/lonpubdir.pm 2001/07/13 12:56:12 1.11
@@ -10,7 +10,7 @@
# 03/23 Guy Albertelli
# 03/24,03/29 Gerd Kortemeyer)
#
-# 03/31 Gerd Kortemeyer
+# 03/31,04/03,05/09,06/23 Gerd Kortemeyer
package Apache::lonpubdir;
@@ -18,6 +18,8 @@ use strict;
use Apache::File;
use File::Copy;
use Apache::Constants qw(:common :http :methods);
+use Apache::loncacc;
+use Apache::lonnet;
sub handler {
@@ -33,18 +35,31 @@ sub handler {
} else {
$fn=$r->filename();
}
+
+ my $uname;
+ my $udom;
+
+ ($uname,$udom)=
+ &Apache::loncacc::constructaccess(
+ $fn,$r->dir_config('lonDefDomain'));
+ unless (($uname) && ($udom)) {
+ $r->log_reason($uname.' at '.$udom.
+ ' trying to publish file '.$ENV{'form.filename'}.
+ ' ('.$fn.') - not authorized',
+ $r->filename);
+ return HTTP_NOT_ACCEPTABLE;
+ }
+ $fn=~s/\/$//;
unless ($fn) {
$r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.
- ' trying to publish empty directory', $r->filename);
+ ' trying to list 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;
@@ -57,24 +72,80 @@ sub handler {
my $thisdisfn=$fn;
$thisdisfn=~s/^\/home\/$uname\/public_html//;
- $r->print('
Construction Space Directory '.$thisdisfn.'
');
+ $r->print('Construction Space Directory '.$thisdisfn.'/
');
+
+ if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) {
+ $r->print('Co-Author: '.$uname.' at '.$udom.
+ '
');
+ }
+
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.'
');
- }
- }
- closedir(DIR);
+ $r->print(''.
+ 'Filename | Modified | Status |
');
+
+ my $filename;
+ my $dirptr=16384;
+ opendir(DIR,$fn);
+ my @files=sort(readdir(DIR));
+ foreach my $filename (@files) {
+ my ($cdev,$cino,$cmode,$cnlink,
+ $cuid,$cgid,$crdev,$csize,
+ $catime,$cmtime,$cctime,
+ $cblksize,$cblocks)=stat($fn.'/'.$filename);
+ my $extension='';
+ if ($filename=~/\.(\w+)$/) { $extension=$1; }
+ if (($extension ne 'meta') && (&Apache::lonnet::fileembstyle($extension))) {
+ my $status='Unpublished';
+ my $bgcol='#FFBBBB';
+ if (-e $resdir.'/'.$filename) {
+ my ($rdev,$rino,$rmode,$rnlink,
+ $ruid,$rgid,$rrdev,$rsize,
+ $ratime,$rmtime,$rctime,
+ $rblksize,$rblocks)=stat($resdir.'/'.$filename);
+ if ($rmtime>=$cmtime) {
+ $status='Published';
+ $bgcol='#BBFFBB';
+ } else {
+ $status='Modified';
+ $bgcol='#FFFFBB';
+ if
+ (&Apache::lonnet::fileembstyle(($filename=~/\.(\w+)$/)) eq 'ssi') {
+ $status.='
Diffs';
+ }
+ }
+ }
+ $r->print(''.$filename.
+ ' | '.localtime($cmtime).' | '.$status.' |
');
+ } elsif ($cmode&$dirptr) {
+ my $disfilename=$filename;
+ if ($filename eq '..') {
+ $disfilename='Parent Directory';
+ }
+ unless ((($filename eq '..') && ($thisdisfn eq '')) ||
+ ($filename eq '.')) {
+ $r->print(''.$disfilename.
+ ' | '.localtime($cmtime).' | |
');
+ }
+ } else {
+ #no extension that we know of and not a directory
+ #just hide it away
+ }
+ }
+ closedir(DIR);
- $r->print('