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

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

  ViewVC Help
Powered by ViewVC 1.1.26