51 |
deleted files! |
deleted files! |
52 |
|
|
53 |
.htusers is in form: |
.htusers is in form: |
54 |
login:Real Name:md5(loginpassword) |
login:Real Name:[md5(loginpassword)|auth_*]:email@host.dom |
55 |
|
|
56 |
|
|
57 |
TODO: |
TODO: |
75 |
|
|
76 |
// error_reporting(4) ; // how verbose ? |
// error_reporting(4) ; // how verbose ? |
77 |
|
|
78 |
|
// from where to include auth_*.php modules? |
79 |
|
$gblIncDir = "/home/httpd/docman"; |
80 |
|
|
81 |
// username/password should not be system |
// username/password should not be system |
82 |
// usernames/passwords !! |
// usernames/passwords !! |
83 |
|
|
|
// $gblPw = "hash_of_your_username_and_password" ; |
|
|
|
|
|
// $gblAuth = false ; // use builtin authentication |
|
|
$gblAuth = true ; // use builtin authentication |
|
|
$gblHash = "md5" ; // hash function to use |
|
|
|
|
84 |
$gblPw = ""; |
$gblPw = ""; |
85 |
|
|
86 |
if ($gblAuth) { |
// date format |
|
$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\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]; |
|
|
$gblEmail=$user[3]; |
|
|
continue ; |
|
|
} |
|
|
} |
|
|
fclose($htusers); |
|
|
} |
|
|
|
|
87 |
// $gblDateFmt="D, F d, Y"; |
// $gblDateFmt="D, F d, Y"; |
|
// $gblTimeFmt="g:i:sA"; |
|
|
|
|
88 |
$gblDateFmt="Y-m-d"; |
$gblDateFmt="Y-m-d"; |
89 |
|
|
90 |
|
// time format |
91 |
|
// $gblTimeFmt="g:i:sA"; |
92 |
$gblTimeFmt="H:i:s"; |
$gblTimeFmt="H:i:s"; |
93 |
|
|
94 |
// Number of backup files to keep |
// Number of backup files to keep |
100 |
// choose GifIcon below unless you have the M$ |
// choose GifIcon below unless you have the M$ |
101 |
// WingDings font installed on your system |
// WingDings font installed on your system |
102 |
|
|
103 |
$gblIcon = "GifIcon" ; // MockIcon or GifIcon |
$gblIcon="GifIcon"; // MockIcon or GifIcon |
104 |
|
|
105 |
// the directory below should be /icons/ or /icons/small/ |
// the directory below should be /icons/ or /icons/small/ |
106 |
// on Apache; a set of icons is included in the distribution |
// on Apache; a set of icons is included in the distribution |
107 |
|
|
108 |
$gblIconLocation = "/icons/" ; |
$gblIconLocation="/icons/"; |
109 |
|
|
110 |
// files you want to be able to edit in text mode |
// files you want to be able to edit in text mode |
111 |
// and view with (primitive) syntax highlighting |
// and view with (primitive) syntax highlighting |
120 |
$gblImages = array( ".jpg",".jpeg",".gif",".png",".ico", |
$gblImages = array( ".jpg",".jpeg",".gif",".png",".ico", |
121 |
".bmp",".xbm") ; |
".bmp",".xbm") ; |
122 |
|
|
123 |
|
// Where are users? (by default in .htusers file) |
124 |
|
$gblUsers = "htusers_file"; |
125 |
|
|
126 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
127 |
|
|
128 |
function StartHTML($title,$text="") { |
function StartHTML($title,$text="") { |
129 |
|
|
130 |
$title = "Site Manager " . $title ; |
$title = "Document Manager " . $title ; |
131 |
$host = $GLOBALS["HTTP_HOST"] ; |
$host = $GLOBALS["HTTP_HOST"] ; |
132 |
$self = $GLOBALS["PHP_SELF"] ; |
$self = $GLOBALS["PHP_SELF"] ; |
133 |
?> |
?> |
206 |
|
|
207 |
function DetailPage($fsRoot,$relDir,$fn) { |
function DetailPage($fsRoot,$relDir,$fn) { |
208 |
|
|
209 |
global $gblEditable, $gblImages ; |
global $gblEditable, $gblImages, $webRoot ; |
210 |
$self = $GLOBALS["PHP_SELF"] ; |
$self = $GLOBALS["PHP_SELF"] ; |
211 |
|
|
212 |
$relPath = $relDir . "/" . $fn ; |
$relPath = $relDir . "/" . $fn ; |
225 |
Error("Creation denied",$relDir) ; |
Error("Creation denied",$relDir) ; |
226 |
|
|
227 |
$text = "Use this page to view, modify or " ; |
$text = "Use this page to view, modify or " ; |
228 |
$text .= "delete a single document on this " ; |
if (is_dir($fsPath)) { |
229 |
|
$text .="delete a directory on this " ; |
230 |
|
} else { |
231 |
|
$text .= "delete a single document on this " ; |
232 |
|
}; |
233 |
$text .= "web site." ; |
$text .= "web site." ; |
234 |
$title = "(Detail Page)" ; |
$title = "(Detail Page)" ; |
235 |
StartHTML($title, $text) ; |
StartHTML($title, $text) ; |
239 |
$fsize = filesize($fsPath) ; |
$fsize = filesize($fsPath) ; |
240 |
$fmodified = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", filemtime($fsPath)) ; |
$fmodified = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", filemtime($fsPath)) ; |
241 |
$faccessed = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", fileatime($fsPath)) ; |
$faccessed = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", fileatime($fsPath)) ; |
242 |
echo "<PRE> file size: " . $fsize . " Bytes<BR>" ; |
$fuid=fileowner($fsPath); |
243 |
|
$fgid=filegroup($fsPath); |
244 |
|
$userinfo = posix_getpwuid($fuid); |
245 |
|
$grpinfo = posix_getgrgid($fgid); |
246 |
|
echo "<PRE>"; |
247 |
|
if (!is_dir($fsPath)) echo " file size: " . $fsize . " Bytes<BR>" ; |
248 |
echo "last modified: <B>" . $fmodified . "</B><BR>" ; |
echo "last modified: <B>" . $fmodified . "</B><BR>" ; |
249 |
echo "last accessed: <B>" . $faccessed . "</B><BR>" ; |
echo "last accessed: <B>" . $faccessed . "</B><BR>" ; |
250 |
echo " owner: <B>" . fileowner($fsPath) . "</B><BR>" ; |
echo " owner: <B>" . $userinfo["name"] . " [$fuid]</B><BR>" ; |
251 |
echo " group: <B>" . filegroup($fsPath) . "</B><BR>" ; |
echo " group: <B>" . $grpinfo["name"] . " [$fgid]</B><BR>" ; |
252 |
echo " permissions: <B>" ; |
echo " permissions: <B>" ; |
253 |
echo printf( "%o", fileperms($fsPath) ) . "</B>" ; |
echo printf( "%o", fileperms($fsPath) ) . "</B>" ; |
254 |
echo "</PRE>" ; |
echo "</PRE>" ; |
255 |
|
|
256 |
} |
} |
257 |
|
|
258 |
if ( $editable && ($writable || !$exists) && !$file_lock ) { |
if ( !is_dir($fsPath) && $editable && ($writable || !$exists) && !$file_lock ) { |
259 |
$fh = fopen($fsPath,"a+") ; |
$fh = fopen($fsPath,"a+") ; |
260 |
rewind($fh) ; |
rewind($fh) ; |
261 |
$fstr = fread($fh,filesize($fsPath)) ; |
$fstr = fread($fh,filesize($fsPath)) ; |
283 |
} |
} |
284 |
if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) { |
if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) { |
285 |
$info = getimagesize($fsPath) ; |
$info = getimagesize($fsPath) ; |
286 |
$tstr = "<IMG SRC=\"".urlpath($relPath)."\" BORDER=0 " ; |
$tstr = "<IMG SRC=\"$webRoot".urlpath($relPath)."\" BORDER=0 " ; |
287 |
$tstr .= $info[3] . " ALT=\"" . $fn . " - " ; |
$tstr .= $info[3] . " ALT=\"" . $fn . " - " ; |
288 |
$tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ; |
$tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ; |
289 |
// echo htmlentities($tstr) . "<BR><BR>" . $tstr ; |
// echo htmlentities($tstr) . "<BR><BR>" . $tstr ; |
355 |
$bakdir=dirname("$fsDir/$fn")."/.bak"; |
$bakdir=dirname("$fsDir/$fn")."/.bak"; |
356 |
if (file_exists($logname)) { |
if (file_exists($logname)) { |
357 |
$log=fopen($logname,"r"); |
$log=fopen($logname,"r"); |
358 |
$cl1=" class=lst"; $cl2=""; |
$cl1=" class=LST"; $cl2=""; |
359 |
$logarr = array(); |
$logarr = array(); |
360 |
while($line = fgetcsv($log,255,"\t")) { |
while($line = fgetcsv($log,255,"\t")) { |
361 |
$cl=$cl1; $cl1=$cl2; $cl2=$cl; |
$cl=$cl1; $cl1=$cl2; $cl2=$cl; |
362 |
array_unshift($logarr,array($cl,$line[0],$line[1],$line[2],$line[3])); |
array_unshift($logarr,array($cl,$line[0],$line[1],$line[2],$line[3])); |
363 |
} |
} |
364 |
fclose($log); |
fclose($log); |
365 |
print "<hr><br><b>CHANGES TO THIS FILE</b><br><table border=0 width=100%>\n"; |
if (is_dir("$fsDir/$fn")) { |
366 |
|
$whatis="DIRECTORY"; |
367 |
|
} else { |
368 |
|
$whatis="FILE"; |
369 |
|
} |
370 |
|
print "<hr><br><b>CHANGES TO THIS $whatis</b><br><table border=0 width=100%>\n"; |
371 |
$bakcount = 0; // start from 0, skip fist backup (it's current) |
$bakcount = 0; // start from 0, skip fist backup (it's current) |
372 |
while ($e = array_shift($logarr)) { |
while ($e = array_shift($logarr)) { |
373 |
if (strstr($e[4],"upload")) { |
if (strstr($e[4],"upload")) { |
374 |
if (file_exists("$bakdir/$bakcount/$name")) { |
if (file_exists("$bakdir/$bakcount/$name")) { |
375 |
$e[4]="<a href=\"".dirname($relPath)."/.bak/$bakcount/$name\">$e[4]</a>"; |
$e[4]="<a href=\"$webRoot".urlpath(dirname($relPath)."/.bak/$bakcount/$name")."\">$e[4]</a>"; |
376 |
} |
} |
377 |
$bakcount++; |
$bakcount++; |
378 |
} |
} |
633 |
|
|
634 |
function Navigate($fsRoot,$relDir) { |
function Navigate($fsRoot,$relDir) { |
635 |
|
|
636 |
global $gblEditable, $gblIcon, $gblModDays ; |
global $gblEditable, $gblIcon, $gblModDays, $webRoot ; |
637 |
|
|
638 |
$self = $GLOBALS["PHP_SELF"] ; |
$self = $GLOBALS["PHP_SELF"] ; |
639 |
if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") { |
|
640 |
$webRoot = "https://" . $GLOBALS["HTTP_HOST"] ; |
$fsDir = $fsRoot . $relDir . "/" ; // current directory |
|
} else { |
|
|
$webRoot = "http://" . $GLOBALS["HTTP_HOST"] ; |
|
|
} |
|
|
$fsDir = $fsRoot . $relDir . "/" ; // current directory |
|
641 |
|
|
642 |
if (!is_dir($fsDir)) Error("Dir not found",$relDir) ; |
if (!is_dir($fsDir)) Error("Dir not found",$relDir) ; |
643 |
|
|
697 |
<?php |
<?php |
698 |
} |
} |
699 |
|
|
700 |
|
function plural($name,$count) { |
701 |
|
$out="$count $name"; |
702 |
|
if ($count > 1) { |
703 |
|
$out.="s"; |
704 |
|
} |
705 |
|
return $out; |
706 |
|
} |
707 |
|
|
708 |
// output subdirs |
// output subdirs |
709 |
if (sizeof($dirList) > 0) { |
if (sizeof($dirList) > 0) { |
710 |
sort($dirList) ; |
sort($dirList) ; |
711 |
?> |
?> |
712 |
|
|
713 |
<TR><TD></TD><TD COLSPAN=5 CLASS=TOP><HR>DIRECTORY NAME</TD></TR> |
<TR><TD></TD><TD COLSPAN=2 CLASS=TOP>DIRECTORY NAME (<?= plural("dir",sizeof($dirList)) ?>)</TD><TD COLSPAN=3 CLASS=TOP>DIRECTORY NOTE</TR> |
714 |
|
|
715 |
<?php |
<?php |
716 |
while (list($key,$dir) = each($dirList)) { |
while (list($key,$dir) = each($dirList)) { |
717 |
|
|
718 |
|
$info_url=$self."?A=E&F=".urlencode($dir)."&D=".urlencode($relDir); |
719 |
$tstr = "<A HREF=\"" . $self . "?D=" ; |
$tstr = "<A HREF=\"" . $self . "?D=" ; |
720 |
$tstr .= urlencode($relDir."/".$dir) ; |
$tstr .= urlencode($relDir."/".$dir) ; |
721 |
$tstr .= "\">" . $dir . "/</A>" ; |
$tstr .= "\">" . $dir . "/</A>" ; |
722 |
|
$note_html="<a href=\"$info_url#note\">".$gblIcon("note")."</a>".ReadNote($fsDir.$dir); |
723 |
?> |
?> |
724 |
|
|
725 |
<TR><TD><?= $gblIcon("fldr") ?></TD> |
<TR><TD> |
726 |
<TD COLSPAN=5 CLASS=LST><?= $tstr ?></TD></TR> |
<A HREF="<?= $info_url ?>" TITLE="View/Edit"> |
727 |
|
<?= $gblIcon("fldr") ?></A></TD> |
728 |
|
<TD COLSPAN=2 CLASS=LST><?= $tstr ?></TD> |
729 |
|
<TD COLSPAN=3 CLASS=LST><?= $note_html ?></TD></TR> |
730 |
|
|
731 |
<?php |
<?php |
732 |
} // iterate over dirs |
} // iterate over dirs |
735 |
|
|
736 |
<TR><TD></TD><TD COLSPAN=5><HR><B><?= $webRoot . $relDir ?> |
<TR><TD></TD><TD COLSPAN=5><HR><B><?= $webRoot . $relDir ?> |
737 |
</B></TD></TR> |
</B></TD></TR> |
738 |
<TR><TD></TD><TD CLASS=TOP>DOCUMENT NAME</TD> |
<TR><TD></TD><TD CLASS=TOP>DOCUMENT NAME (<?= plural("file",sizeof($fileList)) ?>)</TD> |
739 |
<TD><?= $gblIcon("blank").$gblIcon("blank") ?></TD> |
<TD><?= $gblIcon("blank").$gblIcon("blank") ?></TD> |
740 |
<TD CLASS=TOP>NOTE</TD> |
<TD CLASS=TOP>NOTE</TD> |
741 |
<TD CLASS=TOP>LAST UPDATE</TD><TD CLASS=TOP>FILE SIZE</TD></TR> |
<TD CLASS=TOP>LAST UPDATE</TD><TD CLASS=TOP>FILE SIZE</TD></TR> |
867 |
<NOBR>NAME <INPUT TYPE="TEXT" NAME="FN" SIZE=14> |
<NOBR>NAME <INPUT TYPE="TEXT" NAME="FN" SIZE=14> |
868 |
<INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE"> |
<INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE"> |
869 |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"> |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"> |
870 |
<INPUT TYPE="SUBMIT" VALUE="CREATE"></NOBR> |
<INPUT TYPE="SUBMIT" VALUE="CREATE" NAME="CREATE"> |
871 |
|
</NOBR> |
872 |
<NOBR>OR <A HREF="<?= $self ?>?A=U&D=<?= urlencode($relDir) ?>">UPLOAD</A> A FILE |
<NOBR>OR <A HREF="<?= $self ?>?A=U&D=<?= urlencode($relDir) ?>">UPLOAD</A> A FILE |
873 |
</NOBR> |
</NOBR> |
874 |
</TD></TR> |
</TD></TR> |
926 |
|
|
927 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
928 |
|
|
|
function CreateHash($user, $pw) { |
|
|
|
|
|
global $gblHash ; // hash function to use |
|
|
|
|
|
if ($user == "" || $pw == "") { |
|
|
$text = "either no password or no username supplied" ; |
|
|
Error("Create Hash",$text) ; |
|
|
} |
|
|
$title = "(Create Hash)" ; |
|
|
StartHTML($title) ; |
|
|
echo "<P ALIGN=center>" ; |
|
|
echo "<BLOCKQUOTE>Copy the value below and paste it " ; |
|
|
echo "into the<BR>value for \$gblPw in the source of " ; |
|
|
echo "this file<BR><BR><B>" . $gblHash($user.$pw) ; |
|
|
echo "</B><BR><BR>Hash function: " . $gblHash ; |
|
|
echo "</BLOCKQUOTE></P>" ; |
|
|
EndHTML() ; |
|
|
exit ; |
|
|
|
|
|
} // end function CreateHash |
|
|
|
|
|
////////////////////////////////////////////////////////////////// |
|
|
|
|
929 |
function NoEntry() { |
function NoEntry() { |
930 |
|
|
931 |
$user = $GLOBALS["PHP_AUTH_USER"] ; |
$user = $GLOBALS["PHP_AUTH_USER"] ; |
935 |
$title = "(401 Unauthorized)" ; |
$title = "(401 Unauthorized)" ; |
936 |
$text = "No trespassing !" ; |
$text = "No trespassing !" ; |
937 |
StartHTML($title,$text) ; |
StartHTML($title,$text) ; |
|
?> |
|
938 |
|
|
|
<FORM ACTION="<?= $self ?>?HASH=create" METHOD="POST"> |
|
|
<INPUT TYPE="HIDDEN" NAME="USER" VALUE="<?= $user ?>"> |
|
|
<INPUT TYPE="HIDDEN" NAME="PW" VALUE="<?= $pw ?>"> |
|
|
|
|
|
<BLOCKQUOTE><B>If you are a site administrator:</B><BR><BR> |
|
|
Click below to <B>generate a password hash</B><BR>from |
|
|
the username-password pair you just<BR>entered. Then include the hash in |
|
|
the source<BR>of this file.<BR><BR> |
|
|
<INPUT TYPE="SUBMIT" VALUE="CREATE HASH"> |
|
|
</BLOCKQUOTE></FORM> |
|
|
|
|
|
<?php |
|
939 |
EndHTML() ; |
EndHTML() ; |
940 |
exit ; |
exit ; |
941 |
} |
} |
988 |
$msg=fgets($note,4096); |
$msg=fgets($note,4096); |
989 |
fclose($note); |
fclose($note); |
990 |
} |
} |
991 |
return StripSlashes($msg); |
return HtmlSpecialChars(StripSlashes($msg)); |
992 |
|
|
993 |
} |
} |
994 |
|
|
1069 |
|
|
1070 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
1071 |
|
|
1072 |
function safe_rename($from,$to) { |
function safe_rename($fromdir,$fromfile,$tofile) { |
1073 |
if (file_exists($from) && is_writable(dirname($to))) { |
function try_rename($from,$to) { |
1074 |
rename($from,$to); |
# print "$from -> $to\n"; |
1075 |
|
if (file_exists($from) && is_writeable(dirname($to))) { |
1076 |
|
rename($from,$to); |
1077 |
|
} |
1078 |
|
} |
1079 |
|
|
1080 |
|
function try_dir($todir) { |
1081 |
|
if (! file_exists($todir)) { |
1082 |
|
mkdir($todir,0700); |
1083 |
|
} |
1084 |
|
} |
1085 |
|
|
1086 |
|
$to="$fromdir/$tofile"; |
1087 |
|
$todir=dirname($to); |
1088 |
|
$tofile=basename($to); |
1089 |
|
|
1090 |
|
# print "<pre>$fromdir / $fromfile -> $todir / $tofile\n\n"; |
1091 |
|
|
1092 |
|
try_rename("$fromdir/$fromfile","$todir/$tofile"); |
1093 |
|
try_dir("$todir/.log"); |
1094 |
|
try_rename("$fromdir/.log/$fromfile","$todir/.log/$tofile"); |
1095 |
|
try_dir("$todir/.note"); |
1096 |
|
try_rename("$fromdir/.note/$fromfile","$todir/.note/$tofile"); |
1097 |
|
try_dir("$todir/.lock"); |
1098 |
|
try_rename("$fromdir/.lock/$fromfile","$todir/.lock/$tofile"); |
1099 |
|
try_dir("$todir/.bak"); |
1100 |
|
for($i=0;$i<=$GLOBALS[gblNumBackups];$i++) { |
1101 |
|
try_rename("$fromdir/.bak/$i/$fromfile","$todir/.bak/$i/$tofile"); |
1102 |
} |
} |
1103 |
} |
} |
1104 |
|
|
1105 |
|
|
1106 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
1107 |
|
|
1108 |
// recursivly delete directory |
// recursivly delete directory |
1146 |
} |
} |
1147 |
} |
} |
1148 |
fclose($log); |
fclose($log); |
1149 |
$cl1=" class=lst"; $cl2=""; |
$cl1=" class=LST"; $cl2=""; |
1150 |
print "<table border=0 width=100%>\n"; |
print "<table border=0 width=100%>\n"; |
1151 |
while ($e = array_shift($logarr)) { |
while ($e = array_shift($logarr)) { |
1152 |
$cl=$cl1; $cl1=$cl2; $cl2=$cl; |
$cl=$cl1; $cl1=$cl2; $cl2=$cl; |
1177 |
// forks before authentication: style sheet and hash |
// forks before authentication: style sheet and hash |
1178 |
// creation if password not yet set. |
// creation if password not yet set. |
1179 |
if ($STYLE == "get") { CSS() ; exit ; } |
if ($STYLE == "get") { CSS() ; exit ; } |
1180 |
if ($HASH != "") { |
|
1181 |
CreateHash($USER, $PW) ; |
$fsScriptDir = dirname($SCRIPT_FILENAME) ; |
1182 |
exit ; |
// i.e. /home/httpd/html/docman |
1183 |
|
|
1184 |
|
// read user-defined configuration |
1185 |
|
if (file_exists("$fsScriptDir/.docman.conf")) { |
1186 |
|
include("$fsScriptDir/.docman.conf"); |
1187 |
} |
} |
1188 |
|
|
1189 |
// authentication if $gblAuth == true |
// where do we get users from? |
1190 |
if ( $gblAuth && $gblHash($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw || |
if (file_exists("$gblIncDir/$gblUsers.php")) { |
1191 |
|
include("$gblIncDir/$gblUsers.php"); |
1192 |
|
} else { |
1193 |
|
Error("Configuration error","Can't find user handling module at <tt>$gblIncDir/$gblUsers.php</tt> ! Please fix <tt>$fsScriptDir/.docman.conf</tt>"); |
1194 |
|
} |
1195 |
|
|
1196 |
|
// authentication failure |
1197 |
|
if ( md5($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw || |
1198 |
isset($relogin) && $gblPw == $relogin ) { |
isset($relogin) && $gblPw == $relogin ) { |
1199 |
header("WWW-authenticate: basic realm=\"$HTTP_HOST\"") ; |
header("WWW-authenticate: basic realm=\"$HTTP_HOST\"") ; |
1200 |
header("HTTP/1.0 401 Unauthorized") ; |
header("HTTP/1.0 401 Unauthorized") ; |
1208 |
$relDir = urldecode($D) ; // then use GET |
$relDir = urldecode($D) ; // then use GET |
1209 |
} |
} |
1210 |
|
|
1211 |
|
$relDir=stripSlashes($relDir); |
1212 |
|
|
1213 |
if ($relDir == "/") $relDir = "" ; |
if ($relDir == "/") $relDir = "" ; |
1214 |
// default : website root = "" |
// default : website root = "" |
1215 |
|
|
1223 |
$relScriptDir = dirname($SCRIPT_NAME) ; |
$relScriptDir = dirname($SCRIPT_NAME) ; |
1224 |
// i.e. /docman |
// i.e. /docman |
1225 |
|
|
|
$fsScriptDir = dirname($SCRIPT_FILENAME) ; |
|
|
// i.e. /home/httpd/html/docman |
|
|
|
|
1226 |
// start on server root |
// start on server root |
1227 |
// $gblFsRoot = substr($fsScriptDir,0, strlen($fsScriptDir)-strlen($relScriptDir)) ; |
// $gblFsRoot = substr($fsScriptDir,0, strlen($fsScriptDir)-strlen($relScriptDir)) ; |
1228 |
// or on script root |
// or on script root |
1232 |
$fsDir = $gblFsRoot . $relDir ; // current directory |
$fsDir = $gblFsRoot . $relDir ; // current directory |
1233 |
if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ; |
if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ; |
1234 |
|
|
1235 |
|
if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") { |
1236 |
|
$webRoot = "https://"; |
1237 |
|
} else { |
1238 |
|
$webRoot = "http://"; |
1239 |
|
} |
1240 |
|
$webRoot .= $GLOBALS["HTTP_HOST"] . $relScriptDir; |
1241 |
|
|
1242 |
$FN=stripSlashes($FN); |
$FN=stripSlashes($FN); |
1243 |
|
|
1244 |
|
|
1245 |
switch ($POSTACTION) { |
switch ($POSTACTION) { |
1246 |
case "UPLOAD" : |
case "UPLOAD" : |
1247 |
if (!is_writeable($fsDir)) Error("Write denied",$relDir) ; |
if (!is_writeable($fsDir)) Error("Write denied",$relDir) ; |
1317 |
// this functionality is doubled in DetailView(). |
// this functionality is doubled in DetailView(). |
1318 |
// better keep it here altogether |
// better keep it here altogether |
1319 |
// chmod perms to $gblFilePerms |
// chmod perms to $gblFilePerms |
1320 |
if ( file_exists($path) && !is_writable($path) ) |
if ( file_exists($path) && !is_writeable($path) ) |
1321 |
Error("File not writable", $relPath) ; |
Error("File not writable", $relPath) ; |
1322 |
$fh = fopen($path, "w+") ; |
$fh = fopen($path, "w+") ; |
1323 |
if ($fh) { |
if ($fh) { |
1389 |
if ( $CONFIRM != "on" ) break ; |
if ( $CONFIRM != "on" ) break ; |
1390 |
|
|
1391 |
Logit("$fsDir/$FN","renamed $FN to $NEWNAME"); |
Logit("$fsDir/$FN","renamed $FN to $NEWNAME"); |
1392 |
safe_rename("$fsDir/$FN","$fsDir/$NEWNAME"); |
safe_rename($fsDir,$FN,$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"); |
|
|
} |
|
|
|
|
1393 |
break ; |
break ; |
1394 |
|
|
1395 |
case "NOTE" : |
case "NOTE" : |
1435 |
case "E" : |
case "E" : |
1436 |
$F=stripSlashes($F); |
$F=stripSlashes($F); |
1437 |
// detail of $relDir/$F |
// detail of $relDir/$F |
1438 |
if (is_file("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ; |
if (is_file("$gblFsRoot/$relDir/$F") || is_dir("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ; |
1439 |
exit ; |
exit ; |
1440 |
case "C" : |
case "C" : |
1441 |
$F=stripSlashes($F); |
$F=stripSlashes($F); |
1446 |
// checkout |
// checkout |
1447 |
Lock("$gblFsRoot/$relDir/$F"); |
Lock("$gblFsRoot/$relDir/$F"); |
1448 |
header("Content-Disposition: attachment; filename=$F" ); |
header("Content-Disposition: attachment; filename=$F" ); |
1449 |
Header("Location: ".urlpath("$relDir/$F")); |
Header("Location: $webRoot".urlpath("$relDir/$F")); |
1450 |
exit; |
exit; |
1451 |
case "Ci" : |
case "Ci" : |
1452 |
$F=stripSlashes($F); |
$F=stripSlashes($F); |
1463 |
// view |
// view |
1464 |
LogIt("$gblFsRoot/$relDir/$F","viewed"); |
LogIt("$gblFsRoot/$relDir/$F","viewed"); |
1465 |
header("Content-Disposition: attachment; filename=$F" ); |
header("Content-Disposition: attachment; filename=$F" ); |
1466 |
Header("Location: ".urlpath("$relDir/$F")); |
Header("Location: $webRoot".urlpath("$relDir/$F")); |
1467 |
exit; |
exit; |
1468 |
case "Ch" : |
case "Ch" : |
1469 |
StartHTML("(File changes)","All changes chronologicaly..."); |
StartHTML("(File changes)","All changes chronologicaly..."); |