34 |
/* PHP3. Fixed bug which would send you to a non- */ |
/* PHP3. Fixed bug which would send you to a non- */ |
35 |
/* existent address after file modifications. */ |
/* existent address after file modifications. */ |
36 |
|
|
37 |
|
/* |
38 |
|
|
39 |
|
This project is now called Directory Manager. |
40 |
|
|
41 |
|
For more info, please see web pages at |
42 |
|
http://www.rot13.org/~dpavlin/docman.html |
43 |
|
|
44 |
|
It's relased under GPL by |
45 |
|
Dobrica Pavlinusic <dpavlin@rot13.org> |
46 |
|
|
47 |
|
|
48 |
|
IMPORTANT INSTALLATION NOTE: |
49 |
|
deny serving of .* (dot-something) files in web server! |
50 |
|
Otherwise, uses can access your log files, users and/or |
51 |
|
deleted files! |
52 |
|
|
53 |
|
.htusers is in form: |
54 |
|
login:Real Name:[md5(loginpassword)|auth_*]:email@host.dom |
55 |
|
|
56 |
|
|
57 |
|
TODO: |
58 |
|
mixed file/directory output (add type to each entry, |
59 |
|
real support for links) |
60 |
|
access controll |
61 |
|
|
62 |
|
*/ |
63 |
|
|
64 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
65 |
|
|
66 |
// TODO : Don't let the file be modified itself. Create a hash of |
// TODO : Don't let the file be modified itself. Create a hash of |
71 |
|
|
72 |
// GLOBAL PARAMETERS |
// GLOBAL PARAMETERS |
73 |
// ================= |
// ================= |
74 |
// Make modifications here to suit siteman to your needs |
// Make modifications here to suit docman to your needs |
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 |
|
|
84 |
// your (hashed) username/password here |
$gblPw = ""; |
85 |
$gblPw = "hash_of_your_username_and_password" ; |
|
86 |
|
// date format |
87 |
$gblAuth = false ; // use builtin authentication |
// $gblDateFmt="D, F d, Y"; |
88 |
$gblHash = "md5" ; // hash function to use |
$gblDateFmt="Y-m-d"; |
89 |
|
|
90 |
|
// time format |
91 |
|
// $gblTimeFmt="g:i:sA"; |
92 |
|
$gblTimeFmt="H:i:s"; |
93 |
|
|
94 |
|
// Number of backup files to keep |
95 |
|
$gblNumBackups=3; |
96 |
|
|
97 |
|
// show red star if newer than ... days |
98 |
|
$gblModDays=1; |
99 |
|
|
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 |
?> |
?> |
134 |
|
|
135 |
<HTML> |
<HTML> |
136 |
<HEAD> |
<HEAD> |
137 |
<TITLE><?php echo $host . " " . $title ?></TITLE> |
<TITLE><?= $host . " " . $title ?></TITLE> |
138 |
<META NAME="description" CONTENT="PHP port of AnyPortal Site Manager"> |
<META NAME="description" CONTENT="PHP port of AnyPortal Site Manager"> |
139 |
<META NAME="keywords" CONTENT="site manager, web site maintenance"> |
<META NAME="keywords" CONTENT="site manager, web site maintenance"> |
140 |
<META NAME="robots" CONTENT="noindex"> |
<META NAME="robots" CONTENT="noindex"> |
141 |
<META HTTP-EQUIV="expires" CONTENT="0"> |
<META HTTP-EQUIV="expires" CONTENT="0"> |
142 |
<LINK REL="stylesheet" TYPE="text/css" |
<LINK REL="stylesheet" TYPE="text/css" |
143 |
HREF="<?php echo $self ?>?STYLE=get"> |
HREF="<?= $self ?>?STYLE=get"> |
144 |
</HEAD> |
</HEAD> |
145 |
<BODY BGCOLOR="#FFFFFF"> |
<BODY BGCOLOR="#FFFFFF"> |
146 |
<H3 ALIGN="RIGHT"><?php echo $host ?></H3> |
<H3 ALIGN="RIGHT"><?= $host ?></H3> |
147 |
<TABLE BORDER=0 WIDTH="100%"><TR> |
<TABLE BORDER=0 WIDTH="100%"><TR> |
148 |
<TD CLASS=INV><?php echo $title ?></TD></TR></TABLE> |
<TD CLASS=INV><?= $title ?></TD></TR></TABLE> |
149 |
<P><?php echo $text ?></P> |
<P><?= $text ?></P> |
150 |
|
|
151 |
<?php |
<?php |
152 |
} // end function StartHTML |
} // end function StartHTML |
158 |
|
|
159 |
<HR> |
<HR> |
160 |
<P CLASS=FTR> |
<P CLASS=FTR> |
161 |
<B><?php echo date("D, F d, Y") ?> - |
<B><?= date($GLOBALS[gblDateFmt]) ?> - |
162 |
<?php echo date("g:i:sA") ?></B><BR>ANYPORTAL(php) Site Manager |
<?= date($GLOBALS[gblTimeFmt]) ?> - |
163 |
- © 1999 by <A HREF="http://www.anyportal.com">ANYPORTAL</A> |
<?= $GLOBALS[gblUserName] ?> |
164 |
- © 2000 by <A HREF="http://da.nger.org">d@nger.org</A> |
<small> [<a href="<?= $GLOBALS["PHP_SELF"] ?>?relogin=<?= $GLOBALS[gblPw] ?>">logout</a>]</small> |
165 |
|
</B> |
166 |
|
<BR>ANYPORTAL(php) Site Manager |
167 |
|
<br><small> |
168 |
|
© 1999 by <A HREF="http://www.anyportal.com">ANYPORTAL</A>, |
169 |
|
© 2000 by <A HREF="http://da.nger.org">d@nger.org</A>, |
170 |
|
© 2000 by <A HREF="http://www.rot13.org/~dpavlin/">DbP</A> |
171 |
|
</small> |
172 |
</P> |
</P> |
173 |
<BR><BR><BR></BODY></HTML> |
<BR> |
174 |
|
<? //include(".debug.inc") ?> |
175 |
|
<BR><BR></BODY></HTML> |
176 |
|
|
177 |
<?php |
<?php |
178 |
} // end function EndHTML |
} // end function EndHTML |
182 |
function CSS() { |
function CSS() { |
183 |
?> |
?> |
184 |
|
|
185 |
BODY,TD,P,H1,H2,H3 { font-family:Helvetica,Arial,sans-serif; } |
BODY,TD,P,H1,H2,H3 { font-family:Verdana,Helvetica,Arial,sans-serif; } |
186 |
.BLK { color:black; } |
.BLK { color:black; } |
187 |
.RED { color:red; } |
.RED { color:red; } |
188 |
.TOP { color:red; font-size:70%; } /* table headings */ |
.TOP { color:red; font-size:70%; } /* table headings */ |
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 ; |
216 |
$exists = file_exists($fsPath) ; |
$exists = file_exists($fsPath) ; |
217 |
$ext = strtolower(strrchr($relPath,".")) ; |
$ext = strtolower(strrchr($relPath,".")) ; |
218 |
$editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) ; |
$editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) ; |
219 |
$writable = Writeable($fsPath) ; |
$writable = is_writeable($fsPath) ; |
220 |
|
$file_lock = CheckLock($fsPath); |
221 |
|
|
222 |
if (!$editable && !$exists) |
if (!$editable && !$exists) |
223 |
Error("Creation unsupported for type",$relPath) ; |
Error("Creation unsupported for type",$relPath) ; |
224 |
if (!exists && !Writeable($fsDir) ) |
if (!exists && !is_writeable($fsDir) ) |
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) ; |
236 |
|
|
237 |
echo "<H3>" . $relDir . "/" . $fn . "</H3>" ; |
echo "<H3>" . $relDir . "/" . $fn . "</H3>" ; |
238 |
if ($exists) { // get file info |
if ($exists) { // get file info |
239 |
$fsize = filesize($fsPath) ; |
$fsize = filesize($fsPath) ; |
240 |
$fmodified = date("d/M/y G:i:s", filemtime($fsPath)) ; |
$fmodified = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", filemtime($fsPath)) ; |
241 |
$faccessed = date("d/M/y G:i:s", fileatime($fsPath)) ; |
$faccessed = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", fileatime($fsPath)) ; |
242 |
echo "<PRE> file size: " . $fsize . " Bytes<BR>" ; |
$fuid=fileowner($fsPath); |
243 |
echo "last modified: <B>" . $fmodified . "</B><BR>" ; |
$fgid=filegroup($fsPath); |
244 |
echo "last accessed: <B>" . $faccessed . "</B><BR>" ; |
$userinfo = posix_getpwuid($fuid); |
245 |
echo " owner: <B>" . fileowner($fsPath) . "</B><BR>" ; |
$grpinfo = posix_getgrgid($fgid); |
246 |
echo " group: <B>" . filegroup($fsPath) . "</B><BR>" ; |
echo "<PRE>"; |
247 |
echo " permissions: <B>" ; |
if (!is_dir($fsPath)) echo " file size: " . $fsize . " Bytes<BR>" ; |
248 |
echo printf( "%o", fileperms($fsPath) ) . "</B>" ; |
echo "last modified: <B>" . $fmodified . "</B><BR>" ; |
249 |
echo "</PRE>" ; |
echo "last accessed: <B>" . $faccessed . "</B><BR>" ; |
250 |
|
echo " owner: <B>" . $userinfo["name"] . " [$fuid]</B><BR>" ; |
251 |
|
echo " group: <B>" . $grpinfo["name"] . " [$fgid]</B><BR>" ; |
252 |
|
echo " permissions: <B>" ; |
253 |
|
echo printf( "%o", fileperms($fsPath) ) . "</B>" ; |
254 |
|
echo "</PRE>" ; |
255 |
|
|
256 |
} |
} |
257 |
|
|
258 |
if ( $editable && ($writable || !$exists) ) { |
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)) ; |
263 |
$fstr = htmlentities( $fstr ) ; |
$fstr = htmlentities( $fstr ) ; |
264 |
?> |
?> |
265 |
|
|
266 |
<FORM ACTION="<?php echo $self ; ?>" METHOD="POST"> |
<FORM ACTION="<?= $self ; ?>" METHOD="POST"> |
267 |
<SPAN TITLE="Click [SAVE] to store updated contents."> |
<SPAN TITLE="Click [SAVE] to store updated contents."> |
268 |
<B>DOCUMENT CONTENTS</B> |
<B>DOCUMENT CONTENTS</B> |
269 |
</SPAN><BR> |
</SPAN><BR> |
270 |
<TEXTAREA NAME="FILEDATA" ROWS=18 COLS=70 WRAP="OFF"><?php |
<TEXTAREA NAME="FILEDATA" ROWS=18 COLS=70 WRAP="OFF"><?php |
271 |
echo($fstr) ; ?></TEXTAREA> |
echo($fstr) ; ?></TEXTAREA> |
272 |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ; ?>"> |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ; ?>"> |
273 |
<INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?php echo $fn ; ?>"> |
<INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?= $fn ; ?>"> |
274 |
<INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="SAVE"> |
<INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="SAVE"> |
275 |
<INPUT TYPE="TEXT" SIZE=48 MAXLENGTH=255 NAME="RELPATH" |
<INPUT TYPE="HIDDEN" SIZE=48 MAXLENGTH=255 NAME="RELPATH" |
276 |
VALUE="<?php echo $relPath ; ?>"> |
VALUE="<?= $relPath ; ?>"> |
277 |
<INPUT TYPE="RESET" VALUE="RESET"> |
<br> |
278 |
|
<INPUT TYPE="RESET" VALUE="UNDO ALL CHANGES"> |
279 |
<INPUT TYPE="SUBMIT" VALUE="SAVE"> |
<INPUT TYPE="SUBMIT" VALUE="SAVE"> |
280 |
</FORM> |
</FORM> |
281 |
|
|
282 |
<?php |
<?php |
283 |
} |
} |
284 |
else if ( strstr( join(" ",$gblImages), $ext ) ) { |
if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) { |
285 |
$info = getimagesize($fsPath) ; |
$info = getimagesize($fsPath) ; |
286 |
$tstr = "<IMG SRC=\"". $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 ; |
290 |
|
echo $tstr ; |
291 |
} |
} |
292 |
|
|
293 |
?> |
?> |
294 |
|
|
295 |
<FORM ACTION="<?php echo $self ; ?>" METHOD="POST"> |
<FORM ACTION="<?= $self ; ?>" METHOD="POST"> |
296 |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ; ?>"> |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ; ?>"> |
297 |
<INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?php echo $fn ; ?>"> |
<INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?= $fn ; ?>"> |
298 |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR> |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR> |
299 |
|
|
300 |
<?php |
<?php |
301 |
|
|
302 |
|
if ($file_lock) { |
303 |
|
?> |
304 |
|
<hr> |
305 |
|
<SPAN TITLE="Check OK and click UNLOCK to remove lock on file."> |
306 |
|
<B>OK TO FORCE LOCK REMOVAL ON "<?= $fn ; ?>" HELD BY <?= $file_lock ?>? </B></SPAN> |
307 |
|
<INPUT TYPE="CHECKBOX" NAME="CONFIRM"> |
308 |
|
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="UNLOCK"> |
309 |
|
<? |
310 |
|
} // file_lock |
311 |
|
|
312 |
|
if (substr($fn,0,4) == ".del") { |
313 |
|
$action="UNDELETE"; |
314 |
|
$desc="undelete previously deleted file"; |
315 |
|
} else { |
316 |
|
$action="DELETE"; |
317 |
|
$desc="delete"; |
318 |
|
} |
319 |
|
|
320 |
if ($exists && $writable) { |
if ($exists && $writable) { |
321 |
?> |
?> |
322 |
|
|
323 |
<HR><SPAN TITLE="Check OK and click [DELETE] to delete."> |
<HR> |
324 |
<B>OK TO DELETE "<?php echo $fn ; ?>"? </B></SPAN> |
<a name="undelete"> |
325 |
|
<SPAN TITLE="Check OK and click [<?= $action ?>] to <?= $desc ?>."> |
326 |
|
<B>OK TO <?= $action ?> "<?= $fn ; ?>"? </B></SPAN> |
327 |
<INPUT TYPE="CHECKBOX" NAME="CONFIRM"> |
<INPUT TYPE="CHECKBOX" NAME="CONFIRM"> |
328 |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="DELETE"> |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="<?= $action ?>"> |
329 |
|
|
330 |
|
<HR> |
331 |
|
<a name="rename"> |
332 |
|
<SPAN TITLE="Check OK and click [RENAME] to rename."> |
333 |
|
<B>OK TO RENAME "<?= $fn ; ?>" TO |
334 |
|
<INPUT TYPE="TEXT" SIZE=24 MAXLENGTH=255 NAME="NEWNAME" VALUE="<?= $fn ?>"> |
335 |
|
? </B></SPAN> |
336 |
|
<INPUT TYPE="CHECKBOX" NAME="CONFIRM"> |
337 |
|
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="RENAME"> |
338 |
|
|
339 |
|
<?php |
340 |
|
} // exists && writable |
341 |
|
?> |
342 |
|
<HR> |
343 |
|
<a name="note"> |
344 |
|
<B>NOTE FOR "<?= $fn ; ?>": |
345 |
|
<INPUT TYPE="TEXT" SIZE=50 MAXLENGTH=255 NAME="NOTE" VALUE="<?= ReadNote($fsPath) ?>"> |
346 |
|
</B></SPAN> |
347 |
|
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="NOTE"> |
348 |
|
|
349 |
|
</FORM> |
350 |
|
|
351 |
<?php |
<?php |
352 |
|
|
353 |
|
$name=basename("$fsDir/$fn"); |
354 |
|
$logname=dirname("$fsDir/$fn")."/.log/$name"; |
355 |
|
$bakdir=dirname("$fsDir/$fn")."/.bak"; |
356 |
|
if (file_exists($logname)) { |
357 |
|
$log=fopen($logname,"r"); |
358 |
|
$cl1=" class=LST"; $cl2=""; |
359 |
|
$logarr = array(); |
360 |
|
while($line = fgetcsv($log,255,"\t")) { |
361 |
|
$cl=$cl1; $cl1=$cl2; $cl2=$cl; |
362 |
|
array_unshift($logarr,array($cl,$line[0],$line[1],$line[2],$line[3])); |
363 |
|
} |
364 |
|
fclose($log); |
365 |
|
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) |
372 |
|
while ($e = array_shift($logarr)) { |
373 |
|
if (strstr($e[4],"upload")) { |
374 |
|
if (file_exists("$bakdir/$bakcount/$name")) { |
375 |
|
$e[4]="<a href=\"$webRoot".urlpath(dirname($relPath)."/.bak/$bakcount/$name")."\">$e[4]</a>"; |
376 |
|
} |
377 |
|
$bakcount++; |
378 |
|
} |
379 |
|
print "<tr><td$e[0]>$e[1]</td><td$e[0]>$e[2]</td><td$e[0]>$e[3]</td><td$e[0]>$e[4]</td></tr>\n"; |
380 |
|
} |
381 |
|
print "</table>"; |
382 |
} |
} |
383 |
echo "</FORM>" ; |
|
384 |
EndHTML() ; |
EndHTML() ; |
385 |
|
|
386 |
} // end function DetailPage |
} // end function DetailPage |
610 |
case "blank" : |
case "blank" : |
611 |
$d = "blank.gif" ; |
$d = "blank.gif" ; |
612 |
break ; |
break ; |
613 |
|
case "checkout": |
614 |
|
$d = "box2.gif"; |
615 |
|
break; |
616 |
|
case "checkin": |
617 |
|
$d = "hand.up.gif"; |
618 |
|
break; |
619 |
|
case "locked": |
620 |
|
$d = "screw2.gif"; |
621 |
|
break; |
622 |
|
case "note": |
623 |
|
$d = "quill.gif"; |
624 |
|
break; |
625 |
default : |
default : |
626 |
$d = "generic.gif" ; |
$d = "generic.gif" ; |
627 |
} |
} |
633 |
|
|
634 |
function Navigate($fsRoot,$relDir) { |
function Navigate($fsRoot,$relDir) { |
635 |
|
|
636 |
global $gblEditable, $gblIcon ; |
global $gblEditable, $gblIcon, $gblModDays, $webRoot ; |
637 |
|
|
638 |
$self = $GLOBALS["PHP_SELF"] ; |
$self = $GLOBALS["PHP_SELF"] ; |
639 |
$webRoot = "http://" . $GLOBALS["SERVER_NAME"] ; |
|
640 |
$fsDir = $fsRoot . $relDir . "/" ; // current directory |
$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 |
|
|
645 |
if ( !($dir = @opendir($fsDir)) ) |
if ( !($dir = @opendir($fsDir)) ) |
646 |
Error("Read Access denied",$relDir) ; |
Error("Read Access denied",$relDir) ; |
647 |
while ($item = readdir($dir)) { |
while ($item = readdir($dir)) { |
648 |
if ( $item == ".." || $item == "." ) continue ; |
if ( $item == ".." || $item == "." || substr($item,0,1) == "." ) continue ; |
649 |
if ( is_dir($fsDir . $item) ) { |
if ( is_dir($fsDir . $item) ) { |
650 |
$dirList[] = $item ; |
$dirList[] = $item ; |
651 |
} |
} else if ( is_file($fsDir . $item) ) { |
|
else if ( is_file($fsDir . $item) ) { |
|
652 |
$fileList[] = $item ; |
$fileList[] = $item ; |
653 |
} |
} else if ( is_link($fsDir . $item) ) { |
654 |
else { |
$dirList[] = $item ; |
655 |
|
} else { |
656 |
// unknown file type |
// unknown file type |
657 |
// $text = "Could not determine file type of " ; |
// $text = "Could not determine file type of " ; |
658 |
// Error("File Error", $text.$relDir."/".$item) ; |
// Error("File Error", $text.$relDir."/".$item) ; |
660 |
} |
} |
661 |
} |
} |
662 |
closedir($dir) ; |
closedir($dir) ; |
663 |
|
|
664 |
|
// scan deleted files |
665 |
|
if ( $GLOBALS[show_deleted] == 1 && ($dir = @opendir("$fsDir/.del")) ) { |
666 |
|
while ($item = readdir($dir)) { |
667 |
|
if ( substr($item,0,1) == "." ) continue ; |
668 |
|
$fileList[] = ".del/$item" ; |
669 |
|
} |
670 |
|
closedir($dir) ; |
671 |
|
} |
672 |
|
|
673 |
$emptyDir = ! (sizeof($dirList) || sizeof($fileList)) ; |
$emptyDir = ! (sizeof($dirList) || sizeof($fileList)) ; |
674 |
|
|
675 |
// start navigation page |
// start navigation page |
676 |
$text = "Use this page to add, delete or " ; |
$text = "Use this page to add, delete"; |
677 |
$text .= "revise files on this web site." ; |
if (! isset($show_deleted)) { |
678 |
|
$text .= ", <a href=$self?D=".urlencode($relDir)."&show_deleted=1>undelete</a>"; |
679 |
|
} |
680 |
|
$text .= " or revise files on this web site." ; |
681 |
|
$text .= "<br>Examine list of files <a href=\"$self?A=Ch1\">changed in last day</a> or <a href=\"$self?A=Ch\">all changes</a>."; |
682 |
StartHTML("(Navigate)",$text) ; |
StartHTML("(Navigate)",$text) ; |
683 |
|
|
684 |
echo "<TABLE BORDER=0 CELLPADDING=2 |
echo "<TABLE BORDER=0 CELLPADDING=2 |
690 |
if ($parent == "") $parent = "/" ; |
if ($parent == "") $parent = "/" ; |
691 |
?> |
?> |
692 |
|
|
693 |
<TR><TD><?php echo $gblIcon("up") ?></TD><TD COLSPAN=4 CLASS=LST> |
<TR><TD><?= $gblIcon("up") ?></TD><TD COLSPAN=5 CLASS=LST> |
694 |
<A HREF="<?php echo $self ?>?D=<?php echo urlencode($parent) ?>"> |
<A HREF="<?= $self ?>?D=<?= urlencode($parent) ?>"> |
695 |
<B><?php echo $parent ?></B></A></TD></TR> |
<B><?= $parent ?></B></A></TD></TR> |
696 |
|
|
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=4 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><?php echo $gblIcon("fldr") ?></TD> |
<TR><TD> |
726 |
<TD COLSPAN=4 CLASS=LST><?php echo $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 |
733 |
} // end if no dirs |
} // end if no dirs |
734 |
?> |
?> |
735 |
|
|
736 |
<TR><TD></TD><TD COLSPAN=4><HR><B><?php echo $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><?php echo $gblIcon("blank") ?></TD> |
<TD><?= $gblIcon("blank").$gblIcon("blank") ?></TD> |
740 |
|
<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> |
742 |
|
|
743 |
<?php |
<?php |
744 |
if (sizeof($fileList) > 0) { |
if (sizeof($fileList) > 0) { |
745 |
sort($fileList) ; |
sort($fileList) ; |
746 |
while (list($key,$file) = each($fileList)) { |
while (list($key,$file) = each($fileList)) { |
747 |
$path = $fsDir."/".$file ; |
$path = $fsDir."/".$file ; |
748 |
$mod = filemtime($path) ; |
$mod = filemtime($path) ; |
749 |
$sz = filesize($path) ; |
$sz = filesize($path) ; |
750 |
|
|
751 |
if ($sz >= 10240) { |
if ($sz >= 10240) { |
752 |
$sz = (int)(($sz+1023)/1024) . " k" ; |
$sz = (int)(($sz+1023)/1024) . " k" ; |
753 |
} |
} else { |
754 |
else { |
$sz .= " " ; |
755 |
$sz .= " " ; |
} // end size |
756 |
} // end size |
|
757 |
|
$a = $b = "" ; |
758 |
$a = $b = "" ; |
|
759 |
|
$info_url=$self."?A=E&F=".urlencode($file)."&D=".urlencode($relDir); |
760 |
if ( ($mod + 30*86400) > time() ) { |
|
761 |
$a = "<SPAN CLASS=RED TITLE=\"Newer" ; |
if ( ($mod + $gblModDays*86400) > time() ) { |
762 |
$a .= " than 30 days\"> * </SPAN>" ; |
$a = "<SPAN CLASS=RED TITLE=\"Newer" ; |
763 |
} |
$a .= " than $gblModDays days\"> * </SPAN>" ; |
764 |
|
} |
765 |
$tstr = $webRoot . $relDir . "/" . $file ; |
|
766 |
$tstr = "<A HREF=\"" . $tstr . "\">" ; |
$file_lock=CheckLock($path); |
767 |
$tstr .= $file . "</A>" . $a ; |
|
768 |
|
$file_url_html="<A HREF=\"$self?A=V&F=".urlencode($file); |
769 |
$ext = strtolower(strrchr($file,".")) ; |
$file_url_html.="&D=".urlencode($relDir); |
770 |
if ( $ext=="" || |
$file_url_html.="\" TITLE=\"View file\">" ; |
771 |
strstr(join(" ",$gblEditable),$ext) ) |
|
772 |
{ |
if (substr($file,0,5) != ".del/") { |
773 |
$b = "<A HREF=\"" . $self . "?A=C&F=" ; |
$file_url_html .= $file . "</A>" . $a ; |
774 |
$b .= urlencode($file) . "&D=" . urlencode($relDir) ; |
} else { |
775 |
$b .= "\" TITLE=\"List contents\">" ; |
$file_url_html .= substr($file,5,strlen($file)-5) . "</a> <SPAN CLASS=RED TITLE=\"deleted\"> <a href=\"$info_url#undelete\">deleted</a> </span>"; |
776 |
$b .= $gblIcon("view") . "</A>" ; |
} |
777 |
} |
|
778 |
|
$note_html="<a href=\"$info_url#note\">".$gblIcon("note")."</a>".ReadNote($path); |
779 |
|
|
780 |
|
$ext = strtolower(strrchr($file,".")) ; |
781 |
|
|
782 |
|
if ($file_lock) { |
783 |
|
if ($file_lock == $GLOBALS[gblUserName]) { |
784 |
|
$b.="<A HREF=\"$self?A=Ci&F=".urlencode($file); |
785 |
|
$b.="&D=".urlencode($relDir); |
786 |
|
$b.="\" TITLE=\"Checkin (update) file on server\">" ; |
787 |
|
$file_url_html=$b; |
788 |
|
$b.=$gblIcon("checkin")."</A>" ; |
789 |
|
$b.= $gblIcon("blank"); |
790 |
|
$file_url_html.="$file</a> $a"; |
791 |
|
$note_html = $gblIcon("blank")."<b>Please check-in (update) this file</b>"; |
792 |
|
} else { |
793 |
|
$b = $gblIcon("locked"); |
794 |
|
$b.= $gblIcon("blank"); |
795 |
|
$note_html = $gblIcon("blank")."<b>File locked by $file_lock</b>"; |
796 |
|
$file_url_html = "$file $a"; |
797 |
|
} |
798 |
|
} else { |
799 |
|
$b.="<A HREF=\"$self?A=Co&F=".urlencode($file); |
800 |
|
$b.="&D=".urlencode($relDir); |
801 |
|
$b.="\" TITLE=\"Checkout file for edit\">" ; |
802 |
|
$b.=$gblIcon("checkout")."</A>" ; |
803 |
|
|
804 |
|
if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) { |
805 |
|
$b.="<A HREF=\"$self?A=C&F=".urlencode($file); |
806 |
|
$b.="&D=".urlencode($relDir); |
807 |
|
$b.="\" TITLE=\"List contents\">" ; |
808 |
|
$b.=$gblIcon("view")."</A>" ; |
809 |
|
} else { |
810 |
|
$b.= $gblIcon("blank"); |
811 |
|
} |
812 |
|
} |
813 |
|
|
814 |
|
|
815 |
?> |
?> |
816 |
|
|
817 |
<TR><TD> |
<TR><TD> |
818 |
<A HREF="<?php echo $self ?>?A=E&F=<?php echo urlencode($file) |
<A HREF="<?= $info_url ?>" TITLE="View/Edit"> |
819 |
?>&D=<?php echo urlencode($relDir) ?>" TITLE="View/Edit"> |
<?= $gblIcon($ext) ?></A></TD> |
820 |
<?php echo $gblIcon($ext) ?></A></TD> |
<TD CLASS=LST><?= $file_url_html ?></TD> |
821 |
<TD CLASS=LST><?php echo $tstr ?></TD> |
<TD CLASS=LST ALIGN=center><?= $b ?></TD> |
822 |
<TD CLASS=LST ALIGN=center><?php echo $b ?></TD> |
<TD CLASS=LST ALIGN=left><?= $note_html ?></TD> |
823 |
<TD CLASS=LST><?php echo date("d/M/y G:i:s",$mod) ?></TD> |
<TD CLASS=LST><?= date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]",$mod) ?></TD> |
824 |
<TD CLASS=LST><?php echo $sz ?>Bytes</TD></TR> |
<TD CLASS=LST><?= $sz ?>Bytes</TD></TR> |
825 |
|
|
826 |
<?php |
<?php |
827 |
} // iterate over files |
} // iterate over files |
828 |
} // end if no files |
} else { // end if no files |
829 |
|
?> |
830 |
|
<TR><TD></TD><TD COLSPAN=5 CLASS=LST> |
831 |
|
No files in this directory |
832 |
|
</TD></TR> |
833 |
|
<? |
834 |
|
} |
835 |
|
|
836 |
if ($emptyDir) { |
if ($emptyDir) { |
837 |
?> |
?> |
838 |
|
|
839 |
<FORM METHOD="POST" ACTION="<?php echo $self ?>"> |
<FORM METHOD="POST" ACTION="<?= $self ?>"> |
840 |
<TR><TD></TD><TD COLSPAN=4 CLASS=BAR> |
<TR><TD></TD><TD COLSPAN=5 CLASS=BAR> |
841 |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ?>"> |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"> |
842 |
OK TO DELETE THIS EMPTY FOLDER? |
OK TO DELETE THIS EMPTY FOLDER? |
843 |
<INPUT TYPE="CHECKBOX" NAME="CONFIRM"> |
<INPUT TYPE="CHECKBOX" NAME="CONFIRM"> |
844 |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="DELETE"> |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="DELETE"> |
849 |
} // end if emptyDir |
} // end if emptyDir |
850 |
?> |
?> |
851 |
|
|
852 |
<TR><TD></TD><TD COLSPAN=4><HR></TD></TR> |
<TR><TD></TD><TD COLSPAN=5><HR></TD></TR> |
853 |
|
|
854 |
<FORM METHOD="POST" ACTION="<?php echo $self ?>"> |
<? |
855 |
<TR><TD></TD><TD COLSPAN=4 CLASS=BAR>CREATE NEW |
if (file_exists(".info.inc")) { |
856 |
|
print "<TR><TD></TD><TD COLSPAN=5>"; |
857 |
|
include(".info.inc"); |
858 |
|
print "</TD></TR> |
859 |
|
<TR><TD></TD><TD COLSPAN=5><HR></TD></TR>"; |
860 |
|
} |
861 |
|
?> |
862 |
|
|
863 |
|
<FORM METHOD="POST" ACTION="<?= $self ?>"> |
864 |
|
<TR><TD></TD><TD COLSPAN=5 CLASS=BAR>CREATE NEW |
865 |
<INPUT TYPE="RADIO" NAME="T" VALUE="D" CHECKED>DIRECTORY -OR- |
<INPUT TYPE="RADIO" NAME="T" VALUE="D" CHECKED>DIRECTORY -OR- |
866 |
<INPUT TYPE="RADIO" NAME="T" VALUE="F">FILE : |
<INPUT TYPE="RADIO" NAME="T" VALUE="F">FILE : |
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="<?php echo $relDir ?>"> |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"> |
870 |
<INPUT TYPE="SUBMIT" VALUE="CREATE"></NOBR> |
<INPUT TYPE="SUBMIT" VALUE="CREATE" NAME="CREATE"> |
871 |
<NOBR>OR <A HREF="<?php echo $self |
</NOBR> |
872 |
?>?A=U&D=<?php echo 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> |
875 |
</FORM> |
</FORM> |
881 |
|
|
882 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
883 |
|
|
884 |
function UploadPage($fsRoot, $relDir) { |
function UploadPage($fsRoot, $relDir, $filename="") { |
885 |
|
|
886 |
$self = $GLOBALS["PHP_SELF"] ; |
$self = $GLOBALS["PHP_SELF"] ; |
887 |
if ($relDir == "") $relDir = "/" ; |
if ($relDir == "") $relDir = "/" ; |
889 |
|
|
890 |
<P><TABLE BORDER=0 CELLPADDING=5><TR><TD WIDTH=5></TD><TD CLASS=BAR> |
<P><TABLE BORDER=0 CELLPADDING=5><TR><TD WIDTH=5></TD><TD CLASS=BAR> |
891 |
<FORM ENCTYPE="multipart/form-data" METHOD="POST" |
<FORM ENCTYPE="multipart/form-data" METHOD="POST" |
892 |
ACTION="<?php echo $self ?>"> |
ACTION="<?= $self ?>"> |
893 |
DESTINATION DIRECTORY:<B><?php echo " " . $relDir ?></B> |
DESTINATION DIRECTORY:<B><?= " " . $relDir ?></B> |
894 |
|
<? if (isset($filename) && $filename!="") { ?> |
895 |
|
<br>DESTINATION FILE:<B><?= " " . $filename ?></B> |
896 |
|
<INPUT TYPE="HIDDEN" NAME="FILENAME" VALUE="<?= $filename ?>"> |
897 |
|
<? } ?> |
898 |
<P>PATHNAME OF LOCAL FILE<BR> |
<P>PATHNAME OF LOCAL FILE<BR> |
899 |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ?>"> |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"> |
900 |
<INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="UPLOAD"> |
<INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="UPLOAD"> |
901 |
<INPUT SIZE=30 TYPE="FILE" NAME="FN"></P> |
<INPUT SIZE=30 TYPE="FILE" NAME="FN"></P> |
902 |
<P><INPUT TYPE="SUBMIT" VALUE="UPLOAD"></P> |
<P><INPUT TYPE="SUBMIT" VALUE="UPLOAD"></P> |
903 |
<P>If the <B>[BROWSE...]</B> button is not displayed,<BR> |
<P>If the <B>[BROWSE...]</B> button is not displayed,<BR> |
904 |
you must upgrade to an RFC1867-compliant browser.</P> |
you must upgrade to an RFC1867-compliant browser.</P> |
905 |
<P>Your browser:<BR><?php echo $GLOBALS["HTTP_USER_AGENT"] ?></P> |
<P>Your browser:<BR><?= $GLOBALS["HTTP_USER_AGENT"] ?></P> |
906 |
</FORM> |
</FORM> |
907 |
</TD></TR> |
</TD></TR> |
908 |
<TR><TD></TD><TD> |
<TR><TD></TD><TD> |
909 |
<FORM METHOD="POST" ACTION="<?php echo $self ?>"> |
<FORM METHOD="POST" ACTION="<?= $self ?>"> |
910 |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ?>"><BR> |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"><BR> |
911 |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"> |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"> |
912 |
</FORM> |
</FORM> |
913 |
</TD></TR></TABLE></P> |
</TD></TR></TABLE></P> |
926 |
|
|
927 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
928 |
|
|
929 |
function Writeable($path) { |
function NoEntry() { |
|
// fix by -mat- filid brandy, brandy@ecrc.de, 07/JUL/99 |
|
930 |
|
|
931 |
clearstatcache ; |
$user = $GLOBALS["PHP_AUTH_USER"] ; |
932 |
$perms = @fileperms($path) ; |
$pw = $GLOBALS["PHP_AUTH_PW"] ; |
933 |
$owner = @fileowner($path) ; |
$self = $GLOBALS["PHP_SELF"] ; |
|
exec("id",$id) ; |
|
|
eregi( "^uid=([0-9]*)",$id[0], $regs) ; |
|
|
$apacheuid = $regs[1] ; |
|
|
$perms = 0777 & $perms ; |
|
|
if ( $apacheuid != $owner ) { |
|
|
return (06 == (06 & $perms)) ? 1 : 0 ; |
|
|
} |
|
|
else { |
|
|
return (0600 == (0600 & $perms)) ? 1 : 0 ; |
|
|
} |
|
|
|
|
|
} // end function Writable |
|
934 |
|
|
935 |
////////////////////////////////////////////////////////////////// |
$title = "(401 Unauthorized)" ; |
936 |
|
$text = "No trespassing !" ; |
937 |
|
StartHTML($title,$text) ; |
938 |
|
|
|
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>" ; |
|
939 |
EndHTML() ; |
EndHTML() ; |
940 |
exit ; |
exit ; |
941 |
|
} |
942 |
|
|
943 |
|
////////////////////////////////////////////////////////////////// |
944 |
|
|
945 |
|
function LogIt($target,$msg) { |
946 |
|
|
947 |
|
$dir=dirname($target); |
948 |
|
if (! file_exists($dir."/.log")) { |
949 |
|
mkdir($dir."/.log",0700); |
950 |
|
} |
951 |
|
$file=basename($target); |
952 |
|
|
953 |
|
$log=fopen("$dir/.log/$file","a+"); |
954 |
|
fputs($log,date("$GLOBALS[gblDateFmt]\t$GLOBALS[gblTimeFmt]"). |
955 |
|
"\t$GLOBALS[gblUserName]\t$msg\n"); |
956 |
|
fclose($log); |
957 |
|
|
958 |
|
} |
959 |
|
|
|
} // end function CreateHash |
|
960 |
|
|
961 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
962 |
|
|
963 |
function NoEntry() { |
function WriteNote($target,$msg) { |
964 |
|
|
965 |
$user = $GLOBALS["PHP_AUTH_USER"] ; |
$target=stripSlashes($target); |
966 |
$pw = $GLOBALS["PHP_AUTH_PW"] ; |
$dir=dirname($target); |
967 |
$self = $GLOBALS["PHP_SELF"] ; |
if (! file_exists($dir."/.note")) { |
968 |
|
mkdir($dir."/.note",0700); |
969 |
|
} |
970 |
|
$file=basename($target); |
971 |
|
|
972 |
$title = "(401 Unauthorized)" ; |
$note=fopen("$dir/.note/$file","w"); |
973 |
$text = "No trespassing !" ; |
fputs($note,"$msg\n"); |
974 |
StartHTML($title,$text) ; |
fclose($note); |
|
?> |
|
975 |
|
|
976 |
<FORM ACTION="<?php echo $self ?>?HASH=create" METHOD="POST"> |
Logit($target,"added note $msg"); |
977 |
<INPUT TYPE="HIDDEN" NAME="USER" VALUE="<?php echo $user ?>"> |
|
978 |
<INPUT TYPE="HIDDEN" NAME="PW" VALUE="<?php echo $pw ?>"> |
} |
979 |
|
|
980 |
<BLOCKQUOTE><B>If you are a site administrator:</B><BR><BR> |
function ReadNote($target) { |
981 |
Click below to <B>generate a password hash</B><BR>from |
|
982 |
the username-password pair you just<BR>entered. Then include the hash in |
$target=stripSlashes($target); |
983 |
the source<BR>of this file.<BR><BR> |
$dir=dirname($target); |
984 |
<INPUT TYPE="SUBMIT" VALUE="CREATE HASH"> |
$file=basename($target); |
985 |
</BLOCKQUOTE></FORM> |
$msg=""; |
986 |
|
if (file_exists($dir."/.note/$file")) { |
987 |
|
$note=fopen("$dir/.note/$file","r"); |
988 |
|
$msg=fgets($note,4096); |
989 |
|
fclose($note); |
990 |
|
} |
991 |
|
return HtmlSpecialChars(StripSlashes($msg)); |
992 |
|
|
993 |
<?php |
} |
994 |
EndHTML() ; |
|
995 |
exit ; |
////////////////////////////////////////////////////////////////// |
996 |
|
|
997 |
|
function MoveTo($source,$folder) { |
998 |
|
|
999 |
|
$source=stripSlashes($source); |
1000 |
|
$file=basename($source); |
1001 |
|
if (! file_exists($folder)) { |
1002 |
|
mkdir($folder,0700); |
1003 |
|
} |
1004 |
|
if (file_exists($source)) { |
1005 |
|
rename($source,"$folder/$file"); |
1006 |
|
} |
1007 |
|
} |
1008 |
|
|
1009 |
|
////////////////////////////////////////////////////////////////// |
1010 |
|
|
1011 |
|
function Lock($target) { |
1012 |
|
|
1013 |
|
$target=stripSlashes($target); |
1014 |
|
$dir=dirname($target); |
1015 |
|
if (! file_exists($dir."/.lock")) { |
1016 |
|
mkdir($dir."/.lock",0700); |
1017 |
|
} |
1018 |
|
$file=basename($target); |
1019 |
|
|
1020 |
|
if (file_exists("$dir/.lock/$file")) { |
1021 |
|
Logit($target,"attempt to locked allready locked file!"); |
1022 |
|
} else { |
1023 |
|
$lock=fopen("$dir/.lock/$file","w"); |
1024 |
|
fputs($lock,"$GLOBALS[gblUserName]\n"); |
1025 |
|
fclose($lock); |
1026 |
|
|
1027 |
|
Logit($target,"file locked"); |
1028 |
|
} |
1029 |
|
|
1030 |
|
} |
1031 |
|
|
1032 |
|
function CheckLock($target) { |
1033 |
|
|
1034 |
|
$target=stripSlashes($target); |
1035 |
|
$dir=dirname($target); |
1036 |
|
$file=basename($target); |
1037 |
|
$msg=0; |
1038 |
|
if (file_exists($dir."/.lock/$file")) { |
1039 |
|
$lock=fopen("$dir/.lock/$file","r"); |
1040 |
|
$msg=fgets($lock,4096); |
1041 |
|
fclose($lock); |
1042 |
|
} |
1043 |
|
return chop($msg); |
1044 |
|
|
1045 |
|
} |
1046 |
|
|
1047 |
|
function Unlock($target) { |
1048 |
|
|
1049 |
|
$target=stripSlashes($target); |
1050 |
|
$dir=dirname($target); |
1051 |
|
$file=basename($target); |
1052 |
|
if (file_exists($dir."/.lock/$file")) { |
1053 |
|
unlink("$dir/.lock/$file"); |
1054 |
|
Logit($target,"file unlocked"); |
1055 |
|
} else { |
1056 |
|
Logit($target,"attempt to unlocked non-locked file!"); |
1057 |
|
} |
1058 |
|
|
1059 |
|
} |
1060 |
|
|
1061 |
|
////////////////////////////////////////////////////////////////// |
1062 |
|
|
1063 |
|
function urlpath($url) { |
1064 |
|
$url=urlencode(StripSlashes("$url")); |
1065 |
|
$url=str_replace("%2F","/",$url); |
1066 |
|
$url=str_replace("+","%20",$url); |
1067 |
|
return($url); |
1068 |
|
} |
1069 |
|
|
1070 |
|
////////////////////////////////////////////////////////////////// |
1071 |
|
|
1072 |
|
function safe_rename($fromdir,$fromfile,$tofile) { |
1073 |
|
function try_rename($from,$to) { |
1074 |
|
# 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 |
1109 |
|
|
1110 |
|
function rrmdir($dir) { |
1111 |
|
$handle=opendir($dir); |
1112 |
|
while ($file = readdir($handle)) { |
1113 |
|
if ($file != "." && $file != "..") { |
1114 |
|
if (is_dir("$dir/$file")) |
1115 |
|
rrmdir("$dir/$file"); |
1116 |
|
else |
1117 |
|
if (! @unlink("$dir/$file")) return(0); |
1118 |
|
} |
1119 |
|
} |
1120 |
|
closedir($handle); |
1121 |
|
return @rmdir($dir); |
1122 |
|
} |
1123 |
|
|
1124 |
|
////////////////////////////////////////////////////////////////// |
1125 |
|
|
1126 |
|
function ChangeLog($target,$msg) { |
1127 |
|
|
1128 |
|
global $gblFsRoot; |
1129 |
|
$log=fopen("$gblFsRoot/.changelog","a+"); |
1130 |
|
if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot) |
1131 |
|
$target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot)); |
1132 |
|
fputs($log,time()."\t$target\t$GLOBALS[gblUserName]\t$msg\n"); |
1133 |
|
fclose($log); |
1134 |
|
|
1135 |
|
} |
1136 |
|
|
1137 |
|
function DisplayChangeLog($day) { |
1138 |
|
|
1139 |
|
global $gblFsRoot; |
1140 |
|
if (!file_exists("$gblFsRoot/.changelog")) return; |
1141 |
|
$log=fopen("$gblFsRoot/.changelog","r"); |
1142 |
|
$logarr = array(); |
1143 |
|
while($line = fgetcsv($log,255,"\t")) { |
1144 |
|
if ($day!=1 || ($day==1 && (time()-$line[0] < 24*60*60))) { |
1145 |
|
array_unshift($logarr,array($line[0],$line[1],$line[2],$line[3])); |
1146 |
|
} |
1147 |
|
} |
1148 |
|
fclose($log); |
1149 |
|
$cl1=" class=LST"; $cl2=""; |
1150 |
|
print "<table border=0 width=100%>\n"; |
1151 |
|
while ($e = array_shift($logarr)) { |
1152 |
|
$cl=$cl1; $cl1=$cl2; $cl2=$cl; |
1153 |
|
$date = date("$GLOBALS[gblDateFmt]", $e[0]); |
1154 |
|
$time = date("$GLOBALS[gblTimeFmt]", $e[0]); |
1155 |
|
$dir = dirname($e[1]); |
1156 |
|
$file = basename($e[1]); |
1157 |
|
print "<tr><td$cl>$date</td><td$cl>$time</td><td$cl><a href=\"$GLOBALS[PHP_SELF]?D=".urlencode($dir)."\">$dir</a>/$file</td><td$cl>$e[2]</td><td$cl>$e[3]</td></tr>\n"; |
1158 |
|
} |
1159 |
|
print "</table>"; |
1160 |
|
print "<p>".GifIcon(up)." Back to <a href=$GLOBALS[PHP_SELF]>front page</a>.</p>"; |
1161 |
} |
} |
1162 |
|
|
1163 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
1168 |
// local functions : begin with capital letters |
// local functions : begin with capital letters |
1169 |
// global constants: begin with gbl |
// global constants: begin with gbl |
1170 |
|
|
1171 |
$gblFilePerms = "644" ; // default for new files |
$gblFilePerms = 0640 ; // default for new files |
1172 |
$gblDirPerms = 0755 ; // default for new dirs |
$gblDirPerms = 0750 ; // default for new dirs |
1173 |
|
|
1174 |
// phpinfo() ; |
// phpinfo() ; |
1175 |
// exit ; |
// exit ; |
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 && |
if (file_exists("$gblIncDir/$gblUsers.php")) { |
1191 |
$gblHash($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ) { |
include("$gblIncDir/$gblUsers.php"); |
1192 |
header("WWW-authenticate: basic realm=\"$SERVER_NAME\"") ; |
} 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 ) { |
1199 |
|
header("WWW-authenticate: basic realm=\"$HTTP_HOST\"") ; |
1200 |
header("HTTP/1.0 401 Unauthorized") ; |
header("HTTP/1.0 401 Unauthorized") ; |
1201 |
NoEntry() ; |
NoEntry() ; |
1202 |
exit ; |
exit ; |
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 |
|
|
1221 |
// i.e. below $gblFsRoot. |
// i.e. below $gblFsRoot. |
1222 |
|
|
1223 |
$relScriptDir = dirname($SCRIPT_NAME) ; |
$relScriptDir = dirname($SCRIPT_NAME) ; |
1224 |
// i.e. /siteman |
// i.e. /docman |
1225 |
|
|
1226 |
$fsScriptDir = dirname($SCRIPT_FILENAME) ; |
// start on server root |
1227 |
// i.e. /home/httpd/html/siteman |
// $gblFsRoot = substr($fsScriptDir,0, strlen($fsScriptDir)-strlen($relScriptDir)) ; |
1228 |
|
// or on script root |
1229 |
$gblFsRoot = substr($fsScriptDir,0, |
$gblFsRoot = $fsScriptDir; |
|
strlen($fsScriptDir)-strlen($relScriptDir)) ; |
|
1230 |
// i.e. /home/httpd/html |
// i.e. /home/httpd/html |
1231 |
|
|
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); |
1243 |
|
|
1244 |
|
|
1245 |
switch ($POSTACTION) { |
switch ($POSTACTION) { |
1246 |
case "UPLOAD" : |
case "UPLOAD" : |
1247 |
if (!Writeable($fsDir)) Error("Write denied",$relDir) ; |
if (!is_writeable($fsDir)) Error("Write denied",$relDir) ; |
1248 |
if (strstr($FN_name,"/")) |
if (strstr($FN_name,"/")) |
1249 |
Error("Non-conforming filename") ; |
Error("Non-conforming filename") ; |
1250 |
// TODO : should rather check for escapeshellcmds |
// TODO : should rather check for escapeshellcmds |
1251 |
// but maybe RFC 18xx asserts safe filenames .... |
// but maybe RFC 18xx asserts safe filenames .... |
1252 |
$source = $FN ; |
$source = $FN ; |
1253 |
$target = $fsDir . "/" . $FN_name ; |
if (! file_exists($source)) { |
1254 |
exec("cp $source $target") ; |
Error("You must select file with browse to upload it!"); |
1255 |
exec("chmod $gblFilePerms $target") ; |
} |
1256 |
|
if (! isset($FILENAME)) { // from update file |
1257 |
|
$target = "$fsDir/$FN_name" ; |
1258 |
|
} else { |
1259 |
|
$target = "$fsDir/$FILENAME"; |
1260 |
|
} |
1261 |
|
|
1262 |
|
// backup old files first |
1263 |
|
$dir=dirname($target); |
1264 |
|
if (! file_exists($dir."/.bak")) { |
1265 |
|
mkdir($dir."/.bak",0700); |
1266 |
|
} |
1267 |
|
if (! file_exists($dir."/.bak/$GLOBALS[gblNumBackups]")) { |
1268 |
|
mkdir($dir."/.bak/$GLOBALS[gblNumBackups]",0700); |
1269 |
|
} |
1270 |
|
$file=basename($target); |
1271 |
|
for($i=$GLOBALS[gblNumBackups]-1;$i>0;$i--) { |
1272 |
|
MoveTo("$dir/.bak/$i/$file","$dir/.bak/".($i+1)."/"); |
1273 |
|
} |
1274 |
|
MoveTo($target,$dir."/.bak/1/"); |
1275 |
|
|
1276 |
|
copy($source,$target) ; |
1277 |
|
chmod($target,$gblFilePerms) ; |
1278 |
clearstatcache() ; |
clearstatcache() ; |
1279 |
|
Logit($target,"uploaded"); |
1280 |
|
if (isset($FILENAME)) { |
1281 |
|
Unlock($target); |
1282 |
|
} |
1283 |
|
ChangeLog($target,"updated"); |
1284 |
break ; |
break ; |
1285 |
|
|
1286 |
case "SAVE" : |
case "SAVE" : |
1287 |
$path = $gblFsRoot . escapeshellcmd($RELPATH) ; |
$path = $gblFsRoot . $RELPATH ; |
1288 |
$writable = Writeable($path) ; |
$path=stripSlashes($path); |
1289 |
$legaldir = Writeable(dirname($path)) ; |
$writable = is_writeable($path) ; |
1290 |
|
$legaldir = is_writeable(dirname($path)) ; |
1291 |
$exists = (file_exists($path)) ? 1 : 0 ; |
$exists = (file_exists($path)) ? 1 : 0 ; |
1292 |
// check for legal extension here as well |
// check for legal extension here as well |
1293 |
if (!($writable || (!$exists && $legaldir))) |
if (!($writable || (!$exists && $legaldir))) |
1294 |
Error("Write denied",$RELPATH) ; |
Error("Write denied",$RELPATH) ; |
1295 |
$fh = fopen($path, "w") ; |
$fh = fopen($path, "w") ; |
1296 |
|
$FILEDATA=stripSlashes($FILEDATA); |
1297 |
fwrite($fh,$FILEDATA) ; |
fwrite($fh,$FILEDATA) ; |
1298 |
fclose($fh) ; |
fclose($fh) ; |
1299 |
clearstatcache() ; |
clearstatcache() ; |
1300 |
|
Logit($path,"saved changes"); |
1301 |
|
ChangeLog($path,"saved changes"); |
1302 |
break ; |
break ; |
1303 |
|
|
1304 |
case "CREATE" : |
case "CREATE" : |
1305 |
// we know $fsDir exists |
// we know $fsDir exists |
1306 |
if (!Writeable($fsDir)) Error("Write denied",$relDir) ; |
if ($FN == "") break; // no filename! |
1307 |
|
if (!is_writeable($fsDir)) Error("Write denied",$relDir) ; |
1308 |
$path = $fsDir . "/" . $FN ; // file or dir to create |
$path = $fsDir . "/" . $FN ; // file or dir to create |
1309 |
$relPath = $relDir . "/" . $FN ; |
$relPath = $relDir . "/" . $FN ; |
1310 |
switch ( $T ) { |
switch ( $T ) { |
1311 |
case "D" : // create a directory |
case "D" : // create a directory |
1312 |
if ( ! @mkdir($path,$gblDirPerms) ) |
if ( ! @mkdir($path,$gblDirPerms) ) |
1313 |
Error("Mkdir failed",$relPath) ; // eg. if it exists |
Error("Mkdir failed",$relPath) ; // eg. if it exists |
1314 |
clearstatcache() ; |
clearstatcache() ; |
1315 |
break ; |
break ; |
1316 |
case "F" : // create a new file |
case "F" : // create a new file |
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) && !Writable($path) ) |
if ( file_exists($path) && !is_writeable($path) ) |
1321 |
Error("File not writable", $relPath) ; |
Error("File not writable", $relPath) ; |
1322 |
$tstr = $PHP_SELF . "?A=E&D=" . $relDir . "&F=" . $FN ; |
$fh = fopen($path, "w+") ; |
1323 |
header("Location: " . $tstr) ; |
if ($fh) { |
1324 |
exit ; |
fputs($fh,"\n"); |
1325 |
|
fclose($fh) ; |
1326 |
|
LogIt($path,"file created"); |
1327 |
|
} else { |
1328 |
|
Error("Creation of file $relPath failed -- $path"); |
1329 |
|
} |
1330 |
|
$tstr = "$PHP_SELF?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ; |
1331 |
|
header("Location: " . $tstr) ; |
1332 |
|
ChangeLog($target,"created"); |
1333 |
|
exit ; |
1334 |
} |
} |
1335 |
break ; |
break ; |
1336 |
|
|
1341 |
$tstr .= "insufficient privileges: " ; |
$tstr .= "insufficient privileges: " ; |
1342 |
|
|
1343 |
if ( $FN != "") { // delete file |
if ( $FN != "") { // delete file |
1344 |
$path = $fsDir . "/" . $FN ; |
$path = $fsDir . "/" . $FN ; |
1345 |
if ( ! @unlink($path) ) { |
|
1346 |
Error("File delete failed", $tstr . $path) ; |
$dir=dirname($path); |
1347 |
exit ; |
$file=basename($path); |
1348 |
} |
if (! file_exists("$dir/.del")) { |
1349 |
|
mkdir("$dir/.del",0700); |
1350 |
|
} |
1351 |
|
|
1352 |
|
// if ( ! @unlink($path) ) { |
1353 |
|
if ( ! rename($path,"$dir/.del/$file") ) { |
1354 |
|
Error("File delete failed", $tstr . $path) ; |
1355 |
|
Logit($path,"file delete failed"); |
1356 |
|
exit ; |
1357 |
|
} else { |
1358 |
|
Logit($path,"file deleted"); |
1359 |
|
MoveTo("$dir/.log/$file","$dir/.del/.log/"); |
1360 |
|
MoveTo("$dir/.note/$file","$dir/.del/.note/"); |
1361 |
|
MoveTo("$dir/.lock/$file","$dir/.del/.lock/"); |
1362 |
|
} |
1363 |
} |
} |
1364 |
else { // delete directory |
else { // delete directory |
1365 |
if ( ! @rmdir($fsDir) ) { |
if ( ! @rrmdir($fsDir) ) { |
1366 |
Error("Rmdir failed", $tstr . $fsDir) ; |
Error("Rmdir failed", $tstr . $fsDir) ; |
1367 |
} |
} |
1368 |
else { |
else { |
1371 |
} |
} |
1372 |
break ; |
break ; |
1373 |
|
|
1374 |
|
case "UNDELETE" : |
1375 |
|
if ( $CONFIRM != "on" ) break ; |
1376 |
|
|
1377 |
|
if (substr($FN,0,4) != ".del") break ; |
1378 |
|
$file=substr($FN,4,strlen($FN)-4); |
1379 |
|
|
1380 |
|
Logit("$fsDir/.del/$file","undeleted"); |
1381 |
|
MoveTo("$fsDir/.del/$file","$fsDir/"); |
1382 |
|
MoveTo("$fsDir/.del/.log/$file","$fsDir/.log/"); |
1383 |
|
MoveTo("$fsDir/.del/.note/$file","$fsDir/.note/"); |
1384 |
|
MoveTo("$fsDir/.del/.lock/$file","$fsDir/.lock/"); |
1385 |
|
|
1386 |
|
break ; |
1387 |
|
|
1388 |
|
case "RENAME" : |
1389 |
|
if ( $CONFIRM != "on" ) break ; |
1390 |
|
|
1391 |
|
Logit("$fsDir/$FN","renamed $FN to $NEWNAME"); |
1392 |
|
safe_rename($fsDir,$FN,$NEWNAME); |
1393 |
|
break ; |
1394 |
|
|
1395 |
|
case "NOTE" : |
1396 |
|
WriteNote("$fsDir/$FN","$NOTE"); |
1397 |
|
break ; |
1398 |
|
|
1399 |
|
case "UNLOCK" : |
1400 |
|
if ( $CONFIRM != "on" ) break ; |
1401 |
|
Unlock("$fsDir/$FN"); |
1402 |
|
break ; |
1403 |
|
|
1404 |
default : |
default : |
1405 |
// user hit "CANCEL" or undefined action |
// user hit "CANCEL" or undefined action |
1406 |
} |
} |
1416 |
// $A=U : upload to path given in $D |
// $A=U : upload to path given in $D |
1417 |
// $A=E : display detail of file $D/$F and edit |
// $A=E : display detail of file $D/$F and edit |
1418 |
// $A=C : display code in file $D/$F |
// $A=C : display code in file $D/$F |
1419 |
|
// $A=Co : checkout file $D/$F |
1420 |
|
// $A=Ci : checkin file $D/$F |
1421 |
|
// $A=V : view file (do nothing except log) |
1422 |
// default : display directory $D |
// default : display directory $D |
1423 |
|
|
1424 |
switch ($A) { |
switch ($A) { |
1425 |
case "U" : |
case "U" : |
1426 |
// upload to $relDir |
// upload to $relDir |
1427 |
if (!Writeable($gblFsRoot . $relDir)) |
if (!is_writeable($gblFsRoot . $relDir)) |
1428 |
Error("Write access denied",$relDir) ; |
Error("Write access denied",$relDir) ; |
1429 |
$text = "Use this page to upload a single " ; |
$text = "Use this page to upload a single " ; |
1430 |
$text .= "file to <B>$SERVER_NAME</B>." ; |
$text .= "file to <B>$HTTP_HOST</B>." ; |
1431 |
StartHTML("(Upload Page)", $text) ; |
StartHTML("(Upload Page)", $text) ; |
1432 |
UploadPage($gblFsRoot, $relDir) ; |
UploadPage($gblFsRoot, $relDir) ; |
1433 |
EndHTML() ; |
EndHTML() ; |
1434 |
exit ; |
exit ; |
1435 |
case "E" : |
case "E" : |
1436 |
|
$F=stripSlashes($F); |
1437 |
// detail of $relDir/$F |
// detail of $relDir/$F |
1438 |
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); |
1442 |
// listing of $relDir/$F |
// listing of $relDir/$F |
1443 |
DisplayCode($gblFsRoot, $relDir, $F) ; |
DisplayCode($gblFsRoot, $relDir, $F) ; |
1444 |
exit ; |
exit ; |
1445 |
|
case "Co" : |
1446 |
|
// checkout |
1447 |
|
Lock("$gblFsRoot/$relDir/$F"); |
1448 |
|
header("Content-Disposition: attachment; filename=$F" ); |
1449 |
|
Header("Location: $webRoot".urlpath("$relDir/$F")); |
1450 |
|
exit; |
1451 |
|
case "Ci" : |
1452 |
|
$F=stripSlashes($F); |
1453 |
|
// upload && update to $relDir |
1454 |
|
if (!is_writeable($gblFsRoot . $relDir)) |
1455 |
|
Error("Write access denied",$relDir) ; |
1456 |
|
$text = "Use this page to update a single " ; |
1457 |
|
$text .= "file to <B>$HTTP_HOST</B>." ; |
1458 |
|
StartHTML("(Update file Page)", $text) ; |
1459 |
|
UploadPage($gblFsRoot, $relDir, $F) ; |
1460 |
|
EndHTML() ; |
1461 |
|
exit ; |
1462 |
|
case "V" : |
1463 |
|
// view |
1464 |
|
LogIt("$gblFsRoot/$relDir/$F","viewed"); |
1465 |
|
header("Content-Disposition: attachment; filename=$F" ); |
1466 |
|
Header("Location: $webRoot".urlpath("$relDir/$F")); |
1467 |
|
exit; |
1468 |
|
case "Ch" : |
1469 |
|
StartHTML("(File changes)","All changes chronologicaly..."); |
1470 |
|
DisplayChangeLog(0); // all |
1471 |
|
EndHTML() ; |
1472 |
|
exit; |
1473 |
|
case "Ch1" : |
1474 |
|
StartHTML("(File changes)","Changes to files in last day..."); |
1475 |
|
DisplayChangeLog(1); |
1476 |
|
EndHTML() ; |
1477 |
|
exit; |
1478 |
} |
} |
1479 |
|
|
1480 |
// default: display directory $relDir |
// default: display directory $relDir |