76 |
// error_reporting(4) ; // how verbose ? |
// error_reporting(4) ; // how verbose ? |
77 |
|
|
78 |
// from where to include auth_*.php modules? |
// from where to include auth_*.php modules? |
79 |
$gblIncDir = "/data/docman"; |
$gblIncDir = "/home/httpd/docman"; |
80 |
|
|
81 |
// username/password should not be system |
// username/password should not be system |
82 |
// usernames/passwords !! |
// usernames/passwords !! |
83 |
|
|
84 |
$gblPw = ""; |
$gblPw = ""; |
85 |
|
|
|
$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); |
|
|
} |
|
|
} |
|
|
$gblEmail=$user[3]; |
|
|
continue ; |
|
|
} |
|
|
} |
|
|
fclose($htusers); |
|
|
|
|
86 |
// date format |
// date format |
87 |
// $gblDateFmt="D, F d, Y"; |
// $gblDateFmt="D, F d, Y"; |
88 |
$gblDateFmt="Y-m-d"; |
$gblDateFmt="Y-m-d"; |
203 |
|
|
204 |
function DetailPage($fsRoot,$relDir,$fn) { |
function DetailPage($fsRoot,$relDir,$fn) { |
205 |
|
|
206 |
global $gblEditable, $gblImages ; |
global $gblEditable, $gblImages, $webRoot ; |
207 |
$self = $GLOBALS["PHP_SELF"] ; |
$self = $GLOBALS["PHP_SELF"] ; |
208 |
|
|
209 |
$relPath = $relDir . "/" . $fn ; |
$relPath = $relDir . "/" . $fn ; |
271 |
} |
} |
272 |
if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) { |
if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) { |
273 |
$info = getimagesize($fsPath) ; |
$info = getimagesize($fsPath) ; |
274 |
$tstr = "<IMG SRC=\"".urlpath($relPath)."\" BORDER=0 " ; |
$tstr = "<IMG SRC=\"$webRoot".urlpath($relPath)."\" BORDER=0 " ; |
275 |
$tstr .= $info[3] . " ALT=\"" . $fn . " - " ; |
$tstr .= $info[3] . " ALT=\"" . $fn . " - " ; |
276 |
$tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ; |
$tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ; |
277 |
// echo htmlentities($tstr) . "<BR><BR>" . $tstr ; |
// echo htmlentities($tstr) . "<BR><BR>" . $tstr ; |
355 |
while ($e = array_shift($logarr)) { |
while ($e = array_shift($logarr)) { |
356 |
if (strstr($e[4],"upload")) { |
if (strstr($e[4],"upload")) { |
357 |
if (file_exists("$bakdir/$bakcount/$name")) { |
if (file_exists("$bakdir/$bakcount/$name")) { |
358 |
$e[4]="<a href=\"".urlpath(dirname($relPath)."/.bak/$bakcount/$name")."\">$e[4]</a>"; |
$e[4]="<a href=\"$webRoot".urlpath(dirname($relPath)."/.bak/$bakcount/$name")."\">$e[4]</a>"; |
359 |
} |
} |
360 |
$bakcount++; |
$bakcount++; |
361 |
} |
} |
616 |
|
|
617 |
function Navigate($fsRoot,$relDir) { |
function Navigate($fsRoot,$relDir) { |
618 |
|
|
619 |
global $gblEditable, $gblIcon, $gblModDays ; |
global $gblEditable, $gblIcon, $gblModDays, $webRoot ; |
620 |
|
|
621 |
$self = $GLOBALS["PHP_SELF"] ; |
$self = $GLOBALS["PHP_SELF"] ; |
622 |
if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") { |
|
623 |
$webRoot = "https://" . $GLOBALS["HTTP_HOST"] ; |
$fsDir = $fsRoot . $relDir . "/" ; // current directory |
|
} else { |
|
|
$webRoot = "http://" . $GLOBALS["HTTP_HOST"] ; |
|
|
} |
|
|
$fsDir = $fsRoot . $relDir . "/" ; // current directory |
|
624 |
|
|
625 |
if (!is_dir($fsDir)) Error("Dir not found",$relDir) ; |
if (!is_dir($fsDir)) Error("Dir not found",$relDir) ; |
626 |
|
|
1119 |
// creation if password not yet set. |
// creation if password not yet set. |
1120 |
if ($STYLE == "get") { CSS() ; exit ; } |
if ($STYLE == "get") { CSS() ; exit ; } |
1121 |
|
|
1122 |
|
$htusers_file=dirname($SCRIPT_FILENAME)."/.htusers"; |
1123 |
|
if (! file_exists($htusers_file)) { |
1124 |
|
if (is_writable($htuser_file)) { |
1125 |
|
$htusers=fopen($htusers_file,"a+"); |
1126 |
|
fputs($htusers,"# Change owner of $htusers_file to root !!\n"); |
1127 |
|
fputs($htusers,"demo:full name:[md5_hash|auth_*]:e-mail\n"); |
1128 |
|
fclose($htusers); |
1129 |
|
} else { |
1130 |
|
Error("Can't create proto user file!","Please make directory <tt>".dirname($htusers_file)."</tt> writable or create <tt>.htusers</tt> file by hand using <tt>adduser.pl</tt> script!"); |
1131 |
|
exit; |
1132 |
|
} |
1133 |
|
} |
1134 |
|
$htusers=fopen($htusers_file,"r"); |
1135 |
|
while($user = fgetcsv($htusers,255,":")) { |
1136 |
|
if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) { |
1137 |
|
$gblUserName=$user[1]; |
1138 |
|
$gblPw=$user[2]; |
1139 |
|
if (substr($gblPw,0,5) == "auth_" && file_exists("$gblIncDir/$gblPw.php")) { |
1140 |
|
require("$gblIncDir/$gblPw.php"); |
1141 |
|
if ($gblPw($user)) { |
1142 |
|
$gblPw=md5($PHP_AUTH_USER.$PHP_AUTH_PW); |
1143 |
|
} else { |
1144 |
|
$gblPw="error".md5($PHP_AUTH_USER.$PHP_AUTH_PW); |
1145 |
|
} |
1146 |
|
} |
1147 |
|
$gblEmail=$user[3]; |
1148 |
|
continue ; |
1149 |
|
} |
1150 |
|
} |
1151 |
|
fclose($htusers); |
1152 |
|
|
1153 |
// authentication failure |
// authentication failure |
1154 |
if ( md5($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw || |
if ( md5($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw || |
1155 |
isset($relogin) && $gblPw == $relogin ) { |
isset($relogin) && $gblPw == $relogin ) { |
1190 |
$fsDir = $gblFsRoot . $relDir ; // current directory |
$fsDir = $gblFsRoot . $relDir ; // current directory |
1191 |
if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ; |
if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ; |
1192 |
|
|
1193 |
|
if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") { |
1194 |
|
$webRoot = "https://"; |
1195 |
|
} else { |
1196 |
|
$webRoot = "http://"; |
1197 |
|
} |
1198 |
|
$webRoot .= $GLOBALS["HTTP_HOST"] . $relScriptDir; |
1199 |
|
|
1200 |
$FN=stripSlashes($FN); |
$FN=stripSlashes($FN); |
1201 |
|
|
1202 |
switch ($POSTACTION) { |
switch ($POSTACTION) { |
1410 |
// checkout |
// checkout |
1411 |
Lock("$gblFsRoot/$relDir/$F"); |
Lock("$gblFsRoot/$relDir/$F"); |
1412 |
header("Content-Disposition: attachment; filename=$F" ); |
header("Content-Disposition: attachment; filename=$F" ); |
1413 |
Header("Location: ".urlpath("$relDir/$F")); |
Header("Location: $webRoot".urlpath("$relDir/$F")); |
1414 |
exit; |
exit; |
1415 |
case "Ci" : |
case "Ci" : |
1416 |
$F=stripSlashes($F); |
$F=stripSlashes($F); |
1427 |
// view |
// view |
1428 |
LogIt("$gblFsRoot/$relDir/$F","viewed"); |
LogIt("$gblFsRoot/$relDir/$F","viewed"); |
1429 |
header("Content-Disposition: attachment; filename=$F" ); |
header("Content-Disposition: attachment; filename=$F" ); |
1430 |
Header("Location: ".urlpath("$relDir/$F")); |
Header("Location: $webRoot".urlpath("$relDir/$F")); |
1431 |
exit; |
exit; |
1432 |
case "Ch" : |
case "Ch" : |
1433 |
StartHTML("(File changes)","All changes chronologicaly..."); |
StartHTML("(File changes)","All changes chronologicaly..."); |