--- docman.php 2002/07/28 18:27:18 1.21
+++ docman.php 2002/07/28 18:56:49 1.22
@@ -155,7 +155,10 @@
function DetailPage($fsRoot,$relDir,$fn) {
- global $gblEditable, $gblImages, $webRoot, $html, $HTTP_SERVER_VARS ;
+ global $gblEditable, $gblImages,
+ $gblDateFmt, $gblTimeFmt,
+ $webRoot, $html,
+ $HTTP_SERVER_VARS ;
$self = $HTTP_SERVER_VARS["PHP_SELF"] ;
$relPath = $relDir . "/" . $fn ;
@@ -188,8 +191,8 @@
echo "
" . $relDir . "/" . $fn . "
" ;
if ($exists) { // get file info
$fsize = filesize($fsPath) ;
- $fmodified = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", filemtime($fsPath)) ;
- $faccessed = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", fileatime($fsPath)) ;
+ $fmodified = date("$gblDateFmt $gblTimeFmt", filemtime($fsPath)) ;
+ $faccessed = date("$gblDateFmt $gblTimeFmt", fileatime($fsPath)) ;
$fuid=fileowner($fsPath);
$fgid=filegroup($fsPath);
$userinfo = posix_getpwuid($fuid);
@@ -578,7 +581,7 @@
global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide,
$gblIgnoreUnknownFileType, $gblRepositoryDir,
- $gblLogin,
+ $gblLogin, $gblUserName,
$fsRealmDir, $realm, $realm_sep,
$html, $realm_config,
$HTTP_GET_VARS, $HTTP_SERVER_VARS;
@@ -816,7 +819,7 @@
$ext = strtolower(strrchr($file,".")) ;
if ($file_lock) {
- if ($file_lock == $GLOBALS[gblUserName]) {
+ if ($file_lock == $gblUserName) {
$b.="" ;
$file_url_html=$b;
@@ -844,7 +847,7 @@
}
}
- $mod = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]",$mod);
+ $mod = date("$gblDateFmt $gblTimeFmt",$mod);
include("$html/Navigate-fileEntry.html");
@@ -956,6 +959,8 @@
function LogIt($target,$msg, $changelog=0) {
+ global $gblDateFmt, $gblTimeFmt, $gblUserName, $gblFsRoot;
+
$dir=dirname($target);
if (! file_exists($dir."/.log")) {
if (! @mkdir($dir."/.log",0700)) Error("docman installation problem","can't create log directory $dir/.log",1);
@@ -963,18 +968,17 @@
$file=basename($target);
$log=fopen("$dir/.log/$file","a+");
- fputs($log,date("$GLOBALS[gblDateFmt]\t$GLOBALS[gblTimeFmt]").
- "\t$GLOBALS[gblUserName]\t$msg\n");
+ fputs($log,date("$gblDateFmt\t$gblTimeFmt").
+ "\t$gblUserName\t$msg\n");
fclose($log);
if (! $changelog) return;
- global $gblFsRoot;
$log=fopen("$gblFsRoot/.changelog","a+");
if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot)
$target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot));
$msg=str_replace("\t"," ",$msg);
- fputs($log,time()."\t$target\t$GLOBALS[gblUserName]\t$msg\n");
+ fputs($log,time()."\t$target\t$gblUserName\t$msg\n");
fclose($log);
// FIX: implement e-mail notification based on $changelog
@@ -1034,6 +1038,8 @@
function Lock($target) {
+ global $gblUserName;
+
$target=stripSlashes($target);
$dir=dirname($target);
if (! file_exists($dir."/.lock")) {
@@ -1045,7 +1051,7 @@
LogIt($target,"attempt to locked allready locked file!");
} else {
$lock=fopen("$dir/.lock/$file","w");
- fputs($lock,"$GLOBALS[gblUserName]\n");
+ fputs($lock,"$gblUserName\n");
fclose($lock);
LogIt($target,"file locked");
@@ -1094,6 +1100,9 @@
//////////////////////////////////////////////////////////////////
function safe_rename($fromdir,$fromfile,$tofile) {
+
+ global $gblNumBackups;
+
function try_rename($from,$to) {
# print "$from -> $to\n";
if (file_exists($from) && is_writeable(dirname($to))) {
@@ -1123,7 +1132,7 @@
try_dir("$todir/.lock");
try_rename("$fromdir/.lock/$fromfile","$todir/.lock/$tofile");
try_dir("$todir/.bak");
- for($i=0;$i<=$GLOBALS[gblNumBackups];$i++) {
+ for($i=0;$i<=$gblNumBackups;$i++) {
try_rename("$fromdir/.bak/$i/$fromfile","$todir/.bak/$i/$tofile");
}
}
@@ -1151,7 +1160,10 @@
function DisplayChangeLog($day) {
- global $gblFsRoot,$HTTP_SERVER_VARS;
+ global $gblFsRoot, $gblDateFmt, $gblTimeFmt;
+ $HTTP_SERVER_VARS;
+
+ $self = $HTTP_SERVER_VARS["PHP_SELF"];
if (!file_exists("$gblFsRoot/.changelog")) return;
$log=fopen("$gblFsRoot/.changelog","r");
@@ -1170,14 +1182,14 @@
print "\n";
while ($e = array_shift($logarr)) {
$cl=$cl1; $cl1=$cl2; $cl2=$cl;
- $date = date("$GLOBALS[gblDateFmt]", $e[0]);
- $time = date("$GLOBALS[gblTimeFmt]", $e[0]);
+ $date = date($gblDateFmt, $e[0]);
+ $time = date($gblTimeFmt, $e[0]);
$dir = dirname($e[1]);
$file = basename($e[1]);
print "$date | $time | $dir/$file | $e[2] | $e[3] |
\n";
}
print "
";
- print "".GifIcon(up)." Back to front page.
";
+ print "".GifIcon(up)." Back to front page.
";
}
//////////////////////////////////////////////////////////////////
@@ -1537,9 +1549,9 @@
}
function HTTP_POST_VAR($var) {
- global $HTTP_GET_VARS, $GLOBALS;
- if (isset($HTTP_GET_VARS[$var])) {
- $GLOBALS[$var] = stripSlashes($HTTP_GET_VARS[$var]);
+ global $HTTP_POST_VARS, $GLOBALS;
+ if (isset($HTTP_POST_VARS[$var])) {
+ $GLOBALS[$var] = stripSlashes($HTTP_POST_VARS[$var]);
return $GLOBALS[$var];
}
}
@@ -1659,6 +1671,7 @@
$relDir = $DIR;
} else {
trigger_error("Can't get DIR",E_USER_WARNING);
+ $relDir = "/";
}
if (HTTP_POST_VAR("RELPATH")) check_dirname($RELPATH);
HTTP_POST_VAR("T");
@@ -1708,8 +1721,7 @@
Error("You must select file with browse to upload it!");
}
- $FILENAME = $HTTP_POST_VARS["FILENAME"];
- check_filename($FILENAME);
+ if (HTTP_POST_VAR("FILENAME")) check_filename($FILENAME);
if (! isset($FILENAME)) { // from update file
$target = "$fsDir/".basename($FN);
@@ -1722,11 +1734,11 @@
if (! file_exists($dir."/.bak")) {
mkdir($dir."/.bak",0700);
}
- if (! file_exists($dir."/.bak/$GLOBALS[gblNumBackups]")) {
- mkdir($dir."/.bak/$GLOBALS[gblNumBackups]",0700);
+ if (! file_exists($dir."/.bak/$gblNumBackups")) {
+ mkdir($dir."/.bak/$gblNumBackups",0700);
}
$file=basename($target);
- for($i=$GLOBALS[gblNumBackups]-1;$i>0;$i--) {
+ for($i=$gblNumBackups-1;$i>0;$i--) {
MoveTo("$dir/.bak/$i/$file","$dir/.bak/".($i+1)."/");
}
MoveTo($target,$dir."/.bak/1/");
@@ -1866,8 +1878,8 @@
// common to all POSTs : redirect to directory view ($relDir)
if (isset($POSTACTION)) {
- $tstr = $PHP_SELF . "?D=" . urlencode($relDir) ;
- header("Location: " . $tstr) ;
+ $tstr = $HTTP_SERVER_VARS["PHP_SELF"]."?D=".urlencode($relDir);
+ header("Location: ".$tstr) ;
exit ;
}