--- docman.php 2001/01/26 12:39:57 1.30 +++ docman.php 2001/01/30 16:48:36 1.31 @@ -83,32 +83,6 @@ $gblPw = ""; - $htusers_file=dirname($SCRIPT_FILENAME)."/.htusers"; - if (! file_exists($htusers_file)) { - $htusers=fopen($htusers_file,"a+"); - fputs($htusers,"# Change owner of $htusers_file to root !!\n"); - fputs($htusers,"demo:full name:[md5_hash|auth_*]:e-mail\n"); - fclose($htusers); - } - $htusers=fopen($htusers_file,"r"); - while($user = fgetcsv($htusers,255,":")) { - if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) { - $gblUserName=$user[1]; - $gblPw=$user[2]; - if (substr($gblPw,0,5) == "auth_" && file_exists("$gblIncDir/$gblPw.php")) { - require("$gblIncDir/$gblPw.php"); - if ($gblPw($user)) { - $gblPw=md5($PHP_AUTH_USER.$PHP_AUTH_PW); - } else { - $gblPw="error".md5($PHP_AUTH_USER.$PHP_AUTH_PW); - } - } - $gblEmail=$user[3]; - continue ; - } - } - fclose($htusers); - // date format // $gblDateFmt="D, F d, Y"; $gblDateFmt="Y-m-d"; @@ -229,7 +203,7 @@ function DetailPage($fsRoot,$relDir,$fn) { - global $gblEditable, $gblImages ; + global $gblEditable, $gblImages, $webRoot ; $self = $GLOBALS["PHP_SELF"] ; $relPath = $relDir . "/" . $fn ; @@ -297,7 +271,7 @@ } if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) { $info = getimagesize($fsPath) ; - $tstr = "\""" ; // echo htmlentities($tstr) . "

" . $tstr ; @@ -381,7 +355,7 @@ while ($e = array_shift($logarr)) { if (strstr($e[4],"upload")) { if (file_exists("$bakdir/$bakcount/$name")) { - $e[4]="$e[4]"; + $e[4]="$e[4]"; } $bakcount++; } @@ -642,15 +616,11 @@ function Navigate($fsRoot,$relDir) { - global $gblEditable, $gblIcon, $gblModDays ; + global $gblEditable, $gblIcon, $gblModDays, $webRoot ; $self = $GLOBALS["PHP_SELF"] ; - if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") { - $webRoot = "https://" . $GLOBALS["HTTP_HOST"] ; - } else { - $webRoot = "http://" . $GLOBALS["HTTP_HOST"] ; - } - $fsDir = $fsRoot . $relDir . "/" ; // current directory + + $fsDir = $fsRoot . $relDir . "/" ; // current directory if (!is_dir($fsDir)) Error("Dir not found",$relDir) ; @@ -1149,6 +1119,37 @@ // creation if password not yet set. if ($STYLE == "get") { CSS() ; exit ; } + $htusers_file=dirname($SCRIPT_FILENAME)."/.htusers"; + if (! file_exists($htusers_file)) { + if (is_writable($htuser_file)) { + $htusers=fopen($htusers_file,"a+"); + fputs($htusers,"# Change owner of $htusers_file to root !!\n"); + fputs($htusers,"demo:full name:[md5_hash|auth_*]:e-mail\n"); + fclose($htusers); + } else { + Error("Can't create proto user file!","Please make directory ".dirname($htusers_file)." writable or create .htusers file by hand using adduser.pl script!"); + exit; + } + } + $htusers=fopen($htusers_file,"r"); + while($user = fgetcsv($htusers,255,":")) { + if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) { + $gblUserName=$user[1]; + $gblPw=$user[2]; + if (substr($gblPw,0,5) == "auth_" && file_exists("$gblIncDir/$gblPw.php")) { + require("$gblIncDir/$gblPw.php"); + if ($gblPw($user)) { + $gblPw=md5($PHP_AUTH_USER.$PHP_AUTH_PW); + } else { + $gblPw="error".md5($PHP_AUTH_USER.$PHP_AUTH_PW); + } + } + $gblEmail=$user[3]; + continue ; + } + } + fclose($htusers); + // authentication failure if ( md5($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw || isset($relogin) && $gblPw == $relogin ) { @@ -1189,6 +1190,13 @@ $fsDir = $gblFsRoot . $relDir ; // current directory if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ; + if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") { + $webRoot = "https://"; + } else { + $webRoot = "http://"; + } + $webRoot .= $GLOBALS["HTTP_HOST"] . $relScriptDir; + $FN=stripSlashes($FN); switch ($POSTACTION) { @@ -1402,7 +1410,7 @@ // checkout Lock("$gblFsRoot/$relDir/$F"); header("Content-Disposition: attachment; filename=$F" ); - Header("Location: ".urlpath("$relDir/$F")); + Header("Location: $webRoot".urlpath("$relDir/$F")); exit; case "Ci" : $F=stripSlashes($F); @@ -1419,7 +1427,7 @@ // view LogIt("$gblFsRoot/$relDir/$F","viewed"); header("Content-Disposition: attachment; filename=$F" ); - Header("Location: ".urlpath("$relDir/$F")); + Header("Location: $webRoot".urlpath("$relDir/$F")); exit; case "Ch" : StartHTML("(File changes)","All changes chronologicaly...");