35 |
/* existent address after file modifications. */ |
/* existent address after file modifications. */ |
36 |
|
|
37 |
/* |
/* |
|
2000-07-25 Dobrica Pavlinusic <dpavlin@rot13.org> |
|
38 |
|
|
39 |
nuked exec calls (unsecure) |
This project is now called Directory Manager. |
|
nuked writeable function (replaced by php is_writeable) |
|
|
added support for https (tested with apache+mod_ssl) |
|
|
added users file |
|
|
date format user-selectable |
|
|
cycle backup files in bak directory |
|
|
support links as directoryes (for now) |
|
|
support of file history logging |
|
|
undelete capabilities (delete moves to .del directory) |
|
40 |
|
|
41 |
2000-07-26 DbP |
For more info, please see web pages at |
42 |
|
http://www.rot13.org/~dpavlin/docman.html |
43 |
|
|
44 |
added more checking on entered filename (when creating file/dir) |
It's relased under GPL by |
45 |
added rename option |
Dobrica Pavlinusic <dpavlin@rot13.org> |
46 |
|
|
47 |
|
|
48 |
IMPORTANT INSTALLATION NOTE: |
IMPORTANT INSTALLATION NOTE: |
57 |
TODO: |
TODO: |
58 |
mixed file/directory output (add type to each entry, |
mixed file/directory output (add type to each entry, |
59 |
real support for links) |
real support for links) |
60 |
retrieve old versions of files (overwritten) |
access controll |
61 |
show last lock date |
|
|
|
|
62 |
*/ |
*/ |
63 |
|
|
64 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
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 |
|
|
358 |
</FORM> |
</FORM> |
359 |
|
|
360 |
<?php |
<?php |
361 |
|
|
362 |
$name=basename("$fsDir/$fn"); |
$name=basename("$fsDir/$fn"); |
363 |
$logname=dirname("$fsDir/$fn")."/.log/$name"; |
$logname=dirname("$fsDir/$fn")."/.log/$name"; |
364 |
$bakdir=dirname("$fsDir/$fn")."/.bak"; |
$bakdir=dirname("$fsDir/$fn")."/.bak"; |
967 |
|
|
968 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
969 |
|
|
970 |
function Logit($target,$msg) { |
function LogIt($target,$msg) { |
971 |
|
|
972 |
$dir=dirname($target); |
$dir=dirname($target); |
973 |
if (! file_exists($dir."/.log")) { |
if (! file_exists($dir."/.log")) { |
987 |
|
|
988 |
function WriteNote($target,$msg) { |
function WriteNote($target,$msg) { |
989 |
|
|
990 |
|
$target=stripSlashes($target); |
991 |
$dir=dirname($target); |
$dir=dirname($target); |
992 |
if (! file_exists($dir."/.note")) { |
if (! file_exists($dir."/.note")) { |
993 |
mkdir($dir."/.note",0700); |
mkdir($dir."/.note",0700); |
1004 |
|
|
1005 |
function ReadNote($target) { |
function ReadNote($target) { |
1006 |
|
|
1007 |
|
$target=stripSlashes($target); |
1008 |
$dir=dirname($target); |
$dir=dirname($target); |
1009 |
$file=basename($target); |
$file=basename($target); |
1010 |
$msg=""; |
$msg=""; |
1021 |
|
|
1022 |
function MoveTo($source,$folder) { |
function MoveTo($source,$folder) { |
1023 |
|
|
1024 |
|
$source=stripSlashes($source); |
1025 |
$file=basename($source); |
$file=basename($source); |
1026 |
if (! file_exists($folder)) { |
if (! file_exists($folder)) { |
1027 |
mkdir($folder,0700); |
mkdir($folder,0700); |
1035 |
|
|
1036 |
function Lock($target) { |
function Lock($target) { |
1037 |
|
|
1038 |
|
$target=stripSlashes($target); |
1039 |
$dir=dirname($target); |
$dir=dirname($target); |
1040 |
if (! file_exists($dir."/.lock")) { |
if (! file_exists($dir."/.lock")) { |
1041 |
mkdir($dir."/.lock",0700); |
mkdir($dir."/.lock",0700); |
1056 |
|
|
1057 |
function CheckLock($target) { |
function CheckLock($target) { |
1058 |
|
|
1059 |
|
$target=stripSlashes($target); |
1060 |
$dir=dirname($target); |
$dir=dirname($target); |
1061 |
$file=basename($target); |
$file=basename($target); |
1062 |
$msg=0; |
$msg=0; |
1071 |
|
|
1072 |
function Unlock($target) { |
function Unlock($target) { |
1073 |
|
|
1074 |
|
$target=stripSlashes($target); |
1075 |
$dir=dirname($target); |
$dir=dirname($target); |
1076 |
$file=basename($target); |
$file=basename($target); |
1077 |
if (file_exists($dir."/.lock/$file")) { |
if (file_exists($dir."/.lock/$file")) { |
1134 |
function DisplayChangeLog($day) { |
function DisplayChangeLog($day) { |
1135 |
|
|
1136 |
global $gblFsRoot; |
global $gblFsRoot; |
1137 |
|
if (!file_exists("$gblFsRoot/.changelog")) return; |
1138 |
$log=fopen("$gblFsRoot/.changelog","r"); |
$log=fopen("$gblFsRoot/.changelog","r"); |
1139 |
$logarr = array(); |
$logarr = array(); |
1140 |
while($line = fgetcsv($log,255,"\t")) { |
while($line = fgetcsv($log,255,"\t")) { |
1141 |
if ($day!=1 || $day==1 && $line[0]-time() < 24*60) { |
if ($day!=1 || ($day==1 && (time()-$line[0] < 24*60*60))) { |
1142 |
array_unshift($logarr,array($line[0],$line[1],$line[2],$line[3])); |
array_unshift($logarr,array($line[0],$line[1],$line[2],$line[3])); |
1143 |
} |
} |
1144 |
} |
} |
1154 |
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"; |
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"; |
1155 |
} |
} |
1156 |
print "</table>"; |
print "</table>"; |
1157 |
|
print "<p>".GifIcon(up)." Back to <a href=$GLOBALS[PHP_SELF]>front page</a>.</p>"; |
1158 |
} |
} |
1159 |
|
|
1160 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
1205 |
// i.e. below $gblFsRoot. |
// i.e. below $gblFsRoot. |
1206 |
|
|
1207 |
$relScriptDir = dirname($SCRIPT_NAME) ; |
$relScriptDir = dirname($SCRIPT_NAME) ; |
1208 |
// i.e. /siteman |
// i.e. /docman |
1209 |
|
|
1210 |
$fsScriptDir = dirname($SCRIPT_FILENAME) ; |
$fsScriptDir = dirname($SCRIPT_FILENAME) ; |
1211 |
// i.e. /home/httpd/html/siteman |
// i.e. /home/httpd/html/docman |
1212 |
|
|
1213 |
$gblFsRoot = substr($fsScriptDir,0, |
// start on server root |
1214 |
strlen($fsScriptDir)-strlen($relScriptDir)) ; |
// $gblFsRoot = substr($fsScriptDir,0, strlen($fsScriptDir)-strlen($relScriptDir)) ; |
1215 |
|
// or on script root |
1216 |
|
$gblFsRoot = $fsScriptDir; |
1217 |
// i.e. /home/httpd/html |
// i.e. /home/httpd/html |
1218 |
|
|
1219 |
$fsDir = $gblFsRoot . $relDir ; // current directory |
$fsDir = $gblFsRoot . $relDir ; // current directory |
1220 |
if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ; |
if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ; |
1221 |
|
|
1222 |
|
$FN=stripSlashes($FN); |
1223 |
|
|
1224 |
switch ($POSTACTION) { |
switch ($POSTACTION) { |
1225 |
case "UPLOAD" : |
case "UPLOAD" : |
1226 |
if (!is_writeable($fsDir)) Error("Write denied",$relDir) ; |
if (!is_writeable($fsDir)) Error("Write denied",$relDir) ; |
1261 |
|
|
1262 |
case "SAVE" : |
case "SAVE" : |
1263 |
$path = $gblFsRoot . $RELPATH ; |
$path = $gblFsRoot . $RELPATH ; |
1264 |
|
$path=stripSlashes($path); |
1265 |
$writable = is_writeable($path) ; |
$writable = is_writeable($path) ; |
1266 |
$legaldir = is_writeable(dirname($path)) ; |
$legaldir = is_writeable(dirname($path)) ; |
1267 |
$exists = (file_exists($path)) ? 1 : 0 ; |
$exists = (file_exists($path)) ? 1 : 0 ; |
1269 |
if (!($writable || (!$exists && $legaldir))) |
if (!($writable || (!$exists && $legaldir))) |
1270 |
Error("Write denied",$RELPATH) ; |
Error("Write denied",$RELPATH) ; |
1271 |
$fh = fopen($path, "w") ; |
$fh = fopen($path, "w") ; |
1272 |
|
$FILEDATA=stripSlashes($FILEDATA); |
1273 |
fwrite($fh,$FILEDATA) ; |
fwrite($fh,$FILEDATA) ; |
1274 |
fclose($fh) ; |
fclose($fh) ; |
1275 |
clearstatcache() ; |
clearstatcache() ; |
1403 |
// $A=Ci : checkin file $D/$F |
// $A=Ci : checkin file $D/$F |
1404 |
// $A=V : view file (do nothing except log) |
// $A=V : view file (do nothing except log) |
1405 |
// default : display directory $D |
// default : display directory $D |
1406 |
|
|
1407 |
switch ($A) { |
switch ($A) { |
1408 |
case "U" : |
case "U" : |
1409 |
// upload to $relDir |
// upload to $relDir |
1416 |
EndHTML() ; |
EndHTML() ; |
1417 |
exit ; |
exit ; |
1418 |
case "E" : |
case "E" : |
1419 |
|
$F=stripSlashes($F); |
1420 |
// detail of $relDir/$F |
// detail of $relDir/$F |
1421 |
if (is_file("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ; |
if (is_file("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ; |
1422 |
exit ; |
exit ; |
1423 |
case "C" : |
case "C" : |
1424 |
|
$F=stripSlashes($F); |
1425 |
// listing of $relDir/$F |
// listing of $relDir/$F |
1426 |
DisplayCode($gblFsRoot, $relDir, $F) ; |
DisplayCode($gblFsRoot, $relDir, $F) ; |
1427 |
exit ; |
exit ; |
1432 |
Header("Location: ".urlpath("$relDir/$F")); |
Header("Location: ".urlpath("$relDir/$F")); |
1433 |
exit; |
exit; |
1434 |
case "Ci" : |
case "Ci" : |
1435 |
|
$F=stripSlashes($F); |
1436 |
// upload && update to $relDir |
// upload && update to $relDir |
1437 |
if (!is_writeable($gblFsRoot . $relDir)) |
if (!is_writeable($gblFsRoot . $relDir)) |
1438 |
Error("Write access denied",$relDir) ; |
Error("Write access denied",$relDir) ; |