90 |
if ($fsDocumentRoot == "") Error("Configuration error","Can't get SCRIPT_FILENAME from your web server. Please set <tt>\$fsDocumentRoot</tt> in <tt>\$</tt>",1); |
if ($fsDocumentRoot == "") Error("Configuration error","Can't get SCRIPT_FILENAME from your web server. Please set <tt>\$fsDocumentRoot</tt> in <tt>\$</tt>",1); |
91 |
|
|
92 |
// globals for later |
// globals for later |
93 |
$gblLogin = $HTTP_SERVER_VARS["PHP_AUTH_USER"]; |
$gblLogin = HTTP_SERVER_VAR("PHP_AUTH_USER"); |
94 |
$gblPasswd = $HTTP_SERVER_VARS["PHP_AUTH_PW"]; |
$gblPasswd = HTTP_SERVER_VAR("PHP_AUTH_PW"); |
95 |
|
|
96 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
97 |
|
|
188 |
$title = "("._("Detail Page").")" ; |
$title = "("._("Detail Page").")" ; |
189 |
StartHTML($title, $text) ; |
StartHTML($title, $text) ; |
190 |
|
|
191 |
echo "<H3>" . $relDir . "/" . $fn . "</H3>" ; |
print "<H3>".$relDir.$fn."</H3>"; |
192 |
|
|
193 |
if ($exists) { // get file info |
if ($exists) { // get file info |
194 |
$fsize = filesize($fsPath) ; |
$fsize = filesize($fsPath) ; |
195 |
$fmodified = date("$gblDateFmt $gblTimeFmt", filemtime($fsPath)) ; |
$fmodified = date("$gblDateFmt $gblTimeFmt", filemtime($fsPath)) ; |
582 |
|
|
583 |
global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide, |
global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide, |
584 |
$gblIgnoreUnknownFileType, $gblRepositoryDir, |
$gblIgnoreUnknownFileType, $gblRepositoryDir, |
585 |
$gblLogin, $gblUserName, |
$gblLogin, $gblUserName, $gblDateFmt, $gblTimeFmt, |
586 |
$fsRealmDir, $realm, $realm_sep, |
$fsRealmDir, $realm, $realm_sep, |
587 |
$html, $realm_config, |
$html, $realm_config, |
588 |
$HTTP_GET_VARS, $HTTP_SERVER_VARS; |
$HTTP_GET_VARS, $HTTP_SERVER_VARS; |
633 |
if ( HTTP_GET_VAR("show_deleted") == 1 && ($dir = @opendir("$fsDir/.del")) ) { |
if ( HTTP_GET_VAR("show_deleted") == 1 && ($dir = @opendir("$fsDir/.del")) ) { |
634 |
while ($item = readdir($dir)) { |
while ($item = readdir($dir)) { |
635 |
if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") || !check_perm($relDir.$item,trperm_w) ) continue ; |
if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") || !check_perm($relDir.$item,trperm_w) ) continue ; |
636 |
$fileList[$item] = ".del/$item" ; |
if (is_file($fsDir.".del/$item")) { |
637 |
$fileDate[$item] = filemtime($fsDir.".del/$path") ; |
$fileList[$item] = ".del/$item" ; |
638 |
$fileSize[$item] = filesize($fsDir.".del/$path") ; |
$fileDate[$item] = filemtime($fsDir.".del/$item") ; |
639 |
$fileNote[$item] = ReadNote($fsDir.".del/$item"); |
$fileSize[$item] = filesize($fsDir.".del/$item") ; |
640 |
|
$fileNote[$item] = ReadNote($fsDir.".del/$item"); |
641 |
|
} else { |
642 |
|
$dirList[$item] = ".del/$item" ; |
643 |
|
$dirNote[$item] = ReadNote($fsDir.".del/$item"); |
644 |
|
} |
645 |
} |
} |
646 |
closedir($dir) ; |
closedir($dir) ; |
647 |
} |
} |
739 |
$dir = $dirList[$key]; |
$dir = $dirList[$key]; |
740 |
|
|
741 |
$info_url=self_args(array("A"=>"A=E", "F"=>"F=".urlencode($dir), "D"=>$D)); |
$info_url=self_args(array("A"=>"A=E", "F"=>"F=".urlencode($dir), "D"=>$D)); |
742 |
|
if (substr($dir,0,5) == ".del/") { |
743 |
|
$dir = substr($dir,5,strlen($dir)-5); |
744 |
|
$deleted = " <a href=\"$info_url#undelete\"><SPAN CLASS=deleted TITLE=\"deleted\">deleted</span></a>"; |
745 |
|
} else { |
746 |
|
$deleted = ""; |
747 |
|
} |
748 |
|
|
749 |
$dir_url=$self."?D=".urlencode(chopsl($relDir)."/".$dir); |
$dir_url=$self."?D=".urlencode(chopsl($relDir)."/".$dir); |
750 |
include("$html/Navigate-dirEntry.html"); |
include("$html/Navigate-dirEntry.html"); |
751 |
|
|
824 |
if (substr($file,0,5) != ".del/") { |
if (substr($file,0,5) != ".del/") { |
825 |
$file_url_html .= $file . "</A>" . $a ; |
$file_url_html .= $file . "</A>" . $a ; |
826 |
} else { |
} else { |
827 |
$file_url_html .= substr($file,5,strlen($file)-5) . "</a> <SPAN CLASS=RED TITLE=\"deleted\"> <a href=\"$info_url#undelete\">deleted</a> </span>"; |
$file_url_html .= substr($file,5,strlen($file)-5) . "</a> <a href=\"$info_url#undelete\"><SPAN CLASS=deleted TITLE=\"deleted\">deleted</span></a>"; |
828 |
} |
} |
829 |
|
|
830 |
$note_html="<a href=\"$info_url#note\">".$gblIcon("note")."</a>".ReadNote($path); |
$note_html="<a href=\"$info_url#note\">".$gblIcon("note")."</a>".ReadNote($path); |
1173 |
|
|
1174 |
function DisplayChangeLog($day) { |
function DisplayChangeLog($day) { |
1175 |
|
|
1176 |
global $gblFsRoot, $gblDateFmt, $gblTimeFmt; |
global $gblFsRoot, $gblDateFmt, $gblTimeFmt, |
1177 |
$HTTP_SERVER_VARS; |
$HTTP_SERVER_VARS; |
1178 |
|
|
1179 |
$self = $HTTP_SERVER_VARS["PHP_SELF"]; |
$self = $HTTP_SERVER_VARS["PHP_SELF"]; |
1202 |
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"; |
1203 |
} |
} |
1204 |
print "</table>"; |
print "</table>"; |
1205 |
print "<p>".GifIcon(up)." Back to <a href=\"$self\">front page</a>.</p>"; |
print "<p>".GifIcon("up")." Back to <a href=\"$self\">front page</a>.</p>"; |
1206 |
} |
} |
1207 |
|
|
1208 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
1224 |
|
|
1225 |
$ext_arr = explode(".",$file); |
$ext_arr = explode(".",$file); |
1226 |
$ext = array_pop($ext_arr); |
$ext = array_pop($ext_arr); |
1227 |
if ($encoding_ext[$ext]) { |
if (isset($encoding_ext[$ext])) { |
1228 |
$encoding = $encoding_ext[$ext]; |
$encoding = $encoding_ext[$ext]; |
1229 |
$ext = array_pop($ext_arr); |
$ext = array_pop($ext_arr); |
1230 |
} |
} |
1236 |
} |
} |
1237 |
|
|
1238 |
// IE5.5 just downloads index.php if we don't do this |
// IE5.5 just downloads index.php if we don't do this |
1239 |
if(preg_match("/MSIE 5.5/", $HTTP_SERVER_VARS[HTTP_USER_AGENT])) { |
if(preg_match("/MSIE 5.5/", $HTTP_SERVER_VARS["HTTP_USER_AGENT"])) { |
1240 |
header("Content-Disposition: filename=$file"); |
header("Content-Disposition: filename=$file"); |
1241 |
} else { |
} else { |
1242 |
header("Content-Disposition: attachment; filename=$file"); |
header("Content-Disposition: attachment; filename=$file"); |
1418 |
} |
} |
1419 |
|
|
1420 |
// helper function |
// helper function |
1421 |
function unroll_perm($u,$t,$user,$perm,$one_level) { |
function unroll_perm($u,$t,$perm,$one_level) { |
1422 |
|
|
1423 |
if ($t & trmask_one_level && !$one_level) return $perm; |
if ($t & trmask_one_level && !$one_level) return $perm; |
1424 |
|
|
|
// user is user whose trustee is this |
|
|
if ($t & trmask_not && ($u==$user)) return $perm; |
|
|
if (!($t & trmask_not) && ($u!=$user)) return $perm; |
|
|
|
|
1425 |
if ($t & trmask_deny) { |
if ($t & trmask_deny) { |
1426 |
if ($t & trmask_clear) { |
if ($t & trmask_clear) { |
1427 |
$perm['deny'] &= ~$t; |
$perm['deny'] &= ~$t; |
1437 |
}// end of helper function |
}// end of helper function |
1438 |
|
|
1439 |
function check_trustee($user,$path) { |
function check_trustee($user,$path) { |
1440 |
global $trustees; |
global $trustees,$HAVE_TRUSTEE; |
1441 |
$perm['allow'] = 0; |
$perm['allow'] = 0; |
1442 |
$perm['deny'] = 0; |
$perm['deny'] = 0; |
1443 |
|
|
1444 |
if (! isset($trustees)) Error("Trustees not found","Can't find in-memory trustee structure \$trustees. Probably bug in code. Contact <tt>dpavlin@rot13.org</tt>",1); |
// do we use trustees? |
1445 |
|
if (! $HAVE_TRUSTEE) return $perm; |
1446 |
|
|
1447 |
|
if (! isset($trustees)) Error("Trustees not found","Can't find in-memory trustee structure <tt>\$trustees</tt>. Probably bug in code. Contact <tt>dpavlin@rot13.org</tt>",1); |
1448 |
|
|
1449 |
global $debug; |
global $debug; |
1450 |
$debug .= "<br>check_trustee $path ... "; |
$debug .= "<br>check_trustee $path ... "; |
1463 |
|
|
1464 |
if (isset($tr)) { |
if (isset($tr)) { |
1465 |
// first apply trustee for all |
// first apply trustee for all |
1466 |
if (isset($tr['*'])) { |
if (isset($tr['*']) && $user!="anonymous") { |
1467 |
$perm = unroll_perm($user,$tr['*'],'*', $perm, $one_level); |
$perm = unroll_perm($user,$tr['*'],$perm, $one_level); |
1468 |
unset($tr['*']); |
unset($tr['*']); |
1469 |
} |
} |
1470 |
// then apply group policies |
// then apply not and group policies |
1471 |
foreach ($tr as $g=>$t) { |
foreach ($tr as $g=>$t) { |
1472 |
if ($t & trmask_group && in_group($user,$g)) { |
if ($t & trmask_not && $g != $user) { |
1473 |
|
$t = $t & ~trmask_not; |
1474 |
|
$perm = unroll_perm($user,$t,$perm, $one_level); |
1475 |
|
unset($tr[$g]); |
1476 |
|
|
1477 |
|
} elseif ($t & trmask_group && in_group($user,$g)) { |
1478 |
// resolv user |
// resolv user |
1479 |
$t = $t & ~trmask_group; |
$t = $t & ~trmask_group; |
1480 |
$perm = unroll_perm($user,$t,$g, $perm, $one_level); |
$perm = unroll_perm($user,$t,$perm, $one_level); |
1481 |
unset($tr[$g]); |
unset($tr[$g]); |
1482 |
} |
} |
1483 |
} |
} |
1484 |
// then apply user policy |
// then apply user policy |
1485 |
if (isset($tr[$user])) { |
if (isset($tr[$user])) { |
1486 |
$perm = unroll_perm($user,$tr[$user],$user, $perm,$one_level); |
$perm = unroll_perm($user,$tr[$user],$perm,$one_level); |
1487 |
unset($tr[$user]); |
unset($tr[$user]); |
1488 |
} |
} |
1489 |
} |
} |
1549 |
|
|
1550 |
function check_filename($file) { |
function check_filename($file) { |
1551 |
if (strstr($file,"..")) Error("Security violation","No parent dir <tt>..</tt> allowed in file name <tt>$file</tt>",1); |
if (strstr($file,"..")) Error("Security violation","No parent dir <tt>..</tt> allowed in file name <tt>$file</tt>",1); |
1552 |
|
// remove deleted directory (for undelete to work) |
1553 |
|
$file = str_replace(".del/","",$file); |
1554 |
if (strstr($file,"/")) Error("Security violation","No slashes <tt>/</tt> allowed in file name <tt>$file</tt>",1); |
if (strstr($file,"/")) Error("Security violation","No slashes <tt>/</tt> allowed in file name <tt>$file</tt>",1); |
1555 |
} |
} |
1556 |
|
|
1560 |
// [replacement for register_globals in php.ini] |
// [replacement for register_globals in php.ini] |
1561 |
|
|
1562 |
function HTTP_GET_VAR($var) { |
function HTTP_GET_VAR($var) { |
1563 |
global $HTTP_GET_VARS, $GLOBALS; |
global $HTTP_GET_VARS, ${$var}; |
1564 |
if (isset($HTTP_GET_VARS[$var])) { |
if (isset($HTTP_GET_VARS[$var])) { |
1565 |
$GLOBALS[$var] = stripSlashes($HTTP_GET_VARS[$var]); |
$$var = stripSlashes($HTTP_GET_VARS[$var]); |
1566 |
return $GLOBALS[$var]; |
return $$var; |
1567 |
} |
} |
1568 |
} |
} |
1569 |
|
|
1570 |
function HTTP_POST_VAR($var) { |
function HTTP_POST_VAR($var) { |
1571 |
global $HTTP_POST_VARS, $GLOBALS; |
global $HTTP_POST_VARS, ${$var}; |
1572 |
if (isset($HTTP_POST_VARS[$var])) { |
if (isset($HTTP_POST_VARS[$var])) { |
1573 |
$GLOBALS[$var] = stripSlashes($HTTP_POST_VARS[$var]); |
$$var = $HTTP_POST_VARS[$var]; |
1574 |
return $GLOBALS[$var]; |
return $$var; |
1575 |
|
} |
1576 |
|
} |
1577 |
|
|
1578 |
|
function HTTP_SERVER_VAR($var) { |
1579 |
|
global $HTTP_SERVER_VARS, ${$var}; |
1580 |
|
if (isset($HTTP_SERVER_VARS[$var])) { |
1581 |
|
$$var = $HTTP_SERVER_VARS[$var]; |
1582 |
|
return $$var; |
1583 |
} |
} |
1584 |
} |
} |
1585 |
|
|
1602 |
// location of master docman configuration file |
// location of master docman configuration file |
1603 |
$docman_conf = "/etc/docman.conf"; |
$docman_conf = "/etc/docman.conf"; |
1604 |
if (! file_exists($docman_conf)) { |
if (! file_exists($docman_conf)) { |
1605 |
$error = "Can't find master configuration file $docman_conf. See docman2/doc/upgrade.html#docman_conf for more informations"; |
$error = "Can't find master configuration file <tt>$docman_conf</tt>. See <tt>docman2/doc/upgrade.html#docman_conf</tt> for more informations"; |
1606 |
|
|
1607 |
error_log("docman: $error"); |
error_log("docman: $error"); |
1608 |
Error("docman not installed completly",$error); |
Error("docman not installed completly",$error); |
1690 |
// read mime.types |
// read mime.types |
1691 |
readMime(); |
readMime(); |
1692 |
|
|
1693 |
|
HTTP_POST_VAR("FN"); |
1694 |
|
|
1695 |
if ($HTTP_SERVER_VARS["REQUEST_METHOD"] == "POST") { |
if ($HTTP_SERVER_VARS["REQUEST_METHOD"] == "POST") { |
1696 |
// take variables from server |
// take variables from server |
1697 |
if (HTTP_POST_VAR("FN")) check_filename($FN); |
if (HTTP_POST_VAR("FN")) |
1698 |
|
check_filename($FN); |
1699 |
if (HTTP_POST_VAR("DIR")) { |
if (HTTP_POST_VAR("DIR")) { |
1700 |
check_dirname($DIR); |
check_dirname($DIR); |
1701 |
$relDir = $DIR; |
$relDir = $DIR; |
1706 |
if (HTTP_POST_VAR("RELPATH")) check_dirname($RELPATH); |
if (HTTP_POST_VAR("RELPATH")) check_dirname($RELPATH); |
1707 |
HTTP_POST_VAR("T"); |
HTTP_POST_VAR("T"); |
1708 |
HTTP_POST_VAR("CONFIRM"); |
HTTP_POST_VAR("CONFIRM"); |
|
|
|
1709 |
} else { |
} else { |
1710 |
// get |
// get |
1711 |
HTTP_GET_VAR("A"); |
HTTP_GET_VAR("A"); |
1793 |
if (!($writable || (!$exists && $legaldir))) |
if (!($writable || (!$exists && $legaldir))) |
1794 |
Error("Write denied",$RELPATH) ; |
Error("Write denied",$RELPATH) ; |
1795 |
$fh = fopen($path, "w") ; |
$fh = fopen($path, "w") ; |
1796 |
$FILEDATA=stripSlashes($FILEDATA); |
HTTP_POST_VAR("FILEDATA"); |
1797 |
fwrite($fh,$FILEDATA) ; |
fwrite($fh,$FILEDATA) ; |
1798 |
fclose($fh) ; |
fclose($fh) ; |
1799 |
clearstatcache() ; |
clearstatcache() ; |
1802 |
|
|
1803 |
case "CREATE" : |
case "CREATE" : |
1804 |
// we know $fsDir exists |
// we know $fsDir exists |
1805 |
if ($FN == "") break; // no filename! |
if (! check_perm($relDir, trperm_w)) |
1806 |
|
Error("Write access denied","You don't have permission to write in <tt>$relDir</tt>"); |
1807 |
|
if ($T == "D") $type = "directory"; |
1808 |
|
else $type ="file"; |
1809 |
|
if ($FN == "") Error("Can't create $type","You must enter name of $type to create it."); |
1810 |
if (!is_writeable($fsDir)) Error("Write denied",$relDir) ; |
if (!is_writeable($fsDir)) Error("Write denied",$relDir) ; |
1811 |
$path = $fsDir . "/" . $FN ; // file or dir to create |
$path = $fsDir . "/" . $FN ; // file or dir to create |
1812 |
$relPath = $relDir . "/" . $FN ; |
$relPath = $relDir . "/" . $FN ; |
1832 |
} else { |
} else { |
1833 |
Error("Creation of file $relPath failed -- $path"); |
Error("Creation of file $relPath failed -- $path"); |
1834 |
} |
} |
1835 |
$tstr = "$PHP_SELF?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ; |
$tstr = $HTTP_SERVER_VARS["PHP_SELF"]."?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ; |
1836 |
header("Location: " . $tstr) ; |
header("Location: " . $tstr) ; |
1837 |
exit ; |
exit ; |
1838 |
} |
} |
1839 |
break ; |
break ; |
1840 |
|
|
1841 |
case "DELETE" : |
case "DELETE" : |
1842 |
if ( $CONFIRM != "on" ) break ; |
if ( $CONFIRM != "on" ) break; |
1843 |
|
|
1844 |
$tstr = "Attempt to delete non-existing object or " ; |
if ( isset($FN) && $FN != "") { |
1845 |
$tstr .= "insufficient privileges: " ; |
$path=$fsDir."/".$FN; |
1846 |
|
|
1847 |
|
$what = "file"; |
1848 |
|
if (is_dir($path)) { |
1849 |
|
$what = "dir"; |
1850 |
|
} |
1851 |
|
|
1852 |
|
if (! check_perm($relDir."/".$FN, trperm_w)) |
1853 |
|
Error("Access denied","User <tt>$gblLogin</tt> tried to erase $what <tt>$relDir/$FN</tt> without valid trustee.",1); |
1854 |
|
|
1855 |
|
$tstr = "Attempt to delete non-existing object or " ; |
1856 |
|
$tstr .= "insufficient privileges: " ; |
1857 |
|
|
|
if ( $FN != "") { // delete file |
|
|
$path = $fsDir . "/" . $FN ; |
|
|
|
|
1858 |
$dir=dirname($path); |
$dir=dirname($path); |
1859 |
$file=basename($path); |
$file=basename($path); |
1860 |
if (! file_exists("$dir/.del")) { |
if (! file_exists("$dir/.del")) { |
1862 |
} |
} |
1863 |
|
|
1864 |
// if ( ! @unlink($path) ) { |
// if ( ! @unlink($path) ) { |
1865 |
if ( ! rename($path,"$dir/.del/$file") ) { |
if ( ! @rename($path,"$dir/.del/$file") ) { |
1866 |
LogIt($path,"file delete failed"); |
LogIt($path,"$what delete failed"); |
1867 |
Error("File delete failed", $tstr . $path) ; |
Error("Can't delete $what",$tstr.$relDir."/".$FN) ; |
1868 |
} else { |
} else { |
1869 |
LogIt($path,"file deleted",trperm_w); |
LogIt($path,"$what deleted",trperm_w); |
1870 |
MoveTo("$dir/.log/$file","$dir/.del/.log/"); |
MoveTo("$dir/.log/$file","$dir/.del/.log/"); |
1871 |
MoveTo("$dir/.note/$file","$dir/.del/.note/"); |
MoveTo("$dir/.note/$file","$dir/.del/.note/"); |
1872 |
MoveTo("$dir/.lock/$file","$dir/.del/.lock/"); |
MoveTo("$dir/.lock/$file","$dir/.del/.lock/"); |
1873 |
} |
} |
1874 |
} else { // delete directory |
} else { |
1875 |
if ( ! @rrmdir($fsDir) ) { |
Error("Rmdir failed", $tstr . $fsDir) ; |
|
Error("Rmdir failed", $tstr . $fsDir) ; |
|
|
} else { |
|
|
LogIt($path,"dir deleted",trperm_w); |
|
|
$relDir = dirname($relDir) ; // move up |
|
|
} |
|
1876 |
} |
} |
1877 |
break ; |
break ; |
1878 |
|
|