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 |
299 |
|
|
300 |
<?php |
<?php |
301 |
} |
} |
302 |
if ( !$file_lock && strstr(join(" ",$gblImages),$ext) ) { |
if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) { |
303 |
$info = getimagesize($fsPath) ; |
$info = getimagesize($fsPath) ; |
304 |
$tstr = "<IMG SRC=\"".urlpath($relPath)."\" BORDER=0 " ; |
$tstr = "<IMG SRC=\"".urlpath($relPath)."\" BORDER=0 " ; |
305 |
$tstr .= $info[3] . " ALT=\"" . $fn . " - " ; |
$tstr .= $info[3] . " ALT=\"" . $fn . " - " ; |
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") { |
695 |
$text .= ", <a href=$self?D=".urlencode($relDir)."&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 |
762 |
|
|
763 |
$info_url=$self."?A=E&F=".urlencode($file)."&D=".urlencode($relDir); |
$info_url=$self."?A=E&F=".urlencode($file)."&D=".urlencode($relDir); |
764 |
|
|
765 |
if ( ($mod + 30*86400) > time() ) { |
if ( ($mod + $gblModDays*86400) > time() ) { |
766 |
$a = "<SPAN CLASS=RED TITLE=\"Newer" ; |
$a = "<SPAN CLASS=RED TITLE=\"Newer" ; |
767 |
$a .= " than 30 days\"> * </SPAN>" ; |
$a .= " than $gblModDays days\"> * </SPAN>" ; |
768 |
} |
} |
769 |
|
|
770 |
$file_lock=CheckLock($path); |
$file_lock=CheckLock($path); |
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); |
997 |
|
|
998 |
function WriteNote($target,$msg) { |
function WriteNote($target,$msg) { |
999 |
|
|
1000 |
|
$target=stripSlashes($target); |
1001 |
$dir=dirname($target); |
$dir=dirname($target); |
1002 |
if (! file_exists($dir."/.note")) { |
if (! file_exists($dir."/.note")) { |
1003 |
mkdir($dir."/.note",0700); |
mkdir($dir."/.note",0700); |
1014 |
|
|
1015 |
function ReadNote($target) { |
function ReadNote($target) { |
1016 |
|
|
1017 |
|
$target=stripSlashes($target); |
1018 |
$dir=dirname($target); |
$dir=dirname($target); |
1019 |
$file=basename($target); |
$file=basename($target); |
1020 |
$msg=""; |
$msg=""; |
1031 |
|
|
1032 |
function MoveTo($source,$folder) { |
function MoveTo($source,$folder) { |
1033 |
|
|
1034 |
|
$source=stripSlashes($source); |
1035 |
$file=basename($source); |
$file=basename($source); |
1036 |
if (! file_exists($folder)) { |
if (! file_exists($folder)) { |
1037 |
mkdir($folder,0700); |
mkdir($folder,0700); |
1045 |
|
|
1046 |
function Lock($target) { |
function Lock($target) { |
1047 |
|
|
1048 |
|
$target=stripSlashes($target); |
1049 |
$dir=dirname($target); |
$dir=dirname($target); |
1050 |
if (! file_exists($dir."/.lock")) { |
if (! file_exists($dir."/.lock")) { |
1051 |
mkdir($dir."/.lock",0700); |
mkdir($dir."/.lock",0700); |
1066 |
|
|
1067 |
function CheckLock($target) { |
function CheckLock($target) { |
1068 |
|
|
1069 |
|
$target=stripSlashes($target); |
1070 |
$dir=dirname($target); |
$dir=dirname($target); |
1071 |
$file=basename($target); |
$file=basename($target); |
1072 |
$msg=0; |
$msg=0; |
1081 |
|
|
1082 |
function Unlock($target) { |
function Unlock($target) { |
1083 |
|
|
1084 |
|
$target=stripSlashes($target); |
1085 |
$dir=dirname($target); |
$dir=dirname($target); |
1086 |
$file=basename($target); |
$file=basename($target); |
1087 |
if (file_exists($dir."/.lock/$file")) { |
if (file_exists($dir."/.lock/$file")) { |
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 |
|
|
1172 |
// MAIN PROGRAM |
// MAIN PROGRAM |
1173 |
// ============ |
// ============ |
1174 |
// query parameters: capital letters |
// query parameters: capital letters |
1262 |
if (isset($FILENAME)) { |
if (isset($FILENAME)) { |
1263 |
Unlock($target); |
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" : |
1309 |
} |
} |
1310 |
$tstr = "$PHP_SELF?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ; |
$tstr = "$PHP_SELF?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ; |
1311 |
header("Location: " . $tstr) ; |
header("Location: " . $tstr) ; |
1312 |
|
ChangeLog($target,"created"); |
1313 |
exit ; |
exit ; |
1314 |
} |
} |
1315 |
break ; |
break ; |
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 { |
1407 |
// $A=Ci : checkin file $D/$F |
// $A=Ci : checkin file $D/$F |
1408 |
// $A=V : view file (do nothing except log) |
// $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 |
1451 |
header("Content-Disposition: attachment; filename=$F" ); |
header("Content-Disposition: attachment; filename=$F" ); |
1452 |
Header("Location: ".urlpath("$relDir/$F")); |
Header("Location: ".urlpath("$relDir/$F")); |
1453 |
exit; |
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 |