155 |
|
|
156 |
function DetailPage($fsRoot,$relDir,$fn) { |
function DetailPage($fsRoot,$relDir,$fn) { |
157 |
|
|
158 |
global $gblEditable, $gblImages, $webRoot, $html, $HTTP_SERVER_VARS ; |
global $gblEditable, $gblImages, |
159 |
|
$gblDateFmt, $gblTimeFmt, |
160 |
|
$webRoot, $html, |
161 |
|
$HTTP_SERVER_VARS ; |
162 |
$self = $HTTP_SERVER_VARS["PHP_SELF"] ; |
$self = $HTTP_SERVER_VARS["PHP_SELF"] ; |
163 |
|
|
164 |
$relPath = $relDir . "/" . $fn ; |
$relPath = $relDir . "/" . $fn ; |
191 |
echo "<H3>" . $relDir . "/" . $fn . "</H3>" ; |
echo "<H3>" . $relDir . "/" . $fn . "</H3>" ; |
192 |
if ($exists) { // get file info |
if ($exists) { // get file info |
193 |
$fsize = filesize($fsPath) ; |
$fsize = filesize($fsPath) ; |
194 |
$fmodified = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", filemtime($fsPath)) ; |
$fmodified = date("$gblDateFmt $gblTimeFmt", filemtime($fsPath)) ; |
195 |
$faccessed = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", fileatime($fsPath)) ; |
$faccessed = date("$gblDateFmt $gblTimeFmt", fileatime($fsPath)) ; |
196 |
$fuid=fileowner($fsPath); |
$fuid=fileowner($fsPath); |
197 |
$fgid=filegroup($fsPath); |
$fgid=filegroup($fsPath); |
198 |
$userinfo = posix_getpwuid($fuid); |
$userinfo = posix_getpwuid($fuid); |
581 |
|
|
582 |
global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide, |
global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide, |
583 |
$gblIgnoreUnknownFileType, $gblRepositoryDir, |
$gblIgnoreUnknownFileType, $gblRepositoryDir, |
584 |
$gblLogin, |
$gblLogin, $gblUserName, |
585 |
$fsRealmDir, $realm, $realm_sep, |
$fsRealmDir, $realm, $realm_sep, |
586 |
$html, $realm_config, |
$html, $realm_config, |
587 |
$HTTP_GET_VARS, $HTTP_SERVER_VARS; |
$HTTP_GET_VARS, $HTTP_SERVER_VARS; |
819 |
$ext = strtolower(strrchr($file,".")) ; |
$ext = strtolower(strrchr($file,".")) ; |
820 |
|
|
821 |
if ($file_lock) { |
if ($file_lock) { |
822 |
if ($file_lock == $GLOBALS[gblUserName]) { |
if ($file_lock == $gblUserName) { |
823 |
$b.="<A HREF=\"$self?A=Ci&D=".urlencode($relDir)."&F=".urlencode($file); |
$b.="<A HREF=\"$self?A=Ci&D=".urlencode($relDir)."&F=".urlencode($file); |
824 |
$b.="\" TITLE=\"Checkin (update) file on server\">" ; |
$b.="\" TITLE=\"Checkin (update) file on server\">" ; |
825 |
$file_url_html=$b; |
$file_url_html=$b; |
847 |
} |
} |
848 |
} |
} |
849 |
|
|
850 |
$mod = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]",$mod); |
$mod = date("$gblDateFmt $gblTimeFmt",$mod); |
851 |
|
|
852 |
include("$html/Navigate-fileEntry.html"); |
include("$html/Navigate-fileEntry.html"); |
853 |
|
|
959 |
|
|
960 |
function LogIt($target,$msg, $changelog=0) { |
function LogIt($target,$msg, $changelog=0) { |
961 |
|
|
962 |
|
global $gblDateFmt, $gblTimeFmt, $gblUserName, $gblFsRoot; |
963 |
|
|
964 |
$dir=dirname($target); |
$dir=dirname($target); |
965 |
if (! file_exists($dir."/.log")) { |
if (! file_exists($dir."/.log")) { |
966 |
if (! @mkdir($dir."/.log",0700)) Error("docman installation problem","can't create log directory <tt>$dir/.log</tt>",1); |
if (! @mkdir($dir."/.log",0700)) Error("docman installation problem","can't create log directory <tt>$dir/.log</tt>",1); |
968 |
$file=basename($target); |
$file=basename($target); |
969 |
|
|
970 |
$log=fopen("$dir/.log/$file","a+"); |
$log=fopen("$dir/.log/$file","a+"); |
971 |
fputs($log,date("$GLOBALS[gblDateFmt]\t$GLOBALS[gblTimeFmt]"). |
fputs($log,date("$gblDateFmt\t$gblTimeFmt"). |
972 |
"\t$GLOBALS[gblUserName]\t$msg\n"); |
"\t$gblUserName\t$msg\n"); |
973 |
fclose($log); |
fclose($log); |
974 |
|
|
975 |
if (! $changelog) return; |
if (! $changelog) return; |
976 |
|
|
|
global $gblFsRoot; |
|
977 |
$log=fopen("$gblFsRoot/.changelog","a+"); |
$log=fopen("$gblFsRoot/.changelog","a+"); |
978 |
if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot) |
if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot) |
979 |
$target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot)); |
$target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot)); |
980 |
$msg=str_replace("\t"," ",$msg); |
$msg=str_replace("\t"," ",$msg); |
981 |
fputs($log,time()."\t$target\t$GLOBALS[gblUserName]\t$msg\n"); |
fputs($log,time()."\t$target\t$gblUserName\t$msg\n"); |
982 |
fclose($log); |
fclose($log); |
983 |
|
|
984 |
// FIX: implement e-mail notification based on $changelog |
// FIX: implement e-mail notification based on $changelog |
1038 |
|
|
1039 |
function Lock($target) { |
function Lock($target) { |
1040 |
|
|
1041 |
|
global $gblUserName; |
1042 |
|
|
1043 |
$target=stripSlashes($target); |
$target=stripSlashes($target); |
1044 |
$dir=dirname($target); |
$dir=dirname($target); |
1045 |
if (! file_exists($dir."/.lock")) { |
if (! file_exists($dir."/.lock")) { |
1051 |
LogIt($target,"attempt to locked allready locked file!"); |
LogIt($target,"attempt to locked allready locked file!"); |
1052 |
} else { |
} else { |
1053 |
$lock=fopen("$dir/.lock/$file","w"); |
$lock=fopen("$dir/.lock/$file","w"); |
1054 |
fputs($lock,"$GLOBALS[gblUserName]\n"); |
fputs($lock,"$gblUserName\n"); |
1055 |
fclose($lock); |
fclose($lock); |
1056 |
|
|
1057 |
LogIt($target,"file locked"); |
LogIt($target,"file locked"); |
1100 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
1101 |
|
|
1102 |
function safe_rename($fromdir,$fromfile,$tofile) { |
function safe_rename($fromdir,$fromfile,$tofile) { |
1103 |
|
|
1104 |
|
global $gblNumBackups; |
1105 |
|
|
1106 |
function try_rename($from,$to) { |
function try_rename($from,$to) { |
1107 |
# print "$from -> $to\n"; |
# print "$from -> $to\n"; |
1108 |
if (file_exists($from) && is_writeable(dirname($to))) { |
if (file_exists($from) && is_writeable(dirname($to))) { |
1132 |
try_dir("$todir/.lock"); |
try_dir("$todir/.lock"); |
1133 |
try_rename("$fromdir/.lock/$fromfile","$todir/.lock/$tofile"); |
try_rename("$fromdir/.lock/$fromfile","$todir/.lock/$tofile"); |
1134 |
try_dir("$todir/.bak"); |
try_dir("$todir/.bak"); |
1135 |
for($i=0;$i<=$GLOBALS[gblNumBackups];$i++) { |
for($i=0;$i<=$gblNumBackups;$i++) { |
1136 |
try_rename("$fromdir/.bak/$i/$fromfile","$todir/.bak/$i/$tofile"); |
try_rename("$fromdir/.bak/$i/$fromfile","$todir/.bak/$i/$tofile"); |
1137 |
} |
} |
1138 |
} |
} |
1160 |
|
|
1161 |
function DisplayChangeLog($day) { |
function DisplayChangeLog($day) { |
1162 |
|
|
1163 |
global $gblFsRoot,$HTTP_SERVER_VARS; |
global $gblFsRoot, $gblDateFmt, $gblTimeFmt; |
1164 |
|
$HTTP_SERVER_VARS; |
1165 |
|
|
1166 |
|
$self = $HTTP_SERVER_VARS["PHP_SELF"]; |
1167 |
|
|
1168 |
if (!file_exists("$gblFsRoot/.changelog")) return; |
if (!file_exists("$gblFsRoot/.changelog")) return; |
1169 |
$log=fopen("$gblFsRoot/.changelog","r"); |
$log=fopen("$gblFsRoot/.changelog","r"); |
1182 |
print "<table border=0 width=100%>\n"; |
print "<table border=0 width=100%>\n"; |
1183 |
while ($e = array_shift($logarr)) { |
while ($e = array_shift($logarr)) { |
1184 |
$cl=$cl1; $cl1=$cl2; $cl2=$cl; |
$cl=$cl1; $cl1=$cl2; $cl2=$cl; |
1185 |
$date = date("$GLOBALS[gblDateFmt]", $e[0]); |
$date = date($gblDateFmt, $e[0]); |
1186 |
$time = date("$GLOBALS[gblTimeFmt]", $e[0]); |
$time = date($gblTimeFmt, $e[0]); |
1187 |
$dir = dirname($e[1]); |
$dir = dirname($e[1]); |
1188 |
$file = basename($e[1]); |
$file = basename($e[1]); |
1189 |
print "<tr><td$cl>$date</td><td$cl>$time</td><td$cl><a href=\"$HTTP_SERVER_VARS[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=\"$HTTP_SERVER_VARS[PHP_SELF]?D=".urlencode($dir)."\">$dir</a>/$file</td><td$cl>$e[2]</td><td$cl>$e[3]</td></tr>\n"; |
1190 |
} |
} |
1191 |
print "</table>"; |
print "</table>"; |
1192 |
print "<p>".GifIcon(up)." Back to <a href=$HTTP_SERVER_VARS[PHP_SELF]>front page</a>.</p>"; |
print "<p>".GifIcon(up)." Back to <a href=\"$self\">front page</a>.</p>"; |
1193 |
} |
} |
1194 |
|
|
1195 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
1549 |
} |
} |
1550 |
|
|
1551 |
function HTTP_POST_VAR($var) { |
function HTTP_POST_VAR($var) { |
1552 |
global $HTTP_GET_VARS, $GLOBALS; |
global $HTTP_POST_VARS, $GLOBALS; |
1553 |
if (isset($HTTP_GET_VARS[$var])) { |
if (isset($HTTP_POST_VARS[$var])) { |
1554 |
$GLOBALS[$var] = stripSlashes($HTTP_GET_VARS[$var]); |
$GLOBALS[$var] = stripSlashes($HTTP_POST_VARS[$var]); |
1555 |
return $GLOBALS[$var]; |
return $GLOBALS[$var]; |
1556 |
} |
} |
1557 |
} |
} |
1671 |
$relDir = $DIR; |
$relDir = $DIR; |
1672 |
} else { |
} else { |
1673 |
trigger_error("Can't get DIR",E_USER_WARNING); |
trigger_error("Can't get DIR",E_USER_WARNING); |
1674 |
|
$relDir = "/"; |
1675 |
} |
} |
1676 |
if (HTTP_POST_VAR("RELPATH")) check_dirname($RELPATH); |
if (HTTP_POST_VAR("RELPATH")) check_dirname($RELPATH); |
1677 |
HTTP_POST_VAR("T"); |
HTTP_POST_VAR("T"); |
1721 |
Error("You must select file with browse to upload it!"); |
Error("You must select file with browse to upload it!"); |
1722 |
} |
} |
1723 |
|
|
1724 |
$FILENAME = $HTTP_POST_VARS["FILENAME"]; |
if (HTTP_POST_VAR("FILENAME")) check_filename($FILENAME); |
|
check_filename($FILENAME); |
|
1725 |
|
|
1726 |
if (! isset($FILENAME)) { // from update file |
if (! isset($FILENAME)) { // from update file |
1727 |
$target = "$fsDir/".basename($FN); |
$target = "$fsDir/".basename($FN); |
1734 |
if (! file_exists($dir."/.bak")) { |
if (! file_exists($dir."/.bak")) { |
1735 |
mkdir($dir."/.bak",0700); |
mkdir($dir."/.bak",0700); |
1736 |
} |
} |
1737 |
if (! file_exists($dir."/.bak/$GLOBALS[gblNumBackups]")) { |
if (! file_exists($dir."/.bak/$gblNumBackups")) { |
1738 |
mkdir($dir."/.bak/$GLOBALS[gblNumBackups]",0700); |
mkdir($dir."/.bak/$gblNumBackups",0700); |
1739 |
} |
} |
1740 |
$file=basename($target); |
$file=basename($target); |
1741 |
for($i=$GLOBALS[gblNumBackups]-1;$i>0;$i--) { |
for($i=$gblNumBackups-1;$i>0;$i--) { |
1742 |
MoveTo("$dir/.bak/$i/$file","$dir/.bak/".($i+1)."/"); |
MoveTo("$dir/.bak/$i/$file","$dir/.bak/".($i+1)."/"); |
1743 |
} |
} |
1744 |
MoveTo($target,$dir."/.bak/1/"); |
MoveTo($target,$dir."/.bak/1/"); |
1878 |
|
|
1879 |
// common to all POSTs : redirect to directory view ($relDir) |
// common to all POSTs : redirect to directory view ($relDir) |
1880 |
if (isset($POSTACTION)) { |
if (isset($POSTACTION)) { |
1881 |
$tstr = $PHP_SELF . "?D=" . urlencode($relDir) ; |
$tstr = $HTTP_SERVER_VARS["PHP_SELF"]."?D=".urlencode($relDir); |
1882 |
header("Location: " . $tstr) ; |
header("Location: ".$tstr) ; |
1883 |
exit ; |
exit ; |
1884 |
} |
} |
1885 |
|
|