/[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.24 by dpavlin, Mon Jul 29 09:36:22 2002 UTC revision 1.46 by dpavlin, Sat Apr 10 21:21:37 2004 UTC
# Line 1  Line 1 
1  <?php  <?php
2    
3  /*  /*
4   *      Document Manager ][   *      Document Manager ][
5   *   *
6   *      Dobrica Pavlinusic <dpavlin@rot13.org>   *      Dobrica Pavlinusic <dpavlin@rot13.org>
7   *   *
8   *      License: GPL2   *      License: GPL2
9   *   *
10   *      Document Manager 1.x was based on   *      Document Manager 1.x was based on
11   *      Copyright 1999 by John Martin d/b/a www.ANYPORTAL.com   *      Copyright 1999 by John Martin d/b/a www.ANYPORTAL.com
12   *      PHP version Copyright 2000 by Stefan@Wiesendanger.org   *      PHP version Copyright 2000 by Stefan@Wiesendanger.org
13   *   *
14   *      For more info, please see web pages at   *      For more info, please see web pages at
15   *      http://www.rot13.org/~dpavlin/docman.html   *      http://www.rot13.org/~dpavlin/docman.html
16   *   *
17   */   */
18    
19    
20  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
21  // CONFIGURATION OPTIONS  // CONFIGURATION OPTIONS
22    
23          error_reporting(E_ALL) ;                // how verbose ?          error_reporting(E_ALL) ;                // how verbose ?
24    
25          // from where to include auth_*.php modules?          // try to do some guessing about configuration
26          $gblIncDir = "/data/docman2";          $script = $HTTP_SERVER_VARS["SCRIPT_FILENAME"];
27            if (is_link($script)) $script=readlink($script);
28          // force download on view (so it won't open in associated application)          $gblIncDir = dirname($script);
29          $gblForceDownload = 0;          $html = $gblIncDir."/html";
30    
31          // date format          // location of master docman configuration file
32          $gblDateFmt="Y-m-d";          $docman_conf = "/etc/docman.conf";
33  //      $gblDateFmt="D, F d, Y";          if (! file_exists($docman_conf)) {
34                    $error = "Can't find master configuration file <tt>$docman_conf</tt>. See <tt>docman2/doc/upgrade.html#docman_conf</tt> for more informations";
35          // time format  
36          $gblTimeFmt="H:i:s";                  error_log("docman: $error");
37  //      $gblTimeFmt="g:i:sA";                  Error("docman not installed completly",$error);
38            }
39          // Number of backup files to keep          include($docman_conf);
40          $gblNumBackups=3;  
41            if (! isset($gblIncDir)) {
42          // show red star if newer than ... days                  $error = "Can't findi <tt>\$gblIncDir</tt> in master configuration file <tt>$docman_conf</tt>. This variable should point to docman installation directory";
43          $gblModDays=1;  
44                    error_log("docman: $error");
45          // choose GifIcon below unless you have the M$                  Error("docman not installed completly",$error);
46          // WingDings font installed on your system          }
47    
48          $gblIcon="GifIcon";             // MockIcon or GifIcon          // location of html files
49            $html = $gblIncDir."/html";
50          // the directory below should be /icons/ or /icons/small/  
51          // on Apache; a set of icons is included in the distribution          // force download on view (so it won't open in associated application)
52            $gblForceDownload = 0;
53          $gblIconLocation="/icons/";  
54            // date format
55          // files you want to be able to edit in text mode          $gblDateFmt="Y-m-d";
56          // and view with (primitive) syntax highlighting  //      $gblDateFmt="D, F d, Y";
57    
58          $gblEditable = array( ".txt",".asa",".asp",".htm",".html",          // time format
59                                ".cfm",".php3",".php",".phtml",          $gblTimeFmt="H:i:s";
60                                ".shtml",".css" ) ;  //      $gblTimeFmt="g:i:sA";
61    
62          // files that will display as images on the detail page          // Number of backup files to keep
63          // (useless if your browser doesn't support them)          $gblNumBackups=3;
64    
65          $gblImages   = array( ".jpg",".jpeg",".gif",".png",".ico",          // show red star if newer than ... days
66                                ".bmp",".xbm") ;          $gblModDays=1;
67    
68          // which files to hide (separated by ,)          // choose GifIcon below unless you have the M$
69          $gblHide = "";          // WingDings font installed on your system
70    
71          // Where are users? (by default in .htusers file)          $gblIcon="GifIcon";             // MockIcon or GifIcon
72          $gblUsers = "file";  
73            // the directory below should be /icons/ or /icons/small/
74  //////////////////////////////////////////////////////////////////          // on Apache; a set of icons is included in the distribution
75    
76          $gblTitle = "Document Manager";          $gblIconLocation="/icons/";
77          $gblVersion = "2.0-pre1";  
78            // files you want to be able to edit in text mode
79          $secHash    = "";          // and view with (primitive) syntax highlighting
80    
81          // location of html files          $gblEditable = array( ".txt",".asa",".asp",".htm",".html",
82          $html = $gblIncDir."/html";                                ".cfm",".php3",".php",".phtml",
83                                  ".shtml",".css" ) ;
84          LoadLanguage($HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"]);  
85            // files that will display as images on the detail page
86          // for security and configuration          // (useless if your browser doesn't support them)
87          $realm=$HTTP_SERVER_VARS["HTTP_HOST"];  
88            $gblImages   = array( ".jpg",".jpeg",".gif",".png",".ico",
89          $fsDocumentRoot = dirname($HTTP_SERVER_VARS["SCRIPT_FILENAME"]);                                ".bmp",".xbm") ;
90          if ($fsDocumentRoot == "") Error("Configuration error","Can't get SCRIPT_FILENAME from your web server. Please set <tt>\$fsDocumentRoot</tt> in <tt>\$</tt>",1);  
91            // which files to hide (separated by ,)
92          // globals for later          $gblHide = "";
93          $gblLogin = HTTP_SERVER_VAR("PHP_AUTH_USER");  
94          $gblPasswd = HTTP_SERVER_VAR("PHP_AUTH_PW");          // Where are users? (by default in .htusers file)
95            $gblUsers = "file";
96  //////////////////////////////////////////////////////////////////  
97    //////////////////////////////////////////////////////////////////
98  function LoadLanguage($lang) {  
99            $gblTitle = "Document Manager";
100          global $gblIncDir,$html;          $gblVersion = "2.0-rc1";
101    
102          if (file_exists($gblIncDir."/lang/$lang.php")) {          $secHash    = "";
103                  include($gblIncDir."/lang/$lang.php");  
104                  $html .= "-$lang";          // load language
105          } else {          if (isset($HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"])) {
106                  include($gblIncDir."/lang/default.php");                  LoadLanguage($HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"]);
107          }          }
108  }  
109            // does gettext locale function exits?
110  function StartHTML($title,$text="") {          if (! function_exists("_")) {
111                    function _($str) { return $str; }
112          global $html,$fsDocumentRoot,$gblTitle,$HTTP_SERVER_VARS;          }
113    
114          $host  = $HTTP_SERVER_VARS["HTTP_HOST"] ;          // for security and configuration
115          $self  = $HTTP_SERVER_VARS["PHP_SELF"] ;          $realm=$HTTP_SERVER_VARS["HTTP_HOST"];
116    
117          if (file_exists("$fsDocumentRoot/docman.css")) {          // globals for later
118                  $css=dirname($self)."/docman.css";          $gblLogin = HTTP_SERVER_VAR("PHP_AUTH_USER");
119          } else {          $gblPasswd = HTTP_SERVER_VAR("PHP_AUTH_PW");
120                  $css=$self."?STYLE=get";  
121          }  //////////////////////////////////////////////////////////////////
122    
123          include("$html/head.html");  function LoadLanguage($lang) {
124  }  
125            global $gblIncDir,$html;
126  //////////////////////////////////////////////////////////////////  
127            if (file_exists($gblIncDir."/lang/$lang.php")) {
128  function EndHTML() {                  include($gblIncDir."/lang/$lang.php");
129                    $html .= "-$lang";
130          global $gblDateFmt, $gblTimeFmt, $gblUserName, $PHP_SELF,          } elseif (file_exists($gblIncDir."/lang/default.php")) {
131                  $secHash, $gblVersion, $html,                  include($gblIncDir."/lang/default.php");
132                  $gblLogin,$gblPasswd;          }
133    }
134          $url = $PHP_SELF."?relogin=";  
135          if (isset($secHash) && $secHash != "") {  function StartHTML($title,$text="") {
136                  $url .= $secHash;  
137          } else {          global $html,$gblIncDir,$gblTitle,$HTTP_SERVER_VARS;
138                  $url .= md5($gblLogin.$gblPasswd);  
139          }          $host  = $HTTP_SERVER_VARS["HTTP_HOST"] ;
140          if ( (  (isset($gblLogin) && $gblLogin != "") ||          $self  = $HTTP_SERVER_VARS["PHP_SELF"] ;
141                  (!isset($gblLogin) || $gblLogin == "")  
142               ) && ($gblPasswd == "" || !isset($gblPasswd))) {          if (file_exists("$gblIncDir/docman.css")) {
143                  $url_title="login";                  $css = "";
144                  $url .= "&force_login=1";                  $d = dirname($self);
145          } else {                  if ($d != "/") $css = $d;
146                  $url_title="relogin";                  $css .= "/docman.css";
147          }          } else {
148          include("$html/footer.html");                  $css=$self."?STYLE=get";
149            }
150          global $debug;          include("$html/head.html");
151          if ($debug) print $debug;  }
152  } // end function EndHTML  
153    //////////////////////////////////////////////////////////////////
154  //////////////////////////////////////////////////////////////////  
155    function EndHTML() {
156  function DetailPage($fsRoot,$relDir,$fn) {  
157                    global $gblDateFmt, $gblTimeFmt, $gblUserName, $PHP_SELF,
158          global $gblEditable, $gblImages,                  $secHash, $gblVersion, $html,
159                  $gblDateFmt, $gblTimeFmt,                  $gblLogin,$gblPasswd;
160                  $webRoot, $html,  
161                  $HTTP_SERVER_VARS ;          $url = $PHP_SELF."?relogin=";
162          $self = $HTTP_SERVER_VARS["PHP_SELF"] ;          if (isset($secHash) && $secHash != "") {
163                    $url .= $secHash;
164          $relPath  = $relDir . "/" . $fn ;          } else {
165          $fsPath   = $fsRoot . $relPath ;                  $url .= md5($gblLogin.$gblPasswd);
166          $fsDir    = $fsRoot . $relDir ;          }
167            if ( (  (isset($gblLogin) && $gblLogin != "") ||
168          $exists   = file_exists($fsPath) ;                  (!isset($gblLogin) || $gblLogin == "")
169          $ext      = strtolower(strrchr($relPath,".")) ;               ) && ($gblPasswd == "" || !isset($gblPasswd))) {
170          $editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) &&                  $url_title="login";
171                  check_perm($relPath,trperm_w);                  $url .= "&force_login=1";
172          $writable = is_writeable($fsPath) && check_perm($relPath,trperm_w) ;          } else {
173          $writable_dir = is_writeable($fsDir) && check_perm($relDir,trperm_w) ;                  $url_title="relogin";
174          $file_lock = CheckLock($fsPath);          }
175            include("$html/footer.html");
176          if (!$editable && !$exists)  
177                  Error("Creation denied","Can't create <tt>$relPath</tt>") ;  #       global $debug;
178          if (!$exists && !$writable_dir )  #       if ($debug) print $debug;
179                  Error("Creation denied","Can't write in directory <tt>$relDir</tt> while creating <tt>$relPath</tt>for which user has permissions.",1);  } // end function EndHTML
180    
181          $text  = _("Use this page to view, modify or ") ;  //////////////////////////////////////////////////////////////////
182          if (is_dir($fsPath)) {  
183                  $text .=_("delete a directory on this ") ;  function DetailPage($fsRoot,$relDir,$fn) {
184          } else {          
185                  $text .= _("delete a single document on this ") ;          global $gblEditable, $gblImages,
186          };                  $gblDateFmt, $gblTimeFmt,
187          $text .= _("web site.") ;                        $gblPermNote,
188          $title = "("._("Detail Page").")" ;                  $webRoot, $html,
189          StartHTML($title, $text) ;                  $HTTP_SERVER_VARS ;
190            $self = $HTTP_SERVER_VARS["PHP_SELF"] ;
191          echo "<H3>" . $relDir . "/" . $fn . "</H3>" ;  
192          if ($exists) {  // get file info          $relPath  = $relDir . "/" . $fn ;
193                  $fsize = filesize($fsPath) ;          $fsPath   = $fsRoot . $relPath ;
194                  $fmodified = date("$gblDateFmt $gblTimeFmt", filemtime($fsPath)) ;          $fsDir    = $fsRoot . $relDir ;
195                  $faccessed = date("$gblDateFmt $gblTimeFmt", fileatime($fsPath)) ;  
196                  $fuid=fileowner($fsPath);          $exists   = file_exists($fsPath) ;
197                  $fgid=filegroup($fsPath);          $ext      = strtolower(strrchr($relPath,".")) ;
198                  $userinfo = posix_getpwuid($fuid);          $editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) &&
199                  $grpinfo = posix_getgrgid($fgid);                  check_perm($relPath,trperm_w);
200            $writable = is_writeable($fsPath) && check_perm($relPath,trperm_w) ;
201                  include("$html/DetailPage-file.html");          $writable_dir = is_writeable($fsDir) && check_perm($relDir,trperm_w) ;
202          }          $file_lock = CheckLock($fsPath);
203    
204          if ( !is_dir($fsPath) && $editable && ($writable || !$exists) && !$file_lock ) {          if (!$editable && !$exists)
205                  $fh = fopen($fsPath,"a+") ;                  Error("Creation denied","Can't create <tt>$relPath</tt>") ;
206                  rewind($fh) ;          if (!$exists && !$writable_dir )
207                  $fstr = fread($fh,filesize($fsPath)) ;                  Error("Creation denied","Can't write in directory <tt>$relDir</tt> while creating <tt>$relPath</tt>for which user has permissions.",1);
208                  fclose($fh) ;  
209                  $fstr = htmlentities( $fstr ) ;          $text  = _("Use this page to view, modify or ") ;
210  ?>          if (is_dir($fsPath)) {
211                    $text .=_("delete a directory on this ") ;
212  <FORM ACTION="<?= $self ?>" METHOD="POST">          } else {
213  <SPAN TITLE="Click [SAVE] to store updated contents.">                  $text .= _("delete a single document on this ") ;
214          <B>DOCUMENT CONTENTS</B>          };
215  </SPAN><BR>          $text .= _("web site.") ;      
216  <TEXTAREA NAME="FILEDATA" ROWS=18 COLS=70 WRAP="OFF"><?php          $title = "("._("Detail Page").")" ;
217  echo($fstr) ; ?></TEXTAREA>          StartHTML($title, $text) ;
218  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ; ?>">  
219  <INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?= $fn ; ?>">          print "<H3>".$relDir.$fn."</H3>";
220  <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="SAVE">  
221  <INPUT TYPE="HIDDEN" SIZE=48 MAXLENGTH=255 NAME="RELPATH"          if ($exists) {  // get file info
222          VALUE="<?= $relPath ; ?>">                  $fsize = filesize($fsPath) ;
223  <br>                  $fmodified = date("$gblDateFmt $gblTimeFmt", filemtime($fsPath)) ;
224  <INPUT TYPE="RESET" VALUE="UNDO ALL CHANGES">                  $faccessed = date("$gblDateFmt $gblTimeFmt", fileatime($fsPath)) ;
225  <INPUT TYPE="SUBMIT" VALUE="SAVE">                  $fuid=fileowner($fsPath);
226  </FORM>                  $fgid=filegroup($fsPath);
227                    $userinfo = posix_getpwuid($fuid);
228  <?php                  $grpinfo = posix_getgrgid($fgid);
229          }  
230          if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) {                    include("$html/DetailPage-file.html");
231                  $info  = getimagesize($fsPath) ;          }
232                  $tstr = "<IMG SRC=\"$webRoot".urlpath($relPath)."\" BORDER=0 " ;  
233                  $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;          if ( !is_dir($fsPath) && $editable && ($writable || !$exists) && !$file_lock ) {
234                  $tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ;                  $fh = fopen($fsPath,"a+") ;
235  //              echo htmlentities($tstr) . "<BR><BR>" . $tstr ;                  rewind($fh) ;
236                  echo $tstr ;                  $fstr = fread($fh,filesize($fsPath)) ;
237          }                  fclose($fh) ;
238                    $fstr = htmlentities( $fstr ) ;
239  ?>  
240                    include("$html/DetailPage-edit.html");
241  <FORM ACTION="<?= $self ; ?>" METHOD="POST">          }
242  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ; ?>">          if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) {  
243  <INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?= $fn ; ?>">                  $info  = getimagesize($fsPath) ;
244  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR>                  $tstr = "<IMG SRC=\"$self?A=V&D=".urlpath(dirname($relPath))."&F=".urlpath(basename($relPath))."\" BORDER=0 " ;
245                    $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;
246  <?php                  $tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ;
247    //              echo htmlentities($tstr) . "<BR><BR>" . $tstr ;
248          if ($file_lock) {                  echo $tstr ;
249  ?>          }
250  <hr>  
251  <SPAN TITLE="Check OK and click UNLOCK to remove lock on file.">  
252  <B>OK TO FORCE LOCK REMOVAL ON "<?= $fn ; ?>" HELD BY <?= $file_lock ?>? </B></SPAN>          print '<FORM ACTION="'.$self.'" METHOD="POST">
253  <INPUT TYPE="CHECKBOX" NAME="CONFIRM">                  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="'.$relDir.'">
254  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="UNLOCK">                  <INPUT TYPE="HIDDEN" NAME="FN" VALUE="'.$fn.'">
255  <?                  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR>
256          } // file_lock                  ';
257    
258          if (substr($fn,0,4) == ".del") {          if ($file_lock && check_perm($relDir.$fn,trperm_w)) {
259                  $action="UNDELETE";                  include("$html/DetailPage-unlock.html");
260                  $desc="undelete previously deleted file";          } // file_lock
261          } else {  
262                  $action="DELETE";          if (substr($fn,0,4) == ".del") {
263                  $desc="delete";                  $action="UNDELETE";
264          }                  $desc="undelete previously deleted file";
265            } else {
266          if ($exists && $writable) {                  $action="DELETE";
267  ?>                  $desc="delete";
268            }
269  <HR>  
270  <a name="undelete">          if ($exists && $writable) {
271  <SPAN TITLE="Check OK and click [<?= $action ?>] to <?= $desc ?>.">                  include("$html/DetailPage-undelete.html");
272  <B>OK TO <?= $action ?> "<?= $fn ; ?>"? </B></SPAN>                  include("$html/DetailPage-rename.html");
273  <INPUT TYPE="CHECKBOX" NAME="CONFIRM">  
274  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="<?= $action ?>">          }
275            
276  <HR>          if (check_perm($relDir.$fn,$gblPermNote)) {
277  <a name="rename">                  include("$html/DetailPage-note.html");
278  <SPAN TITLE="Check OK and click [RENAME] to rename.">          }
279  <B>OK TO RENAME "<?= $fn ; ?>" TO  
280  <INPUT TYPE="TEXT" SIZE=24 MAXLENGTH=255 NAME="NEWNAME" VALUE="<?= $fn ?>">          print "</FORM>";
281  ? </B></SPAN>  
282  <INPUT TYPE="CHECKBOX" NAME="CONFIRM">          $name=basename("$fsDir/$fn");
283  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="RENAME">          $logname=dirname("$fsDir/$fn")."/.log/$name";
284            $bakdir=dirname("$fsDir/$fn")."/.bak";
285  <?php          if (file_exists($logname)) {
286          }       // exists && writable                  $log=fopen($logname,"r");
287  ?>                  $cl1=" class=LST"; $cl2="";
288  <HR>                  $logarr = array();
289  <a name="note">                  while($line = fgetcsv($log,512,"\t")) {
290  <B>NOTE FOR "<?= $fn ; ?>":                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;
291  <INPUT TYPE="TEXT" SIZE=50 MAXLENGTH=255 NAME="NOTE" VALUE="<?= ReadNote($fsPath) ?>">                          array_unshift($logarr,array($cl,$line[0],$line[1],$line[2],$line[3]));
292  </B></SPAN>                  }
293  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="NOTE">                  fclose($log);
294                    if (is_dir("$fsDir/$fn")) {
295  </FORM>                          $whatis="DIRECTORY";
296                    } else {
297  <?php                          $whatis="FILE";
298                    }
299          $name=basename("$fsDir/$fn");                  print "<hr><br><b>CHANGES TO THIS $whatis</b><br><table border=0 width=100%>\n";
300          $logname=dirname("$fsDir/$fn")."/.log/$name";                  $bakcount = 0;  // start from 0, skip fist backup (it's current)
301          $bakdir=dirname("$fsDir/$fn")."/.bak";                  while ($e = array_shift($logarr)) {
302          if (file_exists($logname)) {                          if (stristr($e[4],"upload") || stristr($e[4],"check-in")) {
303                  $log=fopen($logname,"r");  print "-- $e[4] -- $bakdir/$bakcount/$name --<br>\n";
304                  $cl1=" class=LST"; $cl2="";                                  if (file_exists("$bakdir/$bakcount/$name")) {
305                  $logarr = array();                                          $e[4]="<a href=\"$self?A=V&D=".urlencode($relDir).urlencode(".bak/$bakcount/")."&F=".$name."\">$e[4]</a>";  
306                  while($line = fgetcsv($log,512,"\t")) {                                  }
307                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;                                  $bakcount++;
308                          array_unshift($logarr,array($cl,$line[0],$line[1],$line[2],$line[3]));                          }
309                  }                          print "<tr><td$e[0]>$e[1]</td><td$e[0]>$e[2]</td><td$e[0]>$e[3]</td><td$e[0]>$e[4]</td></tr>\n";
310                  fclose($log);                  }
311                  if (is_dir("$fsDir/$fn")) {                  print "</table>";
312                          $whatis="DIRECTORY";          }
313                  } else {  
314                          $whatis="FILE";          EndHTML() ;
315                  }  
316                  print "<hr><br><b>CHANGES TO THIS $whatis</b><br><table border=0 width=100%>\n";  } // end function DetailPage
317                  $bakcount = 0;  // start from 0, skip fist backup (it's current)  
318                  while ($e = array_shift($logarr)) {  //////////////////////////////////////////////////////////////////
319                          if (strstr($e[4],"upload")) {  
320                                  if (file_exists("$bakdir/$bakcount/$name")) {  function DisplayCode($fsRoot,$relDir,$fn) {
321                                          $e[4]="<a href=\"$webRoot".urlpath(dirname($relPath)."/.bak/$bakcount/$name")."\">$e[4]</a>";  
322                                  }          $path = $fsRoot . $relDir . "/" . $fn ;
323                                  $bakcount++;  
324                          }          if (!file_exists($path)) Error("File not found",$path) ;
325                          print "<tr><td$e[0]>$e[1]</td><td$e[0]>$e[2]</td><td$e[0]>$e[3]</td><td$e[0]>$e[4]</td></tr>\n";  
326                  }          StartHTML("(".$relDir."/".$fn.")","");
327                  print "</table>";  
328          }          $tstr = join("",file($path)) ;
329            $tstr = htmlentities($tstr) ;
330          EndHTML() ;  
331            // Tabs
332  } // end function DetailPage          $tstr = str_replace(chr(9),"   ",$tstr) ;  
333    
334  //////////////////////////////////////////////////////////////////          // ASP tags & XML/PHP tags
335            $aspbeg = "<SPAN CLASS=XML>&lt;%</SPAN><SPAN CLASS=BLK>" ;
336  function DisplayCode($fsRoot,$relDir,$fn) {          $aspend = "</SPAN><SPAN CLASS=XML>%&gt;</SPAN>" ;
337            $tstr = str_replace("&lt;%",$aspbeg,$tstr) ;
338          $path = $fsRoot . $relDir . "/" . $fn ;          $tstr = str_replace("%&gt;",$aspend,$tstr) ;    
339    
340          if (!file_exists($path)) Error("File not found",$path) ;          $xmlbeg = "<SPAN CLASS=XML>&lt;?</SPAN><SPAN CLASS=BLK>" ;
341            $xmlend = "</SPAN><SPAN CLASS=XML>?&gt;</SPAN>" ;
342          StartHTML("(".$relDir."/".$fn.")","");          $tstr = str_replace("&lt;?",$xmlbeg,$tstr) ;
343            $tstr = str_replace("?&gt;",$xmlend,$tstr) ;    
344          $tstr = join("",file($path)) ;  
345          $tstr = htmlentities($tstr) ;          // C style comment
346            $tstr = str_replace("/*","<SPAN CLASS=REM>/*",$tstr) ;  
347          // Tabs          $tstr = str_replace("*/","*/</SPAN>",$tstr) ;                  
348          $tstr = str_replace(chr(9),"   ",$tstr) ;    
349            // HTML comments
350          // ASP tags & XML/PHP tags          $tstr = str_replace("&lt;!--","<I CLASS=RED>&lt;!--",$tstr) ;  
351          $aspbeg = "<SPAN CLASS=XML>&lt;%</SPAN><SPAN CLASS=BLK>" ;          $tstr = str_replace("--&gt;","--&gt;</I>",$tstr) ;  
352          $aspend = "</SPAN><SPAN CLASS=XML>%&gt;</SPAN>" ;  
353          $tstr = str_replace("&lt;%",$aspbeg,$tstr) ;          echo "<PRE>" ;  
354          $tstr = str_replace("%&gt;",$aspend,$tstr) ;      
355            $tstr = split("\n",$tstr) ;
356          $xmlbeg = "<SPAN CLASS=XML>&lt;?</SPAN><SPAN CLASS=BLK>" ;          for ($i = 0 ; $i < sizeof($tstr) ; ++$i) {
357          $xmlend = "</SPAN><SPAN CLASS=XML>?&gt;</SPAN>" ;                  // add line numbers
358          $tstr = str_replace("&lt;?",$xmlbeg,$tstr) ;                  echo "<BR><EM>" ;
359          $tstr = str_replace("?&gt;",$xmlend,$tstr) ;                      echo substr(("000" . ($i+1)), -4) . ":</EM> " ;
360                    $line = $tstr[$i] ;
361          // C style comment                  // C++ style comments
362          $tstr = str_replace("/*","<SPAN CLASS=REM>/*",$tstr) ;                    $pos = strpos($line,"//") ;
363          $tstr = str_replace("*/","*/</SPAN>",$tstr) ;                                    // exceptions: two slashes aren't a script comment
364                    if (strstr($line,"//") &&
365          // HTML comments                      ! ($pos>0 && substr($line,$pos-1,1)==":") &&
366          $tstr = str_replace("&lt;!--","<I CLASS=RED>&lt;!--",$tstr) ;                        ! (substr($line,$pos,8) == "//--&gt;") &&
367          $tstr = str_replace("--&gt;","--&gt;</I>",$tstr) ;                        ! (substr($line,$pos,9) == "// --&gt;")) {
368                     $beg = substr($line,0,strpos($line,"//")) ;
369          echo "<PRE>" ;                     $end = strstr($line,"//") ;
370                     $line = $beg."<SPAN CLASS=REM>".$end."</SPAN>";
371          $tstr = split("\n",$tstr) ;                  }
372          for ($i = 0 ; $i < sizeof($tstr) ; ++$i) {                  // shell & asp style comments
373                  // add line numbers                  $first = substr(ltrim($line),0,1) ;
374                  echo "<BR><EM>" ;                  if ($first == "#" || $first == "'") {
375                  echo substr(("000" . ($i+1)), -4) . ":</EM> " ;                   $line = "<SPAN CLASS=REM>".$line."</SPAN>";
376                  $line = $tstr[$i] ;                  }
377                  // C++ style comments                  print($line) ;
378                  $pos = strpos($line,"//") ;          } // next i
379                  // exceptions: two slashes aren't a script comment  
380                  if (strstr($line,"//") &&          echo "</PRE>" ;
381                      ! ($pos>0 && substr($line,$pos-1,1)==":") &&                  
382                      ! (substr($line,$pos,8) == "//--&gt;") &&          EndHTML() ;
383                      ! (substr($line,$pos,9) == "// --&gt;")) {  
384                   $beg = substr($line,0,strpos($line,"//")) ;  } // end function DisplayCode
385                   $end = strstr($line,"//") ;  
386                   $line = $beg."<SPAN CLASS=REM>".$end."</SPAN>";  //////////////////////////////////////////////////////////////////
387                  }  
388                  // shell & asp style comments  function MockIcon($txt) {
389                  $first = substr(ltrim($line),0,1) ;          $tstr = "<SPAN CLASS=MCK>" ;
390                  if ($first == "#" || $first == "'") {  
391                   $line = "<SPAN CLASS=REM>".$line."</SPAN>";          switch (strtolower($txt)) {
392                  }          case ".bmp" :
393                  print($line) ;          case ".gif" :
394          } // next i          case ".jpg" :
395            case ".jpeg":
396          echo "</PRE>" ;          case ".tif" :
397                            case ".tiff":
398          EndHTML() ;                  $d = 176 ;
399                    break ;
400  } // end function DisplayCode          case ".doc" :
401                    $d = 50 ;
402  //////////////////////////////////////////////////////////////////                  break ;
403            case ".exe" :
404  function MockIcon($txt) {          case ".bat" :
405          $tstr = "<SPAN CLASS=MCK>" ;                  $d = 255 ;
406                    break ;
407          switch (strtolower($txt)) {          case ".bas" :
408          case ".bmp" :          case ".c"   :
409          case ".gif" :          case ".cc"  :
410          case ".jpg" :          case ".src" :
411          case ".jpeg":                  $d = 255 ;
412          case ".tif" :                  break ;
413          case ".tiff":          case "file" :
414                  $d = 176 ;                  $d = 51 ;
415                  break ;                  break ;
416          case ".doc" :          case "fldr" :
417                  $d = 50 ;                  $d = 48 ;
418                  break ;                  break ;
419          case ".exe" :          case ".htm" :
420          case ".bat" :          case ".html":
421                  $d = 255 ;          case ".asa" :
422                  break ;          case ".asp" :
423          case ".bas" :          case ".cfm" :
424          case ".c"   :          case ".php3":
425          case ".cc"  :          case ".php" :
426          case ".src" :          case ".phtml" :
427                  $d = 255 ;          case ".shtml" :
428                  break ;                  $d = 182 ;
429          case "file" :                  break ;
430                  $d = 51 ;          case ".pdf" :
431                  break ;                  $d = 38 ;
432          case "fldr" :                  break;
433                  $d = 48 ;          case ".txt" :
434                  break ;          case ".ini" :
435          case ".htm" :                  $d = 52 ;
436          case ".html":                  break ;
437          case ".asa" :          case ".xls" :
438          case ".asp" :                  $d = 252 ;
439          case ".cfm" :                  break ;
440          case ".php3":          case ".zip" :
441          case ".php" :          case ".arc" :
442          case ".phtml" :          case ".sit" :
443          case ".shtml" :          case ".tar" :
444                  $d = 182 ;          case ".gz"  :
445                  break ;          case ".tgz" :
446          case ".pdf" :          case ".Z"   :
447                  $d = 38 ;                  $d = 59 ;
448                  break;                  break ;
449          case ".txt" :          case "view" :
450          case ".ini" :                  $d = 52 ;
451                  $d = 52 ;                  break ;
452                  break ;          case "up" :
453          case ".xls" :                  $d = 199 ;
454                  $d = 252 ;                  break ;
455                  break ;          case "blank" :
456          case ".zip" :                  return "&nbsp;&nbsp;</SPAN>" ;
457          case ".arc" :                  break ;
458          case ".sit" :          default :
459          case ".tar" :                  $d = 51 ;
460          case ".gz"  :          }
461          case ".tgz" :  
462          case ".Z"   :          return $tstr . chr($d) . "</SPAN>" ;
463                  $d = 59 ;  } // end function MockIcon
464                  break ;  
465          case "view" :  //////////////////////////////////////////////////////////////////
466                  $d = 52 ;  
467                  break ;  function GifIcon($txt = "") {
468          case "up" :          global $gblIconLocation, $gblImages ;
469                  $d = 199 ;  
470                  break ;          switch (strtolower($txt)) {
471          case "blank" :          case ".doc" :
472                  return "&nbsp;&nbsp;</SPAN>" ;                  $d = "layout.gif" ;
473                  break ;                  break ;
474          default :          case ".exe" :
475                  $d = 51 ;          case ".bat" :
476          }                  $d = "screw2.gif" ;
477                    break ;
478          return $tstr . chr($d) . "</SPAN>" ;          case ".bas" :
479  } // end function MockIcon          case ".c"   :
480            case ".cc"  :
481  //////////////////////////////////////////////////////////////////          case ".src" :
482                    $d = "c.gif" ;
483  function GifIcon($txt) {                  break ;
484          global $gblIconLocation ;          case "file" :
485                    $d = "generic.gif" ;
486          switch (strtolower($txt)) {                  break ;
487          case ".bmp" :          case "fldr" :
488          case ".gif" :                  $d = "dir.gif" ;
489          case ".jpg" :                  break ;
490          case ".jpeg":          case ".phps" :
491          case ".tif" :                  $d = "phps.gif" ;
492          case ".tiff":                  break ;
493                  $d = "image2.gif" ;          case ".php3" :
494                  break ;                  $d = "php3.gif" ;
495          case ".doc" :                  break ;
496                  $d = "layout.gif" ;          case ".htm" :
497                  break ;          case ".html":
498          case ".exe" :          case ".asa" :
499          case ".bat" :          case ".asp" :
500                  $d = "screw2.gif" ;          case ".cfm" :
501                  break ;          case ".php3":
502          case ".bas" :          case ".php" :
503          case ".c"   :          case ".phtml" :
504          case ".cc"  :          case ".shtml" :
505          case ".src" :                  $d = "world1.gif" ;
506                  $d = "c.gif" ;                  break ;
507                  break ;          case ".pdf" :
508          case "file" :                  $d = "pdf.gif" ;
509                  $d = "generic.gif" ;                  break;
510                  break ;          case ".txt" :
511          case "fldr" :          case ".ini" :
512                  $d = "dir.gif" ;                  $d = "text.gif" ;
513                  break ;                  break ;
514          case ".phps" :          case ".xls" :
515                  $d = "phps.gif" ;                  $d = "box2.gif" ;
516                  break ;                  break ;
517          case ".php3" :          case ".zip" :
518                  $d = "php3.gif" ;          case ".arc" :
519                  break ;          case ".sit" :
520          case ".htm" :          case ".tar" :
521          case ".html":          case ".gz"  :
522          case ".asa" :          case ".tgz" :
523          case ".asp" :          case ".Z"   :
524          case ".cfm" :                  $d = "compressed.gif" ;
525          case ".php3":                  break ;
526          case ".php" :          case "view" :
527          case ".phtml" :                  $d = "index.gif" ;
528          case ".shtml" :                  break ;
529                  $d = "world1.gif" ;          case "up" :
530                  break ;                  $d = "back.gif" ;
531          case ".pdf" :                  break ;
532                  $d = "pdf.gif" ;          case "blank" :
533                  break;                  $d = "blank.gif" ;
534          case ".txt" :                  break ;
535          case ".ini" :          case "checkout":
536                  $d = "text.gif" ;                  $d = "box2.gif";
537                  break ;                  break;
538          case ".xls" :          case "checkin":
539                  $d = "box2.gif" ;                  $d = "hand.up.gif";
540                  break ;                  break;
541          case ".zip" :          case "locked":
542          case ".arc" :                  $d = "screw2.gif";
543          case ".sit" :                  break;
544          case ".tar" :          case "note":
545          case ".gz"  :                  $d = "quill.gif";
546          case ".tgz" :                  break;
547          case ".Z"   :          default :
548                  $d = "compressed.gif" ;                  if (in_array(strtolower($txt),$gblImages)) {
549                  break ;                          $d = "image2.gif" ;
550          case "view" :                  } else {
551                  $d = "index.gif" ;                          $d = "generic.gif" ;
552                  break ;                  }
553          case "up" :          }
554                  $d = "back.gif" ;  
555                  break ;  
556          case "blank" :          return "<IMG SRC=\"$gblIconLocation" . $d . "\" BORDER=0>" ;
557                  $d = "blank.gif" ;  } // end function GifIcon
558                  break ;  
559          case "checkout":  //////////////////////////////////////////////////////////////////
560                  $d = "box2.gif";  
561                  break;  function Navigate($fsRoot,$relDir) {
562          case "checkin":  
563                  $d = "hand.up.gif";          global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide,
564                  break;                  $gblIgnoreUnknownFileType, $gblRepositoryDir,
565          case "locked":                  $gblLogin, $gblUserName, $gblDateFmt, $gblTimeFmt,
566                  $d = "screw2.gif";                  $gblPermNote,
567                  break;                  $fsRealmDir, $realm, $realm_sep,
568          case "note":                  $html, $realm_config,
569                  $d = "quill.gif";                  $HTTP_GET_VARS, $HTTP_SERVER_VARS;
570                  break;          
571          default :          $self     = $HTTP_SERVER_VARS["PHP_SELF"] ;
572                  $d = "generic.gif" ;  
573          }          $relDir = chopsl($relDir)."/";
574            $fsDir = $fsRoot.$relDir;       // current directory
575          return "<IMG SRC=\"$gblIconLocation" . $d . "\" BORDER=0>" ;  
576  } // end function GifIcon          if (!is_dir($fsDir)) Error("Dir not found","Directory <tt>$relDir<tt> not found on filesystem at <tt>$fsDir</tt>",1) ;
577    
578  //////////////////////////////////////////////////////////////////          global $debug;
579            $debug .= "[$gblLogin|$relDir] before >";
580  function Navigate($fsRoot,$relDir) {  
581            if (! check_perm($relDir,trperm_b))
582          global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide,                  Error("Access denied","User <tt>$gblLogin</tt> tried to access <tt>$relDir</tt> without valid trustee.",1);
583                  $gblIgnoreUnknownFileType, $gblRepositoryDir,          $debug .= "< afeter";
584                  $gblLogin, $gblUserName, $gblDateFmt, $gblTimeFmt,  
585                  $fsRealmDir, $realm, $realm_sep,          $hide_items=",$gblHide,";
586                  $html, $realm_config,  
587                  $HTTP_GET_VARS, $HTTP_SERVER_VARS;          $dirList = array();
588                    $fileList = array();
589          $self     = $HTTP_SERVER_VARS["PHP_SELF"] ;  
590            // read directory contents
591          $relDir = chopsl($relDir)."/";          if ( !($dir = @opendir($fsDir)) )
592          $fsDir = $fsRoot.$relDir;       // current directory                  Error("Read Access denied",$relDir,1) ;
593            while ($item = readdir($dir)) {
594          if (!is_dir($fsDir)) Error("Dir not found","Directory <tt>$relDir<tt> not found on filesystem at <tt>$fsDir</tt>",1) ;                  if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") ) continue ;
595                    if (is_dir($fsDir.$item) || is_link ($fsDir.$item)) {
596          global $debug;                          if (check_perm($relDir.$item,trperm_b)) {
597          $debug .= "[$gblLogin|$relDir] before >";                                  $dirList[$item] = $item ;
598                                    $dirNote[$item] = ReadNote($fsDir.$item);
599          if (! check_perm($relDir,trperm_b))                          }
600                  Error("Access denied","User <tt>$gblLogin</tt> tried to access <tt>$relDir</tt> without valid trustee.",1);                  } else if (is_file($fsDir.$item)) {
601          $debug .= "< afeter";                          if (check_perm($relDir.$item,trperm_r)) {
602                                    $fileList[$item] = $item ;              
603          $hide_items=",$gblHide,";                                  $fileDate[$item] = filemtime($fsDir.$item) ;
604                                    $fileSize[$item] = filesize($fsDir.$item) ;
605          $dirList = array();                                  $fileNote[$item] = ReadNote($fsDir.$item);
606          $fileList = array();                          }
607                    } else {
608          // read directory contents                          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);
609          if ( !($dir = @opendir($fsDir)) )                  }
610                  Error("Read Access denied",$relDir,1) ;          }
611          while ($item = readdir($dir)) {          closedir($dir) ;
612                  if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") ) continue ;  
613                  if (is_dir($fsDir.$item) || is_link ($fsDir.$item)) {          // scan deleted files
614                          if (check_perm($relDir.$item,trperm_b)) {          if ( HTTP_GET_VAR("show_deleted") == 1 && ($dir = @opendir("$fsDir/.del")) ) {
615                                  $dirList[$item] = $item ;                  while ($item = readdir($dir)) {
616                                  $dirNote[$item] = ReadNote($fsDir.$item);                          if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") || !check_perm($relDir.$item,trperm_w) ) continue ;
617                          }                          if (is_file($fsDir.".del/$item")) {
618                  } else if (is_file($fsDir.$item)) {                                  $fileList[$item] = ".del/$item" ;              
619                          if (check_perm($relDir.$item,trperm_r)) {                                  $fileDate[$item] = filemtime($fsDir.".del/$item") ;
620                                  $fileList[$item] = $item ;                                                $fileSize[$item] = filesize($fsDir.".del/$item") ;
621                                  $fileDate[$item] = filemtime($fsDir.$item) ;                                  $fileNote[$item] = ReadNote($fsDir.".del/$item");
622                                  $fileSize[$item] = filesize($fsDir.$item) ;                          } else {
623                                  $fileNote[$item] = ReadNote($fsDir.$item);                                  $dirList[$item] = ".del/$item" ;                
624                          }                                  $dirNote[$item] = ReadNote($fsDir.".del/$item");
625                  } else {                          }
626                          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);                  }
627                  }                  closedir($dir) ;
628          }          }
629          closedir($dir) ;  
630            $emptyDir = ! (sizeof($dirList) || sizeof($fileList)) ;
631          // scan deleted files  
632          if ( HTTP_GET_VAR("show_deleted") == 1 && ($dir = @opendir("$fsDir/.del")) ) {          // start navigation page
633                  while ($item = readdir($dir)) {          $text  = "Use this page to add, delete";
634                          if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") || !check_perm($relDir.$item,trperm_w) ) continue ;          if (! isset($HTTP_GET_VARS["show_deleted"])) {
635                          $fileList[$item] = ".del/$item" ;                                $text .= ", <a href=$self?D=".urlencode($relDir)."&show_deleted=1>undelete</a>";
636                          $fileDate[$item] = filemtime($fsDir.".del/$path") ;          }
637                          $fileSize[$item] = filesize($fsDir.".del/$path") ;          $text .= " or revise files on this web site." ;
638                          $fileNote[$item] = ReadNote($fsDir.".del/$item");          $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>.";
639                  }          StartHTML("(Navigate)",$text) ;
640                  closedir($dir) ;  
641          }          print "<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=3 WIDTH=\"100%\">" ;
642    
643          $emptyDir = ! (sizeof($dirList) || sizeof($fileList)) ;          // updir (parent) bar  
644            if (chopsl($fsDir) != chopsl($fsRoot)) {
645          // start navigation page                  $parent = dirname($relDir) ;
646          $text  = "Use this page to add, delete";                  if ($parent == "") $parent = "/" ;
647          if (! isset($HTTP_GET_VARS["show_deleted"])) {  
648                  $text .= ", <a href=$self?D=".urlencode($relDir)."&show_deleted=1>undelete</a>";                  include("$html/Navigate-parent.html");
649          }          }
650          $text .= " or revise files on this web site." ;  
651          $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>.";          function plural($name,$count) {
652          StartHTML("(Navigate)",$text) ;                  $out="$count $name";
653                    if ($count > 1) {
654          echo "<TABLE BORDER=0 CELLPADDING=2                          $out.="s";
655                  CELLSPACING=3 WIDTH=\"100%\">" ;                  }
656                    return $out;
657          // updir (parent) bar            }
658          if (chopsl($fsDir) != chopsl($fsRoot)) {  
659                  $parent = dirname($relDir) ;          $dsort = HTTP_GET_VAR("dsort");
660                  if ($parent == "") $parent = "/" ;          if (! isset($dsort)) $dsort = "name"; // default directory sort
661    
662                  include("$html/Navigate-parent.html");          $dsort_arr = array(
663          }                  "name" => array ("rname", "note"),
664                    "rname" => array ("name", "note"),
665          function plural($name,$count) {                  "note" => array ("name", "rnote"),
666                  $out="$count $name";                  "rnote" => array ("name", "note")
667                  if ($count > 1) {                  );
668                          $out.="s";  
669                  }          $fsort = HTTP_GET_VAR("fsort");
670                  return $out;          if (! isset($fsort)) $fsort = "name"; // default directory sort
671          }  
672            $fsort_arr = array(
673          if (! HTTP_GET_VAR("dsort")) $dsort = "name"; // default directory sort                  "name" => array ("rname", "note", "date", "size"),
674                    "rname" => array ("name", "note", "date", "size"),
675          $dsort_arr = array(                  "note" => array ("name", "rnote", "date", "size"),
676                  "name" => array ("rname", "note"),                  "rnote" => array ("name", "note", "date", "size"),
677                  "rname" => array ("name", "note"),                  "date" => array ("name", "note", "rdate", "size"),
678                  "note" => array ("name", "rnote"),                  "rdate" => array ("name", "note", "date", "size"),
679                  "rnote" => array ("name", "note")                  "size" => array ("name", "note", "date", "rsize"),
680                  );                  "rsize" => array ("name", "note", "date", "size")
681                    );
682          if (! HTTP_GET_VAR("fsort")) $fsort = "name"; // default directory sort  
683            $D="D=".urlencode($relDir);
684          $fsort_arr = array(  
685                  "name" => array ("rname", "note", "date", "size"),          function self_args($arr = array()) {
686                  "rname" => array ("name", "note", "date", "size"),                  global $self;
687                  "note" => array ("name", "rnote", "date", "size"),                  $arg = implode("&",$arr);
688                  "rnote" => array ("name", "note", "date", "size"),                  if ($arg) {
689                  "date" => array ("name", "note", "rdate", "size"),                          return $self."?".$arg;
690                  "rdate" => array ("name", "note", "date", "size"),                  } else {
691                  "size" => array ("name", "note", "date", "rsize"),                          return $self;
692                  "rsize" => array ("name", "note", "date", "size")                  }
693                  );          }
694            // output subdirs
695          $D="D=".urlencode($relDir);          if (sizeof($dirList) > 0) {
696                    switch ($dsort) {
697          function self_args($arr = array()) {                          case "note":
698                  global $self;                                  $items = $dirNote;
699                  $arg = implode("&",$arr);                                  asort($items);
700                  if ($arg) {                                  break;
701                          return $self."?".$arg;                          case "rnote":
702                  } else {                                  $items = $dirNote;
703                          return $self;                                  arsort($items);
704                  }                                  break;
705          }                          case "rname":
706          // output subdirs                                  $items = $dirList;
707          if (sizeof($dirList) > 0) {                                  krsort($items);
708                  switch ($dsort) {                                  break;
709                          case "note":                          default:
710                                  $items = $dirNote;                                  $items = $dirList;
711                                  asort($items);                                  ksort($items);
712                                  break;                                  break;
713                          case "rnote":                  }
714                                  $items = $dirNote;                  $durl = self_args(array($D,"dsort=".$dsort_arr[$dsort][0]));
715                                  arsort($items);                  $nurl = self_args(array($D,"dsort=".$dsort_arr[$dsort][1]));
716                                  break;  
717                          case "rname":                  include("$html/Navigate-dirHeader.html");
718                                  $items = $dirList;  
719                                  krsort($items);                  while (list($key,$dir) = each($items)) {
720                                  break;  
721                          default:                          $dir = $dirList[$key];
722                                  $items = $dirList;  
723                                  ksort($items);                          $info_url=self_args(array("A"=>"A=E", "F"=>"F=".urlencode($dir), "D"=>$D));
724                                  break;                          if (substr($dir,0,5) == ".del/") {
725                  }                                  $dir = substr($dir,5,strlen($dir)-5);
726                  $durl = self_args(array($D,"dsort=".$dsort_arr[$dsort][0]));                                  $deleted = " <a href=\"$info_url#undelete\"><SPAN CLASS=deleted TITLE=\"deleted\">deleted</span></a>";
727                  $nurl = self_args(array($D,"dsort=".$dsort_arr[$dsort][1]));                          } else {
728                                    $deleted = "";
729                  include("$html/Navigate-dirHeader.html");                          }
730            
731                  while (list($key,$dir) = each($items)) {                          $dir_url=$self."?D=".urlencode(chopsl($relDir)."/".$dir);
732                            if (check_perm($relDir.$dir,$gblPermNote)) {
733                          $dir = $dirList[$key];                                  $note_html="<a href=\"$info_url#note\">".$gblIcon("note")."</a>".$dirNote[$key];
734                            } else {
735                          $info_url=self_args(array("A"=>"A=E", "F"=>"F=".urlencode($dir), "D"=>$D));                                  $note_html=$dirNote[$key];
736                          $dir_url=$self."?D=".urlencode(chopsl($relDir)."/".$dir);                          }
737                          include("$html/Navigate-dirEntry.html");  
738                            $dir_html = isBlank($dir,"directory");
739                  }  // iterate over dirs  
740          }  // end if no dirs                          include("$html/Navigate-dirEntry.html");
741    
742          $durl = self_args(array($D,"fsort=".$fsort_arr[$fsort][0]));                  }  // iterate over dirs
743          $nurl = self_args(array($D,"fsort=".$fsort_arr[$fsort][1]));          }  // end if no dirs
744          $uurl = self_args(array($D,"fsort=".$fsort_arr[$fsort][2]));  
745          $surl = self_args(array($D,"fsort=".$fsort_arr[$fsort][3]));          $durl = self_args(array($D,"fsort=".$fsort_arr[$fsort][0]));
746            $nurl = self_args(array($D,"fsort=".$fsort_arr[$fsort][1]));
747          include("$html/Navigate-fileHeader.html");          $uurl = self_args(array($D,"fsort=".$fsort_arr[$fsort][2]));
748            $surl = self_args(array($D,"fsort=".$fsort_arr[$fsort][3]));
749          if (sizeof($fileList) > 0) {  
750                  switch ($fsort) {          $html_uri = $webRoot;
751                          case "note":  
752                                  $items = $fileNote;          if (substr($relDir,0,1) == "/") {
753                                  asort($items);                  $html_uri .= substr($relDir,1,strlen($relDir)-1);
754                                  break;          } else {
755                          case "rnote":                  $html_uri .= $relDir;
756                                  $items = $fileNote;          }
757                                  arsort($items);  
758                                  break;          include("$html/Navigate-fileHeader.html");
759                          case "date":  
760                                  $items = $fileDate;          if (sizeof($fileList) > 0) {
761                                  asort($items);                  switch ($fsort) {
762                                  break;                          case "note":
763                          case "rdate":                                  $items = $fileNote;
764                                  $items = $fileDate;                                  asort($items);
765                                  arsort($items);                                  break;
766                                  break;                          case "rnote":
767                          case "size":                                  $items = $fileNote;
768                                  $items = $fileSize;                                  arsort($items);
769                                  asort($items);                                  break;
770                                  break;                          case "date":
771                          case "rsize":                                  $items = $fileDate;
772                                  $items = $fileSize;                                  asort($items);
773                                  arsort($items);                                  break;
774                                  break;                          case "rdate":
775                          case "rname":                                  $items = $fileDate;
776                                  $items = $fileList;                                  arsort($items);
777                                  krsort($items);                                  break;
778                                  break;                          case "size":
779                          default:                                  $items = $fileSize;
780                                  $items = $fileList;                                  asort($items);
781                                  ksort($items);                                  break;
782                                  break;                          case "rsize":
783                  }                                  $items = $fileSize;
784                                    arsort($items);
785            while (list($key,$file) = each($items)) {                                  break;
786                  $file = $fileList[$key];                          case "rname":
787                  $path = $fsDir."/".$file ;                                  $items = $fileList;
788                  $mod  = $fileDate[$key];                                  krsort($items);
789                  $sz   = $fileSize[$key];                                  break;
790                                    default:
791                  if ($sz >= 10240) {                                  $items = $fileList;
792                          $sz = (int)(($sz+1023)/1024) . " k" ;                                  ksort($items);
793                  } else {                                  break;
794                          $sz .= " " ;                  }
795                  } // end size  
796              while (list($key,$file) = each($items)) {
797                  $a = $b = "" ;                  $file = $fileList[$key];
798                    $path = $fsDir."/".$file ;
799                  $info_url=$self."?A=E&F=".urlencode($file)."&D=".urlencode($relDir);                  $mod  = $fileDate[$key];
800                    $sz   = $fileSize[$key];
801                  if ( ($mod + $gblModDays*86400) > time() ) {          
802                          $a  = "<SPAN CLASS=RED TITLE=\"Newer" ;                  if ($sz >= 10240) {
803                          $a .= " than $gblModDays days\"> * </SPAN>" ;                          $sz = (int)(($sz+1023)/1024) . " k" ;
804                  }                  } else {
805                            $sz .= " " ;
806                  $file_lock=CheckLock($path);                  } // end size
807    
808                  $file_url_html="<A HREF=\"$self?A=V&D=".urlencode($relDir)."&F=".urlencode($file);                  $a = $b = "" ;
809                  $file_url_html.="\" TITLE=\"View file\">" ;  
810                    $info_url=$self."?A=E&F=".urlencode($file)."&D=".urlencode($relDir);
811                  if (substr($file,0,5) != ".del/") {  
812                          $file_url_html .= $file . "</A>" . $a ;                  if ( ($mod + $gblModDays*86400) > time() ) {
813                  } else {                          $a  = "<SPAN CLASS=RED TITLE=\"Newer" ;
814                          $file_url_html .= substr($file,5,strlen($file)-5) . "</a> <SPAN CLASS=RED TITLE=\"deleted\"> <a href=\"$info_url#undelete\">deleted</a> </span>";                          $a .= " than $gblModDays days\"> * </SPAN>" ;
815                  }                  }
816    
817                  $note_html="<a href=\"$info_url#note\">".$gblIcon("note")."</a>".ReadNote($path);                  $file_lock=CheckLock($path);
818    
819                  $ext = strtolower(strrchr($file,".")) ;                  $file_url_html="<A HREF=\"$self?A=V&D=".urlencode($relDir)."&F=".urlencode($file);
820                    $file_url_html.="\" TITLE=\"View file\">" ;
821                  if ($file_lock) {  
822                          if ($file_lock == $gblUserName) {                  if (substr($file,0,5) != ".del/") {
823                                  $b.="<A HREF=\"$self?A=Ci&D=".urlencode($relDir)."&F=".urlencode($file);                          $file_url_html .= isBlank($file) . "</A>" . $a ;
824                                  $b.="\" TITLE=\"Checkin (update) file on server\">" ;                  } else {
825                                  $file_url_html=$b;                          $file_url_html .= isBlank(substr($file,5,strlen($file)-5)) . "</a> <a href=\"$info_url#undelete\"><SPAN CLASS=deleted TITLE=\"deleted\">deleted</span></a>";
826                                  $b.=$gblIcon("checkin")."</A>" ;                  }
827                                  $b.= $gblIcon("blank");  
828                                  $file_url_html.="$file</a> $a";                  if (check_perm($relDir.$file,$gblPermNote)) {
829                                  $note_html = $gblIcon("blank")."<b>Please check-in (update) this file</b>";                          $note_html="<a href=\"$info_url#note\">".$gblIcon("note")."</a>".$fileNote[$key];
830                          } else {                  } else {
831                                  $b = $gblIcon("locked");                          $note_html=$fileNote[$key];
832                                  $b.= $gblIcon("blank");                  }
833                                  $note_html = $gblIcon("blank")."<b>File locked by $file_lock</b>";  
834                                  $file_url_html = "$file $a";                  $ext = strtolower(strrchr($file,".")) ;
835                          }  
836                  } else {                  if ($file_lock) {
837                          $b.="<A HREF=\"$self?A=Co&D=".urlencode($relDir)."&F=".urlencode($file);                          if ($file_lock == $gblUserName) {
838                          $b.="\" TITLE=\"Checkout file for edit\">" ;                                  $b.="<A HREF=\"$self?A=Ci&D=".urlencode($relDir)."&F=".urlencode($file);
839                          $b.=$gblIcon("checkout")."</A>";                                  $b.="\" TITLE=\"Checkin (update) file on server\">" ;
840                                    $file_url_html=$b;
841                          if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) {                                    $b.=$gblIcon("checkin")."</A>" ;
842                                  $b.="<A HREF=\"$self?A=C&D=".urlencode($relDir)."&F=".urlencode($file);                                  $b.= $gblIcon("blank");
843                                  $b.="\" TITLE=\"List contents\">" ;                                  $file_url_html.="$file</a> $a";
844                                  $b.=$gblIcon("view")."</A>" ;                                  $note_html = $gblIcon("blank")."<b>Please check-in (update) this file</b>";
845                          } else {                          } else {
846                                  $b.= $gblIcon("blank");                                  $b = $gblIcon("locked");
847                          }                                  $b.= $gblIcon("blank");
848                  }                                  $note_html = $gblIcon("blank")."<b>File locked by $file_lock</b>";
849                                    $file_url_html = "$file $a";
850                  $mod = date("$gblDateFmt $gblTimeFmt",$mod);                          }
851                    } else {
852                  include("$html/Navigate-fileEntry.html");                          if (check_perm($relDir.$file,trperm_w)) {
853                                    $b.="<A HREF=\"$self?A=Co&D=".urlencode($relDir)."&F=".urlencode($file);
854            }  // iterate over files                                  $b.="\" TITLE=\"Checkout file for edit\" onClick=\"window.setTimeout('window.location.reload()',3000); return true;\">" ;
855          } else {  // end if no files                                  $b.=$gblIcon("checkout")."</A>";
856  ?>                          }
857   <TR><TD></TD><TD COLSPAN=5 CLASS=LST>  
858    No files in this directory                          if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) {  
859   </TD></TR>                                  $b.="<A HREF=\"$self?A=C&D=".urlencode($relDir)."&F=".urlencode($file);
860  <?                                  $b.="\" TITLE=\"List contents\">" ;
861          }                                  $b.=$gblIcon("view")."</A>" ;
862                            } else {
863          if ($emptyDir && $relDir != "") {                                  $b.= $gblIcon("blank");
864  ?>                          }
865                    }
866  <FORM METHOD="POST" ACTION="<?= $self ?>">  
867   <TR><TD></TD><TD COLSPAN=5 CLASS=BAR>                  $mod = date("$gblDateFmt $gblTimeFmt",$mod);
868    <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">  
869    OK TO DELETE THIS EMPTY FOLDER?                  include("$html/Navigate-fileEntry.html");
870    <INPUT TYPE="CHECKBOX" NAME="CONFIRM">  
871    <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="DELETE">            }  // iterate over files
872   </TD></TR>          } else {  // end if no files
873  </FORM>                  include("$html/Navigate-noFiles.html");
874            }
875  <?php  
876          } // end if emptyDir          if ($emptyDir && $relDir != "") {
877  ?>                  include("$html/Navigate-emptyDir.html");
878            } // end if emptyDir
879  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>  
880            include("$html/Navigate-hr.html");      
881  <?  
882            if (file_exists("$fsRealmDir/$realm".$realm_sep."info.inc")) {
883  if (file_exists("$fsRealmDir/$realm".$realm_sep."info.inc")) {                  print "<TR><TD></TD><TD COLSPAN=5>";
884          print "<TR><TD></TD><TD COLSPAN=5>";                  include("$fsRealmDir/$realm".$realm_sep."info.inc");
885          include("$fsRealmDir/$realm".$realm_sep."info.inc");                  print "</TD></TR>";
886          print "</TD></TR><TR><TD></TD><TD COLSPAN=5><HR></TD></TR>";                  include("$html/Navigate-hr.html");      
887  } elseif (file_exists("$gblRepositoryDir/.info.inc")) {          } elseif (file_exists("$gblRepositoryDir/.info.inc")) {
888          print "<TR><TD></TD><TD COLSPAN=5>";                  print "<TR><TD></TD><TD COLSPAN=5>";
889          include("$gblRepositoryDir/.info.inc");                  include("$gblRepositoryDir/.info.inc");
890          print "</TD></TR><TR><TD></TD><TD COLSPAN=5><HR></TD></TR>";                  print "</TD></TR>";
891  }                  include("$html/Navigate-hr.html");      
892            }
893    
894  ?>          include("$html/Navigate-createNew.html");
895    
896  <FORM METHOD="POST" ACTION="<?= $self ?>">          print "</TABLE>";
897  <TR><TD></TD><TD COLSPAN=5 CLASS=BAR>CREATE NEW  
898   <INPUT TYPE="RADIO" NAME="T" VALUE="D" CHECKED>DIRECTORY -OR-          EndHTML() ;
899   <INPUT TYPE="RADIO" NAME="T" VALUE="F">FILE : &nbsp;&nbsp;  } // end function Navigate
900   <NOBR>NAME <INPUT TYPE="TEXT" NAME="FN" SIZE=14>  
901   <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE">  //////////////////////////////////////////////////////////////////
902   <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">  
903   <INPUT TYPE="SUBMIT" VALUE="CREATE" NAME="CREATE">  function UploadPage($fsRoot, $relDir, $filename="") {
904   </NOBR>  
905   <NOBR>OR <A HREF="<?= $self ?>?A=U&D=<?= urlencode($relDir) ?>">UPLOAD</A> A FILE</NOBR>          global $html, $HTTP_SERVER_VARS;
906  </TD></TR>  
907  </FORM>          $self = $HTTP_SERVER_VARS["PHP_SELF"] ;
908  </TABLE>          include("$html/UploadPage.html");
909    
910  <?php  } // end function UploadPage
911          EndHTML() ;  
912  } // end function Navigate  //////////////////////////////////////////////////////////////////
913    
914  //////////////////////////////////////////////////////////////////  // Error with sysadmin flag are reported to error_log or hidden from
915    // users
916  function UploadPage($fsRoot, $relDir, $filename="") {  
917    function Error($title,$text="",$sysadmin=0,$no_404=0) {
918          global $html, $HTTP_SERVER_VARS;          global $gblSeparateAdminMessages,
919                    $gblMailAdminMessages,$realm,
920          $self = $HTTP_SERVER_VARS["PHP_SELF"] ;                  $HTTP_SERVER_VARS;
921          include("$html/UploadPage.html");          if (! headers_sent() && ! $no_404) header("HTTP/1.0 404 Not Found");
922            if ($sysadmin) {
923  } // end function UploadPage                  if ($gblSeparateAdminMessages) {
924                            $user="Your administrator ";
925  //////////////////////////////////////////////////////////////////                          if ($gblMailAdminMessages) {
926                                    mail($HTTP_SERVER_VARS["SERVER_ADMIN"], "docman $realm error message: $title", strip_tags($text));
927  // Error with sysadmin flag are reported to error_log or hidden from                                  $user.="<tt>".$HTTP_SERVER_VARS["SERVER_ADMIN"]."</tt> ";
928  // users                          }
929                            $user.="has been notified about error" ;
930  function Error($title,$text="",$sysadmin=0,$no_404=0) {                          StartHTML("($title)",$user);
931          global $gblSeparateAdminMessages,                          echo "<P ALIGN=center>Hit your Browser's Back Button.</P>" ;
932                  $gblMailAdminMessages,$realm,                          EndHTML();
933                  $HTTP_SERVER_VARS;                          error_log("docman $realm: ".strip_tags($text));
934          if (! headers_sent() && ! $no_404) header("HTTP/1.0 404 Not Found");                  } else {
935          if ($sysadmin) {                          StartHTML("ADMIN: ".$title,$text) ;
936                  if ($gblSeparateAdminMessages) {                          echo "<P ALIGN=center>Hit your Browser's Back Button.</P>" ;
937                          $user="Your administrator ";                          EndHTML();
938                          if ($gblMailAdminMessages) {                  }
939                                  mail($HTTP_SERVER_VARS["SERVER_ADMIN"], "docman $realm error message: $title", strip_tags($text));          } else {
940                                  $user.="<tt>".$HTTP_SERVER_VARS["SERVER_ADMIN"]."</tt> ";                  StartHTML("(".$title.")",$text) ;
941                          }                  echo "<P ALIGN=center>Hit your Browser's Back Button.</P>" ;
942                          $user.="has been notified about error" ;                  EndHTML() ;
943                          StartHTML("($title)",$user);          }
944                          echo "<P ALIGN=center>Hit your Browser's Back Button.</P>" ;          exit ;
945                          EndHTML();  } // end function Error
946                          error_log("docman $realm: ".strip_tags($text));  
947                  } else {  function LogIt($target,$msg, $changelog=0) {
948                          StartHTML("ADMIN: ".$title,$text) ;  
949                          echo "<P ALIGN=center>Hit your Browser's Back Button.</P>" ;          global $gblDateFmt, $gblTimeFmt, $gblUserName, $gblFsRoot;
950                          EndHTML();  
951                  }          $dir=dirname($target);
952          } else {          if (! file_exists($dir."/.log")) {
953                  StartHTML("(".$title.")",$text) ;                  if (! @mkdir($dir."/.log",0700)) Error("docman installation problem","can't create log directory <tt>$dir/.log</tt>",1);
954                  echo "<P ALIGN=center>Hit your Browser's Back Button.</P>" ;          }
955                  EndHTML() ;          $file=basename($target);
956          }  
957          exit ;          $log=fopen("$dir/.log/$file","a+");
958  } // end function Error          fputs($log,date("$gblDateFmt\t$gblTimeFmt").
959                    "\t$gblUserName\t$msg\n");
960  function LogIt($target,$msg, $changelog=0) {          fclose($log);
961    
962          global $gblDateFmt, $gblTimeFmt, $gblUserName, $gblFsRoot;          if (! $changelog) return;
963    
964          $dir=dirname($target);          $log=fopen("$gblFsRoot/.changelog","a+");
965          if (! file_exists($dir."/.log")) {          if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot)
966                  if (! @mkdir($dir."/.log",0700)) Error("docman installation problem","can't create log directory <tt>$dir/.log</tt>",1);                  $target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot));
967          }          $msg=str_replace("\t"," ",$msg);
968          $file=basename($target);          fputs($log,time()."\t$target\t$gblUserName\t$msg\n");
969            fclose($log);
970          $log=fopen("$dir/.log/$file","a+");  
971          fputs($log,date("$gblDateFmt\t$gblTimeFmt").          // FIX: implement e-mail notification based on $changelog
972                  "\t$gblUserName\t$msg\n");          // permission
973          fclose($log);  }
974    
975          if (! $changelog) return;  
976    //////////////////////////////////////////////////////////////////
977          $log=fopen("$gblFsRoot/.changelog","a+");  
978          if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot)  function WriteNote($target,$msg) {
979                  $target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot));  
980          $msg=str_replace("\t"," ",$msg);          $target=stripSlashes($target);
981          fputs($log,time()."\t$target\t$gblUserName\t$msg\n");          $dir=dirname($target);
982          fclose($log);          if (! file_exists($dir."/.note")) {
983                    mkdir($dir."/.note",0700);
984          // FIX: implement e-mail notification based on $changelog          }
985          // permission          $file=basename($target);
986  }  
987            $note=fopen("$dir/.note/$file","w");
988            if (! $note) {
989  //////////////////////////////////////////////////////////////////                  Error("Error writing note","Can't open note file <tt>$dir/.note/$file</tt> for writing",1);
990            }
991  function WriteNote($target,$msg) {          fputs($note,"$msg\n");
992            fclose($note);
993          $target=stripSlashes($target);  
994          $dir=dirname($target);          LogIt($target,"added note $msg");
995          if (! file_exists($dir."/.note")) {  
996                  mkdir($dir."/.note",0700);  }
997          }  
998          $file=basename($target);  function ReadNote($target) {
999    
1000          $note=fopen("$dir/.note/$file","w");          $target=stripSlashes($target);
1001          fputs($note,"$msg\n");          $dir=dirname($target);
1002          fclose($note);          $file=basename($target);
1003            $msg="";
1004          LogIt($target,"added note $msg");          if (file_exists($dir."/.note/$file")) {
1005                    $note=fopen("$dir/.note/$file","r");
1006  }                  $msg=fgets($note,4096);
1007                    fclose($note);
1008  function ReadNote($target) {          }
1009            return HtmlSpecialChars(StripSlashes($msg));
1010          $target=stripSlashes($target);  
1011          $dir=dirname($target);  }
1012          $file=basename($target);  
1013          $msg="";  //////////////////////////////////////////////////////////////////
1014          if (file_exists($dir."/.note/$file")) {  
1015                  $note=fopen("$dir/.note/$file","r");  function MoveTo($source,$folder) {
1016                  $msg=fgets($note,4096);  
1017                  fclose($note);          $source=stripSlashes($source);
1018          }          $file=basename($source);
1019          return HtmlSpecialChars(StripSlashes($msg));          if (! file_exists($folder)) {
1020                    mkdir($folder,0700);
1021  }          }
1022            if (file_exists($source)) {
1023  //////////////////////////////////////////////////////////////////                  rename($source,"$folder/$file");
1024            }
1025  function MoveTo($source,$folder) {  }
1026    
1027          $source=stripSlashes($source);  //////////////////////////////////////////////////////////////////
1028          $file=basename($source);  
1029          if (! file_exists($folder)) {  function Lock($target) {
1030                  mkdir($folder,0700);  
1031          }          global $gblUserName;
1032          if (file_exists($source)) {  
1033                  rename($source,"$folder/$file");          $target=stripSlashes($target);
1034          }          $dir=dirname($target);
1035  }          if (! file_exists($dir."/.lock")) {
1036                    mkdir($dir."/.lock",0700);
1037  //////////////////////////////////////////////////////////////////          }
1038            $file=basename($target);
1039  function Lock($target) {  
1040            if (file_exists("$dir/.lock/$file")) {
1041          global $gblUserName;                  LogIt($target,"attempt to locked allready locked file!");
1042            } else {
1043          $target=stripSlashes($target);                  $lock=fopen("$dir/.lock/$file","w");
1044          $dir=dirname($target);                  fputs($lock,"$gblUserName\n");
1045          if (! file_exists($dir."/.lock")) {                  fclose($lock);
1046                  mkdir($dir."/.lock",0700);  
1047          }                  LogIt($target,"file locked");
1048          $file=basename($target);          }
1049    
1050          if (file_exists("$dir/.lock/$file")) {  }
1051                  LogIt($target,"attempt to locked allready locked file!");  
1052          } else {  function CheckLock($target) {
1053                  $lock=fopen("$dir/.lock/$file","w");  
1054                  fputs($lock,"$gblUserName\n");          $target=stripSlashes($target);
1055                  fclose($lock);          $dir=dirname($target);
1056            $file=basename($target);
1057                  LogIt($target,"file locked");          $msg=0;
1058          }          if (file_exists($dir."/.lock/$file")) {
1059                    $lock=fopen("$dir/.lock/$file","r");
1060  }                  $msg=fgets($lock,4096);
1061                    fclose($lock);
1062  function CheckLock($target) {          }
1063            return chop($msg);
1064          $target=stripSlashes($target);  
1065          $dir=dirname($target);  }
1066          $file=basename($target);  
1067          $msg=0;  function Unlock($target) {
1068          if (file_exists($dir."/.lock/$file")) {  
1069                  $lock=fopen("$dir/.lock/$file","r");          $target=stripSlashes($target);
1070                  $msg=fgets($lock,4096);          $dir=dirname($target);
1071                  fclose($lock);          $file=basename($target);
1072          }          if (file_exists($dir."/.lock/$file")) {
1073          return chop($msg);                  unlink("$dir/.lock/$file");
1074                    LogIt($target,"file unlocked");
1075  }          } else {
1076                    LogIt($target,"attempt to unlocked non-locked file!");
1077  function Unlock($target) {          }
1078    
1079          $target=stripSlashes($target);  }
1080          $dir=dirname($target);  
1081          $file=basename($target);  //////////////////////////////////////////////////////////////////
1082          if (file_exists($dir."/.lock/$file")) {  
1083                  unlink("$dir/.lock/$file");  function urlpath($url) {
1084                  LogIt($target,"file unlocked");          $url=urlencode(StripSlashes("$url"));
1085          } else {          $url=str_replace("%2F","/",$url);
1086                  LogIt($target,"attempt to unlocked non-locked file!");          $url=str_replace("+","%20",$url);
1087          }          return($url);
1088    }
1089  }  
1090    //////////////////////////////////////////////////////////////////
1091  //////////////////////////////////////////////////////////////////  
1092    function safe_rename($fromdir,$fromfile,$tofile) {
1093  function urlpath($url) {  
1094          $url=urlencode(StripSlashes("$url"));          global $gblNumBackups;
1095          $url=str_replace("%2F","/",$url);  
1096          $url=str_replace("+","%20",$url);          function try_rename($from,$to) {
1097          return($url);  #               print "$from -> $to\n";
1098  }                  if (file_exists($from) && is_writeable(dirname($to))) {
1099                            return rename($from,$to);
1100  //////////////////////////////////////////////////////////////////                  } else {
1101                            return 0;
1102  function safe_rename($fromdir,$fromfile,$tofile) {                  }
1103            }
1104          global $gblNumBackups;  
1105            function try_dir($todir) {
1106          function try_rename($from,$to) {                  if (! file_exists($todir)) {
1107  #               print "$from -> $to\n";                          @mkdir($todir,0700);
1108                  if (file_exists($from) && is_writeable(dirname($to))) {                  }
1109                          return rename($from,$to);          }
1110                  } else {  
1111                          return 0;          $to="$fromdir/$tofile";
1112                  }          $todir=dirname($to);
1113          }          $tofile=basename($to);
1114    
1115          function try_dir($todir) {  #       print "<pre>$fromdir / $fromfile -> $todir / $tofile\n\n";
1116                  if (! file_exists($todir)) {  
1117                          @mkdir($todir,0700);          if (! try_rename("$fromdir/$fromfile","$todir/$tofile")) Error("Rename error","Can't rename file <tt>$fromfile</tt> to <tt>$tofile</tt>",1);
1118                  }          try_dir("$todir/.log");
1119          }          try_rename("$fromdir/.log/$fromfile","$todir/.log/$tofile");
1120            try_dir("$todir/.note");
1121          $to="$fromdir/$tofile";          try_rename("$fromdir/.note/$fromfile","$todir/.note/$tofile");
1122          $todir=dirname($to);          try_dir("$todir/.lock");
1123          $tofile=basename($to);          try_rename("$fromdir/.lock/$fromfile","$todir/.lock/$tofile");
1124            try_dir("$todir/.bak");
1125  #       print "<pre>$fromdir / $fromfile -> $todir / $tofile\n\n";          for($i=0;$i<=$gblNumBackups;$i++) {
1126                    try_rename("$fromdir/.bak/$i/$fromfile","$todir/.bak/$i/$tofile");
1127          if (! try_rename("$fromdir/$fromfile","$todir/$tofile")) Error("Rename error","Can't rename file <tt>$fromfile</tt> to <tt>$tofile</tt>",1);          }
1128          try_dir("$todir/.log");  }
1129          try_rename("$fromdir/.log/$fromfile","$todir/.log/$tofile");  
1130          try_dir("$todir/.note");  
1131          try_rename("$fromdir/.note/$fromfile","$todir/.note/$tofile");  //////////////////////////////////////////////////////////////////
1132          try_dir("$todir/.lock");  
1133          try_rename("$fromdir/.lock/$fromfile","$todir/.lock/$tofile");  // recursivly delete directory
1134          try_dir("$todir/.bak");  
1135          for($i=0;$i<=$gblNumBackups;$i++) {  function rrmdir($dir) {
1136                  try_rename("$fromdir/.bak/$i/$fromfile","$todir/.bak/$i/$tofile");          $handle=opendir($dir);
1137          }          while ($file = readdir($handle)) {
1138  }                  if ($file != "." && $file != "..") {
1139                            if (is_dir("$dir/$file"))
1140                                    rrmdir("$dir/$file");
1141  //////////////////////////////////////////////////////////////////                          else
1142                                    if (! @unlink("$dir/$file")) return(0);
1143  // recursivly delete directory                  }
1144            }
1145  function rrmdir($dir) {          closedir($handle);
1146          $handle=opendir($dir);          return @rmdir($dir);
1147          while ($file = readdir($handle)) {  }
1148                  if ($file != "." && $file != "..") {  
1149                          if (is_dir("$dir/$file"))  //////////////////////////////////////////////////////////////////
1150                                  rrmdir("$dir/$file");  
1151                          else  function DisplayChangeLog($day) {
1152                                  if (! @unlink("$dir/$file")) return(0);  
1153                  }          global $gblFsRoot, $gblDateFmt, $gblTimeFmt,
1154          }                  $HTTP_SERVER_VARS;
1155          closedir($handle);  
1156          return @rmdir($dir);          $self  = $HTTP_SERVER_VARS["PHP_SELF"];
1157  }  
1158            if (!file_exists("$gblFsRoot/.changelog")) return;
1159  //////////////////////////////////////////////////////////////////          $log=fopen("$gblFsRoot/.changelog","r");
1160            $logarr = array();
1161  function DisplayChangeLog($day) {          while($line = fgetcsv($log,512,"\t")) {
1162                    while (sizeof($line) > 4) {
1163          global $gblFsRoot, $gblDateFmt, $gblTimeFmt,                          $tmp = array_pop($line);
1164                  $HTTP_SERVER_VARS;                          $line.=" $tmp";
1165                    }
1166          $self  = $HTTP_SERVER_VARS["PHP_SELF"];                  if ($day!=1 || ($day==1 && (time()-$line[0] < 24*60*60))) {
1167                            array_unshift($logarr,array($line[0],$line[1],$line[2],$line[3]));
1168          if (!file_exists("$gblFsRoot/.changelog")) return;                  }
1169          $log=fopen("$gblFsRoot/.changelog","r");          }
1170          $logarr = array();          fclose($log);
1171          while($line = fgetcsv($log,512,"\t")) {          $cl1=" class=LST"; $cl2="";
1172                  while (sizeof($line) > 4) {          print "<table border=0 width=100%>\n";
1173                          $tmp = array_pop($line);          while ($e = array_shift($logarr)) {
1174                          $line.=" $tmp";                  $cl=$cl1; $cl1=$cl2; $cl2=$cl;
1175                  }                  $date = date($gblDateFmt, $e[0]);
1176                  if ($day!=1 || ($day==1 && (time()-$line[0] < 24*60*60))) {                  $time = date($gblTimeFmt, $e[0]);
1177                          array_unshift($logarr,array($line[0],$line[1],$line[2],$line[3]));                  $dir = dirname($e[1]);
1178                  }                  $file = basename($e[1]);
1179          }                  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";
1180          fclose($log);          }
1181          $cl1=" class=LST"; $cl2="";          print "</table>";
1182          print "<table border=0 width=100%>\n";          print "<p>".GifIcon("up")." Back to <a href=\"$self\">front page</a>.</p>";
1183          while ($e = array_shift($logarr)) {  }
1184                  $cl=$cl1; $cl1=$cl2; $cl2=$cl;  
1185                  $date = date($gblDateFmt, $e[0]);  //////////////////////////////////////////////////////////////////
1186                  $time = date($gblTimeFmt, $e[0]);  
1187                  $dir = dirname($e[1]);  function Download($path,$force=0) {
1188                  $file = basename($e[1]);          global $HTTP_SERVER_VARS,$mime_type;
1189                  print "<tr><td$cl>$date</td><td$cl>$time</td><td$cl><a href=\"$HTTP_SERVER_VARS[PHP_SELF]?D=".urlencode($dir)."\">$dir</a>/$file</td><td$cl>$e[2]</td><td$cl>$e[3]</td></tr>\n";  
1190          }          // default transfer-encoding
1191          print "</table>";          $encoding = "binary";
1192          print "<p>".GifIcon("up")." Back to <a href=\"$self\">front page</a>.</p>";  
1193  }          // known transfer encodings
1194            $encoding_ext = array(
1195  //////////////////////////////////////////////////////////////////                  "gz" => "x-gzip",
1196                    "Z" => "x-compress",
1197  function Download($path,$force=0) {          );
1198          global $HTTP_SERVER_VARS,$mime_type;  
1199            $file = basename($path);
1200          // default transfer-encoding          $size = filesize($path);
1201          $encoding = "binary";  
1202            $ext_arr = explode(".",$file);
1203          // known transfer encodings          $ext = array_pop($ext_arr);
1204          $encoding_ext = array(          if (isset($encoding_ext[$ext])) {
1205                  "gz" => "x-gzip",                  $encoding = $encoding_ext[$ext];
1206                  "Z" => "x-compress",                  $ext = array_pop($ext_arr);
1207          );          }
1208    
1209          $file = basename($path);          if ($force || !isset($mime_type[$ext])) {
1210          $size = filesize($path);                  header("Content-Type: application/force-download");
1211            } else {
1212          $ext_arr = explode(".",$file);                  header("Content-Type: $mime_type[$ext]");
1213          $ext = array_pop($ext_arr);          }
1214          if ($encoding_ext[$ext]) {  
1215                  $encoding = $encoding_ext[$ext];          // IE5.5 just downloads index.php if we don't do this
1216                  $ext = array_pop($ext_arr);          if(preg_match("/MSIE 5.5/", $HTTP_SERVER_VARS["HTTP_USER_AGENT"])) {
1217          }                  header("Content-Disposition: filename=$file");
1218            } else {
1219          if ($force || !isset($mime_type[$ext])) {                  header("Content-Disposition: attachment; filename=$file");
1220                  header("Content-Type: application/force-download");          }
1221          } else {  
1222                  header("Content-Type: $mime_type[$ext]");          header("Content-Transfer-Encoding: $encoding");
1223          }          $fh = fopen($path, "r");
1224            fpassthru($fh);
1225          // IE5.5 just downloads index.php if we don't do this  }
1226          if(preg_match("/MSIE 5.5/", $HTTP_SERVER_VARS[HTTP_USER_AGENT])) {  
1227                  header("Content-Disposition: filename=$file");  
1228          } else {  //////////////////////////////////////////////////////////////////
1229                  header("Content-Disposition: attachment; filename=$file");  
1230          }  function chopsl($path) {
1231            $path=str_replace("//","/",$path);
1232          header("Content-Transfer-Encoding: $encoding");          if (substr($path,strlen($path)-1,1) == "/") $path=substr($path,0,strlen($path)-1);
1233          $fh = fopen($path, "r");          return $path;
1234          fpassthru($fh);  }
1235  }  
1236    //////////////////////////////////////////////////////////////////
1237    /*
1238  //////////////////////////////////////////////////////////////////          Document manager ACL implementation
1239    
1240  function chopsl($path) {          Written by Dobrica Pavlinusic <dpavlin@rot13.org>
1241          $path=str_replace("//","/",$path);  
1242          if (substr($path,strlen($path)-1,1) == "/") $path=substr($path,0,strlen($path)-1);          Based on ideas from Linux trustees code
1243          return $path;          by Vyacheslav Zavadsky <zavadsky@braysystems.com>
1244  }  */
1245    
1246  //////////////////////////////////////////////////////////////////  define('trmask_not',1 << 0);
1247  /*  define('trmask_clear',1 << 1);
1248          Document manager ACL implementation  define('trmask_deny',1 << 2);
1249    define('trmask_one_level',1 << 3);
1250          Written by Dobrica Pavlinusic <dpavlin@rot13.org>  define('trmask_group',1 << 4);
1251    
1252          Based on ideas from Linux trustees code  define('trperm_r',1 << 5);
1253          by Vyacheslav Zavadsky <zavadsky@braysystems.com>  define('trperm_w',1 << 6);
1254  */  define('trperm_b',1 << 7);
1255    define('trperm_n',1 << 8);
1256  define('trmask_not',1 << 0);  
1257  define('trmask_clear',1 << 1);  $trustee_a2n = array(
1258  define('trmask_deny',1 << 2);          '!' => trmask_not,
1259  define('trmask_one_level',1 << 3);          'C' => trmask_clear,
1260  define('trmask_group',1 << 4);          'D' => trmask_deny,
1261            'O' => trmask_one_level,
1262  define('trperm_r',1 << 5);          '+' => trmask_group,
1263  define('trperm_w',1 << 6);          'R' => trperm_r,
1264  define('trperm_b',1 << 7);          'W' => trperm_w,
1265  define('trperm_n',1 << 8);          'B' => trperm_b,
1266            'N' => trperm_n,
1267  $trustee_a2n = array(  );
1268          '!' => trmask_not,  
1269          'C' => trmask_clear,  // debugging function
1270          'D' => trmask_deny,  function display_trustee($t) {
1271          'O' => trmask_one_level,          global $trustee_a2n;
1272          '+' => trmask_group,          $out="";
1273          'R' => trperm_r,          foreach ($trustee_a2n as $c=>$v) {
1274          'W' => trperm_w,                  if ($t & $v) $out.=$c;
1275          'B' => trperm_b,          }
1276          'N' => trperm_n,          return $out;
1277  );  }
1278    function display_all_trustee() {
1279  // debugging function          global $trustees;
1280  function display_trustee($t) {          print "trustee dump:<br>\n";
1281          global $trustee_a2n;          foreach ($trustees as $path => $tr) {
1282          $out="";                  print "<br><tt>$path</tt>\n";
1283          foreach ($trustee_a2n as $c=>$v) {                  foreach ($tr as $user=>$perm) {
1284                  if ($t & $v) $out.=$c;                          print "$user == $perm (".display_trustee($perm).")<br>\n";
1285          }                  }
1286          return $out;          }
1287  }  }
1288  function display_all_trustee() {  
1289          global $trustees;  function init_trustee() {
1290          print "trustee dump:<br>\n";  
1291          foreach ($trustees as $path => $tr) {  global $trustee_conf,$trustee_php,$trustee_a2n,$groups,$trustees;
1292                  print "<br><tt>$path</tt>\n";  
1293                  foreach ($tr as $user=>$perm) {  // do we need to re-create compiled trustees?
1294                          print "$user == $perm (".display_trustee($perm).")<br>\n";  if (! file_exists($trustee_conf)) {
1295                  }          # $error="$trustee_conf doesn't exits";
1296          }          return 0;       # don't use trustees
1297  }  } elseif (file_exists($trustee_conf) && !is_readable($trustee_conf)) {
1298            $error="<tt>$trustee_conf</tt> exits, but is not readable";
1299  function init_trustee() {  } elseif (!is_writable(dirname($trustee_php))) {
1300            $error="<tt>".dirname($trustee_php)."</tt> must be writable by web server user";
1301  global $trustee_conf,$trustee_php,$trustee_a2n,$groups,$trustees;  } elseif (file_exists($trustee_php) && !is_writable($trustee_php)) {
1302            $error="trustees cache file <tt>$trustee_php</tt> exists, but is not writable by web server";
1303  // do we need to re-create compiled trustees?  } elseif (@filemtime($trustee_conf) >= @filemtime($trustee_php)) {
1304  if (! file_exists($trustee_conf)) {          $fp_php=@fopen($trustee_php,"w");
1305          # $error="$trustee_conf doesn't exits";          fputs($fp_php,"<?php // don't edit by hand!\n");
1306          return 0;       # don't use trustees  
1307  } elseif (file_exists($trustee_conf) && !is_readable($trustee_conf)) {          $fp_conf=fopen($trustee_conf,"r");
1308          $error="<tt>$trustee_conf</tt> exits, but is not readable";  
1309  } elseif (!is_writable(dirname($trustee_php))) {          $groups_arr = array();
1310          $error="<tt>".dirname($trustee_php)."</tt> must be writable by web server user";          $perm_arr = array();
1311  } elseif (file_exists($trustee_php) && !is_writable($trustee_php)) {  
1312          $error="trustees cache file <tt>$trustee_php</tt> exists, but is not writable by web server";          $tr_arr = array();
1313  } elseif (@filemtime($trustee_conf) >= @filemtime($trustee_php)) {  
1314          $fp_php=@fopen($trustee_php,"w");          while (! feof($fp_conf)) {
1315          fputs($fp_php,"<?php // don't edit by hand!\n");                  $l = trim(fgets($fp_conf,4096));
1316                    if (substr($l,0,1) == "+") {    // no comment
1317          $fp_conf=fopen($trustee_conf,"r");                          $arr=explode(":",$l);
1318                            $groups_arr[$arr[0]] = str_replace(" ","",$arr[1]) ;
1319          $groups_arr = array();                  } elseif (substr($l,0,1) != "#") {
1320          $perm_arr = array();                          $arr=explode(":",$l);
1321                            $path=array_shift($arr);
1322          $tr_arr = array();                          if ($path == "") continue;
1323                            $sep2="";
1324          while (! feof($fp_conf)) {                          while ($user=array_shift($arr)) {
1325                  $l = trim(fgets($fp_conf,4096));                                  $perm=0;
1326                  if (substr($l,0,1) == "+") {    // no comment                                  if (substr($user,0,1) == "+") {
1327                          $arr=explode(":",$l);                                          $perm|=trmask_group;
1328                          $groups_arr[$arr[0]] = $arr[1] ;                                          $user=substr($user,1,strlen($user)-1);
1329                  } elseif (substr($l,0,1) != "#") {                                  }
1330                          $arr=explode(":",$l);                                  $perm_ascii=array_shift($arr);
1331                          $path=array_shift($arr);                                  for ($i=0;$i<strlen($perm_ascii);$i++) {
1332                          if ($path == "") continue;                                          $ch=strtoupper($perm_ascii[$i]);
1333                          $sep2="";                                          if (isset($trustee_a2n[$ch])) {
1334                          while ($user=array_shift($arr)) {                                                  $perm|=$trustee_a2n[$ch];
1335                                  $perm=0;                                          } else {
1336                                  if (substr($user,0,1) == "+") {                                                  $error.="trustee error in line '$l' [Unknown modifier '$ch']<br>\n";
1337                                          $perm|=trmask_group;                                          }
1338                                          $user=substr($user,1,strlen($user)-1);                                  }
1339                                  }                                  if (isset($tr_arr[$path][$user])) {
1340                                  $perm_ascii=array_shift($arr);                                          $tr_arr[$path][$user] |= $perm;
1341                                  for ($i=0;$i<strlen($perm_ascii);$i++) {                                  } else {
1342                                          $ch=strtoupper($perm_ascii[$i]);                                          $tr_arr[$path][$user] = $perm;
1343                                          if (isset($trustee_a2n[$ch])) {                                  }
1344                                                  $perm|=$trustee_a2n[$ch];                          }
1345                                          } else {                  }
1346                                                  $error.="trustee error in line '$l' [Unknown modifier '$ch']<br>\n";          }
1347                                          }  
1348                                  }          fclose($fp_conf);
1349                                  if (isset($tr_arr[$path][$user])) {  
1350                                          $tr_arr[$path][$user] |= $perm;          // save trustees
1351                                  } else {          $tr_out='$trustees = array (';
1352                                          $tr_arr[$path][$user] = $perm;          $sep1="";
1353                                  }          while (list ($path, $tr) = each ($tr_arr)) {
1354                          }                  $tr_out.="$sep1\n\t'$path'=>array(";
1355                  }                  $sep2="";
1356          }                  while (list($user,$perm)=each($tr)) {
1357                            $tr_out.="$sep2\n\t\t'$user'=>$perm";
1358          fclose($fp_conf);                          $sep2=",";
1359                    }
1360          // save trustees                  $tr_out.="\n\t)";
1361          $tr_out='$trustees = array (';                  $sep1=",";
1362          $sep1="";          }
1363          while (list ($path, $tr) = each ($tr_arr)) {          $tr_out.="\n);";
1364                  $tr_out.="$sep1\n\t'$path'=>array(";  
1365                  $sep2="";          // save groups
1366                  while (list($user,$perm)=each($tr)) {          $gr_out='$groups = array (';
1367                          $tr_out.="$sep2\n\t\t'$user'=>$perm";          $sep="";
1368                          $sep2=",";          while (list ($group, $members) = each ($groups_arr)) {
1369                  }                  $gr_out.="$sep\n\t'";
1370                  $tr_out.="\n\t)";                  $gr_out.=substr($group,1,strlen($group)-1);
1371                  $sep1=",";                  $gr_out.="'=>array('".join("','",explode(",",$members))."')";
1372          }                  $sep=",";
1373          $tr_out.="\n);";          }
1374            $gr_out.="\n);\n";
1375          // save groups  
1376          $gr_out='$groups = array (';          fputs($fp_php,$gr_out);
1377          $sep="";          fputs($fp_php,$tr_out);
1378          while (list ($group, $members) = each ($groups_arr)) {          fputs($fp_php,"?>\n");
1379                  $gr_out.="$sep\n\t'";          fclose($fp_php);
1380                  $gr_out.=substr($group,1,strlen($group)-1);  }
1381                  $gr_out.="'=>array('".join("','",explode(",",$members))."')";  
1382                  $sep=",";  if (isset($error)) {
1383          }          Error("Trustee error",$error,1);
1384          $gr_out.="\n);\n";  } else {
1385            include_once("$trustee_php");
1386          fputs($fp_php,$gr_out);  }
1387          fputs($fp_php,$tr_out);  
1388          fputs($fp_php,"?>\n");  return 1;
1389          fclose($fp_php);  
1390  }  }//init_trustee
1391    
1392  if (isset($error)) {  function in_group($user,$group) {
1393          Error("Trustee error",$error,1);          global $groups;
1394  } else {          return in_array($user,$groups[$group]);
1395          include_once("$trustee_php");  }
1396  }  
1397    // helper function
1398  return 1;  function unroll_perm($u,$t,$perm,$one_level) {
1399    
1400  }//init_trustee          if ($t & trmask_one_level && !$one_level) return $perm;
1401    
1402  function in_group($user,$group) {          if ($t & trmask_deny) {
1403          global $groups;                  if ($t & trmask_clear) {
1404          return in_array($user,$groups[$group]);                          $perm['deny'] &= ~$t;
1405  }                  } else {
1406                            $perm['deny'] |= $t;
1407  // helper function                  }
1408  function unroll_perm($u,$t,$perm,$one_level) {          } elseif ($t & trmask_clear) {
1409                    $perm['allow'] &= ~$t;
1410          if ($t & trmask_one_level && !$one_level) return $perm;          } else {
1411                    $perm['allow'] |= $t;
1412          if ($t & trmask_deny) {          }
1413                  if ($t & trmask_clear) {          return $perm;
1414                          $perm['deny'] &= ~$t;  }// end of helper function
1415                  } else {  
1416                          $perm['deny'] |= $t;  function check_trustee($user,$path) {
1417                  }          global $trustees,$HAVE_TRUSTEE;
1418          } elseif ($t & trmask_clear) {          $perm['allow'] = 0;
1419                  $perm['allow'] &= ~$t;          $perm['deny'] = 0;
1420          } else {  
1421                  $perm['allow'] |= $t;          // do we use trustees?
1422          }          if (! $HAVE_TRUSTEE) return $perm;
1423          return $perm;  
1424  }// end of helper function          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);
1425    
1426  function check_trustee($user,$path) {  global $debug;
1427          global $trustees,$HAVE_TRUSTEE;  $debug .= "<br>check_trustee $path ... ";
1428          $perm['allow'] = 0;  
1429          $perm['deny'] = 0;          $path_arr=explode("/",$path);
1430            $tmppath="";
1431          // do we use trustees?          while (count($path_arr)) {
1432          if (! $HAVE_TRUSTEE) return $perm;                  $p = array_shift($path_arr);
1433    $debug.= "[$p] ";
1434          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);                  # add trailing slash
1435                    if (substr($tmppath,strlen($tmppath)-1,1) != "/") {
1436  global $debug;                          $tmppath.="/";
1437  $debug .= "<br>check_trustee $path ... ";                  }
1438                    # append currnet dir to tmppath
1439          $path_arr=explode("/",$path);                  if (isset($p)) {
1440          $tmppath = "/";                          $tmppath.=$p;
1441          while (count($path_arr)) {                  }
1442                  $tmppath.=array_shift($path_arr);  $debug.= ">> $tmppath ";
1443  $debug.= ">> $tmppath ";  
1444                    if (! isset($trustees[$tmppath])) continue;
1445                  if (! isset($trustees[$tmppath])) continue;                  $tr = $trustees[$tmppath];
1446                  $tr = $trustees[$tmppath];  
1447                    $one_level = (!count($path_arr));
1448                  $one_level = (!count($path_arr));  $debug.=" O($one_level) ";
1449  $debug.=" O($one_level) ";  
1450                    if (isset($tr)) {
1451                  if (isset($tr)) {                          // first apply trustee for all
1452                          // first apply trustee for all                          if (isset($tr['*']) && $user!="anonymous") {
1453                          if (isset($tr['*'])) {                                  $perm = unroll_perm($user,$tr['*'],$perm, $one_level);
1454                                  $perm = unroll_perm($user,$tr['*'],$perm, $one_level);                                  unset($tr['*']);
1455                                  unset($tr['*']);                          }
1456                          }                          // then apply not and group policies
1457                          // then apply not and group policies                          foreach ($tr as $g=>$t) {
1458                          foreach ($tr as $g=>$t) {                                  if ($t & trmask_not && $g != $user) {
1459                                  if ($t & trmask_not && $g != $user) {                                          $t = $t & ~trmask_not;
1460                                          $t = $t & ~trmask_not;                                          $perm = unroll_perm($user,$t,$perm, $one_level);
1461                                          $perm = unroll_perm($user,$t,$perm, $one_level);                                          unset($tr[$g]);
1462                                          unset($tr[$g]);  
1463                                    } elseif ($t & trmask_group && in_group($user,$g)) {
1464                                  } elseif ($t & trmask_group && in_group($user,$g)) {                                          // resolv user
1465                                          // resolv user                                          $t = $t & ~trmask_group;
1466                                          $t = $t & ~trmask_group;                                          $perm = unroll_perm($user,$t,$perm, $one_level);
1467                                          $perm = unroll_perm($user,$t,$perm, $one_level);                                          unset($tr[$g]);
1468                                          unset($tr[$g]);                                  }
1469                                  }                          }
1470                          }                          // then apply user policy
1471                          // then apply user policy                          if (isset($tr[$user])) {
1472                          if (isset($tr[$user])) {                                  $perm = unroll_perm($user,$tr[$user],$perm,$one_level);
1473                                  $perm = unroll_perm($user,$tr[$user],$perm,$one_level);                                  unset($tr[$user]);
1474                                  unset($tr[$user]);                          }
1475                          }                  }
1476                  }  $debug.="d(".display_trustee($perm['deny']).") a(".display_trustee($perm['allow']).") ";
1477  $debug.="d(".display_trustee($perm['deny']).") a(".display_trustee($perm['allow']).") ";  
1478            }
1479          }  $debug.="<br>check_trustee: user: $user path: $path==$tmppath perm: ";
1480  $debug.="<br>check_trustee: user: $user path: $path==$tmppath perm: ";  $debug.="d: ".$perm['deny']." (".display_trustee($perm['deny']).") a: ".$perm['allow']." (".display_trustee($perm['allow']).")<Br>\n";
1481  $debug.="d: ".$perm['deny']." (".display_trustee($perm['deny']).") a: ".$perm['allow']." (".display_trustee($perm['allow']).")<Br>\n";          return $perm;
1482          return $perm;  }
1483  }  
1484    // handy functions
1485  // handy functions  
1486    function check_perm($path,$trperm) {
1487  function check_perm($path,$trperm) {          global $gblLogin,$HAVE_TRUSTEE;
1488          global $gblLogin,$HAVE_TRUSTEE;  
1489            $path = str_replace("//","/",$path);
1490          global $debug;  
1491  $debug.="<br>check_perm: on <tt>$path</tt> for perm ".display_trustee($trperm)."<br>\n";          global $debug;
1492    $debug.="<br>check_perm: on <tt>$path</tt> for perm ".display_trustee($trperm)."<br>\n";
1493          $return = ! $HAVE_TRUSTEE;  
1494          if ($HAVE_TRUSTEE) {          $return = ! $HAVE_TRUSTEE;
1495                  $perm = check_trustee($gblLogin,$path);          if ($HAVE_TRUSTEE) {
1496  $debug.=" d: ".$perm['deny']." (".display_trustee($perm['deny']).") a: ".$perm['allow']." (".display_trustee($perm['allow']).") perm to have: $trperm (".display_trustee($trperm).")";                  $perm = check_trustee($gblLogin,$path);
1497                  if ($perm['deny'] & $trperm) $return=0;  $debug.=" d: ".$perm['deny']." (".display_trustee($perm['deny']).") a: ".$perm['allow']." (".display_trustee($perm['allow']).") perm to have: $trperm (".display_trustee($trperm).")";
1498                  elseif (($perm['allow'] & $trperm) == $trperm) $return=1;                  if ($perm['deny'] & $trperm) $return=0;
1499          }                  elseif (($perm['allow'] & $trperm) == $trperm) $return=1;
1500  $debug.=" return: $return<br>\n";          }
1501          return($return);  $debug.=" return: $return<br>\n";
1502  }          return($return);
1503    }
1504  //////////////////////////////////////////////////////////////////  
1505    //////////////////////////////////////////////////////////////////
1506  function readMime() {  
1507          global $mime_type;  function readMime() {
1508            global $mime_type, $gblMimeTypes;
1509          if (! isset($gblMimeTypes)) {  
1510                  $gblMimeTypes = "/etc/mime.types";          if (! isset($gblMimeTypes)) {
1511          }                  $gblMimeTypes = "/etc/mime.types";
1512            }
1513          $mime = @fopen($gblMimeTypes,"r");  
1514            $mime = @fopen($gblMimeTypes,"r");
1515          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>");  
1516            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>");
1517          while($line = fgets($mime,80)) {  
1518                  if (substr($line,0,1) == "#") continue; // skip comment          while($line = fgets($mime,80)) {
1519                  $arr = preg_split("/[\s\t]+/",$line);                  if (substr($line,0,1) == "#") continue; // skip comment
1520                  $type = array_shift($arr);                  $arr = preg_split("/[\s\t]+/",$line);
1521                  while ($ext = array_shift($arr)) {                  $type = array_shift($arr);
1522                          $mime_type[$ext] = $type;                  while ($ext = array_shift($arr)) {
1523                  }                          $mime_type[$ext] = $type;
1524          }                  }
1525            }
1526          fclose($mime);  
1527  }          fclose($mime);
1528    }
1529  //////////////////////////////////////////////////////////////////  
1530    //////////////////////////////////////////////////////////////////
1531  // check for invalid characters in filename and dirname (.. and /)  
1532    // check for invalid characters in filename and dirname (.. and /)
1533  function check_dirname($file) {  
1534          if (strstr($file,"..")) Error("Security violation","No parent dir <tt>..</tt> allowed in directory name <tt>$file</tt>",1);  function check_dirname($file) {
1535  }          if (strstr($file,"..")) Error("Security violation","No parent dir <tt>..</tt> allowed in directory name <tt>$file</tt>",1);
1536    }
1537  function check_filename($file) {  
1538          if (strstr($file,"..")) Error("Security violation","No parent dir <tt>..</tt> allowed in file name <tt>$file</tt>",1);  function check_filename($file) {
1539          if (strstr($file,"/")) Error("Security violation","No slashes <tt>/</tt> allowed in file name <tt>$file</tt>",1);          if (strstr($file,"..")) Error("Security violation","No parent dir <tt>..</tt> allowed in file name <tt>$file</tt>",1);
1540  }          // remove deleted directory (for undelete to work)
1541            $file = str_replace(".del/","",$file);
1542  //////////////////////////////////////////////////////////////////          if (strstr($file,"/")) Error("Security violation","No slashes <tt>/</tt> allowed in file name <tt>$file</tt>",1);
1543    }
1544  // functions to move HTTP server variables to global namespace  
1545  // [replacement for register_globals in php.ini]  // bla/blo/../foo will return bla/foo
1546    function remove_parent($path) {
1547  function HTTP_GET_VAR($var) {          while (preg_match(",/[^/]+/\.\./,",$path)) {
1548          global $HTTP_GET_VARS, ${$var};                  $path = preg_replace(",/[^/]+/\.\./,","",$path);
1549          if (isset($HTTP_GET_VARS[$var])) {          }
1550                  $$var = stripSlashes($HTTP_GET_VARS[$var]);          if (substr($path,0,1) != "/") $path = "/".$path;
1551                  return $$var;          return $path;
1552          }  }
1553  }  
1554    //////////////////////////////////////////////////////////////////
1555  function HTTP_POST_VAR($var) {  
1556          global $HTTP_POST_VARS, ${$var};  // functions to move HTTP server variables to global namespace
1557          if (isset($HTTP_POST_VARS[$var])) {  // [replacement for register_globals in php.ini]
1558                  $$var = $HTTP_POST_VARS[$var];  
1559                  return $$var;  function HTTP_GET_VAR($var) {
1560          }          global $HTTP_GET_VARS, ${$var};
1561  }          if (isset($HTTP_GET_VARS[$var])) {
1562                    $$var = stripSlashes($HTTP_GET_VARS[$var]);
1563  function HTTP_SERVER_VAR($var) {                  return $$var;
1564          global $HTTP_SERVER_VARS, ${$var};          }
1565          if (isset($HTTP_SERVER_VARS[$var])) {  }
1566                  $$var = $HTTP_SERVER_VARS[$var];  
1567                  return $$var;  function HTTP_POST_VAR($var) {
1568          }          global $HTTP_POST_VARS, ${$var};
1569  }          if (isset($HTTP_POST_VARS[$var])) {
1570                    $$var = $HTTP_POST_VARS[$var];
1571  //////////////////////////////////////////////////////////////////                  return $$var;
1572            }
1573  function Warn($text) {  }
1574  }  
1575    function HTTP_SERVER_VAR($var) {
1576  //////////////////////////////////////////////////////////////////          global $HTTP_SERVER_VARS, ${$var};
1577  // MAIN PROGRAM          if (isset($HTTP_SERVER_VARS[$var])) {
1578                    $$var = $HTTP_SERVER_VARS[$var];
1579          $gblFilePerms = 0640 ;         // default for new files                  return $$var;
1580          $gblDirPerms  = 0750 ;          // default for new dirs          }
1581    }
1582          if (isset($HTTP_GET_VARS["STYLE"]) && $HTTP_GET_VARS["STYLE"] == "get") {  
1583                  include("$html/docman.css");  //////////////////////////////////////////////////////////////////
1584                  exit;  
1585          }  function Warn($text) {
1586    }
1587          // location of master docman configuration file  
1588          $docman_conf = "/etc/docman.conf";  //////////////////////////////////////////////////////////////////
1589          if (! file_exists($docman_conf)) {  
1590                  $error = "Can't find master configuration file <tt>$docman_conf</tt>. See <tt>docman2/doc/upgrade.html#docman_conf</tt> for more informations";  function isBlank($file,$what = "filename") {
1591                            if (trim($file) == "") return "<i>whitespace $what</i>";
1592                  error_log("docman: $error");          if ($file == "") return "<i>no $what</i>";
1593                  Error("docman not installed completly",$error);          return $file;
1594          }  }
1595          include($docman_conf);  
1596    //////////////////////////////////////////////////////////////////
1597          if (! isset($fsRealmDir)) {  // MAIN PROGRAM
1598                  $fsRealmDir = "$gblIncDir/realm";  
1599          }          $gblFilePerms = 0640 ;         // default for new files
1600            $gblDirPerms  = 0750 ;          // default for new dirs
1601          // try to add dir to script name to realm var  
1602          if (is_dir("$fsRealmDir/$realm/".dirname($HTTP_SERVER_VARS["SCRIPT_NAME"]))) {          if (isset($HTTP_GET_VARS["STYLE"]) && $HTTP_GET_VARS["STYLE"] == "get") {
1603                  $realm .= dirname($HTTP_SERVER_VARS["SCRIPT_NAME"]);                  if (! headers_sent()) {
1604                  $realm_sep = "/";                          Header("Content-type: text/css");
1605          } else {                  }
1606                  $realm_sep = ".";                  include("$html/docman.css");
1607          }                  exit;
1608            }
1609          $realm_config = $fsRealmDir."/".$realm.$realm_sep."conf";  
1610            // set fsRealmDir
1611          // read user-defined configuration          if (! isset($fsRealmDir)) {
1612          if (file_exists($realm_config)) {                  $fsRealmDir = "$gblIncDir/realm";
1613                  include($realm_config);          }
1614          } else {  
1615                  Error("Configuration error","Can't find configuration file at <tt>$realm_config</tt> !");          // try to add dir to script name to realm var
1616          }          if (is_dir("$fsRealmDir/$realm/".dirname($HTTP_SERVER_VARS["SCRIPT_NAME"]))) {
1617                    $realm .= dirname($HTTP_SERVER_VARS["SCRIPT_NAME"]);
1618          if (! isset($gblRepositoryDir)) Error("Configuration error","<tt>\$gblRepositoryDir</tt> is not setuped in realm configuration file <tt>$realm_config</tt>");                  $realm_sep = "/";
1619            } else {
1620          // where do we get users from?                  $realm_sep = ".";
1621          if (file_exists("$gblIncDir/htusers/$gblUsers.php")) {          }
1622                  include("$gblIncDir/htusers/$gblUsers.php");  
1623          } else {          $realm_config = $fsRealmDir."/".$realm.$realm_sep."conf";
1624                  Error("Configuration error","Can't find user handling module at <tt>$gblIncDir/htusers/$gblUsers.php</tt> ! Please fix <tt>$realm_config</tt>");  
1625          }          // read user-defined configuration
1626            if (file_exists($realm_config)) {
1627          // take additional login vars                  include($realm_config);
1628          HTTP_GET_VAR("relogin");          } else {
1629          HTTP_GET_VAR("force_login");                  Error("Configuration error","Can't find configuration file at <tt>$realm_config</tt> !");
1630            }
1631          // if no password, or empty password logout  
1632          if (          if (! isset($gblRepositoryDir)) Error("Configuration error","<tt>\$gblRepositoryDir</tt> is not setuped in realm configuration file <tt>$realm_config</tt>");
1633                  isset($gblLogin) && (  
1634                          !isset($relogin) || (          // where do we get users from?
1635                                  isset($relogin) && $relogin != md5($gblLogin.$gblPasswd)          if (file_exists("$gblIncDir/htusers/$gblUsers.php")) {
1636                          )                  include("$gblIncDir/htusers/$gblUsers.php");
1637                  ) && (          } else {
1638                          $gblPasswd == "" || !isset($gblPasswd)                  Error("Configuration error","Can't find user handling module at <tt>$gblIncDir/htusers/$gblUsers.php</tt> ! Please fix <tt>$realm_config</tt>");
1639                  ) && !isset($force_login) && $gblLogin != "anonymous"          }
1640             ) {  
1641                  StartHTML("Logout completed","Your login credentials has been erased") ;          // take additional login vars
1642                  EndHTML() ;          HTTP_GET_VAR("relogin");
1643                  exit ;          HTTP_GET_VAR("force_login");
1644          }  
1645            // if no password, or empty password logout
1646          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);          if (
1647                    isset($gblLogin) && (
1648          // trustee (ACL) file configuration                          !isset($relogin) || (
1649          $trustee_conf="$fsRealmDir/$realm".$realm_sep."trustee";                                  isset($relogin) && $relogin != md5($gblLogin.$gblPasswd)
1650          // compiled version of trustee file                          )
1651          $trustee_php="$gblRepositoryDir/.trustee.php";                  ) && (
1652          // get ACL informations                          $gblPasswd == "" || !isset($gblPasswd)
1653          $HAVE_TRUSTEE = init_trustee();                  ) && !isset($force_login) && $gblLogin != "anonymous"
1654               ) {
1655          if (strtolower($gblLogin) == "anonymous" || !isset($gblLogin)) {                  StartHTML("Logout completed","Your login credentials has been erased") ;
1656                  $perm = check_trustee("anonymous","/");                  EndHTML() ;
1657                  // browsing must be explicitly allowed for root directory                  exit ;
1658                  // of repository for anonymous user to work!          }
1659                  if ($perm['allow'] & trperm_b) {  
1660                          $gblLogin = $gblPasswd = "anonymous";          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);
1661                          $secHash = md5($gblLogin.$gblPasswd);  
1662                          $gblUserName = "Anonymous user";          // trustee (ACL) file configuration
1663                  }          $trustee_conf="$fsRealmDir/$realm".$realm_sep."trustee";
1664          }          // compiled version of trustee file
1665            $trustee_php="$gblRepositoryDir/.trustee.php";
1666          // authentication failure          // get ACL informations
1667          if ( md5($gblLogin.$gblPasswd) != $secHash ||          $HAVE_TRUSTEE = init_trustee();
1668                  isset($relogin) && $secHash == $relogin) {  
1669                  header("WWW-authenticate: basic realm=\"$realm\"") ;          if (strtolower($gblLogin) == "anonymous" || !isset($gblLogin)) {
1670                  header("HTTP/1.0 401 Unauthorized") ;                  $perm = check_trustee("anonymous","/");
1671                  Error("401 Unauthorized","No trespassing !",0,1);                  // browsing must be explicitly allowed for root directory
1672          }                  // of repository for anonymous user to work!
1673                    if ($perm['allow'] & trperm_b) {
1674                            $gblLogin = $gblPasswd = "anonymous";
1675          // read mime.types                          $secHash = md5($gblLogin.$gblPasswd);
1676          readMime();                          $gblUserName = "Anonymous user";
1677                    }
1678  HTTP_POST_VAR("FN");          }
1679    
1680          if ($HTTP_SERVER_VARS["REQUEST_METHOD"] == "POST") {          // authentication failure
1681                  // take variables from server          if ( md5($gblLogin.$gblPasswd) != $secHash ||
1682                  if (HTTP_POST_VAR("FN"))                  isset($relogin) && $secHash == $relogin) {
1683                          check_filename($FN);                  header("WWW-authenticate: basic realm=\"$realm\"") ;
1684                  if (HTTP_POST_VAR("DIR")) {                  header("HTTP/1.0 401 Unauthorized") ;
1685                          check_dirname($DIR);                  Error("401 Unauthorized","No trespassing !",0,1);
1686                          $relDir = $DIR;          }
1687                  } else {  
1688                          trigger_error("Can't get DIR",E_USER_WARNING);  
1689                          $relDir = "/";          // read mime.types
1690                  }          readMime();
1691                  if (HTTP_POST_VAR("RELPATH")) check_dirname($RELPATH);  
1692                  HTTP_POST_VAR("T");          if (! isset($gblPermNote)) {
1693                  HTTP_POST_VAR("CONFIRM");                  $gblPermNote = trperm_r;
1694          } else {          }
1695                  // get  
1696                  HTTP_GET_VAR("A");          HTTP_POST_VAR("FN");
1697                  if (HTTP_GET_VAR("D")) {  
1698                          check_dirname($D);          if ($HTTP_SERVER_VARS["REQUEST_METHOD"] == "POST") {
1699                          $D=urldecode($D);                  // take variables from server
1700                          $relDir = $D;                  if (HTTP_POST_VAR("FN"))
1701                  } else {                          check_filename($FN);
1702                          //trigger_error("Can't get D",E_USER_WARNING);                  if (HTTP_POST_VAR("DIR")) {
1703                          $relDir = "/";                          check_dirname($DIR);
1704                  }                          $relDir = $DIR;
1705                  if (HTTP_GET_VAR("F")) check_filename($F);                  } else {
1706          }                          trigger_error("Can't get DIR",E_USER_WARNING);
1707                            $relDir = "/";
1708          $relScriptDir = dirname($HTTP_SERVER_VARS["SCRIPT_NAME"]) ;                      }
1709          // i.e. /docman                  if (HTTP_POST_VAR("RELPATH")) check_dirname($RELPATH);
1710                    HTTP_POST_VAR("T");
1711          // start on server root                  HTTP_POST_VAR("CONFIRM");
1712          $gblFsRoot = $gblRepositoryDir;          } else {
1713          // i.e. /home/httpd/repository                  // get
1714                    HTTP_GET_VAR("A");
1715          $fsDir = $gblFsRoot . $relDir ; // current directory                  if (HTTP_GET_VAR("D")) {
1716          if ( !is_dir($fsDir) ) Error("Dir not found","Can't find <tt>$relDir</tt> which points to <tt>$fsDir</tt>",1) ;                          check_dirname($D);
1717                            $D=urldecode($D);
1718          if ($relDir == "") $relDir="/";                          $relDir = $D;
1719                    } else {
1720          if (isset($HTTP_SERVER_VARS["HTTPS"]) && $HTTP_SERVER_VARS["HTTPS"] == "on") {                          //trigger_error("Can't get D",E_USER_WARNING);
1721                  $webRoot  = "https://";                          $relDir = "/";
1722          } else {                  }
1723                  $webRoot  = "http://";                  if (HTTP_GET_VAR("F")) check_filename($F);
1724          }          }
1725          $webRoot .= $HTTP_SERVER_VARS["HTTP_HOST"] . $relScriptDir;  
1726            $relScriptDir = dirname($HTTP_SERVER_VARS["SCRIPT_NAME"]) ;    
1727          if (HTTP_POST_VAR("POSTACTION")) switch ($POSTACTION) {          // i.e. /docman
1728          case "UPLOAD" :  
1729                  $FN_name=stripSlashes($HTTP_POST_FILES["FN"]["tmp_name"]);          // start on server root
1730                  $FN=stripSlashes($HTTP_POST_FILES["FN"]["name"]);          $gblFsRoot = $gblRepositoryDir;
1731                  if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;          // i.e. /home/httpd/repository
1732    
1733                  $source = $FN_name ;          $fsDir = $gblFsRoot . $relDir ; // current directory
1734                  if (! file_exists($source)) {          if ( !is_dir($fsDir) ) Error("Dir not found","Can't find <tt>$relDir</tt> which points to <tt>$fsDir</tt>",1) ;
1735                          Error("You must select file with browse to upload it!");  
1736                  }          if ($relDir == "") $relDir="/";
1737    
1738                  if (HTTP_POST_VAR("FILENAME")) check_filename($FILENAME);          if (isset($HTTP_SERVER_VARS["HTTPS"]) && $HTTP_SERVER_VARS["HTTPS"] == "on") {
1739                    $webRoot  = "https://";
1740                  if (! isset($FILENAME)) {       // from update file          } else {
1741                          $target = "$fsDir/".basename($FN);                  $webRoot  = "http://";
1742                  } else {          }
1743                          $target = "$fsDir/$FILENAME";          $webRoot .= $HTTP_SERVER_VARS["HTTP_HOST"] . $relScriptDir;
1744                  }  
1745            if (HTTP_POST_VAR("POSTACTION")) switch ($POSTACTION) {
1746                  // backup old files first          case "UPLOAD" :
1747                  $dir=dirname($target);                  $FN_name=stripSlashes($HTTP_POST_FILES["FN"]["tmp_name"]);
1748                  if (! file_exists($dir."/.bak")) {                  $FN=stripSlashes($HTTP_POST_FILES["FN"]["name"]);
1749                          mkdir($dir."/.bak",0700);                  if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;
1750                  }  
1751                  if (! file_exists($dir."/.bak/$gblNumBackups")) {                  $source = $FN_name ;
1752                          mkdir($dir."/.bak/$gblNumBackups",0700);                  if (! file_exists($source)) {
1753                  }                          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);
1754                  $file=basename($target);                  }
1755                  for($i=$gblNumBackups-1;$i>0;$i--) {  
1756                          MoveTo("$dir/.bak/$i/$file","$dir/.bak/".($i+1)."/");                  if (HTTP_POST_VAR("FILENAME")) check_filename($FILENAME);
1757                  }  
1758                  MoveTo($target,$dir."/.bak/1/");                  if (! isset($FILENAME)) {       // from update file
1759                            $target = "$fsDir/".basename($FN);
1760                  copy($source,$target) ;                  } else {
1761                  chmod($target,$gblFilePerms) ;                          $target = "$fsDir/$FILENAME";
1762                  clearstatcache() ;                  }
1763                  if (isset($FILENAME)) {  
1764                          LogIt($target,"check-in",trperm_r | trperm_w);                  if (! check_perm("$relDir/".basename($target), trperm_w))
1765                          Unlock($target);                          Error("Access denied","User <tt>$gblLogin</tt> tried to upload <tt>$relDir/".basename($target)."</tt> without valid trustee.",1);
1766                  } else {  
1767                          LogIt($target,"uploaded",trperm_r | trperm_w);                  // backup old files first
1768                  }                  $dir=dirname($target);
1769                  break ;                  if (! file_exists($dir."/.bak")) {
1770                            mkdir($dir."/.bak",0700);
1771          case "SAVE" :                  }
1772                  $path = $gblFsRoot . $RELPATH ;                  if (! file_exists($dir."/.bak/$gblNumBackups")) {
1773                  $path=stripSlashes($path);                          mkdir($dir."/.bak/$gblNumBackups",0700);
1774                  $writable = is_writeable($path) ;                  }
1775                  $legaldir = is_writeable(dirname($path)) ;                  $file=basename($target);
1776                  $exists   = (file_exists($path)) ? 1 : 0 ;                  for($i=$gblNumBackups-1;$i>0;$i--) {
1777  // check for legal extension here as well                          MoveTo("$dir/.bak/$i/$file","$dir/.bak/".($i+1)."/");
1778                  if (!($writable || (!$exists && $legaldir)))                  }
1779                          Error("Write denied",$RELPATH) ;                  MoveTo($target,$dir."/.bak/1/");
1780                  $fh = fopen($path, "w") ;  
1781                  HTTP_POST_VAR("FILEDATA");                  copy($source,$target) ;
1782                  fwrite($fh,$FILEDATA) ;                  chmod($target,$gblFilePerms) ;
1783                  fclose($fh) ;                  clearstatcache() ;
1784                  clearstatcache() ;                  if (isset($FILENAME)) {
1785                  LogIt($path,"saved changes",trperm_r);                          LogIt($target,"check-in",trperm_r | trperm_w);
1786                  break ;                          Unlock($target);
1787                    } else {
1788          case "CREATE" :                          LogIt($target,"uploaded",trperm_r | trperm_w);
1789                  // we know $fsDir exists                  }
1790                  if (! check_perm($relDir, trperm_w))                  break ;
1791                          Error("Write access denied","You don't have permission to write in <tt>$relDir</tt>");  
1792                  if ($T == "D") $type = "directory";          case "SAVE" :
1793                  else $type ="file";                  $path = $gblFsRoot . $RELPATH ;
1794                  if ($FN == "") Error("Can't create $type","You must enter name of $type to create it.");                  $path=stripSlashes($path);
1795                  if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;  
1796                  $path = $fsDir . "/" . $FN ;  // file or dir to create                  if (! check_perm("$RELPATH", trperm_w))
1797                  $relPath = $relDir . "/" . $FN ;                          Error("Access denied","User <tt>$gblLogin</tt> tried to save <tt>$RELPATH</tt> without valid trustee.",1);
1798                  switch ( $T ) {  
1799                  case "D" :  // create a directory                  $writable = is_writeable($path) ;
1800                          if ( ! @mkdir($path,$gblDirPerms) )                  $legaldir = is_writeable(dirname($path)) ;
1801                                  Error("Mkdir failed",$relPath) ; // eg. if it exists                  $exists   = (file_exists($path)) ? 1 : 0 ;
1802                          else                  // FIX: more verbose error message
1803                                  LogIt($path."/","dir created",trperm_w);                  if (!($writable || (!$exists && $legaldir)))
1804                          clearstatcache() ;                          Error("Write denied",$RELPATH) ;
1805                          break ;                  $fh = fopen($path, "w") ;
1806                  case "F" :  // create a new file                  HTTP_POST_VAR("FILEDATA");
1807  // this functionality is doubled in DetailView().                  fwrite($fh,stripSlashes($FILEDATA)) ;
1808  // better keep it here altogether                  fclose($fh) ;
1809  // chmod perms to $gblFilePerms                  clearstatcache() ;
1810                          if ( file_exists($path) && !is_writeable($path) )                  LogIt($path,"saved changes",trperm_r);
1811                                  Error("File not writable", $relPath) ;                  break ;
1812                          $fh = fopen($path, "w+") ;  
1813                          if ($fh) {          case "CREATE" :
1814                                  fputs($fh,"\n");                  // we know $fsDir exists
1815                                  fclose($fh) ;                  if (! check_perm($relDir, trperm_w))
1816                                  LogIt($path,"file created",trperm_r | trperm_w);                          Error("Write access denied","You don't have permission to write in <tt>$relDir</tt>");
1817                          } else {                  if ($T == "D") $type = "directory";
1818                                  Error("Creation of file $relPath failed -- $path");                  else $type ="file";
1819                          }                  if ($FN == "") Error("Can't create $type","You must enter name of $type to create it.");
1820                          $tstr = $HTTP_SERVER_VARS["PHP_SELF"]."?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ;                  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) ;
1821                          header("Location: " . $tstr) ;                  $path = "$fsDir/$FN";           // file or dir to create
1822                          exit ;                  $relPath = "$relDir/$FN";
1823                  }  
1824                  break ;                  if (file_exists($path))
1825                            Error("Can't create $type","Object <tt>$relPath</tt> allready exists");
1826          case "DELETE" :    
1827                  if ( $CONFIRM != "on" ) break ;                  switch ( $T ) {
1828                    case "D" :  // create a directory
1829                  $tstr  = "Attempt to delete non-existing object or " ;                          if ( ! @mkdir($path,$gblDirPerms) )
1830                  $tstr .= "insufficient privileges: " ;                                  Error("Mkdir failed",$relPath) ; // eg. if it exists
1831                            else
1832                  if ( $FN != "") {  // delete file                                  LogIt($path."/","dir created",trperm_w);
1833                          $path =  $fsDir . "/" . $FN ;                          clearstatcache() ;
1834                                            break ;
1835                          $dir=dirname($path);                  case "F" :  // create a new file
1836                          $file=basename($path);  // this functionality is doubled in DetailView().
1837                          if (! file_exists("$dir/.del")) {  // better keep it here altogether
1838                                  mkdir("$dir/.del",0700);  // chmod perms to $gblFilePerms
1839                          }                          if ( file_exists($path) && !is_writeable($path) )
1840                                    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) ;
1841  //                      if ( ! @unlink($path) ) {                          $fh = fopen($path, "w+") ;
1842                          if ( ! rename($path,"$dir/.del/$file") ) {                          if ($fh) {
1843                                  LogIt($path,"file delete failed");                                  fputs($fh,"\n");
1844                                  Error("File delete failed", $tstr . $path) ;                                  fclose($fh) ;
1845                          } else {                                  LogIt($path,"file created",trperm_r | trperm_w);
1846                                  LogIt($path,"file deleted",trperm_w);                          } else {
1847                                  MoveTo("$dir/.log/$file","$dir/.del/.log/");                                  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) ;
1848                                  MoveTo("$dir/.note/$file","$dir/.del/.note/");                          }
1849                                  MoveTo("$dir/.lock/$file","$dir/.del/.lock/");                          $tstr = $HTTP_SERVER_VARS["PHP_SELF"]."?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ;
1850                          }                          header("Location: " . $tstr) ;
1851                  } else {  // delete directory                          exit ;
1852                          if ( ! @rrmdir($fsDir) ) {                  }
1853                                  Error("Rmdir failed", $tstr . $fsDir) ;                  break ;
1854                          } else {  
1855                                  LogIt($path,"dir deleted",trperm_w);          case "DELETE" :  
1856                                  $relDir = dirname($relDir) ;  // move up                  if ( $CONFIRM != "on" ) break;
1857                          }  
1858                  }                  if ( isset($FN) && $FN != "") {
1859                  break ;                          $path=$fsDir."/".$FN;
1860                            $what = "file";
1861          case "UNDELETE" :                    } elseif (isset($DIR)) {
1862                  if ( $CONFIRM != "on" ) break ;                          $path=$gblFsRoot."/".$DIR;
1863                            $what = "directory";
1864                  if (substr($FN,0,4) != ".del") break ;                  } else  {
1865                  $file=substr($FN,4,strlen($FN)-4);                          Error("Can't delete object","Can't find filename <tt>\$FN</tt> or dirname in <tt>\$DIR</tt>",1);
1866                    }
1867                  LogIt("$fsDir/.del/$file","undeleted",trperm_w);  
1868                  MoveTo("$fsDir/.del/$file","$fsDir/");                  if (! check_perm("$relDir/$FN", trperm_w))
1869                  MoveTo("$fsDir/.del/.log/$file","$fsDir/.log/");                          Error("Access denied","User <tt>$gblLogin</tt> tried to erase $what <tt>$relDir/$FN</tt> without valid trustee.",1);
1870                  MoveTo("$fsDir/.del/.note/$file","$fsDir/.note/");  
1871                  MoveTo("$fsDir/.del/.lock/$file","$fsDir/.lock/");                  $tstr  = "Attempt to delete non-existing object or insufficient privileges: " ;
1872    
1873                  break ;                  $dir=dirname($path);
1874                    $file=basename($path);
1875          case "RENAME" :    
1876                  if ( $CONFIRM != "on" ) break ;                  if (! file_exists("$dir/.del")) {
1877                            mkdir("$dir/.del",0700);
1878                  $NEWNAME=stripSlashes($HTTP_POST_VARS["NEWNAME"]);                  }
1879                  LogIt("$fsDir/$FN","renamed $FN to $NEWNAME",trperm_r);  
1880                  safe_rename($fsDir,$FN,$NEWNAME);                  if ( ! @rename($path,"$dir/.del/$file") ) {
1881                  break ;                          LogIt($path,"$what delete failed");
1882                            Error("Can't delete $what",$tstr."<tt>".$relDir."/".$FN."</tt>") ;
1883          case "NOTE" :                    } else {
1884                  $NOTE=stripSlashes($HTTP_POST_VARS["NOTE"]);                          LogIt($path,"$what deleted",trperm_w);
1885                  WriteNote("$fsDir/$FN","$NOTE");                          MoveTo("$dir/.log/$file","$dir/.del/.log/");
1886                  break ;                          MoveTo("$dir/.note/$file","$dir/.del/.note/");
1887                            MoveTo("$dir/.lock/$file","$dir/.del/.lock/");
1888          case "UNLOCK" :                    }
1889                  if ( $CONFIRM != "on" ) break ;                  break ;
1890                  Unlock("$fsDir/$FN");  
1891                  break ;          case "UNDELETE" :  
1892                    if ( $CONFIRM != "on" ) break ;
1893          default :  
1894                  // user hit "CANCEL" or undefined action                  if (substr($FN,0,4) != ".del") break ;
1895          }                  $file=substr($FN,4,strlen($FN)-4);
1896    
1897          // common to all POSTs : redirect to directory view ($relDir)                  if (! check_perm("$relDir/$file", trperm_w))
1898          if (isset($POSTACTION)) {                          Error("Access denied","User <tt>$gblLogin</tt> tried to undelete <tt>$relDir/$file</tt> without valid trustee.",1);
1899                  $tstr = $HTTP_SERVER_VARS["PHP_SELF"]."?D=".urlencode($relDir);  
1900                  header("Location: ".$tstr) ;                    LogIt("$fsDir/.del/$file","undeleted",trperm_w);
1901                  exit ;                  MoveTo("$fsDir/.del/$file","$fsDir/");
1902          }                  MoveTo("$fsDir/.del/.log/$file","$fsDir/.log/");
1903                            MoveTo("$fsDir/.del/.note/$file","$fsDir/.note/");
1904          // check for mode.. navigate, code display, upload, or detail?                  MoveTo("$fsDir/.del/.lock/$file","$fsDir/.lock/");
1905          // $A=U : upload to path given in $D  
1906          // $A=E : display detail of file $D/$F and edit                  break ;
1907          // $A=C : display code in file $D/$F  
1908          // $A=Co : checkout file $D/$F          case "RENAME" :  
1909          // $A=Ci : checkin file $D/$F                  if ( $CONFIRM != "on" ) break ;
1910          // $A=V : view file (do nothing except log)  
1911          // $A=I : include file .$F.php from [$gblIncDir|realm]/include_php                  if (HTTP_POST_VAR("NEWNAME")) {
1912          // default : display directory $D                          $dest = remove_parent($relDir.$NEWNAME);
1913                            if (! check_perm($relDir.$FN, trperm_w) ||
1914          if (isset($A)) switch ($A) {                              ! check_perm($dest, trperm_w) )
1915          case "U" :                                  Error("Access denied","User <tt>$gblLogin</tt> tried to rename <tt>$relDir$FN</tt> to <tt>$dest</tt> without valid trustee.",1);
1916                  // upload to $relDir                  } else {
1917                  if (! check_perm($relDir, trperm_w))                          Error("Rename error","Can't find new name in var <tt>\$NEWNAME</tt>",1);
1918                          Error("Write access denied","You don't have permission to write in <tt>$relDir</tt>");                  }
1919                  if (!is_writeable($gblFsRoot . $relDir))                  LogIt("$fsDir/$FN","renamed $FN to $NEWNAME",trperm_r);
1920                          Error("Write access denied","User <tt>$gblLogin</tt> has permission on <tt>$relDir</tt>, but directory is not writable",1);                  safe_rename($fsDir,$FN,$NEWNAME);
1921                  $text  = "Use this page to upload a single " ;                  break ;
1922                  $text .= "file to <B>$realm</B>." ;  
1923                  StartHTML("(Upload Page)", $text) ;          case "NOTE" :
1924                  UploadPage($gblFsRoot, $relDir) ;                  if (! HTTP_POST_VAR("NOTE"))
1925                  EndHTML() ;                          Error("Can't add note to object","Can't find var <tt>\$NOTE</tt>",1);
1926                  exit ;                  if (! check_perm("$relDir/$FN", trperm_w))
1927          case "E" :                          Error("Access denied","User <tt>$gblLogin</tt> tried to add note to <tt>$relDir/$FN</tt> without valid trustee.",1);
1928                  // detail of $relDir/$F  
1929                  if (is_file("$gblFsRoot/$relDir/$F") || is_dir("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ;                  WriteNote("$fsDir/$FN",$NOTE);
1930                  exit ;                  break ;
1931          case "C" :  
1932                  $F=stripSlashes($F);          case "UNLOCK" :  
1933                  // listing of $relDir/$F                  if ( $CONFIRM != "on" ) break ;
1934                  DisplayCode($gblFsRoot, $relDir, $F) ;                  if (! check_perm("$relDir/$FN", trperm_w))
1935                  exit ;                          Error("Access denied","User <tt>$gblLogin</tt> tried to unlock <tt>$relDir/$FN</tt> without valid trustee.",1);
1936          case "Co" :                  Unlock("$fsDir/$FN");
1937                  // checkout                  break ;
1938                  Lock("$gblFsRoot/$relDir/$F");  
1939                  Download("$gblFsRoot/$relDir/$F",1);          default :
1940                  exit;                  // user hit "CANCEL" or undefined action
1941          case "Ci" :          }
1942                  $F=stripSlashes($F);  
1943                  // upload && update to $relDir          // common to all POSTs : redirect to directory view ($relDir)
1944                  if (!is_writeable($gblFsRoot . $relDir))          if (isset($POSTACTION)) {
1945                          Error("Write access denied",$relDir) ;                  $tstr = $HTTP_SERVER_VARS["PHP_SELF"]."?D=".urlencode($relDir);
1946                  $text  = "Use this page to update a single " ;                  header("Location: ".$tstr) ;  
1947                  $text .= "file to <B>$realm</B>." ;                  exit ;
1948                  StartHTML("(Update file Page)", $text) ;          }
1949                  UploadPage($gblFsRoot, $relDir, $F) ;  
1950                  EndHTML() ;          // check for mode.. navigate, code display, upload, or detail?
1951                  exit ;          // $A=U : upload to path given in $D
1952          case "V" :          // $A=E : display detail of file $D/$F and edit
1953                  // view          // $A=C : display code in file $D/$F
1954                  LogIt("$gblFsRoot/$relDir/$F","viewed");          // $A=Co : checkout file $D/$F
1955                  Download("$gblFsRoot/$relDir/$F",$gblForceDownload);          // $A=Ci : checkin file $D/$F
1956                  exit;          // $A=V : view file (do nothing except log)
1957          case "Ch" :          // $A=I : include file .$F.php from [$gblIncDir|realm]/include_php
1958                  StartHTML("(File changes)","All changes chronologicaly...");          // default : display directory $D
1959                  DisplayChangeLog(0);    // all  
1960                  EndHTML() ;          if (isset($A)) switch ($A) {
1961                  exit;          case "U" :
1962          case "Ch1" :                  // upload to $relDir
1963                  StartHTML("(File changes)","Changes to files in last day...");                  if (! check_perm($relDir, trperm_w))
1964                  DisplayChangeLog(1);                          Error("Write access denied","You don't have permission to write in <tt>$relDir</tt>");
1965                  EndHTML() ;                  if (!is_writeable($gblFsRoot . $relDir))
1966                  exit;                          Error("Write access denied","User <tt>$gblLogin</tt> has permission on <tt>$relDir</tt>, but directory is not writable",1);
1967          case "I" :                  $text  = "Use this page to upload a single " ;
1968                  if (! isset($F) || $F == "")                  $text .= "file to <B>$realm</B>." ;
1969                          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);                  StartHTML("(Upload Page)", $text) ;
1970                  $inc_file="$fsRealmDir/$realm".$realm_sep.$F.".php";                  UploadPage($gblFsRoot, $relDir) ;
1971                  if (! file_exists($inc_file)) {                  EndHTML() ;
1972                          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);                  exit ;
1973                  }          case "E" :
1974                  if (!is_readable($inc_file))                  // detail of $relDir/$F
1975                          Error("Read access to include file denied","Can't read PHP include file <tt>$inc_file</tt>. Fix permissions on it.",1);                  if (is_file("$gblFsRoot/$relDir/$F") || is_dir("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ;
1976                  $text  = "Your include file should define \$text variable which holds this text and \$title variable which is page title";                  exit ;
1977                  $title = "You should define \$title variable with page title";          case "C" :
1978                  include($inc_file);                  $F=stripSlashes($F);
1979                  StartHTML($title, $text) ;                  // listing of $relDir/$F
1980                  print "<p>".GifIcon(up)." Back to <a href=$HTTP_SERVER_VARS[PHP_SELF]>front page</a>.</p>";                  DisplayCode($gblFsRoot, $relDir, $F) ;
1981                  EndHTML() ;                  exit ;
1982                  exit ;          case "Co" :
1983          }                  // checkout
1984                    Lock("$gblFsRoot/$relDir/$F");
1985          // default: display directory $relDir                  Download("$gblFsRoot/$relDir/$F",1);
1986          Navigate($gblFsRoot,$relDir) ;                    exit;
1987          exit ;          case "Ci" :
1988                    $F=stripSlashes($F);
1989          Error("Whooah!","By cartesian logic, this never happens",1) ;                  // upload && update to $relDir
1990  ?>                  if (!is_writeable($gblFsRoot . $relDir))
1991                            Error("Write access denied",$relDir) ;
1992                    $text  = "Use this page to update a single " ;
1993                    $text .= "file to <B>$realm</B>." ;
1994                    StartHTML("(Update file Page)", $text) ;
1995                    UploadPage($gblFsRoot, $relDir, $F) ;
1996                    EndHTML() ;
1997                    exit ;
1998            case "V" :
1999                    // view
2000                    LogIt("$gblFsRoot/$relDir/$F","viewed");
2001                    Download("$gblFsRoot/$relDir/$F",$gblForceDownload);
2002                    exit;
2003            case "Ch" :
2004                    StartHTML("(File changes)","All changes chronologicaly...");
2005                    DisplayChangeLog(0);    // all
2006                    EndHTML() ;
2007                    exit;
2008            case "Ch1" :
2009                    StartHTML("(File changes)","Changes to files in last day...");
2010                    DisplayChangeLog(1);
2011                    EndHTML() ;
2012                    exit;
2013            case "I" :
2014                    if (! isset($F) || $F == "")
2015                            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);
2016                    $inc_file="$fsRealmDir/$realm".$realm_sep.$F.".php";
2017                    if (! file_exists($inc_file)) {
2018                            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);
2019                    }
2020                    if (!is_readable($inc_file))
2021                            Error("Read access to include file denied","Can't read PHP include file <tt>$inc_file</tt>. Fix permissions on it.",1);
2022                    $text  = "Your include file should define \$text variable which holds this text and \$title variable which is page title";
2023                    $title = "You should define \$title variable with page title";
2024                    include($inc_file);
2025                    StartHTML($title, $text) ;
2026                    print "<p>".GifIcon(up)." Back to <a href=$HTTP_SERVER_VARS[PHP_SELF]>front page</a>.</p>";
2027                    EndHTML() ;
2028                    exit ;
2029            }
2030    
2031            // default: display directory $relDir
2032            Navigate($gblFsRoot,$relDir) ;  
2033            exit ;
2034    
2035            Error("Whooah!","By cartesian logic, this never happens",1) ;
2036    ?>
2037    

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.46

  ViewVC Help
Powered by ViewVC 1.1.26