/[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.1.1.1 by dpavlin, Sun Jul 21 18:15:47 2002 UTC revision 1.22 by dpavlin, Sun Jul 28 18:56:49 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";
27    
28          // force download (so it won't open in associated application)          // force download on view (so it won't open in associated application)
29          $gblForceDownload = 1;          $gblForceDownload = 0;
30    
31          // date format          // date format
32          $gblDateFmt="Y-m-d";          $gblDateFmt="Y-m-d";
# 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_HOST";    // FIX          $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>");          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 = $PHP_AUTH_USER;          $gblLogin = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
94          $gblPasswd = $PHP_AUTH_PW;          $gblPasswd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
95    
96  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
97    
# Line 109  function LoadLanguage($lang) { Line 109  function LoadLanguage($lang) {
109    
110  function StartHTML($title,$text="") {  function StartHTML($title,$text="") {
111    
112          global $html,$fsDocumentRoot;          global $html,$fsDocumentRoot,$gblTitle,$HTTP_SERVER_VARS;
113    
114          $title = $gblTitle." ".$title ;          $host  = $HTTP_SERVER_VARS["HTTP_HOST"] ;
115          $host  = $GLOBALS["HTTP_HOST"] ;          $self  = $HTTP_SERVER_VARS["PHP_SELF"] ;
         $self  = $GLOBALS["PHP_SELF"] ;  
116    
117          if (file_exists("$fsDocumentRoot/docman.css")) {          if (file_exists("$fsDocumentRoot/docman.css")) {
118                  $css=dirname($self)."/docman.css";                  $css=dirname($self)."/docman.css";
119          } else {          } else {
120                  $css=$self."?STYLE=get&css=$css";                  $css=$self."?STYLE=get";
121          }          }
122    
123          include("$html/head.html");          include("$html/head.html");
# Line 138  function EndHTML() { Line 137  function EndHTML() {
137          } else {          } else {
138                  $url .= md5($gblLogin.$gblPasswd);                  $url .= md5($gblLogin.$gblPasswd);
139          }          }
140          if (isset($gblLogin) && $gblLogin != "" && ($gblPasswd == "" || !isset($gblPasswd))) {          if ( (  (isset($gblLogin) && $gblLogin != "") ||
141                    (!isset($gblLogin) || $gblLogin == "")
142                 ) && ($gblPasswd == "" || !isset($gblPasswd))) {
143                  $url_title="login";                  $url_title="login";
144                  $url .= "&force_login=1";                  $url .= "&force_login=1";
145          } else {          } else {
146                  $url_title="relogin";                  $url_title="relogin";
147          }          }
148          include("$html/footer.html");          include("$html/footer.html");
149          //phpinfo();  
150            global $debug;
151            if ($debug) print $debug;
152  } // end function EndHTML  } // end function EndHTML
153    
154  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
155    
156  function DetailPage($fsRoot,$relDir,$fn) {  function DetailPage($fsRoot,$relDir,$fn) {
157                    
158          global $gblEditable, $gblImages, $webRoot, $html ;          global $gblEditable, $gblImages,
159          $self = $GLOBALS["PHP_SELF"] ;                  $gblDateFmt, $gblTimeFmt,
160                    $webRoot, $html,
161                    $HTTP_SERVER_VARS ;
162            $self = $HTTP_SERVER_VARS["PHP_SELF"] ;
163    
164          $relPath  = $relDir . "/" . $fn ;          $relPath  = $relDir . "/" . $fn ;
165          $fsPath   = $fsRoot . $relPath ;          $fsPath   = $fsRoot . $relPath ;
# Line 161  function DetailPage($fsRoot,$relDir,$fn) Line 167  function DetailPage($fsRoot,$relDir,$fn)
167    
168          $exists   = file_exists($fsPath) ;          $exists   = file_exists($fsPath) ;
169          $ext      = strtolower(strrchr($relPath,".")) ;          $ext      = strtolower(strrchr($relPath,".")) ;
170          $editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) ;          $editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) &&
171          $writable = is_writeable($fsPath) ;                  check_perm($relPath,trperm_w);
172            $writable = is_writeable($fsPath) && check_perm($relPath,trperm_w) ;
173            $writable_dir = is_writeable($fsDir) && check_perm($relDir,trperm_w) ;
174          $file_lock = CheckLock($fsPath);          $file_lock = CheckLock($fsPath);
175    
176          if (!$editable && !$exists)          if (!$editable && !$exists)
177                  Error(_("Creation unsupported for type"),$relPath) ;                  Error("Creation denied","Can't create <tt>$relPath</tt>") ;
178          if (!exists && !is_writeable($fsDir) )          if (!$exists && !$writable_dir )
179                  Error(_("Creation denied"),$relDir) ;                  Error("Creation denied","Can't write in directory <tt>$relDir</tt> while creating <tt>$relPath</tt>for which user has permissions.",1);
180    
181          $text  = _("Use this page to view, modify or ") ;          $text  = _("Use this page to view, modify or ") ;
182          if (is_dir($fsPath)) {          if (is_dir($fsPath)) {
# Line 183  function DetailPage($fsRoot,$relDir,$fn) Line 191  function DetailPage($fsRoot,$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);
# Line 201  function DetailPage($fsRoot,$relDir,$fn) Line 209  function DetailPage($fsRoot,$relDir,$fn)
209                  $fstr = htmlentities( $fstr ) ;                  $fstr = htmlentities( $fstr ) ;
210  ?>  ?>
211    
212  <FORM ACTION="<?= $self ; ?>" METHOD="POST">  <FORM ACTION="<?= $self ?>" METHOD="POST">
213  <SPAN TITLE="Click [SAVE] to store updated contents.">  <SPAN TITLE="Click [SAVE] to store updated contents.">
214          <B>DOCUMENT CONTENTS</B>          <B>DOCUMENT CONTENTS</B>
215  </SPAN><BR>  </SPAN><BR>
# Line 572  function GifIcon($txt) { Line 580  function GifIcon($txt) {
580  function Navigate($fsRoot,$relDir) {  function Navigate($fsRoot,$relDir) {
581    
582          global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide,          global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide,
583                  $HTTP_GET_VARS, $html;                  $gblIgnoreUnknownFileType, $gblRepositoryDir,
584                    $gblLogin, $gblUserName,
585                    $fsRealmDir, $realm, $realm_sep,
586                    $html, $realm_config,
587                    $HTTP_GET_VARS, $HTTP_SERVER_VARS;
588            
589            $self     = $HTTP_SERVER_VARS["PHP_SELF"] ;
590    
591          $self     = $GLOBALS["PHP_SELF"] ;          $relDir = chopsl($relDir)."/";
592            $fsDir = $fsRoot.$relDir;       // current directory
593    
594          if ($relDir == "") $relDir = "/";          if (!is_dir($fsDir)) Error("Dir not found","Directory <tt>$relDir<tt> not found on filesystem at <tt>$fsDir</tt>",1) ;
595    
596          $fsDir = $fsRoot.$relDir."/";   // current directory          global $debug;
597            $debug .= "[$gblLogin|$relDir] before >";
598    
599          if (!is_dir($fsDir)) Error("Dir not found",$relDir) ;          if (! check_perm($relDir,trperm_b))
600                    Error("Access denied","User <tt>$gblLogin</tt> tried to access <tt>$relDir</tt> without valid trustee.",1);
601            $debug .= "< afeter";
602    
603          $hide_items=",$gblHide,";          $hide_items=",$gblHide,";
604    
605  #display_all_trustee();          $dirList = array();
606  print "-- $fsDir --";          $fileList = array();
607    
608          // read directory contents          // read directory contents
609          if ( !($dir = @opendir($fsDir)) )          if ( !($dir = @opendir($fsDir)) )
610                  Error("Read Access denied",$relDir) ;                  Error("Read Access denied",$relDir,1) ;
611          while ($item = readdir($dir)) {          while ($item = readdir($dir)) {
 print "$item, ";  
612                  if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") ) continue ;                  if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") ) continue ;
613                  if ((is_dir($fsDir.$item) || is_link ($fsDir.$item)) && check_perm($relDir.$item,trperm_b)) {                  if (is_dir($fsDir.$item) || is_link ($fsDir.$item)) {
614                          $dirList[$item] = $item ;                          if (check_perm($relDir.$item,trperm_b)) {
615                          $dirNote[$item] = ReadNote($fsDir.$item);                                  $dirList[$item] = $item ;
616                  } else if ( is_file($fsDir.$item) && check_perm($relDir.$item,trperm_r) ) {                                  $dirNote[$item] = ReadNote($fsDir.$item);
617                          $fileList[$item] = $item ;                                        }
618                          $fileDate[$item] = filemtime($fsDir.$item) ;                  } else if (is_file($fsDir.$item)) {
619                          $fileSize[$item] = filesize($fsDir.$item) ;                          if (check_perm($relDir.$item,trperm_r)) {
620                          $fileNote[$item] = ReadNote($fsDir.$item);                                  $fileList[$item] = $item ;              
621                                    $fileDate[$item] = filemtime($fsDir.$item) ;
622                                    $fileSize[$item] = filesize($fsDir.$item) ;
623                                    $fileNote[$item] = ReadNote($fsDir.$item);
624                            }
625                  } else {                  } else {
626                    // unknown file type                          if (! $gblIgnoreUnknownFileType) Error("File Type Error", "Item <tt>".$fsDir.$item."</tt> is not file, directory or link. If you want to ignore errors like this, set <tt>\$gblIgnoreUnknownFileType = 1</tt> in <tt>$realm_config</tt>.",1);
                   // $text = "Could not determine file type of " ;  
                   // Error("File Error", $text.$relDir."/".$item) ;  
                   // exit ;  
627                  }                  }
628          }          }
629          closedir($dir) ;          closedir($dir) ;
630    
631          // scan deleted files          // scan deleted files
632          if ( $GLOBALS[show_deleted] == 1 && ($dir = @opendir("$fsDir/.del")) ) {          if ( HTTP_GET_VAR("show_deleted") == 1 && ($dir = @opendir("$fsDir/.del")) ) {
633                  while ($item = readdir($dir)) {                  while ($item = readdir($dir)) {
634                          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 ;
635                          $fileList[$item] = ".del/$item" ;                                        $fileList[$item] = ".del/$item" ;              
# Line 626  print "$item, "; Line 644  print "$item, ";
644    
645          // start navigation page          // start navigation page
646          $text  = "Use this page to add, delete";          $text  = "Use this page to add, delete";
647          if (! isset($show_deleted)) {          if (! isset($HTTP_GET_VARS["show_deleted"])) {
648                  $text .= ", <a href=$self?D=".urlencode($relDir)."&show_deleted=1>undelete</a>";                  $text .= ", <a href=$self?D=".urlencode($relDir)."&show_deleted=1>undelete</a>";
649          }          }
650          $text .= " or revise files on this web site." ;          $text .= " or revise files on this web site." ;
# Line 636  print "$item, "; Line 654  print "$item, ";
654          echo "<TABLE BORDER=0 CELLPADDING=2          echo "<TABLE BORDER=0 CELLPADDING=2
655                  CELLSPACING=3 WIDTH=\"100%\">" ;                  CELLSPACING=3 WIDTH=\"100%\">" ;
656    
657          // updir bar              // updir (parent) bar  
658          if (chopsl($fsDir) != chopsl($fsRoot)) {          if (chopsl($fsDir) != chopsl($fsRoot)) {
659                  $parent = dirname($relDir) ;                  $parent = dirname($relDir) ;
660                  if ($parent == "") $parent = "/" ;                  if ($parent == "") $parent = "/" ;
# Line 652  print "$item, "; Line 670  print "$item, ";
670                  return $out;                  return $out;
671          }          }
672    
673          $dsort = $HTTP_GET_VARS[dsort];          if (! HTTP_GET_VAR("dsort")) $dsort = "name"; // default directory sort
         if (! isset($dsort)) $dsort = "name";   // default directory sort  
674    
675          $dsort_arr = array(          $dsort_arr = array(
676                  "name" => array ("rname", "note"),                  "name" => array ("rname", "note"),
# Line 662  print "$item, "; Line 679  print "$item, ";
679                  "rnote" => array ("name", "note")                  "rnote" => array ("name", "note")
680                  );                  );
681    
682          $fsort = $HTTP_GET_VARS[fsort];          if (! HTTP_GET_VAR("fsort")) $fsort = "name"; // default directory sort
         if (! isset($fsort)) $fsort = "name";   // default directory sort  
683    
684          $fsort_arr = array(          $fsort_arr = array(
685                  "name" => array ("rname", "note", "date", "size"),                  "name" => array ("rname", "note", "date", "size"),
# Line 679  print "$item, "; Line 695  print "$item, ";
695          $D="D=".urlencode($relDir);          $D="D=".urlencode($relDir);
696    
697          function self_args($arr = array()) {          function self_args($arr = array()) {
698                    global $self;
699                  $arg = implode("&",$arr);                  $arg = implode("&",$arr);
700                  if ($arg) {                  if ($arg) {
701                          return $self."?".$arg;                          return $self."?".$arg;
# Line 715  print "$item, "; Line 732  print "$item, ";
732    
733                          $dir = $dirList[$key];                          $dir = $dirList[$key];
734    
735                          $info_url=self_args(array("A" => "A=E", "F" => "F=".urlencode($dir)));                          $info_url=self_args(array("A"=>"A=E", "F"=>"F=".urlencode($dir), "D"=>$D));
736                          $dir_url=$self."?D=".urlencode($relDir.$dir);                          $dir_url=$self."?D=".urlencode(chopsl($relDir)."/".$dir);
737                          include("$html/Navigate-dirEntry.html");                          include("$html/Navigate-dirEntry.html");
738    
739                  }  // iterate over dirs                  }  // iterate over dirs
# Line 788  print "$item, "; Line 805  print "$item, ";
805    
806                  $file_lock=CheckLock($path);                  $file_lock=CheckLock($path);
807    
808                  $file_url_html="<A HREF=\"$self?A=V&F=".urlencode($file);                  $file_url_html="<A HREF=\"$self?A=V&D=".urlencode($relDir)."&F=".urlencode($file);
                 $file_url_html.="&D=".urlencode($relDir);  
809                  $file_url_html.="\" TITLE=\"View file\">" ;                  $file_url_html.="\" TITLE=\"View file\">" ;
810    
811                  if (substr($file,0,5) != ".del/") {                  if (substr($file,0,5) != ".del/") {
# Line 803  print "$item, "; Line 819  print "$item, ";
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&F=".urlencode($file);                                  $b.="<A HREF=\"$self?A=Ci&D=".urlencode($relDir)."&F=".urlencode($file);
                                 $b.="&D=".urlencode($relDir);  
824                                  $b.="\" TITLE=\"Checkin (update) file on server\">" ;                                  $b.="\" TITLE=\"Checkin (update) file on server\">" ;
825                                  $file_url_html=$b;                                  $file_url_html=$b;
826                                  $b.=$gblIcon("checkin")."</A>" ;                                  $b.=$gblIcon("checkin")."</A>" ;
# Line 819  print "$item, "; Line 834  print "$item, ";
834                                  $file_url_html = "$file $a";                                  $file_url_html = "$file $a";
835                          }                          }
836                  } else {                  } else {
837                          $b.="<A HREF=\"$self?A=Co&F=".urlencode($file);                          $b.="<A HREF=\"$self?A=Co&D=".urlencode($relDir)."&F=".urlencode($file);
                         $b.="&D=".urlencode($relDir);  
838                          $b.="\" TITLE=\"Checkout file for edit\">" ;                          $b.="\" TITLE=\"Checkout file for edit\">" ;
839                          $b.=$gblIcon("checkout")."</A>" ;                          $b.=$gblIcon("checkout")."</A>";
840    
841                          if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) {                            if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) {  
842                                  $b.="<A HREF=\"$self?A=C&F=".urlencode($file);                                  $b.="<A HREF=\"$self?A=C&D=".urlencode($relDir)."&F=".urlencode($file);
                                 $b.="&D=".urlencode($relDir);  
843                                  $b.="\" TITLE=\"List contents\">" ;                                  $b.="\" TITLE=\"List contents\">" ;
844                                  $b.=$gblIcon("view")."</A>" ;                                  $b.=$gblIcon("view")."</A>" ;
845                          } else {                          } else {
# Line 834  print "$item, "; Line 847  print "$item, ";
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    
# Line 866  print "$item, "; Line 879  print "$item, ";
879  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>
880    
881  <?  <?
882  if (file_exists(".info.inc")) {  
883    if (file_exists("$fsRealmDir/$realm".$realm_sep."info.inc")) {
884          print "<TR><TD></TD><TD COLSPAN=5>";          print "<TR><TD></TD><TD COLSPAN=5>";
885          include(".info.inc");          include("$fsRealmDir/$realm".$realm_sep."info.inc");
886          print "</TD></TR>          print "</TD></TR><TR><TD></TD><TD COLSPAN=5><HR></TD></TR>";
887          <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>";  } elseif (file_exists("$gblRepositoryDir/.info.inc")) {
888            print "<TR><TD></TD><TD COLSPAN=5>";
889            include("$gblRepositoryDir/.info.inc");
890            print "</TD></TR><TR><TD></TD><TD COLSPAN=5><HR></TD></TR>";
891  }  }
892    
893    
894  ?>  ?>
895    
896  <FORM METHOD="POST" ACTION="<?= $self ?>">  <FORM METHOD="POST" ACTION="<?= $self ?>">
# Line 896  if (file_exists(".info.inc")) { Line 915  if (file_exists(".info.inc")) {
915    
916  function UploadPage($fsRoot, $relDir, $filename="") {  function UploadPage($fsRoot, $relDir, $filename="") {
917    
918          $self = $GLOBALS["PHP_SELF"] ;          global $html, $HTTP_SERVER_VARS;
         if ($relDir == "") $relDir = "/" ;  
 ?>  
919    
920  <P><TABLE BORDER=0 CELLPADDING=5><TR><TD WIDTH=5></TD><TD CLASS=BAR>          $self = $HTTP_SERVER_VARS["PHP_SELF"] ;
921  <FORM ENCTYPE="multipart/form-data" METHOD="POST"          include("$html/UploadPage.html");
  ACTION="<?= $self ?>">  
 DESTINATION DIRECTORY:<B><?= " " . $relDir ?></B>  
 <? if (isset($filename) && $filename!="") { ?>  
 <br>DESTINATION FILE:<B><?= " " . $filename ?></B>  
 <INPUT TYPE="HIDDEN" NAME="FILENAME" VALUE="<?= $filename ?>">  
 <? } ?>  
 <P>PATHNAME OF LOCAL FILE<BR>  
 <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">  
 <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="UPLOAD">  
 <INPUT SIZE=30 TYPE="FILE" NAME="FN"></P>  
 <P><INPUT TYPE="SUBMIT" VALUE="UPLOAD"></P>  
 <P>If the <B>[BROWSE...]</B> button is not displayed,<BR>  
 you must upgrade to an RFC1867-compliant browser.</P>  
 <P>Your browser:<BR><?= $GLOBALS["HTTP_USER_AGENT"] ?></P>  
 </FORM>  
 </TD></TR>  
 <TR><TD></TD><TD>  
 <FORM METHOD="POST" ACTION="<?= $self ?>">  
 <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"><BR>  
 <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL">  
 </FORM>  
 </TD></TR></TABLE></P>  
922    
 <?php    
923  } // end function UploadPage  } // end function UploadPage
924    
925  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
926    
927  function Error($title,$text="") {  // Error with sysadmin flag are reported to error_log or hidden from
928          StartHTML("(".$title.")",$text) ;  // users
929          echo "<P ALIGN=center>Hit your Browser's Back Button.</P>" ;  
930          EndHTML() ;  function Error($title,$text="",$sysadmin=0,$no_404=0) {
931            global $gblSeparateAdminMessages,
932                    $gblMailAdminMessages,$realm,
933                    $HTTP_SERVER_VARS;
934            if (! headers_sent() && ! $no_404) header("HTTP/1.0 404 Not Found");
935            if ($sysadmin) {
936                    if ($gblSeparateAdminMessages) {
937                            $user="Your administrator ";
938                            if ($gblMailAdminMessages) {
939                                    mail($HTTP_SERVER_VARS["SERVER_ADMIN"], "docman $realm error message: $title", strip_tags($text));
940                                    $user.="<tt>".$HTTP_SERVER_VARS["SERVER_ADMIN"]."</tt> ";
941                            }
942                            $user.="has been notified about error" ;
943                            StartHTML("($title)",$user);
944                            echo "<P ALIGN=center>Hit your Browser's Back Button.</P>" ;
945                            EndHTML();
946                            error_log("docman $realm: ".strip_tags($text));
947                    } else {
948                            StartHTML("ADMIN: ".$title,$text) ;
949                            echo "<P ALIGN=center>Hit your Browser's Back Button.</P>" ;
950                            EndHTML();
951                    }
952            } else {
953                    StartHTML("(".$title.")",$text) ;
954                    echo "<P ALIGN=center>Hit your Browser's Back Button.</P>" ;
955                    EndHTML() ;
956            }
957          exit ;          exit ;
958  } // end function Error  } // end function Error
959    
960  //////////////////////////////////////////////////////////////////  function LogIt($target,$msg, $changelog=0) {
961    
962  function LogIt($target,$msg) {          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>");                  if (! @mkdir($dir."/.log",0700)) Error("docman installation problem","can't create log directory <tt>$dir/.log</tt>",1);
967          }          }
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);
974    
975            if (! $changelog) return;
976    
977            $log=fopen("$gblFsRoot/.changelog","a+");
978            if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot)
979                    $target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot));
980            $msg=str_replace("\t"," ",$msg);
981            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
985            // permission
986  }  }
987    
988    
# Line 970  function WriteNote($target,$msg) { Line 1001  function WriteNote($target,$msg) {
1001          fputs($note,"$msg\n");          fputs($note,"$msg\n");
1002          fclose($note);          fclose($note);
1003    
1004          Logit($target,"added note $msg");          LogIt($target,"added note $msg");
1005    
1006  }  }
1007    
# Line 1007  function MoveTo($source,$folder) { Line 1038  function MoveTo($source,$folder) {
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")) {
# Line 1015  function Lock($target) { Line 1048  function Lock($target) {
1048          $file=basename($target);          $file=basename($target);
1049    
1050          if (file_exists("$dir/.lock/$file")) {          if (file_exists("$dir/.lock/$file")) {
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");
1058          }          }
1059    
1060  }  }
# Line 1048  function Unlock($target) { Line 1081  function Unlock($target) {
1081          $file=basename($target);          $file=basename($target);
1082          if (file_exists($dir."/.lock/$file")) {          if (file_exists($dir."/.lock/$file")) {
1083                  unlink("$dir/.lock/$file");                  unlink("$dir/.lock/$file");
1084                  Logit($target,"file unlocked");                  LogIt($target,"file unlocked");
1085          } else {          } else {
1086                  Logit($target,"attempt to unlocked non-locked file!");                  LogIt($target,"attempt to unlocked non-locked file!");
1087          }          }
1088    
1089  }  }
# Line 1067  function urlpath($url) { Line 1100  function urlpath($url) {
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))) {
1109                          rename($from,$to);                          return rename($from,$to);
1110                    } else {
1111                            return 0;
1112                  }                  }
1113          }          }
1114    
1115          function try_dir($todir) {          function try_dir($todir) {
1116                  if (! file_exists($todir)) {                  if (! file_exists($todir)) {
1117                          mkdir($todir,0700);                          @mkdir($todir,0700);
1118                  }                  }
1119          }          }
1120    
# Line 1086  function safe_rename($fromdir,$fromfile, Line 1124  function safe_rename($fromdir,$fromfile,
1124    
1125  #       print "<pre>$fromdir / $fromfile -> $todir / $tofile\n\n";  #       print "<pre>$fromdir / $fromfile -> $todir / $tofile\n\n";
1126    
1127          try_rename("$fromdir/$fromfile","$todir/$tofile");          if (! try_rename("$fromdir/$fromfile","$todir/$tofile")) Error("Rename error","Can't rename file <tt>$fromfile</tt> to <tt>$tofile</tt>",1);
1128          try_dir("$todir/.log");          try_dir("$todir/.log");
1129          try_rename("$fromdir/.log/$fromfile","$todir/.log/$tofile");          try_rename("$fromdir/.log/$fromfile","$todir/.log/$tofile");
1130          try_dir("$todir/.note");          try_dir("$todir/.note");
# Line 1094  function safe_rename($fromdir,$fromfile, Line 1132  function safe_rename($fromdir,$fromfile,
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  }  }
# Line 1120  function rrmdir($dir) { Line 1158  function rrmdir($dir) {
1158    
1159  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1160    
1161  function ChangeLog($target,$msg) {  function DisplayChangeLog($day) {
   
         global $gblFsRoot;  
         $log=fopen("$gblFsRoot/.changelog","a+");  
         if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot)  
                 $target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot));  
         $msg=str_replace("\t"," ",$msg);  
         fputs($log,time()."\t$target\t$GLOBALS[gblUserName]\t$msg\n");  
         fclose($log);  
1162    
1163  }          global $gblFsRoot, $gblDateFmt, $gblTimeFmt;
1164                    $HTTP_SERVER_VARS;
1165    
1166  function DisplayChangeLog($day) {          $self  = $HTTP_SERVER_VARS["PHP_SELF"];
1167    
         global $gblFsRoot;  
1168          if (!file_exists("$gblFsRoot/.changelog")) return;          if (!file_exists("$gblFsRoot/.changelog")) return;
1169          $log=fopen("$gblFsRoot/.changelog","r");          $log=fopen("$gblFsRoot/.changelog","r");
1170          $logarr = array();          $logarr = array();
# Line 1152  function DisplayChangeLog($day) { Line 1182  function DisplayChangeLog($day) {
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=\"$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=\"$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=$GLOBALS[PHP_SELF]>front page</a>.</p>";          print "<p>".GifIcon(up)." Back to <a href=\"$self\">front page</a>.</p>";
1193  }  }
1194    
1195  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1196    
1197  function Download($path) {  function Download($path,$force=0) {
1198          global $HTTP_USER_AGENT;          global $HTTP_SERVER_VARS,$mime_type;
1199          $file=basename($path);  
1200            // default transfer-encoding
1201            $encoding = "binary";
1202    
1203            // known transfer encodings
1204            $encoding_ext = array(
1205                    "gz" => "x-gzip",
1206                    "Z" => "x-compress",
1207            );
1208    
1209            $file = basename($path);
1210          $size = filesize($path);          $size = filesize($path);
1211          //header("Content-Type: application/octet-stream");  
1212          header("Content-Type: application/force-download");          $ext_arr = explode(".",$file);
1213          header("Content-Length: $size");          $ext = array_pop($ext_arr);
1214            if ($encoding_ext[$ext]) {
1215                    $encoding = $encoding_ext[$ext];
1216                    $ext = array_pop($ext_arr);
1217            }
1218    
1219            if ($force || !isset($mime_type[$ext])) {
1220                    header("Content-Type: application/force-download");
1221            } else {
1222                    header("Content-Type: $mime_type[$ext]");
1223            }
1224    
1225          // IE5.5 just downloads index.php if we don't do this          // IE5.5 just downloads index.php if we don't do this
1226          if(preg_match("/MSIE 5.5/", $HTTP_USER_AGENT)) {          if(preg_match("/MSIE 5.5/", $HTTP_SERVER_VARS[HTTP_USER_AGENT])) {
1227                  header("Content-Disposition: filename=$file");                  header("Content-Disposition: filename=$file");
1228          } else {          } else {
1229                  header("Content-Disposition: attachment; filename=$file");                  header("Content-Disposition: attachment; filename=$file");
1230          }          }
1231          header("Content-Transfer-Encoding: binary");  
1232            header("Content-Transfer-Encoding: $encoding");
1233          $fh = fopen($path, "r");          $fh = fopen($path, "r");
1234          fpassthru($fh);          fpassthru($fh);
1235  }  }
# Line 1186  function Download($path) { Line 1238  function Download($path) {
1238  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1239    
1240  function chopsl($path) {  function chopsl($path) {
         if (substr($path,strlen($path)-1,1) == "/") $path=substr($path,0,strlen($path)-1);  
1241          $path=str_replace("//","/",$path);          $path=str_replace("//","/",$path);
1242            if (substr($path,strlen($path)-1,1) == "/") $path=substr($path,0,strlen($path)-1);
1243          return $path;          return $path;
1244  }  }
1245    
# Line 1201  function chopsl($path) { Line 1253  function chopsl($path) {
1253          by Vyacheslav Zavadsky <zavadsky@braysystems.com>          by Vyacheslav Zavadsky <zavadsky@braysystems.com>
1254  */  */
1255    
1256  define(trmask_not,1 << 0);  define('trmask_not',1 << 0);
1257  define(trmask_clear,1 << 1);  define('trmask_clear',1 << 1);
1258  define(trmask_deny,1 << 2);  define('trmask_deny',1 << 2);
1259  define(trmask_one_level,1 << 3);  define('trmask_one_level',1 << 3);
1260  define(trmask_group,1 << 4);  define('trmask_group',1 << 4);
1261    
1262  define(trperm_r,1 << 5);  define('trperm_r',1 << 5);
1263  define(trperm_w,1 << 6);  define('trperm_w',1 << 6);
1264  define(trperm_b,1 << 7);  define('trperm_b',1 << 7);
1265  define(trperm_n,1 << 8);  define('trperm_n',1 << 8);
1266    
1267  $trustee_a2n = array(  $trustee_a2n = array(
1268          '!' => trmask_not,          '!' => trmask_not,
# Line 1258  if (! file_exists($trustee_conf)) { Line 1310  if (! file_exists($trustee_conf)) {
1310          $error="<tt>".dirname($trustee_php)."</tt> must be writable by web server user";          $error="<tt>".dirname($trustee_php)."</tt> must be writable by web server user";
1311  } elseif (file_exists($trustee_php) && !is_writable($trustee_php)) {  } elseif (file_exists($trustee_php) && !is_writable($trustee_php)) {
1312          $error="trustees cache file <tt>$trustee_php</tt> exists, but is not writable by web server";          $error="trustees cache file <tt>$trustee_php</tt> exists, but is not writable by web server";
1313  } elseif (1 || filemtime($trustee_conf) >= filemtime($trustee_php)) {  } elseif (@filemtime($trustee_conf) >= @filemtime($trustee_php)) {
1314          $fp_php=@fopen($trustee_php,"w");          $fp_php=@fopen($trustee_php,"w");
1315          fputs($fp_php,"<?php // don't edit by hand!\n");          fputs($fp_php,"<?php // don't edit by hand!\n");
1316    
# Line 1267  if (! file_exists($trustee_conf)) { Line 1319  if (! file_exists($trustee_conf)) {
1319          $groups_arr = array();          $groups_arr = array();
1320          $perm_arr = array();          $perm_arr = array();
1321    
         $error=0;  
   
1322          $tr_arr = array();          $tr_arr = array();
1323    
1324          while (! feof($fp_conf)) {          while (! feof($fp_conf)) {
# Line 1296  if (! file_exists($trustee_conf)) { Line 1346  if (! file_exists($trustee_conf)) {
1346                                                  $error.="trustee error in line '$l' [Unknown modifier '$ch']<br>\n";                                                  $error.="trustee error in line '$l' [Unknown modifier '$ch']<br>\n";
1347                                          }                                          }
1348                                  }                                  }
1349                                  $tr_arr[$path][$user] |= $perm;                                  if (isset($tr_arr[$path][$user])) {
1350                                            $tr_arr[$path][$user] |= $perm;
1351                                    } else {
1352                                            $tr_arr[$path][$user] = $perm;
1353                                    }
1354                          }                          }
1355                  }                  }
1356          }          }
# Line 1335  if (! file_exists($trustee_conf)) { Line 1389  if (! file_exists($trustee_conf)) {
1389          fclose($fp_php);          fclose($fp_php);
1390  }  }
1391    
1392  if ($error) {  if (isset($error)) {
1393          Error("Trustee error",$error);          Error("Trustee error",$error,1);
1394  } else {  } else {
1395          include("$trustee_php");          include_once("$trustee_php");
1396  }  }
1397    
1398  return 1;  return 1;
# Line 1346  return 1; Line 1400  return 1;
1400  }//init_trustee  }//init_trustee
1401    
1402  function in_group($user,$group) {  function in_group($user,$group) {
1403          return in_array($groups[$group],$user);          global $groups;
1404            return in_array($user,$groups[$group]);
1405  }  }
1406    
1407  // helper function  // helper function
1408  function unroll_perm($u,$t,$user,$perm) {  function unroll_perm($u,$t,$user,$perm,$one_level) {
1409          // check user  
1410          if ($t & trmask_not && ($u==$user)) continue;          if ($t & trmask_one_level && !$one_level) return $perm;
1411          if (!($t & trmask_not) && ($u!=$user)) continue;  
1412            // user is user whose trustee is this
1413            if ($t & trmask_not && ($u==$user)) return $perm;
1414            if (!($t & trmask_not) && ($u!=$user)) return $perm;
1415    
1416          if ($t & trmask_deny) {          if ($t & trmask_deny) {
1417                  if ($t & trmask_clear) {                  if ($t & trmask_clear) {
1418                          $perm[deny] &= ~$t;                          $perm['deny'] &= ~$t;
1419                  } else {                  } else {
1420                          $perm[deny] |= $t;                          $perm['deny'] |= $t;
1421                  }                  }
1422          } elseif ($t & trmask_clear) {          } elseif ($t & trmask_clear) {
1423                  $perm[allow] &= ~$t;                  $perm['allow'] &= ~$t;
1424          } else {          } else {
1425                  $perm[allow] |= $t;                  $perm['allow'] |= $t;
1426          }          }
1427          return $perm;          return $perm;
1428  }// end of helper function  }// end of helper function
1429    
1430  function check_trustee($user,$path) {  function check_trustee($user,$path) {
1431          global $trustees;          global $trustees;
1432          $perm[allow] = 0;          $perm['allow'] = 0;
1433          $perm[deny] = 0;          $perm['deny'] = 0;
1434    
1435            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);
1436    
1437    global $debug;
1438    $debug .= "<br>check_trustee $path ... ";
1439    
1440          $path_arr=explode("/",$path);          $path_arr=explode("/",$path);
1441          $path = "/";          $tmppath = "/";
1442          while (count($path_arr)) {          while (count($path_arr)) {
1443                  if (substr($path,strlen($path)-1,1) != "/") $path.="/";                  $tmppath.=array_shift($path_arr);
1444                  $path.=array_shift($path_arr);  $debug.= ">> $tmppath ";
1445                  $tr = $trustees[$path];  
1446                    if (! isset($trustees[$tmppath])) continue;
1447                    $tr = $trustees[$tmppath];
1448    
1449                    $one_level = (!count($path_arr));
1450    $debug.=" O($one_level) ";
1451    
1452                  if (isset($tr)) {                  if (isset($tr)) {
1453                          // first apply trustee for all                          // first apply trustee for all
1454                          if (isset($tr['*'])) {                          if (isset($tr['*'])) {
1455                                  $perm = unroll_perm($user,$tr['*'],$user, $perm);                                  $perm = unroll_perm($user,$tr['*'],'*', $perm, $one_level);
1456                                  unset($tr['*']);                                  unset($tr['*']);
1457                          }                          }
1458                          // then apply group policies                          // then apply group policies
1459                          foreach ($tr as $u=>$t) {                          foreach ($tr as $g=>$t) {
1460                                  if ($t & trmask_group && in_group($user,$u)) {                                  if ($t & trmask_group && in_group($user,$g)) {
1461                                          // resolv user                                          // resolv user
1462                                          $t = $t & ~trmask_group;                                          $t = $t & ~trmask_group;
1463                                          $u = $user;                                          $perm = unroll_perm($user,$t,$g, $perm, $one_level);
1464                                          $perm = unroll_perm($u,$t,$user, $perm);                                          unset($tr[$g]);
                                         unset($tr[$u]);  
1465                                  }                                  }
1466                          }                          }
1467                          // then apply use policy                          // then apply user policy
1468                          if (isset($tr[$user])) {                          if (isset($tr[$user])) {
1469                                  $perm = unroll_perm($user,$tr[$user],$user, $perm);                                  $perm = unroll_perm($user,$tr[$user],$user, $perm,$one_level);
1470                                  unset($tr[$user]);                                  unset($tr[$user]);
1471                          }                          }
   
1472                  }                  }
1473    $debug.="d(".display_trustee($perm['deny']).") a(".display_trustee($perm['allow']).") ";
1474    
1475          }          }
1476  #print "<br>user: $user path: $path perm: ";  $debug.="<br>check_trustee: user: $user path: $path==$tmppath perm: ";
1477  #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";
1478          return $perm;          return $perm;
1479  }  }
1480    
# Line 1414  function check_trustee($user,$path) { Line 1482  function check_trustee($user,$path) {
1482    
1483  function check_perm($path,$trperm) {  function check_perm($path,$trperm) {
1484          global $gblLogin,$HAVE_TRUSTEE;          global $gblLogin,$HAVE_TRUSTEE;
1485  print "<br>check_perm: <tt>$path</tt> test perm ".display_trustee($perm)."<br>\n";  
1486            global $debug;
1487    $debug.="<br>check_perm: on <tt>$path</tt> for perm ".display_trustee($trperm)."<br>\n";
1488    
1489          $return = ! $HAVE_TRUSTEE;          $return = ! $HAVE_TRUSTEE;
1490          if ($HAVE_TRUSTEE) {          if ($HAVE_TRUSTEE) {
1491                  $perm = check_trustee($gblLogin,$path);                  $perm = check_trustee($gblLogin,$path);
1492  print " 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).")";
1493                  if ($perm[deny] & $trperm) $return=0;                  if ($perm['deny'] & $trperm) $return=0;
1494                  elseif ($perm[allow] & $trperm) $return=1;                  elseif (($perm['allow'] & $trperm) == $trperm) $return=1;
1495          }          }
1496  print " return: $return<br>\n";  $debug.=" return: $return<br>\n";
1497          return($return);          return($return);
1498  }  }
1499    
1500    //////////////////////////////////////////////////////////////////
1501    
1502    function readMime() {
1503            global $mime_type;
1504    
1505            if (! isset($gblMimeTypes)) {
1506                    $gblMimeTypes = "/etc/mime.types";
1507            }
1508    
1509            $mime = @fopen($gblMimeTypes,"r");
1510    
1511            if (! $mime) Error("Can't read MIME types","<tt>$gblMimeTypes</tt> file not found. You can setup other <tt>mime.types</tt> file using <tt>\$gblMimeTypes</tt> in <tt>$realm_config</tt>");
1512    
1513            while($line = fgets($mime,80)) {
1514                    if (substr($line,0,1) == "#") continue; // skip comment
1515                    $arr = preg_split("/[\s\t]+/",$line);
1516                    $type = array_shift($arr);
1517                    while ($ext = array_shift($arr)) {
1518                            $mime_type[$ext] = $type;
1519                    }
1520            }
1521    
1522            fclose($mime);
1523    }
1524    
1525    //////////////////////////////////////////////////////////////////
1526    
1527    // check for invalid characters in filename and dirname (.. and /)
1528    
1529    function check_dirname($file) {
1530            if (strstr($file,"..")) Error("Security violation","No parent dir <tt>..</tt> allowed in directory name <tt>$file</tt>",1);
1531    }
1532    
1533    function check_filename($file) {
1534            if (strstr($file,"..")) Error("Security violation","No parent dir <tt>..</tt> allowed in file name <tt>$file</tt>",1);
1535            if (strstr($file,"/")) Error("Security violation","No slashes <tt>/</tt> allowed in file name <tt>$file</tt>",1);
1536    }
1537    
1538    //////////////////////////////////////////////////////////////////
1539    
1540    // functions to move HTTP server variables to global namespace
1541    // [replacement for register_globals in php.ini]
1542    
1543    function HTTP_GET_VAR($var) {
1544            global $HTTP_GET_VARS, $GLOBALS;
1545            if (isset($HTTP_GET_VARS[$var])) {
1546                    $GLOBALS[$var] = stripSlashes($HTTP_GET_VARS[$var]);
1547                    return $GLOBALS[$var];
1548            }
1549    }
1550    
1551    function HTTP_POST_VAR($var) {
1552            global $HTTP_POST_VARS, $GLOBALS;
1553            if (isset($HTTP_POST_VARS[$var])) {
1554                    $GLOBALS[$var] = stripSlashes($HTTP_POST_VARS[$var]);
1555                    return $GLOBALS[$var];
1556            }
1557    }
1558    
1559    //////////////////////////////////////////////////////////////////
1560    
1561    function Warn($text) {
1562    }
1563    
1564  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1565  // MAIN PROGRAM  // MAIN PROGRAM
# Line 1433  print " return: $return<br>\n"; Line 1567  print " return: $return<br>\n";
1567          $gblFilePerms = 0640 ;         // default for new files          $gblFilePerms = 0640 ;         // default for new files
1568          $gblDirPerms  = 0750 ;          // default for new dirs          $gblDirPerms  = 0750 ;          // default for new dirs
1569    
1570          if (isset($STYLE) && $STYLE == "get") {          if (isset($HTTP_GET_VARS["STYLE"]) && $HTTP_GET_VARS["STYLE"] == "get") {
1571                  include("$html/docman.css");                  include("$html/docman.css");
1572                  exit;                  exit;
1573          }          }
# Line 1451  print " return: $return<br>\n"; Line 1585  print " return: $return<br>\n";
1585          if (! isset($fsRealmDir)) {          if (! isset($fsRealmDir)) {
1586                  $fsRealmDir = "$gblIncDir/realm";                  $fsRealmDir = "$gblIncDir/realm";
1587          }          }
1588          $realm_config = "$fsRealmDir/$realm.conf";  
1589            // try to add dir to script name to realm var
1590            if (is_dir("$fsRealmDir/$realm/".dirname($HTTP_SERVER_VARS["SCRIPT_NAME"]))) {
1591                    $realm .= dirname($HTTP_SERVER_VARS["SCRIPT_NAME"]);
1592                    $realm_sep = "/";
1593            } else {
1594                    $realm_sep = ".";
1595            }
1596    
1597            $realm_config = $fsRealmDir."/".$realm.$realm_sep."conf";
1598    
1599          // read user-defined configuration          // read user-defined configuration
1600          if (file_exists($realm_config)) {          if (file_exists($realm_config)) {
# Line 1469  print " return: $return<br>\n"; Line 1612  print " return: $return<br>\n";
1612                  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>");
1613          }          }
1614    
1615            // take additional login vars
1616            HTTP_GET_VAR("relogin");
1617            HTTP_GET_VAR("force_login");
1618    
1619          // if no password, or empty password logout          // if no password, or empty password logout
1620          if (          if (
1621                  isset($gblLogin) && (                  isset($gblLogin) && (
# Line 1484  print " return: $return<br>\n"; Line 1631  print " return: $return<br>\n";
1631                  exit ;                  exit ;
1632          }          }
1633    
1634            if (!is_dir($gblRepositoryDir)) Error("Repository dir not found","Can't find repository directory <tt>$gblRepositoryDir</tt>. Please fix that in <tt>$realm_config</tt> variable <tt>\$gblRepositoryDir</tt>.",1);
1635    
1636          // trustee (ACL) file configuration          // trustee (ACL) file configuration
1637          $trustee_conf="$gblIncDir/realm/$realm.trustee";          $trustee_conf="$fsRealmDir/$realm".$realm_sep."trustee";
1638          // compiled version of trustee file          // compiled version of trustee file
1639          $trustee_php="$gblRepositoryDir/.trustee.php";          $trustee_php="$gblRepositoryDir/.trustee.php";
1640          // get ACL informations          // get ACL informations
1641          $HAVE_TRUSTEE = init_trustee();          $HAVE_TRUSTEE = init_trustee();
1642    
1643          if (strtolower($gblLogin) == "anonymous" || !isset($gblPasswd)) {          if (strtolower($gblLogin) == "anonymous" || !isset($gblLogin)) {
1644                  $perm = check_trustee($gblLogin,$path);                  $perm = check_trustee("anonymous","/");
1645                  // browsing must be explicitly allowed for root directory                  // browsing must be explicitly allowed for root directory
1646                  // of repository for anonymous user to work!                  // of repository for anonymous user to work!
1647                  if ($perm[allow] & trperm_b) {                  if ($perm['allow'] & trperm_b) {
1648                            $gblLogin = $gblPasswd = "anonymous";
1649                          $secHash = md5($gblLogin.$gblPasswd);                          $secHash = md5($gblLogin.$gblPasswd);
1650                          $gblUserName = "Anonymous user";                          $gblUserName = "Anonymous user";
1651                  }                  }
# Line 1506  print " return: $return<br>\n"; Line 1656  print " return: $return<br>\n";
1656                  isset($relogin) && $secHash == $relogin) {                  isset($relogin) && $secHash == $relogin) {
1657                  header("WWW-authenticate: basic realm=\"$realm\"") ;                  header("WWW-authenticate: basic realm=\"$realm\"") ;
1658                  header("HTTP/1.0 401 Unauthorized") ;                  header("HTTP/1.0 401 Unauthorized") ;
1659                  Error("401 Unauthorized","No trespassing !");                  Error("401 Unauthorized","No trespassing !",0,1);
                 exit ;  
1660          }          }
1661    
         // get current directory relative to $gblFsRoot  
         $relDir = $DIR ;        // from POST  
         if ($relDir == "") {    // not defined in POST ?  
                 $relDir = urldecode($D) ;  // then use GET  
         }        
1662    
1663          $relDir=stripSlashes($relDir);          // read mime.types
1664            readMime();
1665    
1666          if ($relDir == "/") $relDir = "" ;                if ($HTTP_SERVER_VARS["REQUEST_METHOD"] == "POST") {
1667          // default : website root = ""                  // take variables from server
1668                    if (HTTP_POST_VAR("FN")) check_filename($FN);
1669          if (strstr($relDir,"..")) Error("No updirs allowed");                  if (HTTP_POST_VAR("DIR")) {
1670                            check_dirname($DIR);
1671                            $relDir = $DIR;
1672                    } else {
1673                            trigger_error("Can't get DIR",E_USER_WARNING);
1674                            $relDir = "/";
1675                    }
1676                    if (HTTP_POST_VAR("RELPATH")) check_dirname($RELPATH);
1677                    HTTP_POST_VAR("T");
1678                    HTTP_POST_VAR("CONFIRM");
1679    
1680          // full paths contain "fs" or "Fs". Paths realitve to root of          } else {
1681          // website contain "rel" or "Rel". The script won't let you                  // get
1682          // edit anything above directory equal to http://server.com                  HTTP_GET_VAR("A");
1683          // i.e. below $gblFsRoot.                  if (HTTP_GET_VAR("D")) {
1684                            check_dirname($D);
1685                            $D=urldecode($D);
1686                            $relDir = $D;
1687                    } else {
1688                            //trigger_error("Can't get D",E_USER_WARNING);
1689                            $relDir = "/";
1690                    }
1691                    if (HTTP_GET_VAR("F")) check_filename($F);
1692            }
1693    
1694          $relScriptDir = dirname($SCRIPT_NAME) ;                  $relScriptDir = dirname($HTTP_SERVER_VARS["SCRIPT_NAME"]) ;    
1695          // i.e. /docman          // i.e. /docman
1696    
1697          // start on server root          // start on server root
1698          $gblFsRoot = $gblRepositoryDir;          $gblFsRoot = $gblRepositoryDir;
1699          // i.e. /home/httpd/html          // i.e. /home/httpd/repository
1700    
1701          $fsDir = $gblFsRoot . $relDir ; // current directory          $fsDir = $gblFsRoot . $relDir ; // current directory
1702          if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ;          if ( !is_dir($fsDir) ) Error("Dir not found","Can't find <tt>$relDir</tt> which points to <tt>$fsDir</tt>",1) ;
1703    
1704            if ($relDir == "") $relDir="/";
1705    
1706          if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") {          if (isset($HTTP_SERVER_VARS["HTTPS"]) && $HTTP_SERVER_VARS["HTTPS"] == "on") {
1707                  $webRoot  = "https://";                  $webRoot  = "https://";
1708          } else {          } else {
1709                  $webRoot  = "http://";                  $webRoot  = "http://";
1710          }          }
1711          $webRoot .= $GLOBALS["HTTP_HOST"] . $relScriptDir;          $webRoot .= $HTTP_SERVER_VARS["HTTP_HOST"] . $relScriptDir;
1712    
1713          $FN=stripSlashes($FN);          if (HTTP_POST_VAR("POSTACTION")) switch ($POSTACTION) {
   
         switch ($POSTACTION) {  
1714          case "UPLOAD" :          case "UPLOAD" :
1715                    $FN_name=stripSlashes($HTTP_POST_FILES["FN"]["tmp_name"]);
1716                    $FN=stripSlashes($HTTP_POST_FILES["FN"]["name"]);
1717                  if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;                  if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;
1718                  if (strstr($FN_name,"/"))  
1719                          Error("Non-conforming filename") ;                  $source = $FN_name ;
                 // TODO : should rather check for escapeshellcmds  
                 // but maybe RFC 18xx asserts safe filenames ....  
                 $source = $FN ;  
1720                  if (! file_exists($source)) {                  if (! file_exists($source)) {
1721                          Error("You must select file with browse to upload it!");                          Error("You must select file with browse to upload it!");
1722                  }                  }
1723    
1724                    if (HTTP_POST_VAR("FILENAME")) check_filename($FILENAME);
1725    
1726                  if (! isset($FILENAME)) {       // from update file                  if (! isset($FILENAME)) {       // from update file
1727                          $target = "$fsDir/$FN_name" ;                          $target = "$fsDir/".basename($FN);
1728                  } else {                  } else {
1729                          $target = "$fsDir/$FILENAME";                          $target = "$fsDir/$FILENAME";
1730                  }                  }
# Line 1569  print " return: $return<br>\n"; Line 1734  print " return: $return<br>\n";
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/");
# Line 1581  print " return: $return<br>\n"; Line 1746  print " return: $return<br>\n";
1746                  copy($source,$target) ;                  copy($source,$target) ;
1747                  chmod($target,$gblFilePerms) ;                  chmod($target,$gblFilePerms) ;
1748                  clearstatcache() ;                  clearstatcache() ;
                 Logit($target,"uploaded");  
1749                  if (isset($FILENAME)) {                  if (isset($FILENAME)) {
1750                            LogIt($target,"check-in",trperm_r | trperm_w);
1751                          Unlock($target);                          Unlock($target);
1752                    } else {
1753                            LogIt($target,"uploaded",trperm_r | trperm_w);
1754                  }                  }
                 ChangeLog($target,"updated");  
1755                  break ;                  break ;
1756    
1757          case "SAVE" :          case "SAVE" :
# Line 1602  print " return: $return<br>\n"; Line 1768  print " return: $return<br>\n";
1768                  fwrite($fh,$FILEDATA) ;                  fwrite($fh,$FILEDATA) ;
1769                  fclose($fh) ;                  fclose($fh) ;
1770                  clearstatcache() ;                  clearstatcache() ;
1771                  Logit($path,"saved changes");                  LogIt($path,"saved changes",trperm_r);
                 ChangeLog($path,"saved changes");  
1772                  break ;                  break ;
1773    
1774          case "CREATE" :          case "CREATE" :
# Line 1616  print " return: $return<br>\n"; Line 1781  print " return: $return<br>\n";
1781                  case "D" :  // create a directory                  case "D" :  // create a directory
1782                          if ( ! @mkdir($path,$gblDirPerms) )                          if ( ! @mkdir($path,$gblDirPerms) )
1783                                  Error("Mkdir failed",$relPath) ; // eg. if it exists                                  Error("Mkdir failed",$relPath) ; // eg. if it exists
1784                            else
1785                                    LogIt($path."/","dir created",trperm_w);
1786                          clearstatcache() ;                          clearstatcache() ;
1787                          break ;                          break ;
1788                  case "F" :  // create a new file                  case "F" :  // create a new file
# Line 1628  print " return: $return<br>\n"; Line 1795  print " return: $return<br>\n";
1795                          if ($fh) {                          if ($fh) {
1796                                  fputs($fh,"\n");                                  fputs($fh,"\n");
1797                                  fclose($fh) ;                                  fclose($fh) ;
1798                                  LogIt($path,"file created");                                  LogIt($path,"file created",trperm_r | trperm_w);
1799                          } else {                          } else {
1800                                  Error("Creation of file $relPath failed -- $path");                                  Error("Creation of file $relPath failed -- $path");
1801                          }                          }
1802                          $tstr = "$PHP_SELF?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ;                          $tstr = "$PHP_SELF?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ;
1803                          header("Location: " . $tstr) ;                          header("Location: " . $tstr) ;
                         ChangeLog($target,"created");  
1804                          exit ;                          exit ;
1805                  }                  }
1806                  break ;                  break ;
# Line 1656  print " return: $return<br>\n"; Line 1822  print " return: $return<br>\n";
1822    
1823  //                      if ( ! @unlink($path) ) {  //                      if ( ! @unlink($path) ) {
1824                          if ( ! rename($path,"$dir/.del/$file") ) {                          if ( ! rename($path,"$dir/.del/$file") ) {
1825                                    LogIt($path,"file delete failed");
1826                                  Error("File delete failed", $tstr . $path) ;                                  Error("File delete failed", $tstr . $path) ;
                                 Logit($path,"file delete failed");  
                                 exit ;  
1827                          } else {                          } else {
1828                                  Logit($path,"file deleted");                                  LogIt($path,"file deleted",trperm_w);
1829                                  MoveTo("$dir/.log/$file","$dir/.del/.log/");                                  MoveTo("$dir/.log/$file","$dir/.del/.log/");
1830                                  MoveTo("$dir/.note/$file","$dir/.del/.note/");                                  MoveTo("$dir/.note/$file","$dir/.del/.note/");
1831                                  MoveTo("$dir/.lock/$file","$dir/.del/.lock/");                                  MoveTo("$dir/.lock/$file","$dir/.del/.lock/");
1832                          }                          }
1833                  }                  } else {  // delete directory
1834                  else {  // delete directory                          if ( ! @rrmdir($fsDir) ) {
1835                    if ( ! @rrmdir($fsDir) ) {                                  Error("Rmdir failed", $tstr . $fsDir) ;
1836                      Error("Rmdir failed", $tstr . $fsDir) ;                          } else {
1837                    }                                  LogIt($path,"dir deleted",trperm_w);
1838                    else {                                  $relDir = dirname($relDir) ;  // move up
1839                      $relDir = dirname($relDir) ;  // move up                          }
                   }  
1840                  }                  }
1841                  break ;                  break ;
1842    
# Line 1682  print " return: $return<br>\n"; Line 1846  print " return: $return<br>\n";
1846                  if (substr($FN,0,4) != ".del") break ;                  if (substr($FN,0,4) != ".del") break ;
1847                  $file=substr($FN,4,strlen($FN)-4);                  $file=substr($FN,4,strlen($FN)-4);
1848    
1849                  Logit("$fsDir/.del/$file","undeleted");                  LogIt("$fsDir/.del/$file","undeleted",trperm_w);
1850                  MoveTo("$fsDir/.del/$file","$fsDir/");                  MoveTo("$fsDir/.del/$file","$fsDir/");
1851                  MoveTo("$fsDir/.del/.log/$file","$fsDir/.log/");                  MoveTo("$fsDir/.del/.log/$file","$fsDir/.log/");
1852                  MoveTo("$fsDir/.del/.note/$file","$fsDir/.note/");                  MoveTo("$fsDir/.del/.note/$file","$fsDir/.note/");
# Line 1693  print " return: $return<br>\n"; Line 1857  print " return: $return<br>\n";
1857          case "RENAME" :            case "RENAME" :  
1858                  if ( $CONFIRM != "on" ) break ;                  if ( $CONFIRM != "on" ) break ;
1859    
1860                  Logit("$fsDir/$FN","renamed $FN to $NEWNAME");                  $NEWNAME=stripSlashes($HTTP_POST_VARS["NEWNAME"]);
1861                    LogIt("$fsDir/$FN","renamed $FN to $NEWNAME",trperm_r);
1862                  safe_rename($fsDir,$FN,$NEWNAME);                  safe_rename($fsDir,$FN,$NEWNAME);
1863                  break ;                  break ;
1864    
1865          case "NOTE" :            case "NOTE" :  
1866                    $NOTE=stripSlashes($HTTP_POST_VARS["NOTE"]);
1867                  WriteNote("$fsDir/$FN","$NOTE");                  WriteNote("$fsDir/$FN","$NOTE");
1868                  break ;                  break ;
1869    
# Line 1711  print " return: $return<br>\n"; Line 1877  print " return: $return<br>\n";
1877          }          }
1878    
1879          // common to all POSTs : redirect to directory view ($relDir)          // common to all POSTs : redirect to directory view ($relDir)
1880          if ( $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                    
# Line 1724  print " return: $return<br>\n"; Line 1890  print " return: $return<br>\n";
1890          // $A=Co : checkout file $D/$F          // $A=Co : checkout file $D/$F
1891          // $A=Ci : checkin file $D/$F          // $A=Ci : checkin file $D/$F
1892          // $A=V : view file (do nothing except log)          // $A=V : view file (do nothing except log)
1893          // $A=I : include file .$F.php from $gblFsRoot          // $A=I : include file .$F.php from [$gblIncDir|realm]/include_php
1894          // default : display directory $D          // default : display directory $D
1895    
1896          switch ($A) {          if (isset($A)) switch ($A) {
1897          case "U" :          case "U" :
1898                  // upload to $relDir                  // upload to $relDir
1899                    if (! check_perm($relDir, trperm_w))
1900                            Error("Write access denied","You don't have permission to write in <tt>$relDir</tt>");
1901                  if (!is_writeable($gblFsRoot . $relDir))                  if (!is_writeable($gblFsRoot . $relDir))
1902                          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);
1903                  $text  = "Use this page to upload a single " ;                  $text  = "Use this page to upload a single " ;
1904                  $text .= "file to <B>$HTTP_HOST</B>." ;                  $text .= "file to <B>$realm</B>." ;
1905                  StartHTML("(Upload Page)", $text) ;                  StartHTML("(Upload Page)", $text) ;
1906                  UploadPage($gblFsRoot, $relDir) ;                  UploadPage($gblFsRoot, $relDir) ;
1907                  EndHTML() ;                  EndHTML() ;
1908                  exit ;                  exit ;
1909          case "E" :          case "E" :
                 $F=stripSlashes($F);  
1910                  // detail of $relDir/$F                  // detail of $relDir/$F
1911                  if (is_file("$gblFsRoot/$relDir/$F") || is_dir("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ;                  if (is_file("$gblFsRoot/$relDir/$F") || is_dir("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ;
1912                  exit ;                  exit ;
# Line 1751  print " return: $return<br>\n"; Line 1918  print " return: $return<br>\n";
1918          case "Co" :          case "Co" :
1919                  // checkout                  // checkout
1920                  Lock("$gblFsRoot/$relDir/$F");                  Lock("$gblFsRoot/$relDir/$F");
1921                  Download("$gblFsRoot/$relDir/$F");                  Download("$gblFsRoot/$relDir/$F",1);
1922                  exit;                  exit;
1923          case "Ci" :          case "Ci" :
1924                  $F=stripSlashes($F);                  $F=stripSlashes($F);
# Line 1759  print " return: $return<br>\n"; Line 1926  print " return: $return<br>\n";
1926                  if (!is_writeable($gblFsRoot . $relDir))                  if (!is_writeable($gblFsRoot . $relDir))
1927                          Error("Write access denied",$relDir) ;                          Error("Write access denied",$relDir) ;
1928                  $text  = "Use this page to update a single " ;                  $text  = "Use this page to update a single " ;
1929                  $text .= "file to <B>$HTTP_HOST</B>." ;                  $text .= "file to <B>$realm</B>." ;
1930                  StartHTML("(Update file Page)", $text) ;                  StartHTML("(Update file Page)", $text) ;
1931                  UploadPage($gblFsRoot, $relDir, $F) ;                  UploadPage($gblFsRoot, $relDir, $F) ;
1932                  EndHTML() ;                  EndHTML() ;
# Line 1767  print " return: $return<br>\n"; Line 1934  print " return: $return<br>\n";
1934          case "V" :          case "V" :
1935                  // view                  // view
1936                  LogIt("$gblFsRoot/$relDir/$F","viewed");                  LogIt("$gblFsRoot/$relDir/$F","viewed");
1937                  if ($gblForceDownload) {                  Download("$gblFsRoot/$relDir/$F",$gblForceDownload);
                         Download("$gblFsRoot/$relDir/$F");  
                 } else {  
                         header("Content-Disposition: attachment; filename=$F" );  
                         Header("Location: $webRoot".urlpath("$relDir/$F"));  
                 }  
1938                  exit;                  exit;
1939          case "Ch" :          case "Ch" :
1940                  StartHTML("(File changes)","All changes chronologicaly...");                  StartHTML("(File changes)","All changes chronologicaly...");
# Line 1785  print " return: $return<br>\n"; Line 1947  print " return: $return<br>\n";
1947                  EndHTML() ;                  EndHTML() ;
1948                  exit;                  exit;
1949          case "I" :          case "I" :
1950                  $F=stripSlashes($F);                  if (! isset($F) || $F == "")
1951                  $inc_file="${gblFsRoot}/.${F}.php";                          Error("Can't find file to include","Your request didn't specify file to include which should be in variable <tt>F</tt> like <tt>$HTTP_SERVER_VARS[REQUEST_URI]<b>&F=include_php_file</b></tt>",1);
1952                  if (!isset($F) || $F == "" || !file_exists($inc_file)) Error("Fatal error $inc_file"); // can't find file to include                  $inc_file="$fsRealmDir/$realm".$realm_sep.$F.".php";
1953                    if (! file_exists($inc_file)) {
1954                            Error("Can't find file to include","Can't find include file <tt>$F.php</tt> in <tt>$fsRealmDir/$realm/</tt>. Meybe you should copy <tt>$gblIncDir/include_php/$F.php</tt> to <tt>$inc_file<tt> ?",1);
1955                    }
1956                  if (!is_readable($inc_file))                  if (!is_readable($inc_file))
1957                          Error("Read access to include file denied",".${F}.php");                          Error("Read access to include file denied","Can't read PHP include file <tt>$inc_file</tt>. Fix permissions on it.",1);
1958                  $text  = "Your include file should define \$text variable which holds this text and \$title variable which is page title";                  $text  = "Your include file should define \$text variable which holds this text and \$title variable which is page title";
1959                  $title = "You should define \$title variable with page title";                  $title = "You should define \$title variable with page title";
1960                  include($inc_file);                  include($inc_file);
1961                  StartHTML($title, $text) ;                  StartHTML($title, $text) ;
1962                  print "<p>".GifIcon(up)." Back to <a href=$GLOBALS[PHP_SELF]>front page</a>.</p>";                  print "<p>".GifIcon(up)." Back to <a href=$HTTP_SERVER_VARS[PHP_SELF]>front page</a>.</p>";
1963                  EndHTML() ;                  EndHTML() ;
1964                  exit ;                  exit ;
1965          }          }
# Line 1803  print " return: $return<br>\n"; Line 1968  print " return: $return<br>\n";
1968          Navigate($gblFsRoot,$relDir) ;            Navigate($gblFsRoot,$relDir) ;  
1969          exit ;          exit ;
1970    
1971          Error("Whooah!","By cartesian logic, this never happens") ;          Error("Whooah!","By cartesian logic, this never happens",1) ;
1972  ?>  ?>

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.22

  ViewVC Help
Powered by ViewVC 1.1.26