version 1.2, 2001/06/23 18:51:32
|
version 1.4, 2001/06/24 01:40:14
|
Line 27 use Apache::loncacc;
|
Line 27 use Apache::loncacc;
|
|
|
sub phaseone { |
sub phaseone { |
my ($r,$fn,$uname,$udom)=@_; |
my ($r,$fn,$uname,$udom)=@_; |
my $docroot=$r->dir_config('lonDocRoot'); |
|
|
|
my $urldir='/res/'.$udom.'/'.$uname.$fn; |
$fn=~/(.*)\/([^\/]+)\.(\w+)$/; |
$urldir=~s/\/[^\/]+$/\//; |
my $dir=$1; |
|
my $main=$2; |
|
my $suffix=$3; |
|
|
my $resfn=$docroot.'/res/'.$udom.'/'.$uname.$fn; |
my $conspace='/home/'.$uname.'/public_html'.$fn; |
my $resdir=$resfn; |
|
$resdir=~s/\/[^\/]+$/\//; |
|
|
|
$fn=~/\/([^\/]+)\.(\w+)$/; |
$r->print('<form action=/adm/cfile method=post>'. |
my $main=$1; |
|
my $suffix=$2; |
|
|
|
if (-e $resfn) { |
|
$r->print('<form action=/adm/retrieve method=post>'. |
|
'<input type=hidden name=filename value="/~'.$uname.$fn.'">'. |
'<input type=hidden name=filename value="/~'.$uname.$fn.'">'. |
'<input type=hidden name=phase value=two>'. |
'<input type=hidden name=phase value=two>'. |
'<table border=2><tr><th>Select</th><th>Version</th>'. |
'<input type=hidden name=action value='.$ENV{'form.action'}.'>'); |
'<th>Became this version on ...</th>'. |
if ($ENV{'form.action'} eq 'rename') { |
'<th>Metadata</th></tr>'); |
if (-e $conspace) { |
my $filename; |
if ($ENV{'form.newfilename'}) { |
opendir(DIR,$resdir); |
$ENV{'form.newfilename'}=~/(.*)\/([^\/]+)\.(\w+)$/; |
while ($filename=readdir(DIR)) { |
if ($3 ne $suffix) { |
if ($filename=~/^$main\.(\d+)\.$suffix$/) { |
$r->print( |
my $version=$1; |
'<p><font color=red>Warning: change of MIME type!</font>'); |
my ($rdev,$rino,$rmode,$rnlink, |
} |
$ruid,$rgid,$rrdev,$rsize, |
if (-e |
$ratime,$rmtime,$rctime, |
'/home/httpd/'.$uname.'/'.$dir.'/'.$ENV{'form.newfilename'}) { |
$rblksize,$rblocks)=stat($resdir.'/'.$filename); |
$r->print( |
$r->print('<tr><td><input type=radio name=version value="'. |
'<p><font color=red>Warning: target file exists!</font>'); |
$version.'"></td><th>'.$version.'</th><td>'. |
} |
localtime($rmtime).'</td><td>'. |
$r->print('<input type=hidden name=newfilename value="'. |
'<a href="'.$urldir.$filename.'.meta" target=cat>'. |
$ENV{'form.newfilename'}. |
'Metadata Version '.$version.'</a>'); |
'"><p>Rename <tt>'.$fn.'</tt> to <tt>'. |
if (&Apache::lonnet::fileembstyle($suffix) eq 'ssi') { |
$dir.'/'.$ENV{'form.newfilename'}.'</tt>?'); |
$r->print( |
} else { |
' <a target=cat href="/adm/diff?filename=/~'. |
$r->print('<p>No new filename specified.</form>'); |
$uname.$fn. |
return; |
'&versionone=priv&versiontwo='.$version. |
} |
'">Diffs with Version '.$version.'</a>'); |
|
} |
|
$r->print('</a></td></tr>'); |
|
} |
|
} |
|
closedir(DIR); |
|
my ($rdev,$rino,$rmode,$rnlink, |
|
$ruid,$rgid,$rrdev,$rsize, |
|
$ratime,$rmtime,$rctime, |
|
$rblksize,$rblocks)=stat($resfn); |
|
$r->print('<tr><td><input type=radio name=version value="new"></td>'. |
|
'<th>Current</th><td>'.localtime($rmtime). |
|
'</td><td><a href="'.$urldir.$main.'.'.$suffix.'.meta" target=cat>'. |
|
'Metadata current version</a>'); |
|
if (&Apache::lonnet::fileembstyle($suffix) eq 'ssi') { |
|
$r->print( |
|
' <a target=cat href="/adm/diff?filename=/~'. |
|
$uname.$fn. |
|
'&versionone=priv'. |
|
'">Diffs with current Version</a>'); |
|
} |
|
$r->print('</td></tr></table><p>'. |
|
'<font size=+1 color=red>Retrieval of an old version will '. |
|
'overwrite the file currently in construction space</font><p>'. |
|
'<input type=submit value="Retrieve version"></form>'); |
|
} else { |
|
$r->print('<h3>No previous versions published.</h3>'); |
|
} |
|
} |
|
|
|
sub phasetwo { |
|
my ($r,$fn,$uname,$udom)=@_; |
|
if ($ENV{'form.version'}) { |
|
my $version=$ENV{'form.version'}; |
|
if ($version eq 'new') { |
|
$r->print('<h3>Retrieving current (most recent) version</h3>'); |
|
} else { |
} else { |
$r->print('<h3>Retrieving old version '.$version.'</h3>'); |
$r->print('<p>No such file.</form>'); |
|
return; |
} |
} |
my $logfile; |
} elsif ($ENV{'form.action'} eq 'delete') { |
my $ctarget='/home/'.$uname.'/public_html'.$fn; |
if (-e $conspace) { |
my $vfn=$fn; |
$r->print('<p>Delete <tt>'.$fn.'</tt>?'); |
if ($version ne 'new') { |
} else { |
$vfn=~s/\.(\w+)$/\.$version\.$1/; |
$r->print('<p>No such file.</form>'); |
} |
return; |
my $csource=$r->dir_config('lonDocRoot').'/res/'.$udom.'/'.$uname.$vfn; |
|
unless ($logfile=Apache::File->new('>>'.$ctarget.'.log')) { |
|
$r->print( |
|
'<font color=red>No write permission to user directory, FAIL</font>'); |
|
} |
} |
print $logfile |
} elsif ($ENV{'form.action'} eq 'copy') { |
"\n\n================= Retrieve ".localtime()." ================\n". |
if (-e $conspace) { |
"Version: $version\nSource: $csource\nTarget: $ctarget\n"; |
if ($ENV{'form.newfilename'}) { |
$r->print('<p>Copying file: '); |
$ENV{'form.newfilename'}=~/(.*)\/([^\/]+)\.(\w+)$/; |
if (copy($csource,$ctarget)) { |
if ($3 ne $suffix) { |
$r->print('ok<p>'); |
$r->print( |
print $logfile "Copied sucessfully.\n\n"; |
'<p><font color=red>Warning: change of MIME type!</font>'); |
|
} |
|
if (-e |
|
'/home/httpd/'.$uname.'/'.$dir.'/'.$ENV{'form.newfilename'}) { |
|
$r->print( |
|
'<p><font color=red>Warning: target file exists!</font>'); |
|
} |
|
$r->print('<input type=hidden name=newfilename value="'. |
|
$ENV{'form.newfilename'}. |
|
'"><p>Copy <tt>'.$fn.'</tt> to <tt>'. |
|
$dir.'/'.$ENV{'form.newfilename'}.'</tt>?'); |
|
} else { |
|
$r->print('<p>No new filename specified.</form>'); |
|
return; |
|
} |
} else { |
} else { |
my $error=$!; |
$r->print('<p>No such file.</form>'); |
$r->print('fail, '.$error.'<p>'); |
return; |
print $logfile "Copy failed: $error\n\n"; |
|
} |
} |
$r->print('<font size=+2><a href="/priv/'.$uname.$fn. |
} elsif ($ENV{'form.action'} eq 'newdir') { |
'">Back to '.$fn.'</a></font>'); |
my $newdir='/home/'.$uname.'/public_html/'. |
} else { |
$fn.$ENV{'form.newfilename'}; |
$r->print( |
if (-e $newdir) { |
'<font size=+1 color=red>Please pick a version to retrieve</font><p>'); |
$r->print('<p>Directory exists.</form>'); |
&phaseone($r,$fn,$uname,$udom); |
return; |
|
} |
|
$r->print('<input type=hidden name=newfilename value="'. |
|
$ENV{'form.newfilename'}. |
|
'"><p>Make new directory <tt>'. |
|
$fn.$ENV{'form.newfilename'}.'</tt>?'); |
|
|
} |
} |
|
$r->print('<p><input type=submit value=Continue></form>'); |
|
} |
|
|
|
sub phasetwo { |
|
my ($r,$fn,$uname,$udom)=@_; |
|
$r->print('Under Construction'); |
} |
} |
|
|
sub handler { |
sub handler { |
Line 166 sub handler {
|
Line 146 sub handler {
|
&Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain')); |
&Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain')); |
unless (($uname) && ($udom)) { |
unless (($uname) && ($udom)) { |
$r->log_reason($uname.' at '.$udom. |
$r->log_reason($uname.' at '.$udom. |
' trying to publish file '.$ENV{'form.filename'}. |
' trying to manipulate file '.$ENV{'form.filename'}. |
' ('.$fn.') - not authorized', |
' ('.$fn.') - not authorized', |
$r->filename); |
$r->filename); |
return HTTP_NOT_ACCEPTABLE; |
return HTTP_NOT_ACCEPTABLE; |
Line 203 sub handler {
|
Line 183 sub handler {
|
return OK; |
return OK; |
} |
} |
if ($ENV{'form.phase'} eq 'two') { |
if ($ENV{'form.phase'} eq 'two') { |
# &phasetwo($r,$fn,$uname,$udom); |
&phasetwo($r,$fn,$uname,$udom); |
} else { |
} else { |
# &phaseone($r,$fn,$uname,$udom); |
&phaseone($r,$fn,$uname,$udom); |
} |
} |
|
|
$r->print('</body></html>'); |
$r->print('</body></html>'); |