65 |
TODO: |
TODO: |
66 |
mixed file/directory output (add type to each entry, |
mixed file/directory output (add type to each entry, |
67 |
real support for links) |
real support for links) |
68 |
add more content-management (like cms.sourceforge.net): |
retrieve old versions of files (overwritten) |
69 |
check-out/check-in/reserve |
show last lock date |
70 |
comments to files |
|
71 |
*/ |
*/ |
72 |
|
|
73 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
96 |
$gblPw = ""; |
$gblPw = ""; |
97 |
|
|
98 |
if ($gblAuth) { |
if ($gblAuth) { |
99 |
$htusers=fopen(dirname($SCRIPT_FILENAME)."/.htusers","r"); |
$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,":")) { |
while($user = fgetcsv($htusers,255,":")) { |
108 |
if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) { |
if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) { |
109 |
$gblUserName=$user[1]; |
$gblUserName=$user[1]; |
110 |
$gblPw=$user[2]; |
$gblPw=$user[2]; |
111 |
|
$gblEmail=$user[3]; |
112 |
continue ; |
continue ; |
113 |
} |
} |
114 |
} |
} |
121 |
$gblDateFmt="Y-m-d"; |
$gblDateFmt="Y-m-d"; |
122 |
$gblTimeFmt="H:i:s"; |
$gblTimeFmt="H:i:s"; |
123 |
|
|
124 |
// Number of backup files to keep |
// Number of backup files to keep |
125 |
$gblNumBackups=5; |
$gblNumBackups=3; |
126 |
|
|
127 |
|
// show red star if newer than ... days |
128 |
|
$gblModDays=1; |
129 |
|
|
130 |
// choose GifIcon below unless you have the M$ |
// choose GifIcon below unless you have the M$ |
131 |
// WingDings font installed on your system |
// WingDings font installed on your system |
135 |
// the directory below should be /icons/ or /icons/small/ |
// the directory below should be /icons/ or /icons/small/ |
136 |
// on Apache; a set of icons is included in the distribution |
// on Apache; a set of icons is included in the distribution |
137 |
|
|
138 |
$gblIconLocation = "icons/" ; |
$gblIconLocation = "/icons/" ; |
139 |
|
|
140 |
// files you want to be able to edit in text mode |
// files you want to be able to edit in text mode |
141 |
// and view with (primitive) syntax highlighting |
// and view with (primitive) syntax highlighting |
161 |
|
|
162 |
<HTML> |
<HTML> |
163 |
<HEAD> |
<HEAD> |
164 |
<TITLE><?php echo $host . " " . $title ?></TITLE> |
<TITLE><?= $host . " " . $title ?></TITLE> |
165 |
<META NAME="description" CONTENT="PHP port of AnyPortal Site Manager"> |
<META NAME="description" CONTENT="PHP port of AnyPortal Site Manager"> |
166 |
<META NAME="keywords" CONTENT="site manager, web site maintenance"> |
<META NAME="keywords" CONTENT="site manager, web site maintenance"> |
167 |
<META NAME="robots" CONTENT="noindex"> |
<META NAME="robots" CONTENT="noindex"> |
168 |
<META HTTP-EQUIV="expires" CONTENT="0"> |
<META HTTP-EQUIV="expires" CONTENT="0"> |
169 |
<LINK REL="stylesheet" TYPE="text/css" |
<LINK REL="stylesheet" TYPE="text/css" |
170 |
HREF="<?php echo $self ?>?STYLE=get"> |
HREF="<?= $self ?>?STYLE=get"> |
171 |
</HEAD> |
</HEAD> |
172 |
<BODY BGCOLOR="#FFFFFF"> |
<BODY BGCOLOR="#FFFFFF"> |
173 |
<H3 ALIGN="RIGHT"><?php echo $host ?></H3> |
<H3 ALIGN="RIGHT"><?= $host ?></H3> |
174 |
<TABLE BORDER=0 WIDTH="100%"><TR> |
<TABLE BORDER=0 WIDTH="100%"><TR> |
175 |
<TD CLASS=INV><?php echo $title ?></TD></TR></TABLE> |
<TD CLASS=INV><?= $title ?></TD></TR></TABLE> |
176 |
<P><?php echo $text ?></P> |
<P><?= $text ?></P> |
177 |
|
|
178 |
<?php |
<?php |
179 |
} // end function StartHTML |
} // end function StartHTML |
188 |
<B><?= date($GLOBALS[gblDateFmt]) ?> - |
<B><?= date($GLOBALS[gblDateFmt]) ?> - |
189 |
<?= date($GLOBALS[gblTimeFmt]) ?> - |
<?= date($GLOBALS[gblTimeFmt]) ?> - |
190 |
<?= $GLOBALS[gblUserName] ?> |
<?= $GLOBALS[gblUserName] ?> |
191 |
<small> [<a href="<?= $PHP_SELF ?>?relogin=<?= $GLOBALS[gblPw] ?>">logout</a>]</small> |
<small> [<a href="<?= $GLOBALS["PHP_SELF"] ?>?relogin=<?= $GLOBALS[gblPw] ?>">logout</a>]</small> |
192 |
</B> |
</B> |
193 |
<BR>ANYPORTAL(php) Site Manager |
<BR>ANYPORTAL(php) Site Manager |
194 |
<br><small> |
<br><small> |
198 |
</small> |
</small> |
199 |
</P> |
</P> |
200 |
<BR> |
<BR> |
201 |
<? //include("../debug.inc") ?> |
<? //include(".debug.inc") ?> |
202 |
<BR><BR></BODY></HTML> |
<BR><BR></BODY></HTML> |
203 |
|
|
204 |
<?php |
<?php |
244 |
$ext = strtolower(strrchr($relPath,".")) ; |
$ext = strtolower(strrchr($relPath,".")) ; |
245 |
$editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) ; |
$editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) ; |
246 |
$writable = is_writeable($fsPath) ; |
$writable = is_writeable($fsPath) ; |
247 |
|
$file_lock = CheckLock($fsPath); |
248 |
|
|
249 |
if (!$editable && !$exists) |
if (!$editable && !$exists) |
250 |
Error("Creation unsupported for type",$relPath) ; |
Error("Creation unsupported for type",$relPath) ; |
259 |
|
|
260 |
echo "<H3>" . $relDir . "/" . $fn . "</H3>" ; |
echo "<H3>" . $relDir . "/" . $fn . "</H3>" ; |
261 |
if ($exists) { // get file info |
if ($exists) { // get file info |
262 |
$fsize = filesize($fsPath) ; |
$fsize = filesize($fsPath) ; |
263 |
$fmodified = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", filemtime($fsPath)) ; |
$fmodified = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", filemtime($fsPath)) ; |
264 |
$faccessed = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", fileatime($fsPath)) ; |
$faccessed = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", fileatime($fsPath)) ; |
265 |
echo "<PRE> file size: " . $fsize . " Bytes<BR>" ; |
echo "<PRE> file size: " . $fsize . " Bytes<BR>" ; |
266 |
echo "last modified: <B>" . $fmodified . "</B><BR>" ; |
echo "last modified: <B>" . $fmodified . "</B><BR>" ; |
267 |
echo "last accessed: <B>" . $faccessed . "</B><BR>" ; |
echo "last accessed: <B>" . $faccessed . "</B><BR>" ; |
268 |
echo " owner: <B>" . fileowner($fsPath) . "</B><BR>" ; |
echo " owner: <B>" . fileowner($fsPath) . "</B><BR>" ; |
269 |
echo " group: <B>" . filegroup($fsPath) . "</B><BR>" ; |
echo " group: <B>" . filegroup($fsPath) . "</B><BR>" ; |
270 |
echo " permissions: <B>" ; |
echo " permissions: <B>" ; |
271 |
echo printf( "%o", fileperms($fsPath) ) . "</B>" ; |
echo printf( "%o", fileperms($fsPath) ) . "</B>" ; |
272 |
echo "</PRE>" ; |
echo "</PRE>" ; |
273 |
|
|
274 |
} |
} |
275 |
|
|
276 |
if ( $editable && ($writable || !$exists) ) { |
if ( $editable && ($writable || !$exists) && !$file_lock ) { |
277 |
$fh = fopen($fsPath,"a+") ; |
$fh = fopen($fsPath,"a+") ; |
278 |
rewind($fh) ; |
rewind($fh) ; |
279 |
$fstr = fread($fh,filesize($fsPath)) ; |
$fstr = fread($fh,filesize($fsPath)) ; |
281 |
$fstr = htmlentities( $fstr ) ; |
$fstr = htmlentities( $fstr ) ; |
282 |
?> |
?> |
283 |
|
|
284 |
<FORM ACTION="<?php echo $self ; ?>" METHOD="POST"> |
<FORM ACTION="<?= $self ; ?>" METHOD="POST"> |
285 |
<SPAN TITLE="Click [SAVE] to store updated contents."> |
<SPAN TITLE="Click [SAVE] to store updated contents."> |
286 |
<B>DOCUMENT CONTENTS</B> |
<B>DOCUMENT CONTENTS</B> |
287 |
</SPAN><BR> |
</SPAN><BR> |
288 |
<TEXTAREA NAME="FILEDATA" ROWS=18 COLS=70 WRAP="OFF"><?php |
<TEXTAREA NAME="FILEDATA" ROWS=18 COLS=70 WRAP="OFF"><?php |
289 |
echo($fstr) ; ?></TEXTAREA> |
echo($fstr) ; ?></TEXTAREA> |
290 |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ; ?>"> |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ; ?>"> |
291 |
<INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?php echo $fn ; ?>"> |
<INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?= $fn ; ?>"> |
292 |
<INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="SAVE"> |
<INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="SAVE"> |
293 |
<INPUT TYPE="HIDDEN" SIZE=48 MAXLENGTH=255 NAME="RELPATH" |
<INPUT TYPE="HIDDEN" SIZE=48 MAXLENGTH=255 NAME="RELPATH" |
294 |
VALUE="<?php echo $relPath ; ?>"> |
VALUE="<?= $relPath ; ?>"> |
295 |
<br> |
<br> |
296 |
<INPUT TYPE="RESET" VALUE="UNDO ALL CHANGES"> |
<INPUT TYPE="RESET" VALUE="UNDO ALL CHANGES"> |
297 |
<INPUT TYPE="SUBMIT" VALUE="SAVE"> |
<INPUT TYPE="SUBMIT" VALUE="SAVE"> |
299 |
|
|
300 |
<?php |
<?php |
301 |
} |
} |
302 |
else if ( strstr( join(" ",$gblImages), $ext ) ) { |
if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) { |
303 |
$info = getimagesize($fsPath) ; |
$info = getimagesize($fsPath) ; |
304 |
$tstr = "<IMG SRC=\"". $relPath . "\" BORDER=0 " ; |
$tstr = "<IMG SRC=\"".urlpath($relPath)."\" BORDER=0 " ; |
305 |
$tstr .= $info[3] . " ALT=\"" . $fn . " - " ; |
$tstr .= $info[3] . " ALT=\"" . $fn . " - " ; |
306 |
$tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ; |
$tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ; |
307 |
echo htmlentities($tstr) . "<BR><BR>" . $tstr ; |
// echo htmlentities($tstr) . "<BR><BR>" . $tstr ; |
308 |
|
echo $tstr ; |
309 |
} |
} |
310 |
|
|
311 |
?> |
?> |
312 |
|
|
313 |
<FORM ACTION="<?php echo $self ; ?>" METHOD="POST"> |
<FORM ACTION="<?= $self ; ?>" METHOD="POST"> |
314 |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ; ?>"> |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ; ?>"> |
315 |
<INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?php echo $fn ; ?>"> |
<INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?= $fn ; ?>"> |
316 |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR> |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR> |
317 |
|
|
318 |
<?php |
<?php |
319 |
|
|
320 |
|
if ($file_lock) { |
321 |
|
?> |
322 |
|
<hr> |
323 |
|
<SPAN TITLE="Check OK and click UNLOCK to remove lock on file."> |
324 |
|
<B>OK TO FORCE LOCK REMOVAL ON "<?= $fn ; ?>" HELD BY <?= $file_lock ?>? </B></SPAN> |
325 |
|
<INPUT TYPE="CHECKBOX" NAME="CONFIRM"> |
326 |
|
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="UNLOCK"> |
327 |
|
<? |
328 |
|
} // file_lock |
329 |
|
|
330 |
if (substr($fn,0,4) == ".del") { |
if (substr($fn,0,4) == ".del") { |
331 |
$action="UNDELETE"; |
$action="UNDELETE"; |
332 |
$desc="undelete previously deleted file"; |
$desc="undelete previously deleted file"; |
338 |
if ($exists && $writable) { |
if ($exists && $writable) { |
339 |
?> |
?> |
340 |
|
|
341 |
<HR><SPAN TITLE="Check OK and click [<?= $action ?>] to <?= $desc ?>."> |
<HR> |
342 |
<B>OK TO <?= $action ?> "<?php echo $fn ; ?>"? </B></SPAN> |
<a name="undelete"> |
343 |
|
<SPAN TITLE="Check OK and click [<?= $action ?>] to <?= $desc ?>."> |
344 |
|
<B>OK TO <?= $action ?> "<?= $fn ; ?>"? </B></SPAN> |
345 |
<INPUT TYPE="CHECKBOX" NAME="CONFIRM"> |
<INPUT TYPE="CHECKBOX" NAME="CONFIRM"> |
346 |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="<?= $action ?>"> |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="<?= $action ?>"> |
347 |
|
|
348 |
<HR><SPAN TITLE="Check OK and click [RENAME] to rename."> |
<HR> |
349 |
<B>OK TO RENAME "<?php echo $fn ; ?>" TO |
<a name="rename"> |
350 |
|
<SPAN TITLE="Check OK and click [RENAME] to rename."> |
351 |
|
<B>OK TO RENAME "<?= $fn ; ?>" TO |
352 |
<INPUT TYPE="TEXT" SIZE=24 MAXLENGTH=255 NAME="NEWNAME" VALUE="<?= $fn ?>"> |
<INPUT TYPE="TEXT" SIZE=24 MAXLENGTH=255 NAME="NEWNAME" VALUE="<?= $fn ?>"> |
353 |
? </B></SPAN> |
? </B></SPAN> |
354 |
<INPUT TYPE="CHECKBOX" NAME="CONFIRM"> |
<INPUT TYPE="CHECKBOX" NAME="CONFIRM"> |
355 |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="RENAME"> |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="RENAME"> |
356 |
|
|
357 |
<?php |
<?php |
358 |
} |
} // exists && writable |
359 |
echo "</FORM>" ; |
?> |
360 |
|
<HR> |
361 |
|
<a name="note"> |
362 |
|
<B>NOTE FOR "<?= $fn ; ?>": |
363 |
|
<INPUT TYPE="TEXT" SIZE=50 MAXLENGTH=255 NAME="NOTE" VALUE="<?= ReadNote($fsPath) ?>"> |
364 |
|
</B></SPAN> |
365 |
|
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="NOTE"> |
366 |
|
|
367 |
|
</FORM> |
368 |
|
|
369 |
$logname=dirname("$fsDir/$fn")."/.log/".basename("$fsDir/$fn"); |
<?php |
370 |
|
|
371 |
|
$name=basename("$fsDir/$fn"); |
372 |
|
$logname=dirname("$fsDir/$fn")."/.log/$name"; |
373 |
|
$bakdir=dirname("$fsDir/$fn")."/.bak"; |
374 |
if (file_exists($logname)) { |
if (file_exists($logname)) { |
|
print "<hr><br><b>CHANGES TO THIS FILE</b><br><table border=0 width=100%>\n"; |
|
375 |
$log=fopen($logname,"r"); |
$log=fopen($logname,"r"); |
376 |
$cl1=" class=lst"; $cl2=""; |
$cl1=" class=lst"; $cl2=""; |
377 |
|
$logarr = array(); |
378 |
while($line = fgetcsv($log,255,"\t")) { |
while($line = fgetcsv($log,255,"\t")) { |
379 |
$cl=$cl1; $cl1=$cl2; $cl2=$cl; |
$cl=$cl1; $cl1=$cl2; $cl2=$cl; |
380 |
print "<tr><td$cl>$line[0]</td><td$cl>$line[1]</td><td$cl>$line[2]</td><td$cl>$line[3]</td></tr>\n"; |
array_unshift($logarr,array($cl,$line[0],$line[1],$line[2],$line[3])); |
381 |
} |
} |
382 |
fclose($log); |
fclose($log); |
383 |
|
print "<hr><br><b>CHANGES TO THIS FILE</b><br><table border=0 width=100%>\n"; |
384 |
|
$bakcount = 0; // start from 0, skip fist backup (it's current) |
385 |
|
while ($e = array_shift($logarr)) { |
386 |
|
if (strstr($e[4],"upload")) { |
387 |
|
if (file_exists("$bakdir/$bakcount/$name")) { |
388 |
|
$e[4]="<a href=\"".dirname($relPath)."/.bak/$bakcount/$name\">$e[4]</a>"; |
389 |
|
} |
390 |
|
$bakcount++; |
391 |
|
} |
392 |
|
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"; |
393 |
|
} |
394 |
print "</table>"; |
print "</table>"; |
395 |
} |
} |
396 |
|
|
623 |
case "blank" : |
case "blank" : |
624 |
$d = "blank.gif" ; |
$d = "blank.gif" ; |
625 |
break ; |
break ; |
626 |
|
case "checkout": |
627 |
|
$d = "box2.gif"; |
628 |
|
break; |
629 |
|
case "checkin": |
630 |
|
$d = "hand.up.gif"; |
631 |
|
break; |
632 |
|
case "locked": |
633 |
|
$d = "screw2.gif"; |
634 |
|
break; |
635 |
|
case "note": |
636 |
|
$d = "quill.gif"; |
637 |
|
break; |
638 |
default : |
default : |
639 |
$d = "generic.gif" ; |
$d = "generic.gif" ; |
640 |
} |
} |
646 |
|
|
647 |
function Navigate($fsRoot,$relDir) { |
function Navigate($fsRoot,$relDir) { |
648 |
|
|
649 |
global $gblEditable, $gblIcon ; |
global $gblEditable, $gblIcon, $gblModDays ; |
650 |
|
|
651 |
$self = $GLOBALS["PHP_SELF"] ; |
$self = $GLOBALS["PHP_SELF"] ; |
652 |
if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") { |
if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") { |
692 |
// start navigation page |
// start navigation page |
693 |
$text = "Use this page to add, delete"; |
$text = "Use this page to add, delete"; |
694 |
if (! isset($show_deleted)) { |
if (! isset($show_deleted)) { |
695 |
$text .= ", <a href=$PHP_SELF?show_deleted=1>undelete</a>"; |
$text .= ", <a href=$self?D=".urlencode($relDir)."&show_deleted=1>undelete</a>"; |
696 |
} |
} |
697 |
$text .= " or revise files on this web site." ; |
$text .= " or revise files on this web site." ; |
698 |
|
$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>."; |
699 |
StartHTML("(Navigate)",$text) ; |
StartHTML("(Navigate)",$text) ; |
700 |
|
|
701 |
echo "<TABLE BORDER=0 CELLPADDING=2 |
echo "<TABLE BORDER=0 CELLPADDING=2 |
707 |
if ($parent == "") $parent = "/" ; |
if ($parent == "") $parent = "/" ; |
708 |
?> |
?> |
709 |
|
|
710 |
<TR><TD><?php echo $gblIcon("up") ?></TD><TD COLSPAN=4 CLASS=LST> |
<TR><TD><?= $gblIcon("up") ?></TD><TD COLSPAN=5 CLASS=LST> |
711 |
<A HREF="<?php echo $self ?>?D=<?php echo urlencode($parent) ?>"> |
<A HREF="<?= $self ?>?D=<?= urlencode($parent) ?>"> |
712 |
<B><?php echo $parent ?></B></A></TD></TR> |
<B><?= $parent ?></B></A></TD></TR> |
713 |
|
|
714 |
<?php |
<?php |
715 |
} |
} |
719 |
sort($dirList) ; |
sort($dirList) ; |
720 |
?> |
?> |
721 |
|
|
722 |
<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> |
723 |
|
|
724 |
<?php |
<?php |
725 |
while (list($key,$dir) = each($dirList)) { |
while (list($key,$dir) = each($dirList)) { |
729 |
$tstr .= "\">" . $dir . "/</A>" ; |
$tstr .= "\">" . $dir . "/</A>" ; |
730 |
?> |
?> |
731 |
|
|
732 |
<TR><TD><?php echo $gblIcon("fldr") ?></TD> |
<TR><TD><?= $gblIcon("fldr") ?></TD> |
733 |
<TD COLSPAN=4 CLASS=LST><?php echo $tstr ?></TD></TR> |
<TD COLSPAN=5 CLASS=LST><?= $tstr ?></TD></TR> |
734 |
|
|
735 |
<?php |
<?php |
736 |
} // iterate over dirs |
} // iterate over dirs |
737 |
} // end if no dirs |
} // end if no dirs |
738 |
?> |
?> |
739 |
|
|
740 |
<TR><TD></TD><TD COLSPAN=4><HR><B><?php echo $webRoot . $relDir ?> |
<TR><TD></TD><TD COLSPAN=5><HR><B><?= $webRoot . $relDir ?> |
741 |
</B></TD></TR> |
</B></TD></TR> |
742 |
<TR><TD></TD><TD CLASS=TOP>DOCUMENT NAME</TD> |
<TR><TD></TD><TD CLASS=TOP>DOCUMENT NAME</TD> |
743 |
<TD><?php echo $gblIcon("blank") ?></TD> |
<TD><?= $gblIcon("blank").$gblIcon("blank") ?></TD> |
744 |
|
<TD CLASS=TOP>NOTE</TD> |
745 |
<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> |
746 |
|
|
747 |
<?php |
<?php |
748 |
if (sizeof($fileList) > 0) { |
if (sizeof($fileList) > 0) { |
749 |
sort($fileList) ; |
sort($fileList) ; |
750 |
while (list($key,$file) = each($fileList)) { |
while (list($key,$file) = each($fileList)) { |
751 |
$path = $fsDir."/".$file ; |
$path = $fsDir."/".$file ; |
752 |
$mod = filemtime($path) ; |
$mod = filemtime($path) ; |
753 |
$sz = filesize($path) ; |
$sz = filesize($path) ; |
754 |
|
|
755 |
if ($sz >= 10240) { |
if ($sz >= 10240) { |
756 |
$sz = (int)(($sz+1023)/1024) . " k" ; |
$sz = (int)(($sz+1023)/1024) . " k" ; |
757 |
} |
} else { |
758 |
else { |
$sz .= " " ; |
759 |
$sz .= " " ; |
} // end size |
|
} // end size |
|
|
|
|
|
$a = $b = "" ; |
|
|
|
|
|
if ( ($mod + 30*86400) > time() ) { |
|
|
$a = "<SPAN CLASS=RED TITLE=\"Newer" ; |
|
|
$a .= " than 30 days\"> * </SPAN>" ; |
|
|
} |
|
760 |
|
|
761 |
$tstr = $webRoot . $relDir . "/" . $file ; |
$a = $b = "" ; |
762 |
$tstr = "<A HREF=\"" . $tstr . "\">" ; |
|
763 |
|
$info_url=$self."?A=E&F=".urlencode($file)."&D=".urlencode($relDir); |
764 |
|
|
765 |
|
if ( ($mod + $gblModDays*86400) > time() ) { |
766 |
|
$a = "<SPAN CLASS=RED TITLE=\"Newer" ; |
767 |
|
$a .= " than $gblModDays days\"> * </SPAN>" ; |
768 |
|
} |
769 |
|
|
770 |
|
$file_lock=CheckLock($path); |
771 |
|
|
772 |
|
$file_url_html="<A HREF=\"$self?A=V&F=".urlencode($file); |
773 |
|
$file_url_html.="&D=".urlencode($relDir); |
774 |
|
$file_url_html.="\" TITLE=\"View file\">" ; |
775 |
|
|
776 |
if (substr($file,0,5) != ".del/") { |
if (substr($file,0,5) != ".del/") { |
777 |
$tstr .= $file . "</A>" . $a ; |
$file_url_html .= $file . "</A>" . $a ; |
778 |
} else { |
} else { |
779 |
$tstr .= substr($file,5,strlen($file)-5) . "</a> <SPAN CLASS=RED TITLE=\"deleted\"> deleted </span>"; |
$file_url_html .= substr($file,5,strlen($file)-5) . "</a> <SPAN CLASS=RED TITLE=\"deleted\"> <a href=\"$info_url#undelete\">deleted</a> </span>"; |
780 |
|
} |
781 |
|
|
782 |
|
$note_html="<a href=\"$info_url#note\">".$gblIcon("note")."</a>".ReadNote($path); |
783 |
|
|
784 |
|
$ext = strtolower(strrchr($file,".")) ; |
785 |
|
|
786 |
|
if ($file_lock) { |
787 |
|
if ($file_lock == $GLOBALS[gblUserName]) { |
788 |
|
$b.="<A HREF=\"$self?A=Ci&F=".urlencode($file); |
789 |
|
$b.="&D=".urlencode($relDir); |
790 |
|
$b.="\" TITLE=\"Checkin (update) file on server\">" ; |
791 |
|
$file_url_html=$b; |
792 |
|
$b.=$gblIcon("checkin")."</A>" ; |
793 |
|
$b.= $gblIcon("blank"); |
794 |
|
$file_url_html.="$file</a> $a"; |
795 |
|
$note_html = $gblIcon("blank")."<b>Please check-in (update) this file</b>"; |
796 |
|
} else { |
797 |
|
$b = $gblIcon("locked"); |
798 |
|
$b.= $gblIcon("blank"); |
799 |
|
$note_html = $gblIcon("blank")."<b>File locked by $file_lock</b>"; |
800 |
|
$file_url_html = "$file $a"; |
801 |
|
} |
802 |
|
} else { |
803 |
|
$b.="<A HREF=\"$self?A=Co&F=".urlencode($file); |
804 |
|
$b.="&D=".urlencode($relDir); |
805 |
|
$b.="\" TITLE=\"Checkout file for edit\">" ; |
806 |
|
$b.=$gblIcon("checkout")."</A>" ; |
807 |
|
|
808 |
|
if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) { |
809 |
|
$b.="<A HREF=\"$self?A=C&F=".urlencode($file); |
810 |
|
$b.="&D=".urlencode($relDir); |
811 |
|
$b.="\" TITLE=\"List contents\">" ; |
812 |
|
$b.=$gblIcon("view")."</A>" ; |
813 |
|
} else { |
814 |
|
$b.= $gblIcon("blank"); |
815 |
|
} |
816 |
} |
} |
817 |
|
|
|
$ext = strtolower(strrchr($file,".")) ; |
|
|
if ( $ext=="" || |
|
|
strstr(join(" ",$gblEditable),$ext) ) |
|
|
{ |
|
|
$b = "<A HREF=\"" . $self . "?A=C&F=" ; |
|
|
$b .= urlencode($file) . "&D=" . urlencode($relDir) ; |
|
|
$b .= "\" TITLE=\"List contents\">" ; |
|
|
$b .= $gblIcon("view") . "</A>" ; |
|
|
} |
|
818 |
|
|
819 |
?> |
?> |
820 |
|
|
821 |
<TR><TD> |
<TR><TD> |
822 |
<A HREF="<?php echo $self ?>?A=E&F=<?php echo urlencode($file) |
<A HREF="<?= $info_url ?>" TITLE="View/Edit"> |
823 |
?>&D=<?php echo urlencode($relDir) ?>" TITLE="View/Edit"> |
<?= $gblIcon($ext) ?></A></TD> |
824 |
<?php echo $gblIcon($ext) ?></A></TD> |
<TD CLASS=LST><?= $file_url_html ?></TD> |
825 |
<TD CLASS=LST><?php echo $tstr ?></TD> |
<TD CLASS=LST ALIGN=center><?= $b ?></TD> |
826 |
<TD CLASS=LST ALIGN=center><?php echo $b ?></TD> |
<TD CLASS=LST ALIGN=left><?= $note_html ?></TD> |
827 |
<TD CLASS=LST><?php echo date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]",$mod) ?></TD> |
<TD CLASS=LST><?= date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]",$mod) ?></TD> |
828 |
<TD CLASS=LST><?php echo $sz ?>Bytes</TD></TR> |
<TD CLASS=LST><?= $sz ?>Bytes</TD></TR> |
829 |
|
|
830 |
<?php |
<?php |
831 |
} // iterate over files |
} // iterate over files |
834 |
if ($emptyDir) { |
if ($emptyDir) { |
835 |
?> |
?> |
836 |
|
|
837 |
<FORM METHOD="POST" ACTION="<?php echo $self ?>"> |
<FORM METHOD="POST" ACTION="<?= $self ?>"> |
838 |
<TR><TD></TD><TD COLSPAN=4 CLASS=BAR> |
<TR><TD></TD><TD COLSPAN=5 CLASS=BAR> |
839 |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ?>"> |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"> |
840 |
OK TO DELETE THIS EMPTY FOLDER? |
OK TO DELETE THIS EMPTY FOLDER? |
841 |
<INPUT TYPE="CHECKBOX" NAME="CONFIRM"> |
<INPUT TYPE="CHECKBOX" NAME="CONFIRM"> |
842 |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="DELETE"> |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="DELETE"> |
847 |
} // end if emptyDir |
} // end if emptyDir |
848 |
?> |
?> |
849 |
|
|
850 |
<TR><TD></TD><TD COLSPAN=4><HR></TD></TR> |
<TR><TD></TD><TD COLSPAN=5><HR></TD></TR> |
851 |
|
|
852 |
|
<TR><TD></TD><TD COLSPAN=5> |
853 |
|
<? |
854 |
|
if (file_exists(".info.inc")) { |
855 |
|
include(".info.inc"); |
856 |
|
} |
857 |
|
?> |
858 |
|
</TD></TR> |
859 |
|
|
860 |
|
<TR><TD></TD><TD COLSPAN=5><HR></TD></TR> |
861 |
|
|
862 |
<FORM METHOD="POST" ACTION="<?php echo $self ?>"> |
<FORM METHOD="POST" ACTION="<?= $self ?>"> |
863 |
<TR><TD></TD><TD COLSPAN=4 CLASS=BAR>CREATE NEW |
<TR><TD></TD><TD COLSPAN=5 CLASS=BAR>CREATE NEW |
864 |
<INPUT TYPE="RADIO" NAME="T" VALUE="D" CHECKED>DIRECTORY -OR- |
<INPUT TYPE="RADIO" NAME="T" VALUE="D" CHECKED>DIRECTORY -OR- |
865 |
<INPUT TYPE="RADIO" NAME="T" VALUE="F">FILE : |
<INPUT TYPE="RADIO" NAME="T" VALUE="F">FILE : |
866 |
<NOBR>NAME <INPUT TYPE="TEXT" NAME="FN" SIZE=14> |
<NOBR>NAME <INPUT TYPE="TEXT" NAME="FN" SIZE=14> |
867 |
<INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE"> |
<INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE"> |
868 |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ?>"> |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"> |
869 |
<INPUT TYPE="SUBMIT" VALUE="CREATE"></NOBR> |
<INPUT TYPE="SUBMIT" VALUE="CREATE"></NOBR> |
870 |
<NOBR>OR <A HREF="<?php echo $self |
<NOBR>OR <A HREF="<?= $self ?>?A=U&D=<?= urlencode($relDir) ?>">UPLOAD</A> A FILE |
|
?>?A=U&D=<?php echo urlencode($relDir) ?>">UPLOAD</A> A FILE |
|
871 |
</NOBR> |
</NOBR> |
872 |
</TD></TR> |
</TD></TR> |
873 |
</FORM> |
</FORM> |
879 |
|
|
880 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
881 |
|
|
882 |
function UploadPage($fsRoot, $relDir) { |
function UploadPage($fsRoot, $relDir, $filename) { |
883 |
|
|
884 |
$self = $GLOBALS["PHP_SELF"] ; |
$self = $GLOBALS["PHP_SELF"] ; |
885 |
if ($relDir == "") $relDir = "/" ; |
if ($relDir == "") $relDir = "/" ; |
887 |
|
|
888 |
<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> |
889 |
<FORM ENCTYPE="multipart/form-data" METHOD="POST" |
<FORM ENCTYPE="multipart/form-data" METHOD="POST" |
890 |
ACTION="<?php echo $self ?>"> |
ACTION="<?= $self ?>"> |
891 |
DESTINATION DIRECTORY:<B><?php echo " " . $relDir ?></B> |
DESTINATION DIRECTORY:<B><?= " " . $relDir ?></B> |
892 |
|
<? if (isset($filename)) { ?> |
893 |
|
<br>DESTINATION FILE:<B><?= " " . $filename ?></B> |
894 |
|
<INPUT TYPE="HIDDEN" NAME="FILENAME" VALUE="<?= $filename ?>"> |
895 |
|
<? } ?> |
896 |
<P>PATHNAME OF LOCAL FILE<BR> |
<P>PATHNAME OF LOCAL FILE<BR> |
897 |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ?>"> |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"> |
898 |
<INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="UPLOAD"> |
<INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="UPLOAD"> |
899 |
<INPUT SIZE=30 TYPE="FILE" NAME="FN"></P> |
<INPUT SIZE=30 TYPE="FILE" NAME="FN"></P> |
900 |
<P><INPUT TYPE="SUBMIT" VALUE="UPLOAD"></P> |
<P><INPUT TYPE="SUBMIT" VALUE="UPLOAD"></P> |
901 |
<P>If the <B>[BROWSE...]</B> button is not displayed,<BR> |
<P>If the <B>[BROWSE...]</B> button is not displayed,<BR> |
902 |
you must upgrade to an RFC1867-compliant browser.</P> |
you must upgrade to an RFC1867-compliant browser.</P> |
903 |
<P>Your browser:<BR><?php echo $GLOBALS["HTTP_USER_AGENT"] ?></P> |
<P>Your browser:<BR><?= $GLOBALS["HTTP_USER_AGENT"] ?></P> |
904 |
</FORM> |
</FORM> |
905 |
</TD></TR> |
</TD></TR> |
906 |
<TR><TD></TD><TD> |
<TR><TD></TD><TD> |
907 |
<FORM METHOD="POST" ACTION="<?php echo $self ?>"> |
<FORM METHOD="POST" ACTION="<?= $self ?>"> |
908 |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ?>"><BR> |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"><BR> |
909 |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"> |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"> |
910 |
</FORM> |
</FORM> |
911 |
</TD></TR></TABLE></P> |
</TD></TR></TABLE></P> |
958 |
StartHTML($title,$text) ; |
StartHTML($title,$text) ; |
959 |
?> |
?> |
960 |
|
|
961 |
<FORM ACTION="<?php echo $self ?>?HASH=create" METHOD="POST"> |
<FORM ACTION="<?= $self ?>?HASH=create" METHOD="POST"> |
962 |
<INPUT TYPE="HIDDEN" NAME="USER" VALUE="<?php echo $user ?>"> |
<INPUT TYPE="HIDDEN" NAME="USER" VALUE="<?= $user ?>"> |
963 |
<INPUT TYPE="HIDDEN" NAME="PW" VALUE="<?php echo $pw ?>"> |
<INPUT TYPE="HIDDEN" NAME="PW" VALUE="<?= $pw ?>"> |
964 |
|
|
965 |
<BLOCKQUOTE><B>If you are a site administrator:</B><BR><BR> |
<BLOCKQUOTE><B>If you are a site administrator:</B><BR><BR> |
966 |
Click below to <B>generate a password hash</B><BR>from |
Click below to <B>generate a password hash</B><BR>from |
976 |
|
|
977 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
978 |
|
|
979 |
function Logit($target,$msg) { |
function LogIt($target,$msg) { |
980 |
|
|
981 |
|
$target=stripSlashes($target); |
982 |
$dir=dirname($target); |
$dir=dirname($target); |
983 |
if (! file_exists($dir."/.log")) { |
if (! file_exists($dir."/.log")) { |
984 |
mkdir($dir."/.log",0700); |
mkdir($dir."/.log",0700); |
993 |
} |
} |
994 |
|
|
995 |
|
|
996 |
|
////////////////////////////////////////////////////////////////// |
997 |
|
|
998 |
|
function WriteNote($target,$msg) { |
999 |
|
|
1000 |
|
$target=stripSlashes($target); |
1001 |
|
$dir=dirname($target); |
1002 |
|
if (! file_exists($dir."/.note")) { |
1003 |
|
mkdir($dir."/.note",0700); |
1004 |
|
} |
1005 |
|
$file=basename($target); |
1006 |
|
|
1007 |
|
$note=fopen("$dir/.note/$file","w"); |
1008 |
|
fputs($note,"$msg\n"); |
1009 |
|
fclose($note); |
1010 |
|
|
1011 |
|
Logit($target,"added note $msg"); |
1012 |
|
|
1013 |
|
} |
1014 |
|
|
1015 |
|
function ReadNote($target) { |
1016 |
|
|
1017 |
|
$target=stripSlashes($target); |
1018 |
|
$dir=dirname($target); |
1019 |
|
$file=basename($target); |
1020 |
|
$msg=""; |
1021 |
|
if (file_exists($dir."/.note/$file")) { |
1022 |
|
$note=fopen("$dir/.note/$file","r"); |
1023 |
|
$msg=fgets($note,4096); |
1024 |
|
fclose($note); |
1025 |
|
} |
1026 |
|
return StripSlashes($msg); |
1027 |
|
|
1028 |
|
} |
1029 |
|
|
1030 |
|
////////////////////////////////////////////////////////////////// |
1031 |
|
|
1032 |
|
function MoveTo($source,$folder) { |
1033 |
|
|
1034 |
|
$source=stripSlashes($source); |
1035 |
|
$file=basename($source); |
1036 |
|
if (! file_exists($folder)) { |
1037 |
|
mkdir($folder,0700); |
1038 |
|
} |
1039 |
|
if (file_exists($source)) { |
1040 |
|
rename($source,"$folder/$file"); |
1041 |
|
} |
1042 |
|
} |
1043 |
|
|
1044 |
|
////////////////////////////////////////////////////////////////// |
1045 |
|
|
1046 |
|
function Lock($target) { |
1047 |
|
|
1048 |
|
$target=stripSlashes($target); |
1049 |
|
$dir=dirname($target); |
1050 |
|
if (! file_exists($dir."/.lock")) { |
1051 |
|
mkdir($dir."/.lock",0700); |
1052 |
|
} |
1053 |
|
$file=basename($target); |
1054 |
|
|
1055 |
|
if (file_exists("$dir/.lock/$file")) { |
1056 |
|
Logit($target,"attempt to locked allready locked file!"); |
1057 |
|
} else { |
1058 |
|
$lock=fopen("$dir/.lock/$file","w"); |
1059 |
|
fputs($lock,"$GLOBALS[gblUserName]\n"); |
1060 |
|
fclose($lock); |
1061 |
|
|
1062 |
|
Logit($target,"file locked"); |
1063 |
|
} |
1064 |
|
|
1065 |
|
} |
1066 |
|
|
1067 |
|
function CheckLock($target) { |
1068 |
|
|
1069 |
|
$target=stripSlashes($target); |
1070 |
|
$dir=dirname($target); |
1071 |
|
$file=basename($target); |
1072 |
|
$msg=0; |
1073 |
|
if (file_exists($dir."/.lock/$file")) { |
1074 |
|
$lock=fopen("$dir/.lock/$file","r"); |
1075 |
|
$msg=fgets($lock,4096); |
1076 |
|
fclose($lock); |
1077 |
|
} |
1078 |
|
return chop($msg); |
1079 |
|
|
1080 |
|
} |
1081 |
|
|
1082 |
|
function Unlock($target) { |
1083 |
|
|
1084 |
|
$target=stripSlashes($target); |
1085 |
|
$dir=dirname($target); |
1086 |
|
$file=basename($target); |
1087 |
|
if (file_exists($dir."/.lock/$file")) { |
1088 |
|
unlink("$dir/.lock/$file"); |
1089 |
|
Logit($target,"file unlocked"); |
1090 |
|
} else { |
1091 |
|
Logit($target,"attempt to unlocked non-locked file!"); |
1092 |
|
} |
1093 |
|
|
1094 |
|
} |
1095 |
|
|
1096 |
|
////////////////////////////////////////////////////////////////// |
1097 |
|
|
1098 |
|
function urlpath($url) { |
1099 |
|
$url=urlencode(StripSlashes("$url")); |
1100 |
|
$url=str_replace("%2F","/",$url); |
1101 |
|
$url=str_replace("+","%20",$url); |
1102 |
|
return($url); |
1103 |
|
} |
1104 |
|
|
1105 |
|
////////////////////////////////////////////////////////////////// |
1106 |
|
|
1107 |
|
function safe_rename($from,$to) { |
1108 |
|
if (file_exists($from) && is_writable(dirname($to))) { |
1109 |
|
rename($from,$to); |
1110 |
|
} |
1111 |
|
} |
1112 |
|
|
1113 |
|
////////////////////////////////////////////////////////////////// |
1114 |
|
|
1115 |
|
// recursivly delete directory |
1116 |
|
|
1117 |
|
function rrmdir($dir) { |
1118 |
|
$handle=opendir($dir); |
1119 |
|
while ($file = readdir($handle)) { |
1120 |
|
if ($file != "." && $file != "..") { |
1121 |
|
if (is_dir("$dir/$file")) |
1122 |
|
rrmdir("$dir/$file"); |
1123 |
|
else |
1124 |
|
if (! @unlink("$dir/$file")) return(0); |
1125 |
|
} |
1126 |
|
} |
1127 |
|
closedir($handle); |
1128 |
|
return @rmdir($dir); |
1129 |
|
} |
1130 |
|
|
1131 |
|
////////////////////////////////////////////////////////////////// |
1132 |
|
|
1133 |
|
function ChangeLog($target,$msg) { |
1134 |
|
|
1135 |
|
global $gblFsRoot; |
1136 |
|
$log=fopen("$gblFsRoot/.changelog","a+"); |
1137 |
|
if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot) |
1138 |
|
$target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot)); |
1139 |
|
fputs($log,time()."\t$target\t$GLOBALS[gblUserName]\t$msg\n"); |
1140 |
|
fclose($log); |
1141 |
|
|
1142 |
|
} |
1143 |
|
|
1144 |
|
function DisplayChangeLog($day) { |
1145 |
|
|
1146 |
|
global $gblFsRoot; |
1147 |
|
if (!file_exists("$gblFsRoot/.changelog")) return; |
1148 |
|
$log=fopen("$gblFsRoot/.changelog","r"); |
1149 |
|
$logarr = array(); |
1150 |
|
while($line = fgetcsv($log,255,"\t")) { |
1151 |
|
if ($day!=1 || ($day==1 && (time()-$line[0] < 24*60))) { |
1152 |
|
array_unshift($logarr,array($line[0],$line[1],$line[2],$line[3])); |
1153 |
|
} |
1154 |
|
} |
1155 |
|
fclose($log); |
1156 |
|
$cl1=" class=lst"; $cl2=""; |
1157 |
|
print "<table border=0 width=100%>\n"; |
1158 |
|
while ($e = array_shift($logarr)) { |
1159 |
|
$cl=$cl1; $cl1=$cl2; $cl2=$cl; |
1160 |
|
$date = date("$GLOBALS[gblDateFmt]", $e[0]); |
1161 |
|
$time = date("$GLOBALS[gblTimeFmt]", $e[0]); |
1162 |
|
$dir = dirname($e[1]); |
1163 |
|
$file = basename($e[1]); |
1164 |
|
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"; |
1165 |
|
} |
1166 |
|
print "</table>"; |
1167 |
|
print "<p>".GifIcon(up)." Back to <a href=$GLOBALS[PHP_SELF]>front page</a>.</p>"; |
1168 |
|
} |
1169 |
|
|
1170 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
1171 |
|
|
1235 |
// TODO : should rather check for escapeshellcmds |
// TODO : should rather check for escapeshellcmds |
1236 |
// but maybe RFC 18xx asserts safe filenames .... |
// but maybe RFC 18xx asserts safe filenames .... |
1237 |
$source = $FN ; |
$source = $FN ; |
1238 |
$target = $fsDir . "/" . $FN_name ; |
if (! isset($FILENAME)) { // from update file |
1239 |
|
$target = "$fsDir/$FN_name" ; |
1240 |
|
} else { |
1241 |
|
$target = "$fsDir/$FILENAME"; |
1242 |
|
} |
1243 |
|
|
1244 |
// backup old files first |
// backup old files first |
1245 |
$dir=dirname($target); |
$dir=dirname($target); |
1251 |
} |
} |
1252 |
$file=basename($target); |
$file=basename($target); |
1253 |
for($i=$GLOBALS[gblNumBackups]-1;$i>0;$i--) { |
for($i=$GLOBALS[gblNumBackups]-1;$i>0;$i--) { |
1254 |
if (! file_exists($dir."/.bak/".$i)) { |
MoveTo("$dir/.bak/$i/$file","$dir/.bak/".($i+1)."/"); |
|
mkdir($dir."/.bak/".$i,0700); |
|
|
} |
|
|
if (file_exists($dir."/.bak/".$i."/".$file)) { |
|
|
rename($dir."/.bak/".$i."/".$file, |
|
|
$dir."/.bak/".($i+1)."/".$file); |
|
|
} |
|
|
} |
|
|
if (file_exists($target)) { |
|
|
rename($target,$dir."/.bak/1/".$file); |
|
1255 |
} |
} |
1256 |
|
MoveTo($target,$dir."/.bak/1/"); |
1257 |
|
|
1258 |
copy($source,$target) ; |
copy($source,$target) ; |
1259 |
chmod($target,$gblFilePerms) ; |
chmod($target,$gblFilePerms) ; |
1260 |
clearstatcache() ; |
clearstatcache() ; |
1261 |
Logit($target,"uploaded"); |
Logit($target,"uploaded"); |
1262 |
|
if (isset($FILENAME)) { |
1263 |
|
Unlock($target); |
1264 |
|
} |
1265 |
|
ChangeLog($target,"updated"); |
1266 |
break ; |
break ; |
1267 |
|
|
1268 |
case "SAVE" : |
case "SAVE" : |
1269 |
$path = $gblFsRoot . escapeshellcmd($RELPATH) ; |
$path = $gblFsRoot . $RELPATH ; |
1270 |
$writable = is_writeable($path) ; |
$writable = is_writeable($path) ; |
1271 |
$legaldir = is_writeable(dirname($path)) ; |
$legaldir = is_writeable(dirname($path)) ; |
1272 |
$exists = (file_exists($path)) ? 1 : 0 ; |
$exists = (file_exists($path)) ? 1 : 0 ; |
1278 |
fclose($fh) ; |
fclose($fh) ; |
1279 |
clearstatcache() ; |
clearstatcache() ; |
1280 |
Logit($path,"saved changes"); |
Logit($path,"saved changes"); |
1281 |
|
ChangeLog($path,"saved changes"); |
1282 |
break ; |
break ; |
1283 |
|
|
1284 |
case "CREATE" : |
case "CREATE" : |
1289 |
$relPath = $relDir . "/" . $FN ; |
$relPath = $relDir . "/" . $FN ; |
1290 |
switch ( $T ) { |
switch ( $T ) { |
1291 |
case "D" : // create a directory |
case "D" : // create a directory |
1292 |
if ( ! @mkdir($path,$gblDirPerms) ) |
if ( ! @mkdir($path,$gblDirPerms) ) |
1293 |
Error("Mkdir failed",$relPath) ; // eg. if it exists |
Error("Mkdir failed",$relPath) ; // eg. if it exists |
1294 |
clearstatcache() ; |
clearstatcache() ; |
1295 |
break ; |
break ; |
1296 |
case "F" : // create a new file |
case "F" : // create a new file |
1297 |
// this functionality is doubled in DetailView(). |
// this functionality is doubled in DetailView(). |
1298 |
// better keep it here altogether |
// better keep it here altogether |
1299 |
// chmod perms to $gblFilePerms |
// chmod perms to $gblFilePerms |
1300 |
if ( file_exists($path) && !is_writable($path) ) |
if ( file_exists($path) && !is_writable($path) ) |
1301 |
Error("File not writable", $relPath) ; |
Error("File not writable", $relPath) ; |
1302 |
$tstr = $PHP_SELF . "?A=E&D=" . $relDir . "&F=" . $FN ; |
$fh = fopen($path, "w+") ; |
1303 |
header("Location: " . $tstr) ; |
if ($fh) { |
1304 |
exit ; |
fputs($fh,"\n"); |
1305 |
|
fclose($fh) ; |
1306 |
|
LogIt($path,"file created"); |
1307 |
|
} else { |
1308 |
|
Error("Creation of file $relPath failed -- $path"); |
1309 |
|
} |
1310 |
|
$tstr = "$PHP_SELF?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ; |
1311 |
|
header("Location: " . $tstr) ; |
1312 |
|
ChangeLog($target,"created"); |
1313 |
|
exit ; |
1314 |
} |
} |
1315 |
break ; |
break ; |
1316 |
|
|
1336 |
exit ; |
exit ; |
1337 |
} else { |
} else { |
1338 |
Logit($path,"file deleted"); |
Logit($path,"file deleted"); |
1339 |
if (! file_exists("$dir/.del/.log")) { |
MoveTo("$dir/.log/$file","$dir/.del/.log/"); |
1340 |
mkdir("$dir/.del/.log",0700); |
MoveTo("$dir/.note/$file","$dir/.del/.note/"); |
1341 |
} |
MoveTo("$dir/.lock/$file","$dir/.del/.lock/"); |
|
rename("$dir/.log/$file","$dir/.del/.log/$file"); |
|
1342 |
} |
} |
1343 |
} |
} |
1344 |
else { // delete directory |
else { // delete directory |
1345 |
if ( ! @rmdir($fsDir) ) { |
if ( ! @rrmdir($fsDir) ) { |
1346 |
Error("Rmdir failed", $tstr . $fsDir) ; |
Error("Rmdir failed", $tstr . $fsDir) ; |
1347 |
} |
} |
1348 |
else { |
else { |
1358 |
$file=substr($FN,4,strlen($FN)-4); |
$file=substr($FN,4,strlen($FN)-4); |
1359 |
|
|
1360 |
Logit("$fsDir/.del/$file","undeleted"); |
Logit("$fsDir/.del/$file","undeleted"); |
1361 |
rename("$fsDir/.del/$file","$fsDir/$file"); |
MoveTo("$fsDir/.del/$file","$fsDir/"); |
1362 |
rename("$fsDir/.del/.log/$file","$fsDir/.log/$file"); |
MoveTo("$fsDir/.del/.log/$file","$fsDir/.log/"); |
1363 |
|
MoveTo("$fsDir/.del/.note/$file","$fsDir/.note/"); |
1364 |
|
MoveTo("$fsDir/.del/.lock/$file","$fsDir/.lock/"); |
1365 |
|
|
1366 |
break ; |
break ; |
1367 |
|
|
1369 |
if ( $CONFIRM != "on" ) break ; |
if ( $CONFIRM != "on" ) break ; |
1370 |
|
|
1371 |
Logit("$fsDir/$FN","renamed $FN to $NEWNAME"); |
Logit("$fsDir/$FN","renamed $FN to $NEWNAME"); |
1372 |
rename("$fsDir/$FN","$fsDir/$NEWNAME"); |
safe_rename("$fsDir/$FN","$fsDir/$NEWNAME"); |
1373 |
rename("$fsDir/.log/$FN","$fsDir/.log/$NEWNAME"); |
safe_rename("$fsDir/.log/$FN","$fsDir/.log/$NEWNAME"); |
1374 |
|
safe_rename("$fsDir/.note/$FN","$fsDir/.note/$NEWNAME"); |
1375 |
|
safe_rename("$fsDir/.lock/$FN","$fsDir/.lock/$NEWNAME"); |
1376 |
|
for($i=0;$i<=$GLOBALS[gblNumBackups];$i++) { |
1377 |
|
safe_rename("$fsDir/.bak/$i/$FN","$fsDir/.bak/$i/$NEWNAME"); |
1378 |
|
} |
1379 |
|
|
1380 |
|
break ; |
1381 |
|
|
1382 |
|
case "NOTE" : |
1383 |
|
WriteNote("$fsDir/$FN","$NOTE"); |
1384 |
|
break ; |
1385 |
|
|
1386 |
|
case "UNLOCK" : |
1387 |
|
if ( $CONFIRM != "on" ) break ; |
1388 |
|
Unlock("$fsDir/$FN"); |
1389 |
break ; |
break ; |
1390 |
|
|
1391 |
default : |
default : |
1403 |
// $A=U : upload to path given in $D |
// $A=U : upload to path given in $D |
1404 |
// $A=E : display detail of file $D/$F and edit |
// $A=E : display detail of file $D/$F and edit |
1405 |
// $A=C : display code in file $D/$F |
// $A=C : display code in file $D/$F |
1406 |
|
// $A=Co : checkout file $D/$F |
1407 |
|
// $A=Ci : checkin file $D/$F |
1408 |
|
// $A=V : view file (do nothing except log) |
1409 |
// default : display directory $D |
// default : display directory $D |
1410 |
|
|
1411 |
|
$F=stripSlashes($F); |
1412 |
|
|
1413 |
switch ($A) { |
switch ($A) { |
1414 |
case "U" : |
case "U" : |
1415 |
// upload to $relDir |
// upload to $relDir |
1429 |
// listing of $relDir/$F |
// listing of $relDir/$F |
1430 |
DisplayCode($gblFsRoot, $relDir, $F) ; |
DisplayCode($gblFsRoot, $relDir, $F) ; |
1431 |
exit ; |
exit ; |
1432 |
|
case "Co" : |
1433 |
|
// checkout |
1434 |
|
Lock("$gblFsRoot/$relDir/$F"); |
1435 |
|
header("Content-Disposition: attachment; filename=$F" ); |
1436 |
|
Header("Location: ".urlpath("$relDir/$F")); |
1437 |
|
exit; |
1438 |
|
case "Ci" : |
1439 |
|
// upload && update to $relDir |
1440 |
|
if (!is_writeable($gblFsRoot . $relDir)) |
1441 |
|
Error("Write access denied",$relDir) ; |
1442 |
|
$text = "Use this page to update a single " ; |
1443 |
|
$text .= "file to <B>$SERVER_NAME</B>." ; |
1444 |
|
StartHTML("(Update file Page)", $text) ; |
1445 |
|
UploadPage($gblFsRoot, $relDir, $F) ; |
1446 |
|
EndHTML() ; |
1447 |
|
exit ; |
1448 |
|
case "V" : |
1449 |
|
// view |
1450 |
|
LogIt("$gblFsRoot/$relDir/$F","viewed"); |
1451 |
|
header("Content-Disposition: attachment; filename=$F" ); |
1452 |
|
Header("Location: ".urlpath("$relDir/$F")); |
1453 |
|
exit; |
1454 |
|
case "Ch" : |
1455 |
|
StartHTML("(File changes)","All changes chronologicaly..."); |
1456 |
|
DisplayChangeLog(0); // all |
1457 |
|
EndHTML() ; |
1458 |
|
exit; |
1459 |
|
case "Ch1" : |
1460 |
|
StartHTML("(File changes)","Changes to files in last day..."); |
1461 |
|
DisplayChangeLog(1); |
1462 |
|
EndHTML() ; |
1463 |
|
exit; |
1464 |
} |
} |
1465 |
|
|
1466 |
// default: display directory $relDir |
// default: display directory $relDir |