/[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.36 by dpavlin, Wed Apr 9 16:50:02 2003 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 74  Line 74 
74  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
75    
76          $gblTitle = "Document Manager";          $gblTitle = "Document Manager";
77          $gblVersion = "2.0-pre1";          $gblVersion = "2.0-pre2";
78    
79          $secHash    = "";          $secHash    = "";
80    
81          // location of html files          // location of html files
82          $html = $gblIncDir."/html";          $html = $gblIncDir."/html";
83    
84          LoadLanguage($HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"]);          if (isset($HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"])) {
85                    LoadLanguage($HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"]);
86            }
87    
88          // for security and configuration          // for security and configuration
89          $realm="$HTTP_HOST";    // FIX          $realm=$HTTP_SERVER_VARS["HTTP_HOST"];
90    
91          $fsDocumentRoot = dirname($HTTP_SERVER_VARS[SCRIPT_FILENAME]);          $fsDocumentRoot = dirname($HTTP_SERVER_VARS["SCRIPT_FILENAME"]);
92          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);
93    
94          // globals for later          // globals for later
95          $gblLogin = $PHP_AUTH_USER;          $gblLogin = HTTP_SERVER_VAR("PHP_AUTH_USER");
96          $gblPasswd = $PHP_AUTH_PW;          $gblPasswd = HTTP_SERVER_VAR("PHP_AUTH_PW");
97    
98  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
99    
# Line 109  function LoadLanguage($lang) { Line 111  function LoadLanguage($lang) {
111    
112  function StartHTML($title,$text="") {  function StartHTML($title,$text="") {
113    
114          global $html,$fsDocumentRoot;          global $html,$fsDocumentRoot,$gblTitle,$HTTP_SERVER_VARS;
115    
116          $title = $gblTitle." ".$title ;          $host  = $HTTP_SERVER_VARS["HTTP_HOST"] ;
117          $host  = $GLOBALS["HTTP_HOST"] ;          $self  = $HTTP_SERVER_VARS["PHP_SELF"] ;
         $self  = $GLOBALS["PHP_SELF"] ;  
118    
119          if (file_exists("$fsDocumentRoot/docman.css")) {          if (file_exists("$fsDocumentRoot/docman.css")) {
120                  $css=dirname($self)."/docman.css";                  $css=dirname($self)."/docman.css";
121          } else {          } else {
122                  $css=$self."?STYLE=get&css=$css";                  $css=$self."?STYLE=get";
123          }          }
124    
125          include("$html/head.html");          include("$html/head.html");
# Line 138  function EndHTML() { Line 139  function EndHTML() {
139          } else {          } else {
140                  $url .= md5($gblLogin.$gblPasswd);                  $url .= md5($gblLogin.$gblPasswd);
141          }          }
142          if (isset($gblLogin) && $gblLogin != "" && ($gblPasswd == "" || !isset($gblPasswd))) {          if ( (  (isset($gblLogin) && $gblLogin != "") ||
143                    (!isset($gblLogin) || $gblLogin == "")
144                 ) && ($gblPasswd == "" || !isset($gblPasswd))) {
145                  $url_title="login";                  $url_title="login";
146                  $url .= "&force_login=1";                  $url .= "&force_login=1";
147          } else {          } else {
148                  $url_title="relogin";                  $url_title="relogin";
149          }          }
150          include("$html/footer.html");          include("$html/footer.html");
151          //phpinfo();  
152    #       global $debug;
153    #       if ($debug) print $debug;
154  } // end function EndHTML  } // end function EndHTML
155    
156  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
157    
158  function DetailPage($fsRoot,$relDir,$fn) {  function DetailPage($fsRoot,$relDir,$fn) {
159                    
160          global $gblEditable, $gblImages, $webRoot, $html ;          global $gblEditable, $gblImages,
161          $self = $GLOBALS["PHP_SELF"] ;                  $gblDateFmt, $gblTimeFmt,
162                    $gblPermNote,
163                    $webRoot, $html,
164                    $HTTP_SERVER_VARS ;
165            $self = $HTTP_SERVER_VARS["PHP_SELF"] ;
166    
167          $relPath  = $relDir . "/" . $fn ;          $relPath  = $relDir . "/" . $fn ;
168          $fsPath   = $fsRoot . $relPath ;          $fsPath   = $fsRoot . $relPath ;
# Line 161  function DetailPage($fsRoot,$relDir,$fn) Line 170  function DetailPage($fsRoot,$relDir,$fn)
170    
171          $exists   = file_exists($fsPath) ;          $exists   = file_exists($fsPath) ;
172          $ext      = strtolower(strrchr($relPath,".")) ;          $ext      = strtolower(strrchr($relPath,".")) ;
173          $editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) ;          $editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) &&
174          $writable = is_writeable($fsPath) ;                  check_perm($relPath,trperm_w);
175            $writable = is_writeable($fsPath) && check_perm($relPath,trperm_w) ;
176            $writable_dir = is_writeable($fsDir) && check_perm($relDir,trperm_w) ;
177          $file_lock = CheckLock($fsPath);          $file_lock = CheckLock($fsPath);
178    
179          if (!$editable && !$exists)          if (!$editable && !$exists)
180                  Error(_("Creation unsupported for type"),$relPath) ;                  Error("Creation denied","Can't create <tt>$relPath</tt>") ;
181          if (!exists && !is_writeable($fsDir) )          if (!$exists && !$writable_dir )
182                  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);
183    
184          $text  = _("Use this page to view, modify or ") ;          $text  = _("Use this page to view, modify or ") ;
185          if (is_dir($fsPath)) {          if (is_dir($fsPath)) {
# Line 180  function DetailPage($fsRoot,$relDir,$fn) Line 191  function DetailPage($fsRoot,$relDir,$fn)
191          $title = "("._("Detail Page").")" ;          $title = "("._("Detail Page").")" ;
192          StartHTML($title, $text) ;          StartHTML($title, $text) ;
193    
194          echo "<H3>" . $relDir . "/" . $fn . "</H3>" ;          print "<H3>".$relDir.$fn."</H3>";
195    
196          if ($exists) {  // get file info          if ($exists) {  // get file info
197                  $fsize = filesize($fsPath) ;                  $fsize = filesize($fsPath) ;
198                  $fmodified = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", filemtime($fsPath)) ;                  $fmodified = date("$gblDateFmt $gblTimeFmt", filemtime($fsPath)) ;
199                  $faccessed = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", fileatime($fsPath)) ;                  $faccessed = date("$gblDateFmt $gblTimeFmt", fileatime($fsPath)) ;
200                  $fuid=fileowner($fsPath);                  $fuid=fileowner($fsPath);
201                  $fgid=filegroup($fsPath);                  $fgid=filegroup($fsPath);
202                  $userinfo = posix_getpwuid($fuid);                  $userinfo = posix_getpwuid($fuid);
# Line 199  function DetailPage($fsRoot,$relDir,$fn) Line 211  function DetailPage($fsRoot,$relDir,$fn)
211                  $fstr = fread($fh,filesize($fsPath)) ;                  $fstr = fread($fh,filesize($fsPath)) ;
212                  fclose($fh) ;                  fclose($fh) ;
213                  $fstr = htmlentities( $fstr ) ;                  $fstr = htmlentities( $fstr ) ;
 ?>  
214    
215  <FORM ACTION="<?= $self ; ?>" METHOD="POST">                  include("$html/DetailPage-edit.html");
 <SPAN TITLE="Click [SAVE] to store updated contents.">  
         <B>DOCUMENT CONTENTS</B>  
 </SPAN><BR>  
 <TEXTAREA NAME="FILEDATA" ROWS=18 COLS=70 WRAP="OFF"><?php  
 echo($fstr) ; ?></TEXTAREA>  
 <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ; ?>">  
 <INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?= $fn ; ?>">  
 <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="SAVE">  
 <INPUT TYPE="HIDDEN" SIZE=48 MAXLENGTH=255 NAME="RELPATH"  
         VALUE="<?= $relPath ; ?>">  
 <br>  
 <INPUT TYPE="RESET" VALUE="UNDO ALL CHANGES">  
 <INPUT TYPE="SUBMIT" VALUE="SAVE">  
 </FORM>  
   
 <?php  
216          }          }
217          if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) {            if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) {  
218                  $info  = getimagesize($fsPath) ;                  $info  = getimagesize($fsPath) ;
219                  $tstr = "<IMG SRC=\"$webRoot".urlpath($relPath)."\" BORDER=0 " ;                  $tstr = "<IMG SRC=\"$self?A=V&D=".urlpath(dirname($relPath))."&F=".urlpath(basename($relPath))."\" BORDER=0 " ;
220                  $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;                  $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;
221                  $tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ;                  $tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ;
222  //              echo htmlentities($tstr) . "<BR><BR>" . $tstr ;  //              echo htmlentities($tstr) . "<BR><BR>" . $tstr ;
223                  echo $tstr ;                  echo $tstr ;
224          }          }
225    
 ?>  
   
 <FORM ACTION="<?= $self ; ?>" METHOD="POST">  
 <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ; ?>">  
 <INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?= $fn ; ?>">  
 <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR>  
226    
227  <?php          print '<FORM ACTION="'.$self.'" METHOD="POST">
228                    <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="'.$relDir.'">
229                    <INPUT TYPE="HIDDEN" NAME="FN" VALUE="'.$fn.'">
230                    <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR>
231                    ';
232    
233          if ($file_lock) {          if ($file_lock && check_perm($relDir.$fn,trperm_w)) {
234  ?>                  include("$html/DetailPage-unlock.html");
 <hr>  
 <SPAN TITLE="Check OK and click UNLOCK to remove lock on file.">  
 <B>OK TO FORCE LOCK REMOVAL ON "<?= $fn ; ?>" HELD BY <?= $file_lock ?>? </B></SPAN>  
 <INPUT TYPE="CHECKBOX" NAME="CONFIRM">  
 <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="UNLOCK">  
 <?  
235          } // file_lock          } // file_lock
236    
237          if (substr($fn,0,4) == ".del") {          if (substr($fn,0,4) == ".del") {
# Line 256  echo($fstr) ; ?></TEXTAREA> Line 243  echo($fstr) ; ?></TEXTAREA>
243          }          }
244    
245          if ($exists && $writable) {          if ($exists && $writable) {
246  ?>                  include("$html/DetailPage-undelete.html");
247                    include("$html/DetailPage-rename.html");
 <HR>  
 <a name="undelete">  
 <SPAN TITLE="Check OK and click [<?= $action ?>] to <?= $desc ?>.">  
 <B>OK TO <?= $action ?> "<?= $fn ; ?>"? </B></SPAN>  
 <INPUT TYPE="CHECKBOX" NAME="CONFIRM">  
 <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="<?= $action ?>">  
   
 <HR>  
 <a name="rename">  
 <SPAN TITLE="Check OK and click [RENAME] to rename.">  
 <B>OK TO RENAME "<?= $fn ; ?>" TO  
 <INPUT TYPE="TEXT" SIZE=24 MAXLENGTH=255 NAME="NEWNAME" VALUE="<?= $fn ?>">  
 ? </B></SPAN>  
 <INPUT TYPE="CHECKBOX" NAME="CONFIRM">  
 <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="RENAME">  
248    
249  <?php          }
250          }       // exists && writable          
251  ?>          if (check_perm($relDir.$fn,$gblPermNote)) {
252  <HR>                  include("$html/DetailPage-note.html");
253  <a name="note">          }
 <B>NOTE FOR "<?= $fn ; ?>":  
 <INPUT TYPE="TEXT" SIZE=50 MAXLENGTH=255 NAME="NOTE" VALUE="<?= ReadNote($fsPath) ?>">  
 </B></SPAN>  
 <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="NOTE">  
   
 </FORM>  
254    
255  <?php          print "</FORM>";
256    
257          $name=basename("$fsDir/$fn");          $name=basename("$fsDir/$fn");
258          $logname=dirname("$fsDir/$fn")."/.log/$name";          $logname=dirname("$fsDir/$fn")."/.log/$name";
# Line 472  function MockIcon($txt) { Line 438  function MockIcon($txt) {
438    
439  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
440    
441  function GifIcon($txt) {  function GifIcon($txt = "") {
442          global $gblIconLocation ;          global $gblIconLocation, $gblImages ;
443    
444          switch (strtolower($txt)) {          switch (strtolower($txt)) {
         case ".bmp" :  
         case ".gif" :  
         case ".jpg" :  
         case ".jpeg":  
         case ".tif" :  
         case ".tiff":  
                 $d = "image2.gif" ;  
                 break ;  
445          case ".doc" :          case ".doc" :
446                  $d = "layout.gif" ;                  $d = "layout.gif" ;
447                  break ;                  break ;
# Line 561  function GifIcon($txt) { Line 519  function GifIcon($txt) {
519                  $d = "quill.gif";                  $d = "quill.gif";
520                  break;                  break;
521          default :          default :
522                  $d = "generic.gif" ;                  if (in_array(strtolower($txt),$gblImages)) {
523                            $d = "image2.gif" ;
524                    } else {
525                            $d = "generic.gif" ;
526                    }
527          }          }
528    
529    
530          return "<IMG SRC=\"$gblIconLocation" . $d . "\" BORDER=0>" ;          return "<IMG SRC=\"$gblIconLocation" . $d . "\" BORDER=0>" ;
531  } // end function GifIcon  } // end function GifIcon
532    
# Line 572  function GifIcon($txt) { Line 535  function GifIcon($txt) {
535  function Navigate($fsRoot,$relDir) {  function Navigate($fsRoot,$relDir) {
536    
537          global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide,          global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide,
538                  $HTTP_GET_VARS, $html;                  $gblIgnoreUnknownFileType, $gblRepositoryDir,
539                    $gblLogin, $gblUserName, $gblDateFmt, $gblTimeFmt,
540                    $gblPermNote,
541                    $fsRealmDir, $realm, $realm_sep,
542                    $html, $realm_config,
543                    $HTTP_GET_VARS, $HTTP_SERVER_VARS;
544            
545            $self     = $HTTP_SERVER_VARS["PHP_SELF"] ;
546    
547          $self     = $GLOBALS["PHP_SELF"] ;          $relDir = chopsl($relDir)."/";
548            $fsDir = $fsRoot.$relDir;       // current directory
549    
550          if ($relDir == "") $relDir = "/";          if (!is_dir($fsDir)) Error("Dir not found","Directory <tt>$relDir<tt> not found on filesystem at <tt>$fsDir</tt>",1) ;
551    
552          $fsDir = $fsRoot.$relDir."/";   // current directory          global $debug;
553            $debug .= "[$gblLogin|$relDir] before >";
554    
555          if (!is_dir($fsDir)) Error("Dir not found",$relDir) ;          if (! check_perm($relDir,trperm_b))
556                    Error("Access denied","User <tt>$gblLogin</tt> tried to access <tt>$relDir</tt> without valid trustee.",1);
557            $debug .= "< afeter";
558    
559          $hide_items=",$gblHide,";          $hide_items=",$gblHide,";
560    
561  #display_all_trustee();          $dirList = array();
562  print "-- $fsDir --";          $fileList = array();
563    
564          // read directory contents          // read directory contents
565          if ( !($dir = @opendir($fsDir)) )          if ( !($dir = @opendir($fsDir)) )
566                  Error("Read Access denied",$relDir) ;                  Error("Read Access denied",$relDir,1) ;
567          while ($item = readdir($dir)) {          while ($item = readdir($dir)) {
 print "$item, ";  
568                  if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") ) continue ;                  if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") ) continue ;
569                  if ((is_dir($fsDir.$item) || is_link ($fsDir.$item)) && check_perm($relDir.$item,trperm_b)) {                  if (is_dir($fsDir.$item) || is_link ($fsDir.$item)) {
570                          $dirList[$item] = $item ;                          if (check_perm($relDir.$item,trperm_b)) {
571                          $dirNote[$item] = ReadNote($fsDir.$item);                                  $dirList[$item] = $item ;
572                  } else if ( is_file($fsDir.$item) && check_perm($relDir.$item,trperm_r) ) {                                  $dirNote[$item] = ReadNote($fsDir.$item);
573                          $fileList[$item] = $item ;                                        }
574                          $fileDate[$item] = filemtime($fsDir.$item) ;                  } else if (is_file($fsDir.$item)) {
575                          $fileSize[$item] = filesize($fsDir.$item) ;                          if (check_perm($relDir.$item,trperm_r)) {
576                          $fileNote[$item] = ReadNote($fsDir.$item);                                  $fileList[$item] = $item ;              
577                                    $fileDate[$item] = filemtime($fsDir.$item) ;
578                                    $fileSize[$item] = filesize($fsDir.$item) ;
579                                    $fileNote[$item] = ReadNote($fsDir.$item);
580                            }
581                  } else {                  } else {
582                    // 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 ;  
583                  }                  }
584          }          }
585          closedir($dir) ;          closedir($dir) ;
586    
587          // scan deleted files          // scan deleted files
588          if ( $GLOBALS[show_deleted] == 1 && ($dir = @opendir("$fsDir/.del")) ) {          if ( HTTP_GET_VAR("show_deleted") == 1 && ($dir = @opendir("$fsDir/.del")) ) {
589                  while ($item = readdir($dir)) {                  while ($item = readdir($dir)) {
590                          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 ;
591                          $fileList[$item] = ".del/$item" ;                                        if (is_file($fsDir.".del/$item")) {
592                          $fileDate[$item] = filemtime($fsDir.".del/$path") ;                                  $fileList[$item] = ".del/$item" ;              
593                          $fileSize[$item] = filesize($fsDir.".del/$path") ;                                  $fileDate[$item] = filemtime($fsDir.".del/$item") ;
594                          $fileNote[$item] = ReadNote($fsDir.".del/$item");                                  $fileSize[$item] = filesize($fsDir.".del/$item") ;
595                                    $fileNote[$item] = ReadNote($fsDir.".del/$item");
596                            } else {
597                                    $dirList[$item] = ".del/$item" ;                
598                                    $dirNote[$item] = ReadNote($fsDir.".del/$item");
599                            }
600                  }                  }
601                  closedir($dir) ;                  closedir($dir) ;
602          }          }
# Line 626  print "$item, "; Line 605  print "$item, ";
605    
606          // start navigation page          // start navigation page
607          $text  = "Use this page to add, delete";          $text  = "Use this page to add, delete";
608          if (! isset($show_deleted)) {          if (! isset($HTTP_GET_VARS["show_deleted"])) {
609                  $text .= ", <a href=$self?D=".urlencode($relDir)."&show_deleted=1>undelete</a>";                  $text .= ", <a href=$self?D=".urlencode($relDir)."&show_deleted=1>undelete</a>";
610          }          }
611          $text .= " or revise files on this web site." ;          $text .= " or revise files on this web site." ;
612          $text .= "<br>Examine list of files <a href=\"$self?A=Ch1\">changed in last day</a> or <a href=\"$self?A=Ch\">all changes</a>.";          $text .= "<br>Examine list of files <a href=\"$self?A=Ch1\">changed in last day</a> or <a href=\"$self?A=Ch\">all changes</a>.";
613          StartHTML("(Navigate)",$text) ;          StartHTML("(Navigate)",$text) ;
614    
615          echo "<TABLE BORDER=0 CELLPADDING=2          print "<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=3 WIDTH=\"100%\">" ;
                 CELLSPACING=3 WIDTH=\"100%\">" ;  
616    
617          // updir bar              // updir (parent) bar  
618          if (chopsl($fsDir) != chopsl($fsRoot)) {          if (chopsl($fsDir) != chopsl($fsRoot)) {
619                  $parent = dirname($relDir) ;                  $parent = dirname($relDir) ;
620                  if ($parent == "") $parent = "/" ;                  if ($parent == "") $parent = "/" ;
# Line 652  print "$item, "; Line 630  print "$item, ";
630                  return $out;                  return $out;
631          }          }
632    
633          $dsort = $HTTP_GET_VARS[dsort];          $dsort = HTTP_GET_VAR("dsort");
634          if (! isset($dsort)) $dsort = "name";   // default directory sort          if (! isset($dsort)) $dsort = "name"; // default directory sort
635    
636          $dsort_arr = array(          $dsort_arr = array(
637                  "name" => array ("rname", "note"),                  "name" => array ("rname", "note"),
# Line 662  print "$item, "; Line 640  print "$item, ";
640                  "rnote" => array ("name", "note")                  "rnote" => array ("name", "note")
641                  );                  );
642    
643          $fsort = $HTTP_GET_VARS[fsort];          $fsort = HTTP_GET_VAR("fsort");
644          if (! isset($fsort)) $fsort = "name";   // default directory sort          if (! isset($fsort)) $fsort = "name"; // default directory sort
645    
646          $fsort_arr = array(          $fsort_arr = array(
647                  "name" => array ("rname", "note", "date", "size"),                  "name" => array ("rname", "note", "date", "size"),
# Line 679  print "$item, "; Line 657  print "$item, ";
657          $D="D=".urlencode($relDir);          $D="D=".urlencode($relDir);
658    
659          function self_args($arr = array()) {          function self_args($arr = array()) {
660                    global $self;
661                  $arg = implode("&",$arr);                  $arg = implode("&",$arr);
662                  if ($arg) {                  if ($arg) {
663                          return $self."?".$arg;                          return $self."?".$arg;
# Line 715  print "$item, "; Line 694  print "$item, ";
694    
695                          $dir = $dirList[$key];                          $dir = $dirList[$key];
696    
697                          $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));
698                          $dir_url=$self."?D=".urlencode($relDir.$dir);                          if (substr($dir,0,5) == ".del/") {
699                                    $dir = substr($dir,5,strlen($dir)-5);
700                                    $deleted = " <a href=\"$info_url#undelete\"><SPAN CLASS=deleted TITLE=\"deleted\">deleted</span></a>";
701                            } else {
702                                    $deleted = "";
703                            }
704            
705                            $dir_url=$self."?D=".urlencode(chopsl($relDir)."/".$dir);
706                            if (check_perm($relDir.$dir,$gblPermNote)) {
707                                    $note_html="<a href=\"$info_url#note\">".$gblIcon("note")."</a>".$dirNote[$key];
708                            } else {
709                                    $note_html=$dirNote[$key];
710                            }
711    
712                            $dir_html = isBlank($dir,"directory");
713    
714                          include("$html/Navigate-dirEntry.html");                          include("$html/Navigate-dirEntry.html");
715    
716                  }  // iterate over dirs                  }  // iterate over dirs
# Line 727  print "$item, "; Line 721  print "$item, ";
721          $uurl = self_args(array($D,"fsort=".$fsort_arr[$fsort][2]));          $uurl = self_args(array($D,"fsort=".$fsort_arr[$fsort][2]));
722          $surl = self_args(array($D,"fsort=".$fsort_arr[$fsort][3]));          $surl = self_args(array($D,"fsort=".$fsort_arr[$fsort][3]));
723    
724            $html_uri = $webRoot;
725    
726            if (substr($relDir,0,1) == "/") {
727                    $html_uri .= substr($relDir,1,strlen($relDir)-1);
728            } else {
729                    $html_uri .= $relDir;
730            }
731    
732          include("$html/Navigate-fileHeader.html");          include("$html/Navigate-fileHeader.html");
733    
734          if (sizeof($fileList) > 0) {          if (sizeof($fileList) > 0) {
# Line 788  print "$item, "; Line 790  print "$item, ";
790    
791                  $file_lock=CheckLock($path);                  $file_lock=CheckLock($path);
792    
793                  $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);  
794                  $file_url_html.="\" TITLE=\"View file\">" ;                  $file_url_html.="\" TITLE=\"View file\">" ;
795    
796                  if (substr($file,0,5) != ".del/") {                  if (substr($file,0,5) != ".del/") {
797                          $file_url_html .= $file . "</A>" . $a ;                          $file_url_html .= isBlank($file) . "</A>" . $a ;
798                  } else {                  } else {
799                          $file_url_html .= substr($file,5,strlen($file)-5) . "</a> <SPAN CLASS=RED TITLE=\"deleted\"> <a href=\"$info_url#undelete\">deleted</a> </span>";                          $file_url_html .= isBlank(substr($file,5,strlen($file)-5)) . "</a> <a href=\"$info_url#undelete\"><SPAN CLASS=deleted TITLE=\"deleted\">deleted</span></a>";
800                  }                  }
801    
802                  $note_html="<a href=\"$info_url#note\">".$gblIcon("note")."</a>".ReadNote($path);                  if (check_perm($relDir.$file,$gblPermNote)) {
803                            $note_html="<a href=\"$info_url#note\">".$gblIcon("note")."</a>".$fileNote[$key];
804                    } else {
805                            $note_html=$fileNote[$key];
806                    }
807    
808                  $ext = strtolower(strrchr($file,".")) ;                  $ext = strtolower(strrchr($file,".")) ;
809    
810                  if ($file_lock) {                  if ($file_lock) {
811                          if ($file_lock == $GLOBALS[gblUserName]) {                          if ($file_lock == $gblUserName) {
812                                  $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);  
813                                  $b.="\" TITLE=\"Checkin (update) file on server\">" ;                                  $b.="\" TITLE=\"Checkin (update) file on server\">" ;
814                                  $file_url_html=$b;                                  $file_url_html=$b;
815                                  $b.=$gblIcon("checkin")."</A>" ;                                  $b.=$gblIcon("checkin")."</A>" ;
# Line 819  print "$item, "; Line 823  print "$item, ";
823                                  $file_url_html = "$file $a";                                  $file_url_html = "$file $a";
824                          }                          }
825                  } else {                  } else {
826                          $b.="<A HREF=\"$self?A=Co&F=".urlencode($file);                          if (check_perm($relDir.$file,trperm_w)) {
827                          $b.="&D=".urlencode($relDir);                                  $b.="<A HREF=\"$self?A=Co&D=".urlencode($relDir)."&F=".urlencode($file);
828                          $b.="\" TITLE=\"Checkout file for edit\">" ;                                  $b.="\" TITLE=\"Checkout file for edit\">" ;
829                          $b.=$gblIcon("checkout")."</A>" ;                                  $b.=$gblIcon("checkout")."</A>";
830                            }
831    
832                          if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) {                            if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) {  
833                                  $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);  
834                                  $b.="\" TITLE=\"List contents\">" ;                                  $b.="\" TITLE=\"List contents\">" ;
835                                  $b.=$gblIcon("view")."</A>" ;                                  $b.=$gblIcon("view")."</A>" ;
836                          } else {                          } else {
# Line 834  print "$item, "; Line 838  print "$item, ";
838                          }                          }
839                  }                  }
840    
841                  $mod = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]",$mod);                  $mod = date("$gblDateFmt $gblTimeFmt",$mod);
842    
843                  include("$html/Navigate-fileEntry.html");                  include("$html/Navigate-fileEntry.html");
844    
845            }  // iterate over files            }  // iterate over files
846          } else {  // end if no files          } else {  // end if no files
847  ?>                  include("$html/Navigate-noFiles.html");
  <TR><TD></TD><TD COLSPAN=5 CLASS=LST>  
   No files in this directory  
  </TD></TR>  
 <?  
848          }          }
849    
850          if ($emptyDir && $relDir != "") {          if ($emptyDir && $relDir != "") {
851  ?>                  include("$html/Navigate-emptyDir.html");
   
 <FORM METHOD="POST" ACTION="<?= $self ?>">  
  <TR><TD></TD><TD COLSPAN=5 CLASS=BAR>  
   <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">  
   OK TO DELETE THIS EMPTY FOLDER?  
   <INPUT TYPE="CHECKBOX" NAME="CONFIRM">  
   <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="DELETE">  
  </TD></TR>  
 </FORM>  
   
 <?php  
852          } // end if emptyDir          } // end if emptyDir
 ?>  
853    
854  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>          include("$html/Navigate-hr.html");      
855    
856  <?          if (file_exists("$fsRealmDir/$realm".$realm_sep."info.inc")) {
857  if (file_exists(".info.inc")) {                  print "<TR><TD></TD><TD COLSPAN=5>";
858          print "<TR><TD></TD><TD COLSPAN=5>";                  include("$fsRealmDir/$realm".$realm_sep."info.inc");
859          include(".info.inc");                  print "</TD></TR>";
860          print "</TD></TR>                  include("$html/Navigate-hr.html");      
861          <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>";          } elseif (file_exists("$gblRepositoryDir/.info.inc")) {
862  }                  print "<TR><TD></TD><TD COLSPAN=5>";
863  ?>                  include("$gblRepositoryDir/.info.inc");
864                    print "</TD></TR>";
865                    include("$html/Navigate-hr.html");      
866            }
867    
868            include("$html/Navigate-createNew.html");
869    
870  <FORM METHOD="POST" ACTION="<?= $self ?>">          print "</TABLE>";
 <TR><TD></TD><TD COLSPAN=5 CLASS=BAR>CREATE NEW  
  <INPUT TYPE="RADIO" NAME="T" VALUE="D" CHECKED>DIRECTORY -OR-  
  <INPUT TYPE="RADIO" NAME="T" VALUE="F">FILE : &nbsp;&nbsp;  
  <NOBR>NAME <INPUT TYPE="TEXT" NAME="FN" SIZE=14>  
  <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE">  
  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">  
  <INPUT TYPE="SUBMIT" VALUE="CREATE" NAME="CREATE">  
  </NOBR>  
  <NOBR>OR <A HREF="<?= $self ?>?A=U&D=<?= urlencode($relDir) ?>">UPLOAD</A> A FILE</NOBR>  
 </TD></TR>  
 </FORM>  
 </TABLE>  
871    
 <?php  
872          EndHTML() ;          EndHTML() ;
873  } // end function Navigate  } // end function Navigate
874    
# Line 896  if (file_exists(".info.inc")) { Line 876  if (file_exists(".info.inc")) {
876    
877  function UploadPage($fsRoot, $relDir, $filename="") {  function UploadPage($fsRoot, $relDir, $filename="") {
878    
879          $self = $GLOBALS["PHP_SELF"] ;          global $html, $HTTP_SERVER_VARS;
         if ($relDir == "") $relDir = "/" ;  
 ?>  
880    
881  <P><TABLE BORDER=0 CELLPADDING=5><TR><TD WIDTH=5></TD><TD CLASS=BAR>          $self = $HTTP_SERVER_VARS["PHP_SELF"] ;
882  <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>  
883    
 <?php    
884  } // end function UploadPage  } // end function UploadPage
885    
886  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
887    
888  function Error($title,$text="") {  // Error with sysadmin flag are reported to error_log or hidden from
889          StartHTML("(".$title.")",$text) ;  // users
890          echo "<P ALIGN=center>Hit your Browser's Back Button.</P>" ;  
891          EndHTML() ;  function Error($title,$text="",$sysadmin=0,$no_404=0) {
892            global $gblSeparateAdminMessages,
893                    $gblMailAdminMessages,$realm,
894                    $HTTP_SERVER_VARS;
895            if (! headers_sent() && ! $no_404) header("HTTP/1.0 404 Not Found");
896            if ($sysadmin) {
897                    if ($gblSeparateAdminMessages) {
898                            $user="Your administrator ";
899                            if ($gblMailAdminMessages) {
900                                    mail($HTTP_SERVER_VARS["SERVER_ADMIN"], "docman $realm error message: $title", strip_tags($text));
901                                    $user.="<tt>".$HTTP_SERVER_VARS["SERVER_ADMIN"]."</tt> ";
902                            }
903                            $user.="has been notified about error" ;
904                            StartHTML("($title)",$user);
905                            echo "<P ALIGN=center>Hit your Browser's Back Button.</P>" ;
906                            EndHTML();
907                            error_log("docman $realm: ".strip_tags($text));
908                    } else {
909                            StartHTML("ADMIN: ".$title,$text) ;
910                            echo "<P ALIGN=center>Hit your Browser's Back Button.</P>" ;
911                            EndHTML();
912                    }
913            } else {
914                    StartHTML("(".$title.")",$text) ;
915                    echo "<P ALIGN=center>Hit your Browser's Back Button.</P>" ;
916                    EndHTML() ;
917            }
918          exit ;          exit ;
919  } // end function Error  } // end function Error
920    
921  //////////////////////////////////////////////////////////////////  function LogIt($target,$msg, $changelog=0) {
922    
923  function LogIt($target,$msg) {          global $gblDateFmt, $gblTimeFmt, $gblUserName, $gblFsRoot;
924    
925          $dir=dirname($target);          $dir=dirname($target);
926          if (! file_exists($dir."/.log")) {          if (! file_exists($dir."/.log")) {
927                  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);
928          }          }
929          $file=basename($target);          $file=basename($target);
930    
931          $log=fopen("$dir/.log/$file","a+");          $log=fopen("$dir/.log/$file","a+");
932          fputs($log,date("$GLOBALS[gblDateFmt]\t$GLOBALS[gblTimeFmt]").          fputs($log,date("$gblDateFmt\t$gblTimeFmt").
933                  "\t$GLOBALS[gblUserName]\t$msg\n");                  "\t$gblUserName\t$msg\n");
934          fclose($log);          fclose($log);
935    
936            if (! $changelog) return;
937    
938            $log=fopen("$gblFsRoot/.changelog","a+");
939            if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot)
940                    $target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot));
941            $msg=str_replace("\t"," ",$msg);
942            fputs($log,time()."\t$target\t$gblUserName\t$msg\n");
943            fclose($log);
944    
945            // FIX: implement e-mail notification based on $changelog
946            // permission
947  }  }
948    
949    
# Line 967  function WriteNote($target,$msg) { Line 959  function WriteNote($target,$msg) {
959          $file=basename($target);          $file=basename($target);
960    
961          $note=fopen("$dir/.note/$file","w");          $note=fopen("$dir/.note/$file","w");
962            if (! $note) {
963                    Error("Error writing note","Can't open note file <tt>$dir/.note/$file</tt> for writing",1);
964            }
965          fputs($note,"$msg\n");          fputs($note,"$msg\n");
966          fclose($note);          fclose($note);
967    
968          Logit($target,"added note $msg");          LogIt($target,"added note $msg");
969    
970  }  }
971    
# Line 1007  function MoveTo($source,$folder) { Line 1002  function MoveTo($source,$folder) {
1002    
1003  function Lock($target) {  function Lock($target) {
1004    
1005            global $gblUserName;
1006    
1007          $target=stripSlashes($target);          $target=stripSlashes($target);
1008          $dir=dirname($target);          $dir=dirname($target);
1009          if (! file_exists($dir."/.lock")) {          if (! file_exists($dir."/.lock")) {
# Line 1015  function Lock($target) { Line 1012  function Lock($target) {
1012          $file=basename($target);          $file=basename($target);
1013    
1014          if (file_exists("$dir/.lock/$file")) {          if (file_exists("$dir/.lock/$file")) {
1015                  Logit($target,"attempt to locked allready locked file!");                  LogIt($target,"attempt to locked allready locked file!");
1016          } else {          } else {
1017                  $lock=fopen("$dir/.lock/$file","w");                  $lock=fopen("$dir/.lock/$file","w");
1018                  fputs($lock,"$GLOBALS[gblUserName]\n");                  fputs($lock,"$gblUserName\n");
1019                  fclose($lock);                  fclose($lock);
1020    
1021                  Logit($target,"file locked");                  LogIt($target,"file locked");
1022          }          }
1023    
1024  }  }
# Line 1048  function Unlock($target) { Line 1045  function Unlock($target) {
1045          $file=basename($target);          $file=basename($target);
1046          if (file_exists($dir."/.lock/$file")) {          if (file_exists($dir."/.lock/$file")) {
1047                  unlink("$dir/.lock/$file");                  unlink("$dir/.lock/$file");
1048                  Logit($target,"file unlocked");                  LogIt($target,"file unlocked");
1049          } else {          } else {
1050                  Logit($target,"attempt to unlocked non-locked file!");                  LogIt($target,"attempt to unlocked non-locked file!");
1051          }          }
1052    
1053  }  }
# Line 1067  function urlpath($url) { Line 1064  function urlpath($url) {
1064  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1065    
1066  function safe_rename($fromdir,$fromfile,$tofile) {  function safe_rename($fromdir,$fromfile,$tofile) {
1067    
1068            global $gblNumBackups;
1069    
1070          function try_rename($from,$to) {          function try_rename($from,$to) {
1071  #               print "$from -> $to\n";  #               print "$from -> $to\n";
1072                  if (file_exists($from) && is_writeable(dirname($to))) {                  if (file_exists($from) && is_writeable(dirname($to))) {
1073                          rename($from,$to);                          return rename($from,$to);
1074                    } else {
1075                            return 0;
1076                  }                  }
1077          }          }
1078    
1079          function try_dir($todir) {          function try_dir($todir) {
1080                  if (! file_exists($todir)) {                  if (! file_exists($todir)) {
1081                          mkdir($todir,0700);                          @mkdir($todir,0700);
1082                  }                  }
1083          }          }
1084    
# Line 1086  function safe_rename($fromdir,$fromfile, Line 1088  function safe_rename($fromdir,$fromfile,
1088    
1089  #       print "<pre>$fromdir / $fromfile -> $todir / $tofile\n\n";  #       print "<pre>$fromdir / $fromfile -> $todir / $tofile\n\n";
1090    
1091          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);
1092          try_dir("$todir/.log");          try_dir("$todir/.log");
1093          try_rename("$fromdir/.log/$fromfile","$todir/.log/$tofile");          try_rename("$fromdir/.log/$fromfile","$todir/.log/$tofile");
1094          try_dir("$todir/.note");          try_dir("$todir/.note");
# Line 1094  function safe_rename($fromdir,$fromfile, Line 1096  function safe_rename($fromdir,$fromfile,
1096          try_dir("$todir/.lock");          try_dir("$todir/.lock");
1097          try_rename("$fromdir/.lock/$fromfile","$todir/.lock/$tofile");          try_rename("$fromdir/.lock/$fromfile","$todir/.lock/$tofile");
1098          try_dir("$todir/.bak");          try_dir("$todir/.bak");
1099          for($i=0;$i<=$GLOBALS[gblNumBackups];$i++) {          for($i=0;$i<=$gblNumBackups;$i++) {
1100                  try_rename("$fromdir/.bak/$i/$fromfile","$todir/.bak/$i/$tofile");                  try_rename("$fromdir/.bak/$i/$fromfile","$todir/.bak/$i/$tofile");
1101          }          }
1102  }  }
# Line 1120  function rrmdir($dir) { Line 1122  function rrmdir($dir) {
1122    
1123  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1124    
1125  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);  
1126    
1127  }          global $gblFsRoot, $gblDateFmt, $gblTimeFmt,
1128                    $HTTP_SERVER_VARS;
1129    
1130  function DisplayChangeLog($day) {          $self  = $HTTP_SERVER_VARS["PHP_SELF"];
1131    
         global $gblFsRoot;  
1132          if (!file_exists("$gblFsRoot/.changelog")) return;          if (!file_exists("$gblFsRoot/.changelog")) return;
1133          $log=fopen("$gblFsRoot/.changelog","r");          $log=fopen("$gblFsRoot/.changelog","r");
1134          $logarr = array();          $logarr = array();
# Line 1152  function DisplayChangeLog($day) { Line 1146  function DisplayChangeLog($day) {
1146          print "<table border=0 width=100%>\n";          print "<table border=0 width=100%>\n";
1147          while ($e = array_shift($logarr)) {          while ($e = array_shift($logarr)) {
1148                  $cl=$cl1; $cl1=$cl2; $cl2=$cl;                  $cl=$cl1; $cl1=$cl2; $cl2=$cl;
1149                  $date = date("$GLOBALS[gblDateFmt]", $e[0]);                  $date = date($gblDateFmt, $e[0]);
1150                  $time = date("$GLOBALS[gblTimeFmt]", $e[0]);                  $time = date($gblTimeFmt, $e[0]);
1151                  $dir = dirname($e[1]);                  $dir = dirname($e[1]);
1152                  $file = basename($e[1]);                  $file = basename($e[1]);
1153                  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";
1154          }          }
1155          print "</table>";          print "</table>";
1156          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>";
1157  }  }
1158    
1159  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1160    
1161  function Download($path) {  function Download($path,$force=0) {
1162          global $HTTP_USER_AGENT;          global $HTTP_SERVER_VARS,$mime_type;
1163          $file=basename($path);  
1164            // default transfer-encoding
1165            $encoding = "binary";
1166    
1167            // known transfer encodings
1168            $encoding_ext = array(
1169                    "gz" => "x-gzip",
1170                    "Z" => "x-compress",
1171            );
1172    
1173            $file = basename($path);
1174          $size = filesize($path);          $size = filesize($path);
1175          //header("Content-Type: application/octet-stream");  
1176          header("Content-Type: application/force-download");          $ext_arr = explode(".",$file);
1177          header("Content-Length: $size");          $ext = array_pop($ext_arr);
1178            if (isset($encoding_ext[$ext])) {
1179                    $encoding = $encoding_ext[$ext];
1180                    $ext = array_pop($ext_arr);
1181            }
1182    
1183            if ($force || !isset($mime_type[$ext])) {
1184                    header("Content-Type: application/force-download");
1185            } else {
1186                    header("Content-Type: $mime_type[$ext]");
1187            }
1188    
1189          // IE5.5 just downloads index.php if we don't do this          // IE5.5 just downloads index.php if we don't do this
1190          if(preg_match("/MSIE 5.5/", $HTTP_USER_AGENT)) {          if(preg_match("/MSIE 5.5/", $HTTP_SERVER_VARS["HTTP_USER_AGENT"])) {
1191                  header("Content-Disposition: filename=$file");                  header("Content-Disposition: filename=$file");
1192          } else {          } else {
1193                  header("Content-Disposition: attachment; filename=$file");                  header("Content-Disposition: attachment; filename=$file");
1194          }          }
1195          header("Content-Transfer-Encoding: binary");  
1196            header("Content-Transfer-Encoding: $encoding");
1197          $fh = fopen($path, "r");          $fh = fopen($path, "r");
1198          fpassthru($fh);          fpassthru($fh);
1199  }  }
# Line 1186  function Download($path) { Line 1202  function Download($path) {
1202  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1203    
1204  function chopsl($path) {  function chopsl($path) {
         if (substr($path,strlen($path)-1,1) == "/") $path=substr($path,0,strlen($path)-1);  
1205          $path=str_replace("//","/",$path);          $path=str_replace("//","/",$path);
1206            if (substr($path,strlen($path)-1,1) == "/") $path=substr($path,0,strlen($path)-1);
1207          return $path;          return $path;
1208  }  }
1209    
# Line 1201  function chopsl($path) { Line 1217  function chopsl($path) {
1217          by Vyacheslav Zavadsky <zavadsky@braysystems.com>          by Vyacheslav Zavadsky <zavadsky@braysystems.com>
1218  */  */
1219    
1220  define(trmask_not,1 << 0);  define('trmask_not',1 << 0);
1221  define(trmask_clear,1 << 1);  define('trmask_clear',1 << 1);
1222  define(trmask_deny,1 << 2);  define('trmask_deny',1 << 2);
1223  define(trmask_one_level,1 << 3);  define('trmask_one_level',1 << 3);
1224  define(trmask_group,1 << 4);  define('trmask_group',1 << 4);
1225    
1226  define(trperm_r,1 << 5);  define('trperm_r',1 << 5);
1227  define(trperm_w,1 << 6);  define('trperm_w',1 << 6);
1228  define(trperm_b,1 << 7);  define('trperm_b',1 << 7);
1229  define(trperm_n,1 << 8);  define('trperm_n',1 << 8);
1230    
1231  $trustee_a2n = array(  $trustee_a2n = array(
1232          '!' => trmask_not,          '!' => trmask_not,
# Line 1258  if (! file_exists($trustee_conf)) { Line 1274  if (! file_exists($trustee_conf)) {
1274          $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";
1275  } elseif (file_exists($trustee_php) && !is_writable($trustee_php)) {  } elseif (file_exists($trustee_php) && !is_writable($trustee_php)) {
1276          $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";
1277  } elseif (1 || filemtime($trustee_conf) >= filemtime($trustee_php)) {  } elseif (@filemtime($trustee_conf) >= @filemtime($trustee_php)) {
1278          $fp_php=@fopen($trustee_php,"w");          $fp_php=@fopen($trustee_php,"w");
1279          fputs($fp_php,"<?php // don't edit by hand!\n");          fputs($fp_php,"<?php // don't edit by hand!\n");
1280    
# Line 1267  if (! file_exists($trustee_conf)) { Line 1283  if (! file_exists($trustee_conf)) {
1283          $groups_arr = array();          $groups_arr = array();
1284          $perm_arr = array();          $perm_arr = array();
1285    
         $error=0;  
   
1286          $tr_arr = array();          $tr_arr = array();
1287    
1288          while (! feof($fp_conf)) {          while (! feof($fp_conf)) {
1289                  $l = trim(fgets($fp_conf,4096));                  $l = trim(fgets($fp_conf,4096));
1290                  if (substr($l,0,1) == "+") {    // no comment                  if (substr($l,0,1) == "+") {    // no comment
1291                          $arr=explode(":",$l);                          $arr=explode(":",$l);
1292                          $groups_arr[$arr[0]] = $arr[1] ;                          $groups_arr[$arr[0]] = str_replace(" ","",$arr[1]) ;
1293                  } elseif (substr($l,0,1) != "#") {                  } elseif (substr($l,0,1) != "#") {
1294                          $arr=explode(":",$l);                          $arr=explode(":",$l);
1295                          $path=array_shift($arr);                          $path=array_shift($arr);
# Line 1296  if (! file_exists($trustee_conf)) { Line 1310  if (! file_exists($trustee_conf)) {
1310                                                  $error.="trustee error in line '$l' [Unknown modifier '$ch']<br>\n";                                                  $error.="trustee error in line '$l' [Unknown modifier '$ch']<br>\n";
1311                                          }                                          }
1312                                  }                                  }
1313                                  $tr_arr[$path][$user] |= $perm;                                  if (isset($tr_arr[$path][$user])) {
1314                                            $tr_arr[$path][$user] |= $perm;
1315                                    } else {
1316                                            $tr_arr[$path][$user] = $perm;
1317                                    }
1318                          }                          }
1319                  }                  }
1320          }          }
# Line 1335  if (! file_exists($trustee_conf)) { Line 1353  if (! file_exists($trustee_conf)) {
1353          fclose($fp_php);          fclose($fp_php);
1354  }  }
1355    
1356  if ($error) {  if (isset($error)) {
1357          Error("Trustee error",$error);          Error("Trustee error",$error,1);
1358  } else {  } else {
1359          include("$trustee_php");          include_once("$trustee_php");
1360  }  }
1361    
1362  return 1;  return 1;
# Line 1346  return 1; Line 1364  return 1;
1364  }//init_trustee  }//init_trustee
1365    
1366  function in_group($user,$group) {  function in_group($user,$group) {
1367          return in_array($groups[$group],$user);          global $groups;
1368            return in_array($user,$groups[$group]);
1369  }  }
1370    
1371  // helper function  // helper function
1372  function unroll_perm($u,$t,$user,$perm) {  function unroll_perm($u,$t,$perm,$one_level) {
1373          // check user  
1374          if ($t & trmask_not && ($u==$user)) continue;          if ($t & trmask_one_level && !$one_level) return $perm;
         if (!($t & trmask_not) && ($u!=$user)) continue;  
1375    
1376          if ($t & trmask_deny) {          if ($t & trmask_deny) {
1377                  if ($t & trmask_clear) {                  if ($t & trmask_clear) {
1378                          $perm[deny] &= ~$t;                          $perm['deny'] &= ~$t;
1379                  } else {                  } else {
1380                          $perm[deny] |= $t;                          $perm['deny'] |= $t;
1381                  }                  }
1382          } elseif ($t & trmask_clear) {          } elseif ($t & trmask_clear) {
1383                  $perm[allow] &= ~$t;                  $perm['allow'] &= ~$t;
1384          } else {          } else {
1385                  $perm[allow] |= $t;                  $perm['allow'] |= $t;
1386          }          }
1387          return $perm;          return $perm;
1388  }// end of helper function  }// end of helper function
1389    
1390  function check_trustee($user,$path) {  function check_trustee($user,$path) {
1391          global $trustees;          global $trustees,$HAVE_TRUSTEE;
1392          $perm[allow] = 0;          $perm['allow'] = 0;
1393          $perm[deny] = 0;          $perm['deny'] = 0;
1394    
1395            // do we use trustees?
1396            if (! $HAVE_TRUSTEE) return $perm;
1397    
1398            if (! isset($trustees)) Error("Trustees not found","Can't find in-memory trustee structure <tt>\$trustees</tt>. Probably bug in code. Contact <tt>dpavlin@rot13.org</tt>",1);
1399    
1400    global $debug;
1401    $debug .= "<br>check_trustee $path ... ";
1402    
1403          $path_arr=explode("/",$path);          $path_arr=explode("/",$path);
1404          $path = "/";          $tmppath = "/";
1405          while (count($path_arr)) {          while (count($path_arr)) {
1406                  if (substr($path,strlen($path)-1,1) != "/") $path.="/";                  $tmppath.=array_shift($path_arr);
1407                  $path.=array_shift($path_arr);  $debug.= ">> $tmppath ";
1408                  $tr = $trustees[$path];  
1409                    if (! isset($trustees[$tmppath])) continue;
1410                    $tr = $trustees[$tmppath];
1411    
1412                    $one_level = (!count($path_arr));
1413    $debug.=" O($one_level) ";
1414    
1415                  if (isset($tr)) {                  if (isset($tr)) {
1416                          // first apply trustee for all                          // first apply trustee for all
1417                          if (isset($tr['*'])) {                          if (isset($tr['*']) && $user!="anonymous") {
1418                                  $perm = unroll_perm($user,$tr['*'],$user, $perm);                                  $perm = unroll_perm($user,$tr['*'],$perm, $one_level);
1419                                  unset($tr['*']);                                  unset($tr['*']);
1420                          }                          }
1421                          // then apply group policies                          // then apply not and group policies
1422                          foreach ($tr as $u=>$t) {                          foreach ($tr as $g=>$t) {
1423                                  if ($t & trmask_group && in_group($user,$u)) {                                  if ($t & trmask_not && $g != $user) {
1424                                            $t = $t & ~trmask_not;
1425                                            $perm = unroll_perm($user,$t,$perm, $one_level);
1426                                            unset($tr[$g]);
1427    
1428                                    } elseif ($t & trmask_group && in_group($user,$g)) {
1429                                          // resolv user                                          // resolv user
1430                                          $t = $t & ~trmask_group;                                          $t = $t & ~trmask_group;
1431                                          $u = $user;                                          $perm = unroll_perm($user,$t,$perm, $one_level);
1432                                          $perm = unroll_perm($u,$t,$user, $perm);                                          unset($tr[$g]);
                                         unset($tr[$u]);  
1433                                  }                                  }
1434                          }                          }
1435                          // then apply use policy                          // then apply user policy
1436                          if (isset($tr[$user])) {                          if (isset($tr[$user])) {
1437                                  $perm = unroll_perm($user,$tr[$user],$user, $perm);                                  $perm = unroll_perm($user,$tr[$user],$perm,$one_level);
1438                                  unset($tr[$user]);                                  unset($tr[$user]);
1439                          }                          }
   
1440                  }                  }
1441    $debug.="d(".display_trustee($perm['deny']).") a(".display_trustee($perm['allow']).") ";
1442    
1443          }          }
1444  #print "<br>user: $user path: $path perm: ";  $debug.="<br>check_trustee: user: $user path: $path==$tmppath perm: ";
1445  #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";
1446          return $perm;          return $perm;
1447  }  }
1448    
# Line 1414  function check_trustee($user,$path) { Line 1450  function check_trustee($user,$path) {
1450    
1451  function check_perm($path,$trperm) {  function check_perm($path,$trperm) {
1452          global $gblLogin,$HAVE_TRUSTEE;          global $gblLogin,$HAVE_TRUSTEE;
1453  print "<br>check_perm: <tt>$path</tt> test perm ".display_trustee($perm)."<br>\n";  
1454            $path = str_replace("//","/",$path);
1455    
1456            global $debug;
1457    $debug.="<br>check_perm: on <tt>$path</tt> for perm ".display_trustee($trperm)."<br>\n";
1458    
1459          $return = ! $HAVE_TRUSTEE;          $return = ! $HAVE_TRUSTEE;
1460          if ($HAVE_TRUSTEE) {          if ($HAVE_TRUSTEE) {
1461                  $perm = check_trustee($gblLogin,$path);                  $perm = check_trustee($gblLogin,$path);
1462  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).")";
1463                  if ($perm[deny] & $trperm) $return=0;                  if ($perm['deny'] & $trperm) $return=0;
1464                  elseif ($perm[allow] & $trperm) $return=1;                  elseif (($perm['allow'] & $trperm) == $trperm) $return=1;
1465          }          }
1466  print " return: $return<br>\n";  $debug.=" return: $return<br>\n";
1467          return($return);          return($return);
1468  }  }
1469    
1470    //////////////////////////////////////////////////////////////////
1471    
1472    function readMime() {
1473            global $mime_type;
1474    
1475            if (! isset($gblMimeTypes)) {
1476                    $gblMimeTypes = "/etc/mime.types";
1477            }
1478    
1479            $mime = @fopen($gblMimeTypes,"r");
1480    
1481            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>");
1482    
1483            while($line = fgets($mime,80)) {
1484                    if (substr($line,0,1) == "#") continue; // skip comment
1485                    $arr = preg_split("/[\s\t]+/",$line);
1486                    $type = array_shift($arr);
1487                    while ($ext = array_shift($arr)) {
1488                            $mime_type[$ext] = $type;
1489                    }
1490            }
1491    
1492            fclose($mime);
1493    }
1494    
1495    //////////////////////////////////////////////////////////////////
1496    
1497    // check for invalid characters in filename and dirname (.. and /)
1498    
1499    function check_dirname($file) {
1500            if (strstr($file,"..")) Error("Security violation","No parent dir <tt>..</tt> allowed in directory name <tt>$file</tt>",1);
1501    }
1502    
1503    function check_filename($file) {
1504            if (strstr($file,"..")) Error("Security violation","No parent dir <tt>..</tt> allowed in file name <tt>$file</tt>",1);
1505            // remove deleted directory (for undelete to work)
1506            $file = str_replace(".del/","",$file);
1507            if (strstr($file,"/")) Error("Security violation","No slashes <tt>/</tt> allowed in file name <tt>$file</tt>",1);
1508    }
1509    
1510    // bla/blo/../foo will return bla/foo
1511    function remove_parent($path) {
1512            while (preg_match(",/[^/]+/\.\./,",$path)) {
1513                    $path = preg_replace(",/[^/]+/\.\./,","",$path);
1514            }
1515            if (substr($path,0,1) != "/") $path = "/".$path;
1516            return $path;
1517    }
1518    
1519    //////////////////////////////////////////////////////////////////
1520    
1521    // functions to move HTTP server variables to global namespace
1522    // [replacement for register_globals in php.ini]
1523    
1524    function HTTP_GET_VAR($var) {
1525            global $HTTP_GET_VARS, ${$var};
1526            if (isset($HTTP_GET_VARS[$var])) {
1527                    $$var = stripSlashes($HTTP_GET_VARS[$var]);
1528                    return $$var;
1529            }
1530    }
1531    
1532    function HTTP_POST_VAR($var) {
1533            global $HTTP_POST_VARS, ${$var};
1534            if (isset($HTTP_POST_VARS[$var])) {
1535                    $$var = $HTTP_POST_VARS[$var];
1536                    return $$var;
1537            }
1538    }
1539    
1540    function HTTP_SERVER_VAR($var) {
1541            global $HTTP_SERVER_VARS, ${$var};
1542            if (isset($HTTP_SERVER_VARS[$var])) {
1543                    $$var = $HTTP_SERVER_VARS[$var];
1544                    return $$var;
1545            }
1546    }
1547    
1548    //////////////////////////////////////////////////////////////////
1549    
1550    function Warn($text) {
1551    }
1552    
1553    //////////////////////////////////////////////////////////////////
1554    
1555    function isBlank($file,$what = "filename") {
1556            if (trim($file) == "") return "<i>whitespace $what</i>";
1557            if ($file == "") return "<i>no $what</i>";
1558            return $file;
1559    }
1560    
1561  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1562  // MAIN PROGRAM  // MAIN PROGRAM
# Line 1433  print " return: $return<br>\n"; Line 1564  print " return: $return<br>\n";
1564          $gblFilePerms = 0640 ;         // default for new files          $gblFilePerms = 0640 ;         // default for new files
1565          $gblDirPerms  = 0750 ;          // default for new dirs          $gblDirPerms  = 0750 ;          // default for new dirs
1566    
1567          if (isset($STYLE) && $STYLE == "get") {          if (isset($HTTP_GET_VARS["STYLE"]) && $HTTP_GET_VARS["STYLE"] == "get") {
1568                  include("$html/docman.css");                  include("$html/docman.css");
1569                  exit;                  exit;
1570          }          }
# Line 1441  print " return: $return<br>\n"; Line 1572  print " return: $return<br>\n";
1572          // location of master docman configuration file          // location of master docman configuration file
1573          $docman_conf = "/etc/docman.conf";          $docman_conf = "/etc/docman.conf";
1574          if (! file_exists($docman_conf)) {          if (! file_exists($docman_conf)) {
1575                  $error = "Can't find master configuration file $docman_conf. See docman2/doc/upgrade.html#docman_conf for more informations";                  $error = "Can't find master configuration file <tt>$docman_conf</tt>. See <tt>docman2/doc/upgrade.html#docman_conf</tt> for more informations";
1576                                    
1577                  error_log("docman: $error");                  error_log("docman: $error");
1578                  Error("docman not installed completly",$error);                  Error("docman not installed completly",$error);
# Line 1451  print " return: $return<br>\n"; Line 1582  print " return: $return<br>\n";
1582          if (! isset($fsRealmDir)) {          if (! isset($fsRealmDir)) {
1583                  $fsRealmDir = "$gblIncDir/realm";                  $fsRealmDir = "$gblIncDir/realm";
1584          }          }
1585          $realm_config = "$fsRealmDir/$realm.conf";  
1586            // try to add dir to script name to realm var
1587            if (is_dir("$fsRealmDir/$realm/".dirname($HTTP_SERVER_VARS["SCRIPT_NAME"]))) {
1588                    $realm .= dirname($HTTP_SERVER_VARS["SCRIPT_NAME"]);
1589                    $realm_sep = "/";
1590            } else {
1591                    $realm_sep = ".";
1592            }
1593    
1594            $realm_config = $fsRealmDir."/".$realm.$realm_sep."conf";
1595    
1596          // read user-defined configuration          // read user-defined configuration
1597          if (file_exists($realm_config)) {          if (file_exists($realm_config)) {
# Line 1469  print " return: $return<br>\n"; Line 1609  print " return: $return<br>\n";
1609                  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>");
1610          }          }
1611    
1612            // take additional login vars
1613            HTTP_GET_VAR("relogin");
1614            HTTP_GET_VAR("force_login");
1615    
1616          // if no password, or empty password logout          // if no password, or empty password logout
1617          if (          if (
1618                  isset($gblLogin) && (                  isset($gblLogin) && (
# Line 1484  print " return: $return<br>\n"; Line 1628  print " return: $return<br>\n";
1628                  exit ;                  exit ;
1629          }          }
1630    
1631            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);
1632    
1633          // trustee (ACL) file configuration          // trustee (ACL) file configuration
1634          $trustee_conf="$gblIncDir/realm/$realm.trustee";          $trustee_conf="$fsRealmDir/$realm".$realm_sep."trustee";
1635          // compiled version of trustee file          // compiled version of trustee file
1636          $trustee_php="$gblRepositoryDir/.trustee.php";          $trustee_php="$gblRepositoryDir/.trustee.php";
1637          // get ACL informations          // get ACL informations
1638          $HAVE_TRUSTEE = init_trustee();          $HAVE_TRUSTEE = init_trustee();
1639    
1640          if (strtolower($gblLogin) == "anonymous" || !isset($gblPasswd)) {          if (strtolower($gblLogin) == "anonymous" || !isset($gblLogin)) {
1641                  $perm = check_trustee($gblLogin,$path);                  $perm = check_trustee("anonymous","/");
1642                  // browsing must be explicitly allowed for root directory                  // browsing must be explicitly allowed for root directory
1643                  // of repository for anonymous user to work!                  // of repository for anonymous user to work!
1644                  if ($perm[allow] & trperm_b) {                  if ($perm['allow'] & trperm_b) {
1645                            $gblLogin = $gblPasswd = "anonymous";
1646                          $secHash = md5($gblLogin.$gblPasswd);                          $secHash = md5($gblLogin.$gblPasswd);
1647                          $gblUserName = "Anonymous user";                          $gblUserName = "Anonymous user";
1648                  }                  }
# Line 1506  print " return: $return<br>\n"; Line 1653  print " return: $return<br>\n";
1653                  isset($relogin) && $secHash == $relogin) {                  isset($relogin) && $secHash == $relogin) {
1654                  header("WWW-authenticate: basic realm=\"$realm\"") ;                  header("WWW-authenticate: basic realm=\"$realm\"") ;
1655                  header("HTTP/1.0 401 Unauthorized") ;                  header("HTTP/1.0 401 Unauthorized") ;
1656                  Error("401 Unauthorized","No trespassing !");                  Error("401 Unauthorized","No trespassing !",0,1);
                 exit ;  
1657          }          }
1658    
         // get current directory relative to $gblFsRoot  
         $relDir = $DIR ;        // from POST  
         if ($relDir == "") {    // not defined in POST ?  
                 $relDir = urldecode($D) ;  // then use GET  
         }        
1659    
1660          $relDir=stripSlashes($relDir);          // read mime.types
1661            readMime();
1662    
1663          if ($relDir == "/") $relDir = "" ;                if (! isset($gblPermNote)) {
1664          // default : website root = ""                  $gblPermNote = trperm_r;
1665            }
1666    
1667          if (strstr($relDir,"..")) Error("No updirs allowed");          HTTP_POST_VAR("FN");
1668    
1669          // full paths contain "fs" or "Fs". Paths realitve to root of          if ($HTTP_SERVER_VARS["REQUEST_METHOD"] == "POST") {
1670          // website contain "rel" or "Rel". The script won't let you                  // take variables from server
1671          // edit anything above directory equal to http://server.com                  if (HTTP_POST_VAR("FN"))
1672          // i.e. below $gblFsRoot.                          check_filename($FN);
1673                    if (HTTP_POST_VAR("DIR")) {
1674                            check_dirname($DIR);
1675                            $relDir = $DIR;
1676                    } else {
1677                            trigger_error("Can't get DIR",E_USER_WARNING);
1678                            $relDir = "/";
1679                    }
1680                    if (HTTP_POST_VAR("RELPATH")) check_dirname($RELPATH);
1681                    HTTP_POST_VAR("T");
1682                    HTTP_POST_VAR("CONFIRM");
1683            } else {
1684                    // get
1685                    HTTP_GET_VAR("A");
1686                    if (HTTP_GET_VAR("D")) {
1687                            check_dirname($D);
1688                            $D=urldecode($D);
1689                            $relDir = $D;
1690                    } else {
1691                            //trigger_error("Can't get D",E_USER_WARNING);
1692                            $relDir = "/";
1693                    }
1694                    if (HTTP_GET_VAR("F")) check_filename($F);
1695            }
1696    
1697          $relScriptDir = dirname($SCRIPT_NAME) ;                  $relScriptDir = dirname($HTTP_SERVER_VARS["SCRIPT_NAME"]) ;    
1698          // i.e. /docman          // i.e. /docman
1699    
1700          // start on server root          // start on server root
1701          $gblFsRoot = $gblRepositoryDir;          $gblFsRoot = $gblRepositoryDir;
1702          // i.e. /home/httpd/html          // i.e. /home/httpd/repository
1703    
1704          $fsDir = $gblFsRoot . $relDir ; // current directory          $fsDir = $gblFsRoot . $relDir ; // current directory
1705          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) ;
1706    
1707            if ($relDir == "") $relDir="/";
1708    
1709          if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") {          if (isset($HTTP_SERVER_VARS["HTTPS"]) && $HTTP_SERVER_VARS["HTTPS"] == "on") {
1710                  $webRoot  = "https://";                  $webRoot  = "https://";
1711          } else {          } else {
1712                  $webRoot  = "http://";                  $webRoot  = "http://";
1713          }          }
1714          $webRoot .= $GLOBALS["HTTP_HOST"] . $relScriptDir;          $webRoot .= $HTTP_SERVER_VARS["HTTP_HOST"] . $relScriptDir;
1715    
1716          $FN=stripSlashes($FN);          if (HTTP_POST_VAR("POSTACTION")) switch ($POSTACTION) {
   
         switch ($POSTACTION) {  
1717          case "UPLOAD" :          case "UPLOAD" :
1718                    $FN_name=stripSlashes($HTTP_POST_FILES["FN"]["tmp_name"]);
1719                    $FN=stripSlashes($HTTP_POST_FILES["FN"]["name"]);
1720                  if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;                  if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;
1721                  if (strstr($FN_name,"/"))  
1722                          Error("Non-conforming filename") ;                  $source = $FN_name ;
                 // TODO : should rather check for escapeshellcmds  
                 // but maybe RFC 18xx asserts safe filenames ....  
                 $source = $FN ;  
1723                  if (! file_exists($source)) {                  if (! file_exists($source)) {
1724                          Error("You must select file with browse to upload it!");                          Error("You must select file with browse to upload it!","If file is too big, you might need to modify php configuration options <tt>post_max_size</tt> and <tt>upload_max_filesize</tt>",1);
1725                  }                  }
1726    
1727                    if (HTTP_POST_VAR("FILENAME")) check_filename($FILENAME);
1728    
1729                  if (! isset($FILENAME)) {       // from update file                  if (! isset($FILENAME)) {       // from update file
1730                          $target = "$fsDir/$FN_name" ;                          $target = "$fsDir/".basename($FN);
1731                  } else {                  } else {
1732                          $target = "$fsDir/$FILENAME";                          $target = "$fsDir/$FILENAME";
1733                  }                  }
1734    
1735                    if (! check_perm("$relDir/".basename($target), trperm_w))
1736                            Error("Access denied","User <tt>$gblLogin</tt> tried to upload <tt>$relDir/".basename($target)."</tt> without valid trustee.",1);
1737    
1738                  // backup old files first                  // backup old files first
1739                  $dir=dirname($target);                  $dir=dirname($target);
1740                  if (! file_exists($dir."/.bak")) {                  if (! file_exists($dir."/.bak")) {
1741                          mkdir($dir."/.bak",0700);                          mkdir($dir."/.bak",0700);
1742                  }                  }
1743                  if (! file_exists($dir."/.bak/$GLOBALS[gblNumBackups]")) {                  if (! file_exists($dir."/.bak/$gblNumBackups")) {
1744                          mkdir($dir."/.bak/$GLOBALS[gblNumBackups]",0700);                          mkdir($dir."/.bak/$gblNumBackups",0700);
1745                  }                  }
1746                  $file=basename($target);                  $file=basename($target);
1747                  for($i=$GLOBALS[gblNumBackups]-1;$i>0;$i--) {                  for($i=$gblNumBackups-1;$i>0;$i--) {
1748                          MoveTo("$dir/.bak/$i/$file","$dir/.bak/".($i+1)."/");                          MoveTo("$dir/.bak/$i/$file","$dir/.bak/".($i+1)."/");
1749                  }                  }
1750                  MoveTo($target,$dir."/.bak/1/");                  MoveTo($target,$dir."/.bak/1/");
# Line 1581  print " return: $return<br>\n"; Line 1752  print " return: $return<br>\n";
1752                  copy($source,$target) ;                  copy($source,$target) ;
1753                  chmod($target,$gblFilePerms) ;                  chmod($target,$gblFilePerms) ;
1754                  clearstatcache() ;                  clearstatcache() ;
                 Logit($target,"uploaded");  
1755                  if (isset($FILENAME)) {                  if (isset($FILENAME)) {
1756                            LogIt($target,"check-in",trperm_r | trperm_w);
1757                          Unlock($target);                          Unlock($target);
1758                    } else {
1759                            LogIt($target,"uploaded",trperm_r | trperm_w);
1760                  }                  }
                 ChangeLog($target,"updated");  
1761                  break ;                  break ;
1762    
1763          case "SAVE" :          case "SAVE" :
1764                  $path = $gblFsRoot . $RELPATH ;                  $path = $gblFsRoot . $RELPATH ;
1765                  $path=stripSlashes($path);                  $path=stripSlashes($path);
1766    
1767                    if (! check_perm("$RELPATH", trperm_w))
1768                            Error("Access denied","User <tt>$gblLogin</tt> tried to save <tt>$RELPATH</tt> without valid trustee.",1);
1769    
1770                  $writable = is_writeable($path) ;                  $writable = is_writeable($path) ;
1771                  $legaldir = is_writeable(dirname($path)) ;                  $legaldir = is_writeable(dirname($path)) ;
1772                  $exists   = (file_exists($path)) ? 1 : 0 ;                  $exists   = (file_exists($path)) ? 1 : 0 ;
1773  // check for legal extension here as well                  // FIX: more verbose error message
1774                  if (!($writable || (!$exists && $legaldir)))                  if (!($writable || (!$exists && $legaldir)))
1775                          Error("Write denied",$RELPATH) ;                          Error("Write denied",$RELPATH) ;
1776                  $fh = fopen($path, "w") ;                  $fh = fopen($path, "w") ;
1777                  $FILEDATA=stripSlashes($FILEDATA);                  HTTP_POST_VAR("FILEDATA");
1778                  fwrite($fh,$FILEDATA) ;                  fwrite($fh,$FILEDATA) ;
1779                  fclose($fh) ;                  fclose($fh) ;
1780                  clearstatcache() ;                  clearstatcache() ;
1781                  Logit($path,"saved changes");                  LogIt($path,"saved changes",trperm_r);
                 ChangeLog($path,"saved changes");  
1782                  break ;                  break ;
1783    
1784          case "CREATE" :          case "CREATE" :
1785                  // we know $fsDir exists                  // we know $fsDir exists
1786                  if ($FN == "") break;           // no filename!                  if (! check_perm($relDir, trperm_w))
1787                  if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;                          Error("Write access denied","You don't have permission to write in <tt>$relDir</tt>");
1788                  $path = $fsDir . "/" . $FN ;  // file or dir to create                  if ($T == "D") $type = "directory";
1789                  $relPath = $relDir . "/" . $FN ;                  else $type ="file";
1790                    if ($FN == "") Error("Can't create $type","You must enter name of $type to create it.");
1791                    if (!is_writeable($fsDir)) Error("Write denied","User <tt>$gblLogin</tt> has trustee to write in <tt>$relDir</tt> but permissions on <tt>$fsDir</tt> are wrong!", 1) ;
1792                    $path = "$fsDir/$FN";           // file or dir to create
1793                    $relPath = "$relDir/$FN";
1794    
1795                    if (file_exists($path))
1796                            Error("Can't create $type","Object <tt>$relPath</tt> allready exists");
1797    
1798                  switch ( $T ) {                  switch ( $T ) {
1799                  case "D" :  // create a directory                  case "D" :  // create a directory
1800                          if ( ! @mkdir($path,$gblDirPerms) )                          if ( ! @mkdir($path,$gblDirPerms) )
1801                                  Error("Mkdir failed",$relPath) ; // eg. if it exists                                  Error("Mkdir failed",$relPath) ; // eg. if it exists
1802                            else
1803                                    LogIt($path."/","dir created",trperm_w);
1804                          clearstatcache() ;                          clearstatcache() ;
1805                          break ;                          break ;
1806                  case "F" :  // create a new file                  case "F" :  // create a new file
# Line 1623  print " return: $return<br>\n"; Line 1808  print " return: $return<br>\n";
1808  // better keep it here altogether  // better keep it here altogether
1809  // chmod perms to $gblFilePerms  // chmod perms to $gblFilePerms
1810                          if ( file_exists($path) && !is_writeable($path) )                          if ( file_exists($path) && !is_writeable($path) )
1811                                  Error("File not writable", $relPath) ;                                  Error("File not writable", "User <tt>$gblLogin</tt> has trustee to write in <tt>$relPath</tt> but permissions on <tt>$path</tt> are wrong!", 1) ;
1812                          $fh = fopen($path, "w+") ;                          $fh = fopen($path, "w+") ;
1813                          if ($fh) {                          if ($fh) {
1814                                  fputs($fh,"\n");                                  fputs($fh,"\n");
1815                                  fclose($fh) ;                                  fclose($fh) ;
1816                                  LogIt($path,"file created");                                  LogIt($path,"file created",trperm_r | trperm_w);
1817                          } else {                          } else {
1818                                  Error("Creation of file $relPath failed -- $path");                                  Error("Creation of file $relPath failed", "User <tt>$gblLogin</tt> has trustee to write in <tt>$relPath</tt> but creation of <tt>$path</tt> failed!", 1) ;
1819                          }                          }
1820                          $tstr = "$PHP_SELF?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ;                          $tstr = $HTTP_SERVER_VARS["PHP_SELF"]."?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ;
1821                          header("Location: " . $tstr) ;                          header("Location: " . $tstr) ;
                         ChangeLog($target,"created");  
1822                          exit ;                          exit ;
1823                  }                  }
1824                  break ;                  break ;
1825    
1826          case "DELETE" :            case "DELETE" :  
1827                  if ( $CONFIRM != "on" ) break ;                  if ( $CONFIRM != "on" ) break;
1828    
1829                  $tstr  = "Attempt to delete non-existing object or " ;                  if ( isset($FN) && $FN != "") {
1830                  $tstr .= "insufficient privileges: " ;                          $path=$fsDir."/".$FN;
1831                            $what = "file";
1832                    } elseif (isset($DIR)) {
1833                            $path=$gblFsRoot."/".$DIR;
1834                            $what = "directory";
1835                    } else  {
1836                            Error("Can't delete object","Can't find filename <tt>\$FN</tt> or dirname in <tt>\$DIR</tt>",1);
1837                    }
1838    
1839                  if ( $FN != "") {  // delete file                  if (! check_perm("$relDir/$FN", trperm_w))
1840                          $path =  $fsDir . "/" . $FN ;                          Error("Access denied","User <tt>$gblLogin</tt> tried to erase $what <tt>$relDir/$FN</tt> without valid trustee.",1);
                   
                         $dir=dirname($path);  
                         $file=basename($path);  
                         if (! file_exists("$dir/.del")) {  
                                 mkdir("$dir/.del",0700);  
                         }  
1841    
1842  //                      if ( ! @unlink($path) ) {                  $tstr  = "Attempt to delete non-existing object or insufficient privileges: " ;
1843                          if ( ! rename($path,"$dir/.del/$file") ) {  
1844                                  Error("File delete failed", $tstr . $path) ;                  $dir=dirname($path);
1845                                  Logit($path,"file delete failed");                  $file=basename($path);
1846                                  exit ;  
1847                          } else {                  if (! file_exists("$dir/.del")) {
1848                                  Logit($path,"file deleted");                          mkdir("$dir/.del",0700);
                                 MoveTo("$dir/.log/$file","$dir/.del/.log/");  
                                 MoveTo("$dir/.note/$file","$dir/.del/.note/");  
                                 MoveTo("$dir/.lock/$file","$dir/.del/.lock/");  
                         }  
1849                  }                  }
1850                  else {  // delete directory  
1851                    if ( ! @rrmdir($fsDir) ) {                  if ( ! @rename($path,"$dir/.del/$file") ) {
1852                      Error("Rmdir failed", $tstr . $fsDir) ;                          LogIt($path,"$what delete failed");
1853                    }                          Error("Can't delete $what",$tstr."<tt>".$relDir."/".$FN."</tt>") ;
1854                    else {                  } else {
1855                      $relDir = dirname($relDir) ;  // move up                          LogIt($path,"$what deleted",trperm_w);
1856                    }                          MoveTo("$dir/.log/$file","$dir/.del/.log/");
1857                            MoveTo("$dir/.note/$file","$dir/.del/.note/");
1858                            MoveTo("$dir/.lock/$file","$dir/.del/.lock/");
1859                  }                  }
1860                  break ;                  break ;
1861    
# Line 1682  print " return: $return<br>\n"; Line 1865  print " return: $return<br>\n";
1865                  if (substr($FN,0,4) != ".del") break ;                  if (substr($FN,0,4) != ".del") break ;
1866                  $file=substr($FN,4,strlen($FN)-4);                  $file=substr($FN,4,strlen($FN)-4);
1867    
1868                  Logit("$fsDir/.del/$file","undeleted");                  if (! check_perm("$relDir/$file", trperm_w))
1869                            Error("Access denied","User <tt>$gblLogin</tt> tried to undelete <tt>$relDir/$file</tt> without valid trustee.",1);
1870    
1871                    LogIt("$fsDir/.del/$file","undeleted",trperm_w);
1872                  MoveTo("$fsDir/.del/$file","$fsDir/");                  MoveTo("$fsDir/.del/$file","$fsDir/");
1873                  MoveTo("$fsDir/.del/.log/$file","$fsDir/.log/");                  MoveTo("$fsDir/.del/.log/$file","$fsDir/.log/");
1874                  MoveTo("$fsDir/.del/.note/$file","$fsDir/.note/");                  MoveTo("$fsDir/.del/.note/$file","$fsDir/.note/");
# Line 1693  print " return: $return<br>\n"; Line 1879  print " return: $return<br>\n";
1879          case "RENAME" :            case "RENAME" :  
1880                  if ( $CONFIRM != "on" ) break ;                  if ( $CONFIRM != "on" ) break ;
1881    
1882                  Logit("$fsDir/$FN","renamed $FN to $NEWNAME");                  if (HTTP_POST_VAR("NEWNAME")) {
1883                            $dest = remove_parent($relDir.$NEWNAME);
1884                            if (! check_perm($relDir.$FN, trperm_w) ||
1885                                ! check_perm($dest, trperm_w) )
1886                                    Error("Access denied","User <tt>$gblLogin</tt> tried to rename <tt>$relDir$FN</tt> to <tt>$dest</tt> without valid trustee.",1);
1887                    } else {
1888                            Error("Rename error","Can't find new name in var <tt>\$NEWNAME</tt>",1);
1889                    }
1890                    LogIt("$fsDir/$FN","renamed $FN to $NEWNAME",trperm_r);
1891                  safe_rename($fsDir,$FN,$NEWNAME);                  safe_rename($fsDir,$FN,$NEWNAME);
1892                  break ;                  break ;
1893    
1894          case "NOTE" :            case "NOTE" :
1895                  WriteNote("$fsDir/$FN","$NOTE");                  if (! HTTP_POST_VAR("NOTE"))
1896                            Error("Can't add note to object","Can't find var <tt>\$NOTE</tt>",1);
1897                    if (! check_perm("$relDir/$FN", trperm_w))
1898                            Error("Access denied","User <tt>$gblLogin</tt> tried to add note to <tt>$relDir/$FN</tt> without valid trustee.",1);
1899    
1900                    WriteNote("$fsDir/$FN",$NOTE);
1901                  break ;                  break ;
1902    
1903          case "UNLOCK" :            case "UNLOCK" :  
1904                  if ( $CONFIRM != "on" ) break ;                  if ( $CONFIRM != "on" ) break ;
1905                    if (! check_perm("$relDir/$FN", trperm_w))
1906                            Error("Access denied","User <tt>$gblLogin</tt> tried to unlock <tt>$relDir/$FN</tt> without valid trustee.",1);
1907                  Unlock("$fsDir/$FN");                  Unlock("$fsDir/$FN");
1908                  break ;                  break ;
1909    
# Line 1711  print " return: $return<br>\n"; Line 1912  print " return: $return<br>\n";
1912          }          }
1913    
1914          // common to all POSTs : redirect to directory view ($relDir)          // common to all POSTs : redirect to directory view ($relDir)
1915          if ( $POSTACTION != "" ) {          if (isset($POSTACTION)) {
1916                  $tstr = $PHP_SELF . "?D=" . urlencode($relDir) ;                  $tstr = $HTTP_SERVER_VARS["PHP_SELF"]."?D=".urlencode($relDir);
1917                  header("Location: " . $tstr) ;                    header("Location: ".$tstr) ;  
1918                  exit ;                  exit ;
1919          }          }
1920            
1921          // check for mode.. navigate, code display, upload, or detail?          // check for mode.. navigate, code display, upload, or detail?
1922          // $A=U : upload to path given in $D          // $A=U : upload to path given in $D
1923          // $A=E : display detail of file $D/$F and edit          // $A=E : display detail of file $D/$F and edit
# Line 1724  print " return: $return<br>\n"; Line 1925  print " return: $return<br>\n";
1925          // $A=Co : checkout file $D/$F          // $A=Co : checkout file $D/$F
1926          // $A=Ci : checkin file $D/$F          // $A=Ci : checkin file $D/$F
1927          // $A=V : view file (do nothing except log)          // $A=V : view file (do nothing except log)
1928          // $A=I : include file .$F.php from $gblFsRoot          // $A=I : include file .$F.php from [$gblIncDir|realm]/include_php
1929          // default : display directory $D          // default : display directory $D
1930    
1931          switch ($A) {          if (isset($A)) switch ($A) {
1932          case "U" :          case "U" :
1933                  // upload to $relDir                  // upload to $relDir
1934                    if (! check_perm($relDir, trperm_w))
1935                            Error("Write access denied","You don't have permission to write in <tt>$relDir</tt>");
1936                  if (!is_writeable($gblFsRoot . $relDir))                  if (!is_writeable($gblFsRoot . $relDir))
1937                          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);
1938                  $text  = "Use this page to upload a single " ;                  $text  = "Use this page to upload a single " ;
1939                  $text .= "file to <B>$HTTP_HOST</B>." ;                  $text .= "file to <B>$realm</B>." ;
1940                  StartHTML("(Upload Page)", $text) ;                  StartHTML("(Upload Page)", $text) ;
1941                  UploadPage($gblFsRoot, $relDir) ;                  UploadPage($gblFsRoot, $relDir) ;
1942                  EndHTML() ;                  EndHTML() ;
1943                  exit ;                  exit ;
1944          case "E" :          case "E" :
                 $F=stripSlashes($F);  
1945                  // detail of $relDir/$F                  // detail of $relDir/$F
1946                  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) ;
1947                  exit ;                  exit ;
# Line 1751  print " return: $return<br>\n"; Line 1953  print " return: $return<br>\n";
1953          case "Co" :          case "Co" :
1954                  // checkout                  // checkout
1955                  Lock("$gblFsRoot/$relDir/$F");                  Lock("$gblFsRoot/$relDir/$F");
1956                  Download("$gblFsRoot/$relDir/$F");                  Download("$gblFsRoot/$relDir/$F",1);
1957                  exit;                  exit;
1958          case "Ci" :          case "Ci" :
1959                  $F=stripSlashes($F);                  $F=stripSlashes($F);
# Line 1759  print " return: $return<br>\n"; Line 1961  print " return: $return<br>\n";
1961                  if (!is_writeable($gblFsRoot . $relDir))                  if (!is_writeable($gblFsRoot . $relDir))
1962                          Error("Write access denied",$relDir) ;                          Error("Write access denied",$relDir) ;
1963                  $text  = "Use this page to update a single " ;                  $text  = "Use this page to update a single " ;
1964                  $text .= "file to <B>$HTTP_HOST</B>." ;                  $text .= "file to <B>$realm</B>." ;
1965                  StartHTML("(Update file Page)", $text) ;                  StartHTML("(Update file Page)", $text) ;
1966                  UploadPage($gblFsRoot, $relDir, $F) ;                  UploadPage($gblFsRoot, $relDir, $F) ;
1967                  EndHTML() ;                  EndHTML() ;
# Line 1767  print " return: $return<br>\n"; Line 1969  print " return: $return<br>\n";
1969          case "V" :          case "V" :
1970                  // view                  // view
1971                  LogIt("$gblFsRoot/$relDir/$F","viewed");                  LogIt("$gblFsRoot/$relDir/$F","viewed");
1972                  if ($gblForceDownload) {                  Download("$gblFsRoot/$relDir/$F",$gblForceDownload);
                         Download("$gblFsRoot/$relDir/$F");  
                 } else {  
                         header("Content-Disposition: attachment; filename=$F" );  
                         Header("Location: $webRoot".urlpath("$relDir/$F"));  
                 }  
1973                  exit;                  exit;
1974          case "Ch" :          case "Ch" :
1975                  StartHTML("(File changes)","All changes chronologicaly...");                  StartHTML("(File changes)","All changes chronologicaly...");
# Line 1785  print " return: $return<br>\n"; Line 1982  print " return: $return<br>\n";
1982                  EndHTML() ;                  EndHTML() ;
1983                  exit;                  exit;
1984          case "I" :          case "I" :
1985                  $F=stripSlashes($F);                  if (! isset($F) || $F == "")
1986                  $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);
1987                  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";
1988                    if (! file_exists($inc_file)) {
1989                            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);
1990                    }
1991                  if (!is_readable($inc_file))                  if (!is_readable($inc_file))
1992                          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);
1993                  $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";
1994                  $title = "You should define \$title variable with page title";                  $title = "You should define \$title variable with page title";
1995                  include($inc_file);                  include($inc_file);
1996                  StartHTML($title, $text) ;                  StartHTML($title, $text) ;
1997                  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>";
1998                  EndHTML() ;                  EndHTML() ;
1999                  exit ;                  exit ;
2000          }          }
# Line 1803  print " return: $return<br>\n"; Line 2003  print " return: $return<br>\n";
2003          Navigate($gblFsRoot,$relDir) ;            Navigate($gblFsRoot,$relDir) ;  
2004          exit ;          exit ;
2005    
2006          Error("Whooah!","By cartesian logic, this never happens") ;          Error("Whooah!","By cartesian logic, this never happens",1) ;
2007  ?>  ?>

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

  ViewVC Help
Powered by ViewVC 1.1.26