/[docman2]/docman.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /docman.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.15 by dpavlin, Sun Jul 28 13:08:21 2002 UTC revision 1.18 by dpavlin, Sun Jul 28 16:24:54 2002 UTC
# Line 20  Line 20 
20  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
21  // CONFIGURATION OPTIONS  // CONFIGURATION OPTIONS
22    
23  //      error_reporting(4) ;            // how verbose ?          error_reporting(E_ALL) ;                // how verbose ?
24    
25          // from where to include auth_*.php modules?          // from where to include auth_*.php modules?
26          $gblIncDir = "/data/docman2";          $gblIncDir = "/data/docman2";
# Line 84  Line 84 
84          LoadLanguage($HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"]);          LoadLanguage($HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"]);
85    
86          // for security and configuration          // for security and configuration
87          $realm=$HTTP_SERVER_VARS[HTTP_HOST];          $realm=$HTTP_SERVER_VARS["HTTP_HOST"];
88    
89          $fsDocumentRoot = dirname($HTTP_SERVER_VARS[SCRIPT_FILENAME]);          $fsDocumentRoot = dirname($HTTP_SERVER_VARS[SCRIPT_FILENAME]);
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);
# Line 138  function EndHTML() { Line 138  function EndHTML() {
138          } else {          } else {
139                  $url .= md5($gblLogin.$gblPasswd);                  $url .= md5($gblLogin.$gblPasswd);
140          }          }
141          if (isset($gblLogin) && $gblLogin != "" && ($gblPasswd == "" || !isset($gblPasswd))) {          if ( (  (isset($gblLogin) && $gblLogin != "") ||
142                    (!isset($gblLogin) || $gblLogin == "")
143                 ) && ($gblPasswd == "" || !isset($gblPasswd))) {
144                  $url_title="login";                  $url_title="login";
145                  $url .= "&force_login=1";                  $url .= "&force_login=1";
146          } else {          } else {
# Line 582  function Navigate($fsRoot,$relDir) { Line 584  function Navigate($fsRoot,$relDir) {
584                    
585          $self     = $HTTP_SERVER_VARS["PHP_SELF"] ;          $self     = $HTTP_SERVER_VARS["PHP_SELF"] ;
586    
587          if ($relDir == "") $relDir = "/";          $relDir = chopsl($relDir)."/";
588            $fsDir = $fsRoot.$relDir;       // current directory
589    
590          $fsDir = $fsRoot.$relDir."/";   // current directory          if (!is_dir($fsDir)) Error("Dir not found","Directory <tt>$relDir<tt> not found on filesystem at <tt>$fsDir</tt>",1) ;
591    
592          if (!is_dir($fsDir)) Error("Dir not found",$relDir,1) ;          global $debug;
593            $debug .= "[$gblLogin|$relDir] before >";
594    
595            if (! check_perm($relDir,(trperm_b | trperm_r)))
596                    Error("Access denied","User <tt>$gblLogin</tt> tried to access <tt>$relDir</tt> without valid trustee.",1);
597            $debug .= "< afeter";
598    
599          $hide_items=",$gblHide,";          $hide_items=",$gblHide,";
600    
# Line 904  function UploadPage($fsRoot, $relDir, $f Line 912  function UploadPage($fsRoot, $relDir, $f
912          global $html, $HTTP_SERVER_VARS;          global $html, $HTTP_SERVER_VARS;
913    
914          $self = $HTTP_SERVER_VARS["PHP_SELF"] ;          $self = $HTTP_SERVER_VARS["PHP_SELF"] ;
         if ($relDir == "") $relDir = "/" ;  
   
915          include("$html/UploadPage.html");          include("$html/UploadPage.html");
916    
917  } // end function UploadPage  } // end function UploadPage
# Line 1375  return 1; Line 1381  return 1;
1381  }//init_trustee  }//init_trustee
1382    
1383  function in_group($user,$group) {  function in_group($user,$group) {
1384          return in_array($groups[$group],$user);          global $groups;
1385            return in_array($user,$groups[$group]);
1386  }  }
1387    
1388  // helper function  // helper function
1389  function unroll_perm($u,$t,$user,$perm) {  function unroll_perm($u,$t,$user,$perm) {
1390          // check user  
1391            // check user FIX
1392          if ($t & trmask_not && ($u==$user)) continue;          if ($t & trmask_not && ($u==$user)) continue;
1393          if (!($t & trmask_not) && ($u!=$user)) continue;          if (!($t & trmask_not) && ($u!=$user)) continue;
1394    
# Line 1402  function check_trustee($user,$path) { Line 1410  function check_trustee($user,$path) {
1410          global $trustees;          global $trustees;
1411          $perm[allow] = 0;          $perm[allow] = 0;
1412          $perm[deny] = 0;          $perm[deny] = 0;
1413    
1414    global $debug;
1415    $debug .= "<br>check_trustee $path ... ";
1416    
1417          $path_arr=explode("/",$path);          $path_arr=explode("/",$path);
1418          $path = "/";          $tmppath = "/";
1419          while (count($path_arr)) {          while (count($path_arr)) {
1420                  if (substr($path,strlen($path)-1,1) != "/") $path.="/";                  $tmppath.=array_shift($path_arr);
1421                  $path.=array_shift($path_arr);  $debug.= ">> $tmppath ";
1422                  $tr = $trustees[$path];                  if (substr($tmppath,strlen($tmppath)-1,1) != "/") $tmppath.="/";
1423                    $tr = $trustees[$tmppath];
1424    
1425                    # clear one level flag
1426                    $perm[allow] &= ~trperm_one_level;
1427                    $perm[deny] &= ~trperm_one_level;
1428    
1429                  if (isset($tr)) {                  if (isset($tr)) {
1430                          // first apply trustee for all                          // first apply trustee for all
# Line 1416  function check_trustee($user,$path) { Line 1433  function check_trustee($user,$path) {
1433                                  unset($tr['*']);                                  unset($tr['*']);
1434                          }                          }
1435                          // then apply group policies                          // then apply group policies
1436                          foreach ($tr as $u=>$t) {                          foreach ($tr as $g=>$t) {
1437                                  if ($t & trmask_group && in_group($user,$u)) {                                  if ($t & trmask_group && in_group($user,$g)) {
1438                                          // resolv user                                          // resolv user
1439                                          $t = $t & ~trmask_group;                                          $t = $t & ~trmask_group;
1440                                          $u = $user;                                          $perm = unroll_perm($user,$t,$user, $perm);
1441                                          $perm = unroll_perm($u,$t,$user, $perm);                                          unset($tr[$g]);
                                         unset($tr[$u]);  
1442                                  }                                  }
1443                          }                          }
1444                          // then apply use policy                          // then apply user policy
1445                          if (isset($tr[$user])) {                          if (isset($tr[$user])) {
1446                                  $perm = unroll_perm($user,$tr[$user],$user, $perm);                                  $perm = unroll_perm($user,$tr[$user],$user, $perm);
1447                                  unset($tr[$user]);                                  unset($tr[$user]);
1448                          }                          }
   
1449                  }                  }
1450    $debug.="d:".display_trustee($perm[deny])." a:".display_trustee($perm[allow])." ";
1451    
1452          }          }
1453  #print "<br>user: $user path: $path perm: ";  $debug.="<br>check_trustee: user: $user path: $path==$tmppath perm: ";
1454  #print "d: $perm[deny] (".display_trustee($perm[deny]).") a: $perm[allow] (".display_trustee($perm[allow]).")<Br>\n";  $debug.="d: $perm[deny] (".display_trustee($perm[deny]).") a: $perm[allow] (".display_trustee($perm[allow]).")<Br>\n";
1455          return $perm;          return $perm;
1456  }  }
1457    
# Line 1446  function check_perm($path,$trperm) { Line 1462  function check_perm($path,$trperm) {
1462    
1463          global $debug;          global $debug;
1464  $debug.="<br>check_perm: <tt>$path</tt> test perm ".display_trustee($perm)."<br>\n";  $debug.="<br>check_perm: <tt>$path</tt> test perm ".display_trustee($perm)."<br>\n";
1465    
1466          $return = ! $HAVE_TRUSTEE;          $return = ! $HAVE_TRUSTEE;
1467          if ($HAVE_TRUSTEE) {          if ($HAVE_TRUSTEE) {
1468                  $perm = check_trustee($gblLogin,$path);                  $perm = check_trustee($gblLogin,$path);
1469  $debug.=" d: $perm[deny] (".display_trustee($perm[deny]).") a: $perm[allow] (".display_trustee($perm[allow]).") perm: $trperm";  $debug.=" d: $perm[deny] (".display_trustee($perm[deny]).") a: $perm[allow] (".display_trustee($perm[allow]).") perm to have: $trperm (".display_trustee($trperm).")";
1470                  if ($perm[deny] & $trperm) $return=0;                  if ($perm[deny] & $trperm) $return=0;
1471                  elseif ($perm[allow] & $trperm) $return=1;                  elseif (($perm[allow] & $trperm) == $trperm) $return=1;
1472          }          }
1473  $debug.=" return: $return<br>\n";  $debug.=" return: $return<br>\n";
1474          return($return);          return($return);
# Line 1547  function check_filename($file) { Line 1564  function check_filename($file) {
1564                  Error("Configuration error","Can't find user handling module at <tt>$gblIncDir/htusers/$gblUsers.php</tt> ! Please fix <tt>$realm_config</tt>");                  Error("Configuration error","Can't find user handling module at <tt>$gblIncDir/htusers/$gblUsers.php</tt> ! Please fix <tt>$realm_config</tt>");
1565          }          }
1566    
1567          // if no password, or empty password logout          // take additional login vars
1568          $relogin = $HTTP_GET_VARS[relogin];          $relogin = $HTTP_GET_VARS[relogin];
1569          $force_login = $HTTP_GET_VARS[force_login];          $force_login = $HTTP_GET_VARS[force_login];
1570    
1571            // if no password, or empty password logout
1572          if (          if (
1573                  isset($gblLogin) && (                  isset($gblLogin) && (
1574                          !isset($relogin) || (                          !isset($relogin) || (
# Line 1573  function check_filename($file) { Line 1592  function check_filename($file) {
1592          // get ACL informations          // get ACL informations
1593          $HAVE_TRUSTEE = init_trustee();          $HAVE_TRUSTEE = init_trustee();
1594    
1595          if (strtolower($gblLogin) == "anonymous" || !isset($gblPasswd)) {          if (strtolower($gblLogin) == "anonymous" || !isset($gblLogin)) {
1596                  $perm = check_trustee($gblLogin,$path);                  $perm = check_trustee("anonymous",$path);
1597                  // browsing must be explicitly allowed for root directory                  // browsing must be explicitly allowed for root directory
1598                  // of repository for anonymous user to work!                  // of repository for anonymous user to work!
1599                  if ($perm[allow] & trperm_b) {                  if ($perm[allow] & trperm_b) {
1600                            $gblLogin = $gblPasswd = "anonymous";
1601                          $secHash = md5($gblLogin.$gblPasswd);                          $secHash = md5($gblLogin.$gblPasswd);
1602                          $gblUserName = "Anonymous user";                          $gblUserName = "Anonymous user";
1603                  }                  }
# Line 1620  function check_filename($file) { Line 1640  function check_filename($file) {
1640                  $relDir = $D;                  $relDir = $D;
1641          }          }
1642    
         if ($relDir == "/") $relDir = "" ;        
   
1643          $relScriptDir = dirname($SCRIPT_NAME) ;                  $relScriptDir = dirname($SCRIPT_NAME) ;        
1644          // i.e. /docman          // i.e. /docman
1645    
# Line 1630  function check_filename($file) { Line 1648  function check_filename($file) {
1648          // i.e. /home/httpd/repository          // i.e. /home/httpd/repository
1649    
1650          $fsDir = $gblFsRoot . $relDir ; // current directory          $fsDir = $gblFsRoot . $relDir ; // current directory
1651          if ( !is_dir($fsDir) ) Error("Dir not found",$relDir,1) ;          if ( !is_dir($fsDir) ) Error("Dir not found","Can't find <tt>$relDir</tt> which points to <tt>$fsDir</tt>",1) ;
1652    
1653            if ($relDir == "") $relDir="/";
1654    
1655          if (isset($HTTP_SERVER_VARS["HTTPS"]) && $HTTP_SERVER_VARS["HTTPS"] == "on") {          if (isset($HTTP_SERVER_VARS["HTTPS"]) && $HTTP_SERVER_VARS["HTTPS"] == "on") {
1656                  $webRoot  = "https://";                  $webRoot  = "https://";
# Line 1826  function check_filename($file) { Line 1846  function check_filename($file) {
1846          switch ($A) {          switch ($A) {
1847          case "U" :          case "U" :
1848                  // upload to $relDir                  // upload to $relDir
1849                    if (! check_perm($relDir, trperm_w))
1850                            Error("Write access denied","You don't have permission to write in <tt>$relDir</tt>");
1851                  if (!is_writeable($gblFsRoot . $relDir))                  if (!is_writeable($gblFsRoot . $relDir))
1852                          Error("Write access denied",$relDir) ;                          Error("Write access denied","User <tt>$gblLogin</tt> has permission on <tt>$relDir</tt>, but directory is not writable",1);
1853                  $text  = "Use this page to upload a single " ;                  $text  = "Use this page to upload a single " ;
1854                  $text .= "file to <B>$realm</B>." ;                  $text .= "file to <B>$realm</B>." ;
1855                  StartHTML("(Upload Page)", $text) ;                  StartHTML("(Upload Page)", $text) ;

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.18

  ViewVC Help
Powered by ViewVC 1.1.26