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 |
|
2000-07-25 Dobrica Pavlinusic <dpavlin@rot13.org> |
39 |
|
|
40 |
|
nuked exec calls (unsecure) |
41 |
|
nuked writeable function (replaced by php is_writeable) |
42 |
|
added support for https (tested with apache+mod_ssl) |
43 |
|
added users file |
44 |
|
date format user-selectable |
45 |
|
cycle backup files in bak directory |
46 |
|
support links as directoryes (for now) |
47 |
|
support of file history logging |
48 |
|
undelete capabilities (delete moves to .del directory) |
49 |
|
|
50 |
|
2000-07-26 DbP |
51 |
|
|
52 |
|
added more checking on entered filename (when creating file/dir) |
53 |
|
added rename option |
54 |
|
|
55 |
|
|
56 |
|
IMPORTANT INSTALLATION NOTE: |
57 |
|
deny serving of .* (dot-something) files in web server! |
58 |
|
Otherwise, uses can access your log files, users and/or |
59 |
|
deleted files! |
60 |
|
|
61 |
|
.htusers is in form: |
62 |
|
login:Real Name:md5(loginpassword) |
63 |
|
|
64 |
|
|
65 |
|
TODO: |
66 |
|
mixed file/directory output (add type to each entry, |
67 |
|
real support for links) |
68 |
|
add more content-management (like cms.sourceforge.net): |
69 |
|
check-out/check-in/reserve |
70 |
|
comments to files |
71 |
|
*/ |
72 |
|
|
73 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
74 |
|
|
75 |
// 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 |
87 |
// username/password should not be system |
// username/password should not be system |
88 |
// usernames/passwords !! |
// usernames/passwords !! |
89 |
|
|
90 |
// your (hashed) username/password here |
// $gblPw = "hash_of_your_username_and_password" ; |
91 |
$gblPw = "hash_of_your_username_and_password" ; |
|
92 |
|
// $gblAuth = false ; // use builtin authentication |
93 |
$gblAuth = false ; // use builtin authentication |
$gblAuth = true ; // use builtin authentication |
94 |
$gblHash = "md5" ; // hash function to use |
$gblHash = "md5" ; // hash function to use |
95 |
|
|
96 |
|
$gblPw = ""; |
97 |
|
|
98 |
|
if ($gblAuth) { |
99 |
|
$htusers_file=dirname($SCRIPT_FILENAME)."/.htusers"; |
100 |
|
if (! file_exists($htusers_file)) { |
101 |
|
$htusers=fopen($htusers_file,"a+"); |
102 |
|
fputs($htusers,"# Change owner of $htusers_file to root !!\n"); |
103 |
|
fputs($htusers,"demo:full name:md5_hash\n"); |
104 |
|
fclose($htusers); |
105 |
|
} |
106 |
|
$htusers=fopen($htusers_file,"r"); |
107 |
|
while($user = fgetcsv($htusers,255,":")) { |
108 |
|
if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) { |
109 |
|
$gblUserName=$user[1]; |
110 |
|
$gblPw=$user[2]; |
111 |
|
continue ; |
112 |
|
} |
113 |
|
} |
114 |
|
fclose($htusers); |
115 |
|
} |
116 |
|
|
117 |
|
// $gblDateFmt="D, F d, Y"; |
118 |
|
// $gblTimeFmt="g:i:sA"; |
119 |
|
|
120 |
|
$gblDateFmt="Y-m-d"; |
121 |
|
$gblTimeFmt="H:i:s"; |
122 |
|
|
123 |
|
// Number of backup files to keep |
124 |
|
$gblNumBackups=5; |
125 |
|
|
126 |
// choose GifIcon below unless you have the M$ |
// choose GifIcon below unless you have the M$ |
127 |
// WingDings font installed on your system |
// WingDings font installed on your system |
128 |
|
|
131 |
// the directory below should be /icons/ or /icons/small/ |
// the directory below should be /icons/ or /icons/small/ |
132 |
// on Apache; a set of icons is included in the distribution |
// on Apache; a set of icons is included in the distribution |
133 |
|
|
134 |
$gblIconLocation = "icons/" ; |
$gblIconLocation = "/icons/" ; |
135 |
|
|
136 |
// files you want to be able to edit in text mode |
// files you want to be able to edit in text mode |
137 |
// and view with (primitive) syntax highlighting |
// and view with (primitive) syntax highlighting |
157 |
|
|
158 |
<HTML> |
<HTML> |
159 |
<HEAD> |
<HEAD> |
160 |
<TITLE><?php echo $host . " " . $title ?></TITLE> |
<TITLE><?= $host . " " . $title ?></TITLE> |
161 |
<META NAME="description" CONTENT="PHP port of AnyPortal Site Manager"> |
<META NAME="description" CONTENT="PHP port of AnyPortal Site Manager"> |
162 |
<META NAME="keywords" CONTENT="site manager, web site maintenance"> |
<META NAME="keywords" CONTENT="site manager, web site maintenance"> |
163 |
<META NAME="robots" CONTENT="noindex"> |
<META NAME="robots" CONTENT="noindex"> |
164 |
<META HTTP-EQUIV="expires" CONTENT="0"> |
<META HTTP-EQUIV="expires" CONTENT="0"> |
165 |
<LINK REL="stylesheet" TYPE="text/css" |
<LINK REL="stylesheet" TYPE="text/css" |
166 |
HREF="<?php echo $self ?>?STYLE=get"> |
HREF="<?= $self ?>?STYLE=get"> |
167 |
</HEAD> |
</HEAD> |
168 |
<BODY BGCOLOR="#FFFFFF"> |
<BODY BGCOLOR="#FFFFFF"> |
169 |
<H3 ALIGN="RIGHT"><?php echo $host ?></H3> |
<H3 ALIGN="RIGHT"><?= $host ?></H3> |
170 |
<TABLE BORDER=0 WIDTH="100%"><TR> |
<TABLE BORDER=0 WIDTH="100%"><TR> |
171 |
<TD CLASS=INV><?php echo $title ?></TD></TR></TABLE> |
<TD CLASS=INV><?= $title ?></TD></TR></TABLE> |
172 |
<P><?php echo $text ?></P> |
<P><?= $text ?></P> |
173 |
|
|
174 |
<?php |
<?php |
175 |
} // end function StartHTML |
} // end function StartHTML |
181 |
|
|
182 |
<HR> |
<HR> |
183 |
<P CLASS=FTR> |
<P CLASS=FTR> |
184 |
<B><?php echo date("D, F d, Y") ?> - |
<B><?= date($GLOBALS[gblDateFmt]) ?> - |
185 |
<?php echo date("g:i:sA") ?></B><BR>ANYPORTAL(php) Site Manager |
<?= date($GLOBALS[gblTimeFmt]) ?> - |
186 |
- © 1999 by <A HREF="http://www.anyportal.com">ANYPORTAL</A> |
<?= $GLOBALS[gblUserName] ?> |
187 |
- © 2000 by <A HREF="http://da.nger.org">d@nger.org</A> |
<small> [<a href="<?= $PHP_SELF ?>?relogin=<?= $GLOBALS[gblPw] ?>">logout</a>]</small> |
188 |
|
</B> |
189 |
|
<BR>ANYPORTAL(php) Site Manager |
190 |
|
<br><small> |
191 |
|
© 1999 by <A HREF="http://www.anyportal.com">ANYPORTAL</A>, |
192 |
|
© 2000 by <A HREF="http://da.nger.org">d@nger.org</A>, |
193 |
|
© 2000 by <A HREF="http://www.rot13.org/~dpavlin/">DbP</A> |
194 |
|
</small> |
195 |
</P> |
</P> |
196 |
<BR><BR><BR></BODY></HTML> |
<BR> |
197 |
|
<? include(".debug.inc") ?> |
198 |
|
<BR><BR></BODY></HTML> |
199 |
|
|
200 |
<?php |
<?php |
201 |
} // end function EndHTML |
} // end function EndHTML |
205 |
function CSS() { |
function CSS() { |
206 |
?> |
?> |
207 |
|
|
208 |
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; } |
209 |
.BLK { color:black; } |
.BLK { color:black; } |
210 |
.RED { color:red; } |
.RED { color:red; } |
211 |
.TOP { color:red; font-size:70%; } /* table headings */ |
.TOP { color:red; font-size:70%; } /* table headings */ |
239 |
$exists = file_exists($fsPath) ; |
$exists = file_exists($fsPath) ; |
240 |
$ext = strtolower(strrchr($relPath,".")) ; |
$ext = strtolower(strrchr($relPath,".")) ; |
241 |
$editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) ; |
$editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) ; |
242 |
$writable = Writeable($fsPath) ; |
$writable = is_writeable($fsPath) ; |
243 |
|
|
244 |
if (!$editable && !$exists) |
if (!$editable && !$exists) |
245 |
Error("Creation unsupported for type",$relPath) ; |
Error("Creation unsupported for type",$relPath) ; |
246 |
if (!exists && !Writeable($fsDir) ) |
if (!exists && !is_writeable($fsDir) ) |
247 |
Error("Creation denied",$relDir) ; |
Error("Creation denied",$relDir) ; |
248 |
|
|
249 |
$text = "Use this page to view, modify or " ; |
$text = "Use this page to view, modify or " ; |
254 |
|
|
255 |
echo "<H3>" . $relDir . "/" . $fn . "</H3>" ; |
echo "<H3>" . $relDir . "/" . $fn . "</H3>" ; |
256 |
if ($exists) { // get file info |
if ($exists) { // get file info |
257 |
$fsize = filesize($fsPath) ; |
$fsize = filesize($fsPath) ; |
258 |
$fmodified = date("d/M/y G:i:s", filemtime($fsPath)) ; |
$fmodified = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", filemtime($fsPath)) ; |
259 |
$faccessed = date("d/M/y G:i:s", fileatime($fsPath)) ; |
$faccessed = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", fileatime($fsPath)) ; |
260 |
echo "<PRE> file size: " . $fsize . " Bytes<BR>" ; |
echo "<PRE> file size: " . $fsize . " Bytes<BR>" ; |
261 |
echo "last modified: <B>" . $fmodified . "</B><BR>" ; |
echo "last modified: <B>" . $fmodified . "</B><BR>" ; |
262 |
echo "last accessed: <B>" . $faccessed . "</B><BR>" ; |
echo "last accessed: <B>" . $faccessed . "</B><BR>" ; |
263 |
echo " owner: <B>" . fileowner($fsPath) . "</B><BR>" ; |
echo " owner: <B>" . fileowner($fsPath) . "</B><BR>" ; |
264 |
echo " group: <B>" . filegroup($fsPath) . "</B><BR>" ; |
echo " group: <B>" . filegroup($fsPath) . "</B><BR>" ; |
265 |
echo " permissions: <B>" ; |
echo " permissions: <B>" ; |
266 |
echo printf( "%o", fileperms($fsPath) ) . "</B>" ; |
echo printf( "%o", fileperms($fsPath) ) . "</B>" ; |
267 |
echo "</PRE>" ; |
echo "</PRE>" ; |
268 |
|
|
269 |
} |
} |
270 |
|
|
271 |
if ( $editable && ($writable || !$exists) ) { |
if ( $editable && ($writable || !$exists) ) { |
276 |
$fstr = htmlentities( $fstr ) ; |
$fstr = htmlentities( $fstr ) ; |
277 |
?> |
?> |
278 |
|
|
279 |
<FORM ACTION="<?php echo $self ; ?>" METHOD="POST"> |
<FORM ACTION="<?= $self ; ?>" METHOD="POST"> |
280 |
<SPAN TITLE="Click [SAVE] to store updated contents."> |
<SPAN TITLE="Click [SAVE] to store updated contents."> |
281 |
<B>DOCUMENT CONTENTS</B> |
<B>DOCUMENT CONTENTS</B> |
282 |
</SPAN><BR> |
</SPAN><BR> |
283 |
<TEXTAREA NAME="FILEDATA" ROWS=18 COLS=70 WRAP="OFF"><?php |
<TEXTAREA NAME="FILEDATA" ROWS=18 COLS=70 WRAP="OFF"><?php |
284 |
echo($fstr) ; ?></TEXTAREA> |
echo($fstr) ; ?></TEXTAREA> |
285 |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ; ?>"> |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ; ?>"> |
286 |
<INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?php echo $fn ; ?>"> |
<INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?= $fn ; ?>"> |
287 |
<INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="SAVE"> |
<INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="SAVE"> |
288 |
<INPUT TYPE="TEXT" SIZE=48 MAXLENGTH=255 NAME="RELPATH" |
<INPUT TYPE="HIDDEN" SIZE=48 MAXLENGTH=255 NAME="RELPATH" |
289 |
VALUE="<?php echo $relPath ; ?>"> |
VALUE="<?= $relPath ; ?>"> |
290 |
<INPUT TYPE="RESET" VALUE="RESET"> |
<br> |
291 |
|
<INPUT TYPE="RESET" VALUE="UNDO ALL CHANGES"> |
292 |
<INPUT TYPE="SUBMIT" VALUE="SAVE"> |
<INPUT TYPE="SUBMIT" VALUE="SAVE"> |
293 |
</FORM> |
</FORM> |
294 |
|
|
303 |
} |
} |
304 |
?> |
?> |
305 |
|
|
306 |
<FORM ACTION="<?php echo $self ; ?>" METHOD="POST"> |
<FORM ACTION="<?= $self ; ?>" METHOD="POST"> |
307 |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ; ?>"> |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ; ?>"> |
308 |
<INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?php echo $fn ; ?>"> |
<INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?= $fn ; ?>"> |
309 |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR> |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR> |
310 |
|
|
311 |
<?php |
<?php |
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"> |
328 |
|
<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"> |
<INPUT TYPE="CHECKBOX" NAME="CONFIRM"> |
337 |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="DELETE"> |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="RENAME"> |
338 |
|
|
339 |
|
<HR> |
340 |
|
<a name="note"> |
341 |
|
<B>NOTE FOR "<?= $fn ; ?>": |
342 |
|
<INPUT TYPE="TEXT" SIZE=50 MAXLENGTH=255 NAME="NOTE" VALUE="<?= ReadNote($fsPath) ?>"> |
343 |
|
</B></SPAN> |
344 |
|
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="NOTE"> |
345 |
|
|
346 |
<?php |
<?php |
347 |
} |
} |
348 |
echo "</FORM>" ; |
echo "</FORM>" ; |
349 |
|
|
350 |
|
$logname=dirname("$fsDir/$fn")."/.log/".basename("$fsDir/$fn"); |
351 |
|
if (file_exists($logname)) { |
352 |
|
print "<hr><br><b>CHANGES TO THIS FILE</b><br><table border=0 width=100%>\n"; |
353 |
|
$log=fopen($logname,"r"); |
354 |
|
$cl1=" class=lst"; $cl2=""; |
355 |
|
while($line = fgetcsv($log,255,"\t")) { |
356 |
|
$cl=$cl1; $cl1=$cl2; $cl2=$cl; |
357 |
|
print "<tr><td$cl>$line[0]</td><td$cl>$line[1]</td><td$cl>$line[2]</td><td$cl>$line[3]</td></tr>\n"; |
358 |
|
} |
359 |
|
fclose($log); |
360 |
|
print "</table>"; |
361 |
|
} |
362 |
|
|
363 |
EndHTML() ; |
EndHTML() ; |
364 |
|
|
365 |
} // end function DetailPage |
} // end function DetailPage |
589 |
case "blank" : |
case "blank" : |
590 |
$d = "blank.gif" ; |
$d = "blank.gif" ; |
591 |
break ; |
break ; |
592 |
|
case "checkout": |
593 |
|
$d = "down.gif"; |
594 |
|
break; |
595 |
|
case "checkin": |
596 |
|
$d = "up.gif"; |
597 |
|
break; |
598 |
|
case "note": |
599 |
|
$d = "quill.gif"; |
600 |
|
break; |
601 |
default : |
default : |
602 |
$d = "generic.gif" ; |
$d = "generic.gif" ; |
603 |
} |
} |
612 |
global $gblEditable, $gblIcon ; |
global $gblEditable, $gblIcon ; |
613 |
|
|
614 |
$self = $GLOBALS["PHP_SELF"] ; |
$self = $GLOBALS["PHP_SELF"] ; |
615 |
$webRoot = "http://" . $GLOBALS["SERVER_NAME"] ; |
if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") { |
616 |
|
$webRoot = "https://" . $GLOBALS["SERVER_NAME"] ; |
617 |
|
} else { |
618 |
|
$webRoot = "http://" . $GLOBALS["SERVER_NAME"] ; |
619 |
|
} |
620 |
$fsDir = $fsRoot . $relDir . "/" ; // current directory |
$fsDir = $fsRoot . $relDir . "/" ; // current directory |
621 |
|
|
622 |
if (!is_dir($fsDir)) Error("Dir not found",$relDir) ; |
if (!is_dir($fsDir)) Error("Dir not found",$relDir) ; |
625 |
if ( !($dir = @opendir($fsDir)) ) |
if ( !($dir = @opendir($fsDir)) ) |
626 |
Error("Read Access denied",$relDir) ; |
Error("Read Access denied",$relDir) ; |
627 |
while ($item = readdir($dir)) { |
while ($item = readdir($dir)) { |
628 |
if ( $item == ".." || $item == "." ) continue ; |
if ( $item == ".." || $item == "." || substr($item,0,1) == "." ) continue ; |
629 |
if ( is_dir($fsDir . $item) ) { |
if ( is_dir($fsDir . $item) ) { |
630 |
$dirList[] = $item ; |
$dirList[] = $item ; |
631 |
} |
} else if ( is_file($fsDir . $item) ) { |
|
else if ( is_file($fsDir . $item) ) { |
|
632 |
$fileList[] = $item ; |
$fileList[] = $item ; |
633 |
} |
} else if ( is_link($fsDir . $item) ) { |
634 |
else { |
$dirList[] = $item ; |
635 |
|
} else { |
636 |
// unknown file type |
// unknown file type |
637 |
// $text = "Could not determine file type of " ; |
// $text = "Could not determine file type of " ; |
638 |
// Error("File Error", $text.$relDir."/".$item) ; |
// Error("File Error", $text.$relDir."/".$item) ; |
640 |
} |
} |
641 |
} |
} |
642 |
closedir($dir) ; |
closedir($dir) ; |
643 |
|
|
644 |
|
// scan deleted files |
645 |
|
if ( $GLOBALS[show_deleted] == 1 && ($dir = @opendir("$fsDir/.del")) ) { |
646 |
|
while ($item = readdir($dir)) { |
647 |
|
if ( substr($item,0,1) == "." ) continue ; |
648 |
|
$fileList[] = ".del/$item" ; |
649 |
|
} |
650 |
|
closedir($dir) ; |
651 |
|
} |
652 |
|
|
653 |
$emptyDir = ! (sizeof($dirList) || sizeof($fileList)) ; |
$emptyDir = ! (sizeof($dirList) || sizeof($fileList)) ; |
654 |
|
|
655 |
// start navigation page |
// start navigation page |
656 |
$text = "Use this page to add, delete or " ; |
$text = "Use this page to add, delete"; |
657 |
$text .= "revise files on this web site." ; |
if (! isset($show_deleted)) { |
658 |
|
$text .= ", <a href=".$GLOBALS[PHP_SELF]."?D=".urlencode($relDir)."&show_deleted=1>undelete</a>"; |
659 |
|
} |
660 |
|
$text .= " or revise files on this web site." ; |
661 |
StartHTML("(Navigate)",$text) ; |
StartHTML("(Navigate)",$text) ; |
662 |
|
|
663 |
echo "<TABLE BORDER=0 CELLPADDING=2 |
echo "<TABLE BORDER=0 CELLPADDING=2 |
669 |
if ($parent == "") $parent = "/" ; |
if ($parent == "") $parent = "/" ; |
670 |
?> |
?> |
671 |
|
|
672 |
<TR><TD><?php echo $gblIcon("up") ?></TD><TD COLSPAN=4 CLASS=LST> |
<TR><TD><?= $gblIcon("up") ?></TD><TD COLSPAN=5 CLASS=LST> |
673 |
<A HREF="<?php echo $self ?>?D=<?php echo urlencode($parent) ?>"> |
<A HREF="<?= $self ?>?D=<?= urlencode($parent) ?>"> |
674 |
<B><?php echo $parent ?></B></A></TD></TR> |
<B><?= $parent ?></B></A></TD></TR> |
675 |
|
|
676 |
<?php |
<?php |
677 |
} |
} |
681 |
sort($dirList) ; |
sort($dirList) ; |
682 |
?> |
?> |
683 |
|
|
684 |
<TR><TD></TD><TD COLSPAN=4 CLASS=TOP><HR>DIRECTORY NAME</TD></TR> |
<TR><TD></TD><TD COLSPAN=5 CLASS=TOP><HR>DIRECTORY NAME</TD></TR> |
685 |
|
|
686 |
<?php |
<?php |
687 |
while (list($key,$dir) = each($dirList)) { |
while (list($key,$dir) = each($dirList)) { |
691 |
$tstr .= "\">" . $dir . "/</A>" ; |
$tstr .= "\">" . $dir . "/</A>" ; |
692 |
?> |
?> |
693 |
|
|
694 |
<TR><TD><?php echo $gblIcon("fldr") ?></TD> |
<TR><TD><?= $gblIcon("fldr") ?></TD> |
695 |
<TD COLSPAN=4 CLASS=LST><?php echo $tstr ?></TD></TR> |
<TD COLSPAN=5 CLASS=LST><?= $tstr ?></TD></TR> |
696 |
|
|
697 |
<?php |
<?php |
698 |
} // iterate over dirs |
} // iterate over dirs |
699 |
} // end if no dirs |
} // end if no dirs |
700 |
?> |
?> |
701 |
|
|
702 |
<TR><TD></TD><TD COLSPAN=4><HR><B><?php echo $webRoot . $relDir ?> |
<TR><TD></TD><TD COLSPAN=5><HR><B><?= $webRoot . $relDir ?> |
703 |
</B></TD></TR> |
</B></TD></TR> |
704 |
<TR><TD></TD><TD CLASS=TOP>DOCUMENT NAME</TD> |
<TR><TD></TD><TD CLASS=TOP>DOCUMENT NAME</TD> |
705 |
<TD><?php echo $gblIcon("blank") ?></TD> |
<TD><?= $gblIcon("blank") ?></TD> |
706 |
|
<TD CLASS=TOP>NOTE</TD> |
707 |
<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> |
708 |
|
|
709 |
<?php |
<?php |
710 |
if (sizeof($fileList) > 0) { |
if (sizeof($fileList) > 0) { |
711 |
sort($fileList) ; |
sort($fileList) ; |
712 |
while (list($key,$file) = each($fileList)) { |
while (list($key,$file) = each($fileList)) { |
713 |
$path = $fsDir."/".$file ; |
$path = $fsDir."/".$file ; |
714 |
$mod = filemtime($path) ; |
$mod = filemtime($path) ; |
715 |
$sz = filesize($path) ; |
$sz = filesize($path) ; |
716 |
|
|
717 |
if ($sz >= 10240) { |
if ($sz >= 10240) { |
718 |
$sz = (int)(($sz+1023)/1024) . " k" ; |
$sz = (int)(($sz+1023)/1024) . " k" ; |
719 |
} |
} else { |
720 |
else { |
$sz .= " " ; |
721 |
$sz .= " " ; |
} // end size |
722 |
} // end size |
|
723 |
|
$a = $b = "" ; |
724 |
$a = $b = "" ; |
|
725 |
|
$info_url=$self."?A=E&F=".urlencode($file)."&D=".urlencode($relDir); |
726 |
if ( ($mod + 30*86400) > time() ) { |
|
727 |
$a = "<SPAN CLASS=RED TITLE=\"Newer" ; |
if ( ($mod + 30*86400) > time() ) { |
728 |
$a .= " than 30 days\"> * </SPAN>" ; |
$a = "<SPAN CLASS=RED TITLE=\"Newer" ; |
729 |
} |
$a .= " than 30 days\"> * </SPAN>" ; |
730 |
|
} |
731 |
$tstr = $webRoot . $relDir . "/" . $file ; |
|
732 |
$tstr = "<A HREF=\"" . $tstr . "\">" ; |
$tstr = $webRoot . $relDir . "/" . $file ; |
733 |
$tstr .= $file . "</A>" . $a ; |
$tstr = "<A HREF=\"" . $tstr . "\">" ; |
734 |
|
|
735 |
$ext = strtolower(strrchr($file,".")) ; |
if (substr($file,0,5) != ".del/") { |
736 |
if ( $ext=="" || |
$tstr .= $file . "</A>" . $a ; |
737 |
strstr(join(" ",$gblEditable),$ext) ) |
} else { |
738 |
{ |
$tstr .= substr($file,5,strlen($file)-5) . "</a> <SPAN CLASS=RED TITLE=\"deleted\"> <a href=\"$info_url#undelete\">deleted</a> </span>"; |
739 |
$b = "<A HREF=\"" . $self . "?A=C&F=" ; |
} |
740 |
$b .= urlencode($file) . "&D=" . urlencode($relDir) ; |
|
741 |
$b .= "\" TITLE=\"List contents\">" ; |
// $b = $gblIcon("checkout"); |
742 |
$b .= $gblIcon("view") . "</A>" ; |
// $b .= $gblIcon("checkin"); |
743 |
} |
|
744 |
|
$ext = strtolower(strrchr($file,".")) ; |
745 |
|
if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) { |
746 |
|
$b .= "<A HREF=\"" . $self . "?A=C&F=" ; |
747 |
|
$b .= urlencode($file) . "&D=" . urlencode($relDir) ; |
748 |
|
$b .= "\" TITLE=\"List contents\">" ; |
749 |
|
$b .= $gblIcon("view") . "</A>" ; |
750 |
|
} else { |
751 |
|
$b .= $gblIcon("blank"); |
752 |
|
} |
753 |
|
|
754 |
|
|
755 |
?> |
?> |
756 |
|
|
757 |
<TR><TD> |
<TR><TD> |
758 |
<A HREF="<?php echo $self ?>?A=E&F=<?php echo urlencode($file) |
<A HREF="<?= $info_url ?>" TITLE="View/Edit"> |
759 |
?>&D=<?php echo urlencode($relDir) ?>" TITLE="View/Edit"> |
<?= $gblIcon($ext) ?></A></TD> |
760 |
<?php echo $gblIcon($ext) ?></A></TD> |
<TD CLASS=LST><?= $tstr ?></TD> |
761 |
<TD CLASS=LST><?php echo $tstr ?></TD> |
<TD CLASS=LST ALIGN=center><?= $b ?></TD> |
762 |
<TD CLASS=LST ALIGN=center><?php echo $b ?></TD> |
<TD CLASS=LST ALIGN=left><a href="<?= $info_url ?>#note"><?= $gblIcon("note") ?></a><?= ReadNote($path) ?></TD> |
763 |
<TD CLASS=LST><?php echo date("d/M/y G:i:s",$mod) ?></TD> |
<TD CLASS=LST><?= date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]",$mod) ?></TD> |
764 |
<TD CLASS=LST><?php echo $sz ?>Bytes</TD></TR> |
<TD CLASS=LST><?= $sz ?>Bytes</TD></TR> |
765 |
|
|
766 |
<?php |
<?php |
767 |
} // iterate over files |
} // iterate over files |
770 |
if ($emptyDir) { |
if ($emptyDir) { |
771 |
?> |
?> |
772 |
|
|
773 |
<FORM METHOD="POST" ACTION="<?php echo $self ?>"> |
<FORM METHOD="POST" ACTION="<?= $self ?>"> |
774 |
<TR><TD></TD><TD COLSPAN=4 CLASS=BAR> |
<TR><TD></TD><TD COLSPAN=5 CLASS=BAR> |
775 |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ?>"> |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"> |
776 |
OK TO DELETE THIS EMPTY FOLDER? |
OK TO DELETE THIS EMPTY FOLDER? |
777 |
<INPUT TYPE="CHECKBOX" NAME="CONFIRM"> |
<INPUT TYPE="CHECKBOX" NAME="CONFIRM"> |
778 |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="DELETE"> |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="DELETE"> |
783 |
} // end if emptyDir |
} // end if emptyDir |
784 |
?> |
?> |
785 |
|
|
786 |
<TR><TD></TD><TD COLSPAN=4><HR></TD></TR> |
<TR><TD></TD><TD COLSPAN=5><HR></TD></TR> |
787 |
|
|
788 |
<FORM METHOD="POST" ACTION="<?php echo $self ?>"> |
<FORM METHOD="POST" ACTION="<?= $self ?>"> |
789 |
<TR><TD></TD><TD COLSPAN=4 CLASS=BAR>CREATE NEW |
<TR><TD></TD><TD COLSPAN=5 CLASS=BAR>CREATE NEW |
790 |
<INPUT TYPE="RADIO" NAME="T" VALUE="D" CHECKED>DIRECTORY -OR- |
<INPUT TYPE="RADIO" NAME="T" VALUE="D" CHECKED>DIRECTORY -OR- |
791 |
<INPUT TYPE="RADIO" NAME="T" VALUE="F">FILE : |
<INPUT TYPE="RADIO" NAME="T" VALUE="F">FILE : |
792 |
<NOBR>NAME <INPUT TYPE="TEXT" NAME="FN" SIZE=14> |
<NOBR>NAME <INPUT TYPE="TEXT" NAME="FN" SIZE=14> |
793 |
<INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE"> |
<INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE"> |
794 |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ?>"> |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"> |
795 |
<INPUT TYPE="SUBMIT" VALUE="CREATE"></NOBR> |
<INPUT TYPE="SUBMIT" VALUE="CREATE"></NOBR> |
796 |
<NOBR>OR <A HREF="<?php echo $self |
<NOBR>OR <A HREF="<?= $self |
797 |
?>?A=U&D=<?php echo urlencode($relDir) ?>">UPLOAD</A> A FILE |
?>?A=U&D=<?= urlencode($relDir) ?>">UPLOAD</A> A FILE |
798 |
</NOBR> |
</NOBR> |
799 |
</TD></TR> |
</TD></TR> |
800 |
</FORM> |
</FORM> |
814 |
|
|
815 |
<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> |
816 |
<FORM ENCTYPE="multipart/form-data" METHOD="POST" |
<FORM ENCTYPE="multipart/form-data" METHOD="POST" |
817 |
ACTION="<?php echo $self ?>"> |
ACTION="<?= $self ?>"> |
818 |
DESTINATION DIRECTORY:<B><?php echo " " . $relDir ?></B> |
DESTINATION DIRECTORY:<B><?= " " . $relDir ?></B> |
819 |
<P>PATHNAME OF LOCAL FILE<BR> |
<P>PATHNAME OF LOCAL FILE<BR> |
820 |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ?>"> |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"> |
821 |
<INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="UPLOAD"> |
<INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="UPLOAD"> |
822 |
<INPUT SIZE=30 TYPE="FILE" NAME="FN"></P> |
<INPUT SIZE=30 TYPE="FILE" NAME="FN"></P> |
823 |
<P><INPUT TYPE="SUBMIT" VALUE="UPLOAD"></P> |
<P><INPUT TYPE="SUBMIT" VALUE="UPLOAD"></P> |
824 |
<P>If the <B>[BROWSE...]</B> button is not displayed,<BR> |
<P>If the <B>[BROWSE...]</B> button is not displayed,<BR> |
825 |
you must upgrade to an RFC1867-compliant browser.</P> |
you must upgrade to an RFC1867-compliant browser.</P> |
826 |
<P>Your browser:<BR><?php echo $GLOBALS["HTTP_USER_AGENT"] ?></P> |
<P>Your browser:<BR><?= $GLOBALS["HTTP_USER_AGENT"] ?></P> |
827 |
</FORM> |
</FORM> |
828 |
</TD></TR> |
</TD></TR> |
829 |
<TR><TD></TD><TD> |
<TR><TD></TD><TD> |
830 |
<FORM METHOD="POST" ACTION="<?php echo $self ?>"> |
<FORM METHOD="POST" ACTION="<?= $self ?>"> |
831 |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ?>"><BR> |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"><BR> |
832 |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"> |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"> |
833 |
</FORM> |
</FORM> |
834 |
</TD></TR></TABLE></P> |
</TD></TR></TABLE></P> |
847 |
|
|
848 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
849 |
|
|
|
function Writeable($path) { |
|
|
// fix by -mat- filid brandy, brandy@ecrc.de, 07/JUL/99 |
|
|
|
|
|
clearstatcache ; |
|
|
$perms = @fileperms($path) ; |
|
|
$owner = @fileowner($path) ; |
|
|
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 |
|
|
|
|
|
////////////////////////////////////////////////////////////////// |
|
|
|
|
850 |
function CreateHash($user, $pw) { |
function CreateHash($user, $pw) { |
851 |
|
|
852 |
global $gblHash ; // hash function to use |
global $gblHash ; // hash function to use |
881 |
StartHTML($title,$text) ; |
StartHTML($title,$text) ; |
882 |
?> |
?> |
883 |
|
|
884 |
<FORM ACTION="<?php echo $self ?>?HASH=create" METHOD="POST"> |
<FORM ACTION="<?= $self ?>?HASH=create" METHOD="POST"> |
885 |
<INPUT TYPE="HIDDEN" NAME="USER" VALUE="<?php echo $user ?>"> |
<INPUT TYPE="HIDDEN" NAME="USER" VALUE="<?= $user ?>"> |
886 |
<INPUT TYPE="HIDDEN" NAME="PW" VALUE="<?php echo $pw ?>"> |
<INPUT TYPE="HIDDEN" NAME="PW" VALUE="<?= $pw ?>"> |
887 |
|
|
888 |
<BLOCKQUOTE><B>If you are a site administrator:</B><BR><BR> |
<BLOCKQUOTE><B>If you are a site administrator:</B><BR><BR> |
889 |
Click below to <B>generate a password hash</B><BR>from |
Click below to <B>generate a password hash</B><BR>from |
899 |
|
|
900 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
901 |
|
|
902 |
|
function Logit($target,$msg) { |
903 |
|
|
904 |
|
$dir=dirname($target); |
905 |
|
if (! file_exists($dir."/.log")) { |
906 |
|
mkdir($dir."/.log",0700); |
907 |
|
} |
908 |
|
$file=basename($target); |
909 |
|
|
910 |
|
$log=fopen("$dir/.log/$file","a+"); |
911 |
|
fputs($log,date("$GLOBALS[gblDateFmt]\t$GLOBALS[gblTimeFmt]"). |
912 |
|
"\t$GLOBALS[gblUserName]\t$msg\n"); |
913 |
|
fclose($log); |
914 |
|
|
915 |
|
} |
916 |
|
|
917 |
|
|
918 |
|
////////////////////////////////////////////////////////////////// |
919 |
|
|
920 |
|
function WriteNote($target,$msg) { |
921 |
|
|
922 |
|
$dir=dirname($target); |
923 |
|
if (! file_exists($dir."/.note")) { |
924 |
|
mkdir($dir."/.note",0700); |
925 |
|
} |
926 |
|
$file=basename($target); |
927 |
|
|
928 |
|
$note=fopen("$dir/.note/$file","w"); |
929 |
|
fputs($note,"$msg\n"); |
930 |
|
fclose($note); |
931 |
|
|
932 |
|
Logit($target,"added note $msg"); |
933 |
|
|
934 |
|
} |
935 |
|
|
936 |
|
function ReadNote($target) { |
937 |
|
|
938 |
|
$dir=dirname($target); |
939 |
|
$file=basename($target); |
940 |
|
$msg=""; |
941 |
|
if (file_exists($dir."/.note/$file")) { |
942 |
|
$note=fopen("$dir/.note/$file","r"); |
943 |
|
$msg=fgets($note,4096); |
944 |
|
fclose($note); |
945 |
|
} |
946 |
|
return $msg; |
947 |
|
|
948 |
|
} |
949 |
|
|
950 |
|
////////////////////////////////////////////////////////////////// |
951 |
|
|
952 |
|
function MoveTo($source,$folder) { |
953 |
|
|
954 |
|
$file=basename($source); |
955 |
|
if (! file_exists($folder)) { |
956 |
|
mkdir($folder,0700); |
957 |
|
} |
958 |
|
if (file_exists($source)) { |
959 |
|
rename($source,"$folder/$file"); |
960 |
|
} |
961 |
|
} |
962 |
|
|
963 |
|
////////////////////////////////////////////////////////////////// |
964 |
|
|
965 |
// MAIN PROGRAM |
// MAIN PROGRAM |
966 |
// ============ |
// ============ |
967 |
// query parameters: capital letters |
// query parameters: capital letters |
968 |
// local functions : begin with capital letters |
// local functions : begin with capital letters |
969 |
// global constants: begin with gbl |
// global constants: begin with gbl |
970 |
|
|
971 |
$gblFilePerms = "644" ; // default for new files |
$gblFilePerms = 0640 ; // default for new files |
972 |
$gblDirPerms = 0755 ; // default for new dirs |
$gblDirPerms = 0750 ; // default for new dirs |
973 |
|
|
974 |
// phpinfo() ; |
// phpinfo() ; |
975 |
// exit ; |
// exit ; |
983 |
} |
} |
984 |
|
|
985 |
// authentication if $gblAuth == true |
// authentication if $gblAuth == true |
986 |
if ( $gblAuth && |
if ( $gblAuth && $gblHash($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw || |
987 |
$gblHash($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ) { |
isset($relogin) && $gblPw == $relogin ) { |
988 |
header("WWW-authenticate: basic realm=\"$SERVER_NAME\"") ; |
header("WWW-authenticate: basic realm=\"$SERVER_NAME\"") ; |
989 |
header("HTTP/1.0 401 Unauthorized") ; |
header("HTTP/1.0 401 Unauthorized") ; |
990 |
NoEntry() ; |
NoEntry() ; |
1022 |
|
|
1023 |
switch ($POSTACTION) { |
switch ($POSTACTION) { |
1024 |
case "UPLOAD" : |
case "UPLOAD" : |
1025 |
if (!Writeable($fsDir)) Error("Write denied",$relDir) ; |
if (!is_writeable($fsDir)) Error("Write denied",$relDir) ; |
1026 |
if (strstr($FN_name,"/")) |
if (strstr($FN_name,"/")) |
1027 |
Error("Non-conforming filename") ; |
Error("Non-conforming filename") ; |
1028 |
// TODO : should rather check for escapeshellcmds |
// TODO : should rather check for escapeshellcmds |
1029 |
// but maybe RFC 18xx asserts safe filenames .... |
// but maybe RFC 18xx asserts safe filenames .... |
1030 |
$source = $FN ; |
$source = $FN ; |
1031 |
$target = $fsDir . "/" . $FN_name ; |
$target = $fsDir . "/" . $FN_name ; |
1032 |
exec("cp $source $target") ; |
|
1033 |
exec("chmod $gblFilePerms $target") ; |
// backup old files first |
1034 |
|
$dir=dirname($target); |
1035 |
|
if (! file_exists($dir."/.bak")) { |
1036 |
|
mkdir($dir."/.bak",0700); |
1037 |
|
} |
1038 |
|
if (! file_exists($dir."/.bak/$GLOBALS[gblNumBackups]")) { |
1039 |
|
mkdir($dir."/.bak/$GLOBALS[gblNumBackups]",0700); |
1040 |
|
} |
1041 |
|
$file=basename($target); |
1042 |
|
for($i=$GLOBALS[gblNumBackups]-1;$i>0;$i--) { |
1043 |
|
MoveTo("$dir/.bak/$i/$file","$dir/.bak/".($i+1)."/"); |
1044 |
|
} |
1045 |
|
MoveTo($target,$dir."/.bak/1/".$file); |
1046 |
|
|
1047 |
|
copy($source,$target) ; |
1048 |
|
chmod($target,$gblFilePerms) ; |
1049 |
clearstatcache() ; |
clearstatcache() ; |
1050 |
|
Logit($target,"uploaded"); |
1051 |
break ; |
break ; |
1052 |
|
|
1053 |
case "SAVE" : |
case "SAVE" : |
1054 |
$path = $gblFsRoot . escapeshellcmd($RELPATH) ; |
$path = $gblFsRoot . escapeshellcmd($RELPATH) ; |
1055 |
$writable = Writeable($path) ; |
$writable = is_writeable($path) ; |
1056 |
$legaldir = Writeable(dirname($path)) ; |
$legaldir = is_writeable(dirname($path)) ; |
1057 |
$exists = (file_exists($path)) ? 1 : 0 ; |
$exists = (file_exists($path)) ? 1 : 0 ; |
1058 |
// check for legal extension here as well |
// check for legal extension here as well |
1059 |
if (!($writable || (!$exists && $legaldir))) |
if (!($writable || (!$exists && $legaldir))) |
1062 |
fwrite($fh,$FILEDATA) ; |
fwrite($fh,$FILEDATA) ; |
1063 |
fclose($fh) ; |
fclose($fh) ; |
1064 |
clearstatcache() ; |
clearstatcache() ; |
1065 |
|
Logit($path,"saved changes"); |
1066 |
break ; |
break ; |
1067 |
|
|
1068 |
case "CREATE" : |
case "CREATE" : |
1069 |
// we know $fsDir exists |
// we know $fsDir exists |
1070 |
if (!Writeable($fsDir)) Error("Write denied",$relDir) ; |
if ($FN == "") break; // no filename! |
1071 |
|
if (!is_writeable($fsDir)) Error("Write denied",$relDir) ; |
1072 |
$path = $fsDir . "/" . $FN ; // file or dir to create |
$path = $fsDir . "/" . $FN ; // file or dir to create |
1073 |
$relPath = $relDir . "/" . $FN ; |
$relPath = $relDir . "/" . $FN ; |
1074 |
switch ( $T ) { |
switch ( $T ) { |
1081 |
// this functionality is doubled in DetailView(). |
// this functionality is doubled in DetailView(). |
1082 |
// better keep it here altogether |
// better keep it here altogether |
1083 |
// chmod perms to $gblFilePerms |
// chmod perms to $gblFilePerms |
1084 |
if ( file_exists($path) && !Writable($path) ) |
if ( file_exists($path) && !is_writable($path) ) |
1085 |
Error("File not writable", $relPath) ; |
Error("File not writable", $relPath) ; |
1086 |
$tstr = $PHP_SELF . "?A=E&D=" . $relDir . "&F=" . $FN ; |
$tstr = $PHP_SELF . "?A=E&D=" . $relDir . "&F=" . $FN ; |
1087 |
header("Location: " . $tstr) ; |
header("Location: " . $tstr) ; |
1096 |
$tstr .= "insufficient privileges: " ; |
$tstr .= "insufficient privileges: " ; |
1097 |
|
|
1098 |
if ( $FN != "") { // delete file |
if ( $FN != "") { // delete file |
1099 |
$path = $fsDir . "/" . $FN ; |
$path = $fsDir . "/" . $FN ; |
1100 |
if ( ! @unlink($path) ) { |
|
1101 |
Error("File delete failed", $tstr . $path) ; |
$dir=dirname($path); |
1102 |
exit ; |
$file=basename($path); |
1103 |
} |
if (! file_exists("$dir/.del")) { |
1104 |
|
mkdir("$dir/.del",0700); |
1105 |
|
} |
1106 |
|
|
1107 |
|
// if ( ! @unlink($path) ) { |
1108 |
|
if ( ! rename($path,"$dir/.del/$file") ) { |
1109 |
|
Error("File delete failed", $tstr . $path) ; |
1110 |
|
Logit($path,"file delete failed"); |
1111 |
|
exit ; |
1112 |
|
} else { |
1113 |
|
Logit($path,"file deleted"); |
1114 |
|
if (! file_exists("$dir/.del/.log")) { |
1115 |
|
mkdir("$dir/.del/.log",0700); |
1116 |
|
} |
1117 |
|
MoveTo("$dir/.log/$file","$dir/.del/.log/"); |
1118 |
|
MoveTo("$dir/.note/$file","$dir/.del/.note/"); |
1119 |
|
} |
1120 |
} |
} |
1121 |
else { // delete directory |
else { // delete directory |
1122 |
if ( ! @rmdir($fsDir) ) { |
if ( ! @rmdir($fsDir) ) { |
1128 |
} |
} |
1129 |
break ; |
break ; |
1130 |
|
|
1131 |
|
case "UNDELETE" : |
1132 |
|
if ( $CONFIRM != "on" ) break ; |
1133 |
|
|
1134 |
|
if (substr($FN,0,4) != ".del") break ; |
1135 |
|
$file=substr($FN,4,strlen($FN)-4); |
1136 |
|
|
1137 |
|
Logit("$fsDir/.del/$file","undeleted"); |
1138 |
|
MoveTo("$fsDir/.del/$file","$fsDir/"); |
1139 |
|
MoveTo("$fsDir/.del/.log/$file","$fsDir/.log/"); |
1140 |
|
MoveTo("$fsDir/.del/.note/$file","$fsDir/.note/"); |
1141 |
|
|
1142 |
|
break ; |
1143 |
|
|
1144 |
|
case "RENAME" : |
1145 |
|
if ( $CONFIRM != "on" ) break ; |
1146 |
|
|
1147 |
|
Logit("$fsDir/$FN","renamed $FN to $NEWNAME"); |
1148 |
|
rename("$fsDir/$FN","$fsDir/$NEWNAME"); |
1149 |
|
rename("$fsDir/.log/$FN","$fsDir/.log/$NEWNAME"); |
1150 |
|
|
1151 |
|
break ; |
1152 |
|
|
1153 |
|
case "NOTE" : |
1154 |
|
WriteNote("$fsDir/$FN","$NOTE"); |
1155 |
|
break ; |
1156 |
|
|
1157 |
default : |
default : |
1158 |
// user hit "CANCEL" or undefined action |
// user hit "CANCEL" or undefined action |
1159 |
} |
} |
1174 |
switch ($A) { |
switch ($A) { |
1175 |
case "U" : |
case "U" : |
1176 |
// upload to $relDir |
// upload to $relDir |
1177 |
if (!Writeable($gblFsRoot . $relDir)) |
if (!is_writeable($gblFsRoot . $relDir)) |
1178 |
Error("Write access denied",$relDir) ; |
Error("Write access denied",$relDir) ; |
1179 |
$text = "Use this page to upload a single " ; |
$text = "Use this page to upload a single " ; |
1180 |
$text .= "file to <B>$SERVER_NAME</B>." ; |
$text .= "file to <B>$SERVER_NAME</B>." ; |
1184 |
exit ; |
exit ; |
1185 |
case "E" : |
case "E" : |
1186 |
// detail of $relDir/$F |
// detail of $relDir/$F |
1187 |
DetailPage($gblFsRoot, $relDir, $F) ; |
if (is_file("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ; |
1188 |
exit ; |
exit ; |
1189 |
case "C" : |
case "C" : |
1190 |
// listing of $relDir/$F |
// listing of $relDir/$F |