--- docman.php 2000/08/04 10:13:10 1.7 +++ docman.php 2000/08/04 11:25:05 1.11 @@ -65,9 +65,7 @@ TODO: mixed file/directory output (add type to each entry, real support for links) - add more content-management (like cms.sourceforge.net): - check-out/check-in/reserve - comments to files + retrieve old versions of files (overwritten) */ ////////////////////////////////////////////////////////////////// @@ -194,7 +192,7 @@


- +

" ; - echo htmlentities($tstr) . "

" . $tstr ; +// echo htmlentities($tstr) . "

" . $tstr ; + echo $tstr ; } ?> @@ -362,17 +362,29 @@
CHANGES TO THIS FILE
\n"; $log=fopen($logname,"r"); $cl1=" class=lst"; $cl2=""; + $logarr = array(); while($line = fgetcsv($log,255,"\t")) { $cl=$cl1; $cl1=$cl2; $cl2=$cl; - print "$line[0]$line[1]$line[2]$line[3]\n"; + array_unshift($logarr,array($cl,$line[0],$line[1],$line[2],$line[3])); } fclose($log); + print "

CHANGES TO THIS FILE
\n"; + $bakcount = 0; // start from 0, skip fist backup (it's current) + while ($e = array_shift($logarr)) { + if (strstr($e[4],"upload")) { + if (file_exists("$bakdir/$bakcount/$name")) { + $e[4]="$e[4]"; + } + $bakcount++; + } + print "$e[1]$e[2]$e[3]$e[4]\n"; + } print "
"; } @@ -848,8 +860,7 @@ - OR UPLOAD A FILE + OR UPLOAD A FILE @@ -1070,11 +1081,19 @@ ////////////////////////////////////////////////////////////////// -function redir_to_url($url) { - $url=urlencode(StripSlashes("$relDir/$F")); +function urlpath($url) { + $url=urlencode(StripSlashes("$url")); $url=str_replace("%2F","/",$url); $url=str_replace("+","%20",$url); - Header("Location: $url"); + return($url); +} + +////////////////////////////////////////////////////////////////// + +function safe_rename($from,$to) { + if (file_exists($from) && is_writable(dirname($to))) { + rename($from,$to); + } } ////////////////////////////////////////////////////////////////// @@ -1276,10 +1295,13 @@ if ( $CONFIRM != "on" ) break ; Logit("$fsDir/$FN","renamed $FN to $NEWNAME"); - rename("$fsDir/$FN","$fsDir/$NEWNAME"); - rename("$fsDir/.log/$FN","$fsDir/.log/$NEWNAME"); - rename("$fsDir/.note/$FN","$fsDir/.note/$NEWNAME"); - rename("$fsDir/.lock/$FN","$fsDir/.lock/$NEWNAME"); + safe_rename("$fsDir/$FN","$fsDir/$NEWNAME"); + safe_rename("$fsDir/.log/$FN","$fsDir/.log/$NEWNAME"); + safe_rename("$fsDir/.note/$FN","$fsDir/.note/$NEWNAME"); + safe_rename("$fsDir/.lock/$FN","$fsDir/.lock/$NEWNAME"); + for($i=0;$i<=$GLOBALS[gblNumBackups];$i++) { + safe_rename("$fsDir/.bak/$i/$FN","$fsDir/.bak/$i/$NEWNAME"); + } break ; @@ -1334,7 +1356,7 @@ case "Co" : // checkout Lock("$gblFsRoot/$relDir/$F"); - redir_to_url("$relDir/$F"); + Header("Location: ".urlpath("$relDir/$F")); exit; case "Ci" : // upload && update to $relDir @@ -1348,8 +1370,8 @@ exit ; case "V" : // view - Log("viewed"); - redir_to_url("$relDir/$F"); + LogIt("$gblFsRoot/$relDir/$F","viewed"); + Header("Location: ".urlpath("$relDir/$F")); exit; }