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

Diff of /docman.php

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

revision 1.1.1.1 by dpavlin, Fri May 12 12:01:08 2000 UTC revision 1.57 by dpavlin, Wed Feb 20 12:15:06 2002 UTC
# Line 34  Line 34 
34  /*             PHP3. Fixed bug which would send you to a non-   */  /*             PHP3. Fixed bug which would send you to a non-   */
35  /*             existent address after file modifications.       */  /*             existent address after file modifications.       */
36    
37    /*
38    
39            This project is now called Directory Manager.
40    
41            For more info, please see web pages at
42            http://www.rot13.org/~dpavlin/docman.html
43    
44            It's relased under GPL by
45            Dobrica Pavlinusic <dpavlin@rot13.org>
46    
47    
48    IMPORTANT INSTALLATION NOTE:
49            deny serving of .* (dot-something) files in web server!
50            Otherwise, uses can access your log files, users and/or
51            deleted files!
52    
53            .htusers is in form:
54            login:Real Name:[md5(loginpassword)|auth_*]:email@host.dom
55    
56    
57    TODO:
58            mixed file/directory output (add type to each entry,
59                    real support for links)
60            access controll
61    
62    */
63    
64  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
65    
66  // TODO : Don't let the file be modified itself. Create a hash of  // TODO : Don't let the file be modified itself. Create a hash of
# Line 44  Line 71 
71    
72  // GLOBAL PARAMETERS  // GLOBAL PARAMETERS
73  // =================  // =================
74  // Make modifications here to suit siteman to your needs  // Make modifications here to suit docman to your needs
75    
76  //      error_reporting(4) ;            // how verbose ?  //      error_reporting(4) ;            // how verbose ?
77    
78            // from where to include auth_*.php modules?
79            $gblIncDir = "/home/httpd/docman";
80    
81            // do we want to force download? (default is 0 for backward
82            // compatibility, but it's defined as 1 in docman.conf for all
83            // future applications!
84            $gblForceDownload = 0;
85    
86          // username/password should not be system          // username/password should not be system
87          // usernames/passwords !!          // usernames/passwords !!
88    
89          // your (hashed) username/password here          $gblPw    = "";
90          $gblPw    = "hash_of_your_username_and_password" ;                
91                    // date format
92          $gblAuth  = false ;             // use builtin authentication  //      $gblDateFmt="D, F d, Y";
93          $gblHash  = "md5" ;             // hash function to use          $gblDateFmt="Y-m-d";
94    
95            // time format
96    //      $gblTimeFmt="g:i:sA";
97            $gblTimeFmt="H:i:s";
98    
99            // Number of backup files to keep
100            $gblNumBackups=3;
101    
102            // show red star if newer than ... days
103            $gblModDays=1;
104    
105          // choose GifIcon below unless you have the M$          // choose GifIcon below unless you have the M$
106          // WingDings font installed on your system          // WingDings font installed on your system
107    
108          $gblIcon = "GifIcon" ;          // MockIcon or GifIcon          $gblIcon="GifIcon";             // MockIcon or GifIcon
109    
110          // the directory below should be /icons/ or /icons/small/          // the directory below should be /icons/ or /icons/small/
111          // on Apache; a set of icons is included in the distribution          // on Apache; a set of icons is included in the distribution
112    
113          $gblIconLocation = "icons/" ;          $gblIconLocation="/icons/";
114    
115          // files you want to be able to edit in text mode          // files you want to be able to edit in text mode
116          // and view with (primitive) syntax highlighting          // and view with (primitive) syntax highlighting
# Line 80  Line 125 
125          $gblImages   = array( ".jpg",".jpeg",".gif",".png",".ico",          $gblImages   = array( ".jpg",".jpeg",".gif",".png",".ico",
126                                ".bmp",".xbm") ;                                ".bmp",".xbm") ;
127    
128            // which files to hide (separated by ,)
129            $gblHide = "";
130    
131            // Where are users? (by default in .htusers file)
132            $gblUsers = "htusers_file";
133    
134  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
135    
136            $gblVersion = "1.9-dev";
137    
138  function StartHTML($title,$text="") {  function StartHTML($title,$text="") {
139    
140          $title = "Site Manager " . $title ;          $title = "Document Manager " . $title ;
141          $host  = $GLOBALS["HTTP_HOST"] ;          $host  = $GLOBALS["HTTP_HOST"] ;
142          $self  = $GLOBALS["PHP_SELF"] ;          $self  = $GLOBALS["PHP_SELF"] ;
143  ?>  ?>
144    
145  <HTML>  <HTML>
146  <HEAD>  <HEAD>
147   <TITLE><?php echo $host . " " . $title ?></TITLE>   <TITLE><?= $host . " " . $title ?></TITLE>
148   <META NAME="description" CONTENT="PHP port of AnyPortal Site Manager">   <META NAME="description" CONTENT="Document Manager">
149   <META NAME="keywords" CONTENT="site manager, web site maintenance">   <META NAME="keywords" CONTENT="site manager, web site maintenance">
150   <META NAME="robots" CONTENT="noindex">   <META NAME="robots" CONTENT="noindex">
151   <META HTTP-EQUIV="expires" CONTENT="0">   <META HTTP-EQUIV="expires" CONTENT="0">
152   <LINK REL="stylesheet" TYPE="text/css"   <LINK REL="stylesheet" TYPE="text/css"
153          HREF="<?php echo $self ?>?STYLE=get">          HREF="<?= $self ?>?STYLE=get">
154  </HEAD>  </HEAD>
155  <BODY BGCOLOR="#FFFFFF">  <BODY BGCOLOR="#FFFFFF">
156   <H3 ALIGN="RIGHT"><?php echo $host ?></H3>   <H3 ALIGN="RIGHT"><?= $host ?></H3>
157  <TABLE BORDER=0 WIDTH="100%"><TR>  <TABLE BORDER=0 WIDTH="100%"><TR>
158   <TD CLASS=INV><?php echo $title ?></TD></TR></TABLE>   <TD CLASS=INV><?= $title ?></TD></TR></TABLE>
159   <P><?php echo $text ?></P>   <P><?= $text ?></P>
160    
161  <?php  <?php
162  } // end function StartHTML  } // end function StartHTML
# Line 111  function StartHTML($title,$text="") { Line 164  function StartHTML($title,$text="") {
164  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
165    
166  function EndHTML() {  function EndHTML() {
167    
168    global $gblDateFmt, $gblTimeFmt, $gblUserName, $PHP_SELF, $gblPw, $gblVersion;
169    
170  ?>  ?>
171    
172  <HR>  <HR>
173  <P CLASS=FTR>  <P CLASS=FTR>
174  <B><?php echo date("D, F d, Y") ?> -  <B><?= date($gblDateFmt) ?> -
175  <?php echo date("g:i:sA") ?></B><BR>ANYPORTAL(php) Site Manager  <?= date($gblTimeFmt) ?> -
176  - &copy; 1999 by <A HREF="http://www.anyportal.com">ANYPORTAL</A>  <?= $gblUserName ?>
177  - &copy; 2000 by <A HREF="http://da.nger.org">d@nger.org</A>  <?php
178            global $PHP_AUTH_USER,$PHP_AUTH_PW;
179            $url = $PHP_SELF."?relogin=";
180            if (isset($gblPw) && $gblPw != "") {
181                    $url .= $gblPw;
182            } else {
183                    $url .= md5($PHP_AUTH_USER.$PHP_AUTH_PW);
184            }
185            if (isset($PHP_AUTH_USER) && $PHP_AUTH_USER != "" && ($PHP_AUTH_PW == "" || !isset($PHP_AUTH_PW))) {
186                    $url_title="login";
187                    $url .= "&force_login=1";
188            } else {
189                    $url_title="relogin";
190            }
191    ?>
192    <small> [<a href="<?= $url ?>"><?= $url_title ?></a>]</small>
193    </B>
194    <BR><small>
195    Document Manager <?= $gblVersion ?>, based on ANYPORTAL(php) Site Manager
196    <br>
197    &copy; 1999 by <A HREF="http://www.anyportal.com">ANYPORTAL</A>,
198    &copy; 2000 by <A HREF="http://da.nger.org">d@nger.org</A>,
199    &copy; 2000-2002 by <A HREF="http://www.rot13.org/~dpavlin/">DbP</A>
200    </small>
201  </P>  </P>
202  <BR><BR><BR></BODY></HTML>  <BR>
203    <? //include(".debug.inc") ?>
204    <BR><BR></BODY></HTML>
205    
206  <?php  <?php
207  } // end function EndHTML  } // end function EndHTML
# Line 130  function EndHTML() { Line 211  function EndHTML() {
211  function CSS() {  function CSS() {
212  ?>  ?>
213    
214  BODY,TD,P,H1,H2,H3 { font-family:Helvetica,Arial,sans-serif; }  BODY,TD,P,H1,H2,H3 { font-family:Verdana,Helvetica,Arial,sans-serif; }
215  .BLK { color:black; }  .BLK { color:black; }
216  .RED { color:red; }  .RED { color:red; }
217  .TOP { color:red; font-size:70%; } /* table headings */  .TOP { color:red; font-size:70%; } /* table headings */
# Line 154  A:HOVER { color:red; } Line 235  A:HOVER { color:red; }
235    
236  function DetailPage($fsRoot,$relDir,$fn) {  function DetailPage($fsRoot,$relDir,$fn) {
237                    
238          global $gblEditable, $gblImages ;          global $gblEditable, $gblImages, $webRoot ;
239          $self = $GLOBALS["PHP_SELF"] ;          $self = $GLOBALS["PHP_SELF"] ;
240    
241          $relPath  = $relDir . "/" . $fn ;          $relPath  = $relDir . "/" . $fn ;
# Line 164  function DetailPage($fsRoot,$relDir,$fn) Line 245  function DetailPage($fsRoot,$relDir,$fn)
245          $exists   = file_exists($fsPath) ;          $exists   = file_exists($fsPath) ;
246          $ext      = strtolower(strrchr($relPath,".")) ;          $ext      = strtolower(strrchr($relPath,".")) ;
247          $editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) ;          $editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) ;
248          $writable = Writeable($fsPath) ;          $writable = is_writeable($fsPath) ;
249            $file_lock = CheckLock($fsPath);
250    
251          if (!$editable && !$exists)          if (!$editable && !$exists)
252                  Error("Creation unsupported for type",$relPath) ;                  Error("Creation unsupported for type",$relPath) ;
253          if (!exists && !Writeable($fsDir) )          if (!exists && !is_writeable($fsDir) )
254                  Error("Creation denied",$relDir) ;                  Error("Creation denied",$relDir) ;
255    
256          $text  = "Use this page to view, modify or " ;          $text  = "Use this page to view, modify or " ;
257          $text .= "delete a single document on this " ;          if (is_dir($fsPath)) {
258                    $text .="delete a directory on this " ;
259            } else {
260                    $text .= "delete a single document on this " ;
261            };
262          $text .= "web site." ;            $text .= "web site." ;  
263          $title = "(Detail Page)" ;          $title = "(Detail Page)" ;
264          StartHTML($title, $text) ;          StartHTML($title, $text) ;
265    
266          echo "<H3>" . $relDir . "/" . $fn . "</H3>" ;          echo "<H3>" . $relDir . "/" . $fn . "</H3>" ;
267          if ($exists) {  // get file info          if ($exists) {  // get file info
268            $fsize = filesize($fsPath) ;                  $fsize = filesize($fsPath) ;
269            $fmodified = date("d/M/y G:i:s", filemtime($fsPath)) ;                  $fmodified = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", filemtime($fsPath)) ;
270            $faccessed = date("d/M/y G:i:s", fileatime($fsPath)) ;                  $faccessed = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", fileatime($fsPath)) ;
271            echo "<PRE>    file size: " . $fsize . " Bytes<BR>" ;                  $fuid=fileowner($fsPath);
272            echo "last modified: <B>" . $fmodified . "</B><BR>" ;                  $fgid=filegroup($fsPath);
273            echo "last accessed: <B>" . $faccessed . "</B><BR>" ;                  $userinfo = posix_getpwuid($fuid);
274            echo "        owner: <B>" . fileowner($fsPath) . "</B><BR>" ;                  $grpinfo = posix_getgrgid($fgid);
275            echo "        group: <B>" . filegroup($fsPath) . "</B><BR>" ;                  echo "<PRE>";
276            echo "  permissions: <B>" ;                  if (!is_dir($fsPath)) echo "    file size: " . $fsize . " Bytes<BR>" ;
277            echo printf( "%o", fileperms($fsPath) ) . "</B>" ;                  echo "last modified: <B>" . $fmodified . "</B><BR>" ;
278            echo "</PRE>" ;                  echo "last accessed: <B>" . $faccessed . "</B><BR>" ;
279                    echo "        owner: <B>" . $userinfo["name"] . " [$fuid]</B><BR>" ;
280                    echo "        group: <B>" . $grpinfo["name"] . " [$fgid]</B><BR>" ;
281                    echo "  permissions: <B>" ;
282                    echo printf( "%o", fileperms($fsPath) ) . "</B>" ;
283                    echo "</PRE>" ;
284    
285          }          }
286    
287          if ( $editable && ($writable || !$exists) ) {          if ( !is_dir($fsPath) && $editable && ($writable || !$exists) && !$file_lock ) {
288                  $fh = fopen($fsPath,"a+") ;                  $fh = fopen($fsPath,"a+") ;
289                  rewind($fh) ;                  rewind($fh) ;
290                  $fstr = fread($fh,filesize($fsPath)) ;                  $fstr = fread($fh,filesize($fsPath)) ;
# Line 200  function DetailPage($fsRoot,$relDir,$fn) Line 292  function DetailPage($fsRoot,$relDir,$fn)
292                  $fstr = htmlentities( $fstr ) ;                  $fstr = htmlentities( $fstr ) ;
293  ?>  ?>
294    
295  <FORM ACTION="<?php echo $self ; ?>" METHOD="POST">  <FORM ACTION="<?= $self ; ?>" METHOD="POST">
296  <SPAN TITLE="Click [SAVE] to store updated contents.">  <SPAN TITLE="Click [SAVE] to store updated contents.">
297          <B>DOCUMENT CONTENTS</B>          <B>DOCUMENT CONTENTS</B>
298  </SPAN><BR>  </SPAN><BR>
299  <TEXTAREA NAME="FILEDATA" ROWS=18 COLS=70 WRAP="OFF"><?php  <TEXTAREA NAME="FILEDATA" ROWS=18 COLS=70 WRAP="OFF"><?php
300  echo($fstr) ; ?></TEXTAREA>  echo($fstr) ; ?></TEXTAREA>
301  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ; ?>">  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ; ?>">
302  <INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?php echo $fn ; ?>">  <INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?= $fn ; ?>">
303  <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="SAVE">  <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="SAVE">
304  <INPUT TYPE="TEXT" SIZE=48 MAXLENGTH=255 NAME="RELPATH"  <INPUT TYPE="HIDDEN" SIZE=48 MAXLENGTH=255 NAME="RELPATH"
305          VALUE="<?php echo $relPath ; ?>">          VALUE="<?= $relPath ; ?>">
306  <INPUT TYPE="RESET" VALUE="RESET">  <br>
307    <INPUT TYPE="RESET" VALUE="UNDO ALL CHANGES">
308  <INPUT TYPE="SUBMIT" VALUE="SAVE">  <INPUT TYPE="SUBMIT" VALUE="SAVE">
309  </FORM>  </FORM>
310    
311  <?php  <?php
312          }          }
313          else if ( strstr( join(" ",$gblImages), $ext ) ) {            if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) {  
314            $info  = getimagesize($fsPath) ;                  $info  = getimagesize($fsPath) ;
315            $tstr  = "<IMG SRC=\"". $relPath . "\" BORDER=0 " ;                  $tstr = "<IMG SRC=\"$webRoot".urlpath($relPath)."\" BORDER=0 " ;
316            $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;                  $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;
317            $tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ;                  $tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ;
318            echo htmlentities($tstr) . "<BR><BR>" . $tstr ;  //              echo htmlentities($tstr) . "<BR><BR>" . $tstr ;
319                    echo $tstr ;
320          }          }
321    
322  ?>  ?>
323    
324  <FORM ACTION="<?php echo $self ; ?>" METHOD="POST">  <FORM ACTION="<?= $self ; ?>" METHOD="POST">
325  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ; ?>">  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ; ?>">
326  <INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?php echo $fn ; ?>">  <INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?= $fn ; ?>">
327  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR>  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR>
328    
329  <?php  <?php
330    
331            if ($file_lock) {
332    ?>
333    <hr>
334    <SPAN TITLE="Check OK and click UNLOCK to remove lock on file.">
335    <B>OK TO FORCE LOCK REMOVAL ON "<?= $fn ; ?>" HELD BY <?= $file_lock ?>? </B></SPAN>
336    <INPUT TYPE="CHECKBOX" NAME="CONFIRM">
337    <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="UNLOCK">
338    <?
339            } // file_lock
340    
341            if (substr($fn,0,4) == ".del") {
342                    $action="UNDELETE";
343                    $desc="undelete previously deleted file";
344            } else {
345                    $action="DELETE";
346                    $desc="delete";
347            }
348    
349          if ($exists && $writable) {          if ($exists && $writable) {
350  ?>  ?>
351    
352  <HR><SPAN TITLE="Check OK and click [DELETE] to delete.">  <HR>
353  <B>OK TO DELETE "<?php echo $fn ; ?>"? </B></SPAN>  <a name="undelete">
354    <SPAN TITLE="Check OK and click [<?= $action ?>] to <?= $desc ?>.">
355    <B>OK TO <?= $action ?> "<?= $fn ; ?>"? </B></SPAN>
356    <INPUT TYPE="CHECKBOX" NAME="CONFIRM">
357    <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="<?= $action ?>">
358    
359    <HR>
360    <a name="rename">
361    <SPAN TITLE="Check OK and click [RENAME] to rename.">
362    <B>OK TO RENAME "<?= $fn ; ?>" TO
363    <INPUT TYPE="TEXT" SIZE=24 MAXLENGTH=255 NAME="NEWNAME" VALUE="<?= $fn ?>">
364    ? </B></SPAN>
365  <INPUT TYPE="CHECKBOX" NAME="CONFIRM">  <INPUT TYPE="CHECKBOX" NAME="CONFIRM">
366  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="DELETE">  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="RENAME">
367    
368  <?php  <?php
369            }       // exists && writable
370    ?>
371    <HR>
372    <a name="note">
373    <B>NOTE FOR "<?= $fn ; ?>":
374    <INPUT TYPE="TEXT" SIZE=50 MAXLENGTH=255 NAME="NOTE" VALUE="<?= ReadNote($fsPath) ?>">
375    </B></SPAN>
376    <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="NOTE">
377    
378    </FORM>
379    
380    <?php
381    
382            $name=basename("$fsDir/$fn");
383            $logname=dirname("$fsDir/$fn")."/.log/$name";
384            $bakdir=dirname("$fsDir/$fn")."/.bak";
385            if (file_exists($logname)) {
386                    $log=fopen($logname,"r");
387                    $cl1=" class=LST"; $cl2="";
388                    $logarr = array();
389                    while($line = fgetcsv($log,512,"\t")) {
390                            $cl=$cl1; $cl1=$cl2; $cl2=$cl;
391                            array_unshift($logarr,array($cl,$line[0],$line[1],$line[2],$line[3]));
392                    }
393                    fclose($log);
394                    if (is_dir("$fsDir/$fn")) {
395                            $whatis="DIRECTORY";
396                    } else {
397                            $whatis="FILE";
398                    }
399                    print "<hr><br><b>CHANGES TO THIS $whatis</b><br><table border=0 width=100%>\n";
400                    $bakcount = 0;  // start from 0, skip fist backup (it's current)
401                    while ($e = array_shift($logarr)) {
402                            if (strstr($e[4],"upload")) {
403                                    if (file_exists("$bakdir/$bakcount/$name")) {
404                                            $e[4]="<a href=\"$webRoot".urlpath(dirname($relPath)."/.bak/$bakcount/$name")."\">$e[4]</a>";
405                                    }
406                                    $bakcount++;
407                            }
408                            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";
409                    }
410                    print "</table>";
411          }          }
412          echo "</FORM>" ;  
413          EndHTML() ;          EndHTML() ;
414    
415  } // end function DetailPage  } // end function DetailPage
# Line 472  function GifIcon($txt) { Line 639  function GifIcon($txt) {
639          case "blank" :          case "blank" :
640                  $d = "blank.gif" ;                  $d = "blank.gif" ;
641                  break ;                  break ;
642            case "checkout":
643                    $d = "box2.gif";
644                    break;
645            case "checkin":
646                    $d = "hand.up.gif";
647                    break;
648            case "locked":
649                    $d = "screw2.gif";
650                    break;
651            case "note":
652                    $d = "quill.gif";
653                    break;
654          default :          default :
655                  $d = "generic.gif" ;                  $d = "generic.gif" ;
656          }          }
# Line 483  function GifIcon($txt) { Line 662  function GifIcon($txt) {
662    
663  function Navigate($fsRoot,$relDir) {  function Navigate($fsRoot,$relDir) {
664    
665          global $gblEditable, $gblIcon ;          global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide ;
666    
667          $self     = $GLOBALS["PHP_SELF"] ;          $self     = $GLOBALS["PHP_SELF"] ;
668          $webRoot  = "http://" . $GLOBALS["SERVER_NAME"] ;  
669          $fsDir    = $fsRoot . $relDir . "/" ; // current directory          $fsDir = $fsRoot . $relDir . "/" ; // current directory
670    
671          if (!is_dir($fsDir)) Error("Dir not found",$relDir) ;          if (!is_dir($fsDir)) Error("Dir not found",$relDir) ;
672    
673            $hide_items=",$gblHide,";
674    
675          // read directory contents          // read directory contents
676          if ( !($dir = @opendir($fsDir)) )          if ( !($dir = @opendir($fsDir)) )
677                  Error("Read Access denied",$relDir) ;                  Error("Read Access denied",$relDir) ;
678          while ($item = readdir($dir)) {          while ($item = readdir($dir)) {
679                  if ( $item == ".." || $item == "." ) continue ;                  if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") ) continue ;
680                  if ( is_dir($fsDir . $item) ) {                  if ( is_dir($fsDir . $item) ) {
681                          $dirList[] = $item ;                          $dirList[] = $item ;
682                  }                  } else if ( is_file($fsDir . $item) ) {
                 else if ( is_file($fsDir . $item) ) {  
683                          $fileList[] = $item ;                                    $fileList[] = $item ;          
684                  }                  } else if ( is_link($fsDir . $item) ) {
685                  else {                          $dirList[] = $item ;
686                    } else {
687                    // unknown file type                    // unknown file type
688                    // $text = "Could not determine file type of " ;                    // $text = "Could not determine file type of " ;
689                    // Error("File Error", $text.$relDir."/".$item) ;                    // Error("File Error", $text.$relDir."/".$item) ;
# Line 510  function Navigate($fsRoot,$relDir) { Line 691  function Navigate($fsRoot,$relDir) {
691                  }                  }
692          }          }
693          closedir($dir) ;          closedir($dir) ;
694    
695            // scan deleted files
696            if ( $GLOBALS[show_deleted] == 1 && ($dir = @opendir("$fsDir/.del")) ) {
697                    while ($item = readdir($dir)) {
698                            if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") ) continue ;
699                            $fileList[] = ".del/$item" ;            
700                    }
701                    closedir($dir) ;
702            }
703    
704          $emptyDir = ! (sizeof($dirList) || sizeof($fileList)) ;          $emptyDir = ! (sizeof($dirList) || sizeof($fileList)) ;
705    
706          // start navigation page          // start navigation page
707          $text  = "Use this page to add, delete or " ;          $text  = "Use this page to add, delete";
708          $text .= "revise files on this web site." ;          if (! isset($show_deleted)) {
709                    $text .= ", <a href=$self?D=".urlencode($relDir)."&show_deleted=1>undelete</a>";
710            }
711            $text .= " or revise files on this web site." ;
712            $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>.";
713          StartHTML("(Navigate)",$text) ;          StartHTML("(Navigate)",$text) ;
714    
715          echo "<TABLE BORDER=0 CELLPADDING=2          echo "<TABLE BORDER=0 CELLPADDING=2
716                  CELLSPACING=3 WIDTH=\"100%\">" ;                  CELLSPACING=3 WIDTH=\"100%\">" ;
717    
718          // updir bar              // updir bar    
719          if ($fsDir != $fsRoot) {          if (chopsl($fsDir) != chopsl($fsRoot)) {
720                  $parent = dirname($relDir) ;                  $parent = dirname($relDir) ;
721                  if ($parent == "") $parent = "/" ;                  if ($parent == "") $parent = "/" ;
722  ?>  ?>
723    
724  <TR><TD><?php echo $gblIcon("up") ?></TD><TD COLSPAN=4 CLASS=LST>  <TR><TD><?= $gblIcon("up") ?></TD><TD COLSPAN=5 CLASS=LST>
725  <A HREF="<?php echo $self ?>?D=<?php echo urlencode($parent) ?>">  <A HREF="<?= $self ?>?D=<?= urlencode($parent) ?>">
726  <B><?php echo $parent ?></B></A></TD></TR>  <B><?= $parent ?></B></A></TD></TR>
727    
728  <?php  <?php
729          }          }
730    
731    function plural($name,$count) {
732            $out="$count $name";
733            if ($count > 1) {
734                    $out.="s";
735            }
736            return $out;
737    }
738    
739          // output subdirs          // output subdirs
740          if (sizeof($dirList) > 0) {          if (sizeof($dirList) > 0) {
741                  sort($dirList) ;                  sort($dirList) ;
742  ?>  ?>
743    
744  <TR><TD></TD><TD COLSPAN=4 CLASS=TOP><HR>DIRECTORY NAME</TD></TR>  <TR><TD></TD><TD COLSPAN=2 CLASS=TOP>DIRECTORY NAME (<?= plural("dir",sizeof($dirList)) ?>)</TD><TD COLSPAN=3 CLASS=TOP>DIRECTORY NOTE</TR>
745    
746  <?php  <?php
747                  while (list($key,$dir) = each($dirList)) {                  while (list($key,$dir) = each($dirList)) {
748    
749                            $info_url=$self."?A=E&F=".urlencode($dir)."&D=".urlencode($relDir);
750                          $tstr = "<A HREF=\"" . $self . "?D=" ;                          $tstr = "<A HREF=\"" . $self . "?D=" ;
751                          $tstr .= urlencode($relDir."/".$dir) ;                          $tstr .= urlencode($relDir."/".$dir) ;
752                          $tstr .= "\">" . $dir . "/</A>" ;                          $tstr .= "\">" . $dir . "/</A>" ;
753                            $note_html="<a href=\"$info_url#note\">".$gblIcon("note")."</a>".ReadNote($fsDir.$dir);
754  ?>  ?>
755    
756  <TR><TD><?php echo $gblIcon("fldr") ?></TD>  <TR><TD>
757  <TD COLSPAN=4 CLASS=LST><?php echo $tstr ?></TD></TR>  <A HREF="<?= $info_url ?>" TITLE="View/Edit">
758    <?= $gblIcon("fldr") ?></A></TD>
759    <TD COLSPAN=2 CLASS=LST><?= $tstr ?></TD>
760    <TD COLSPAN=3 CLASS=LST><?= $note_html ?></TD></TR>
761    
762  <?php  <?php
763                  }  // iterate over dirs                  }  // iterate over dirs
764          }  // end if no dirs          }  // end if no dirs
765  ?>  ?>
766    
767  <TR><TD></TD><TD COLSPAN=4><HR><B><?php echo $webRoot . $relDir ?>  <TR><TD></TD><TD COLSPAN=5><HR><B><?= $webRoot . $relDir ?>
768  </B></TD></TR>  </B></TD></TR>
769  <TR><TD></TD><TD CLASS=TOP>DOCUMENT NAME</TD>  <TR><TD></TD><TD CLASS=TOP>DOCUMENT NAME (<?= plural("file",sizeof($fileList)) ?>)</TD>
770  <TD><?php echo $gblIcon("blank") ?></TD>  <TD><?= $gblIcon("blank").$gblIcon("blank") ?></TD>
771    <TD CLASS=TOP>NOTE</TD>
772  <TD CLASS=TOP>LAST UPDATE</TD><TD CLASS=TOP>FILE SIZE</TD></TR>  <TD CLASS=TOP>LAST UPDATE</TD><TD CLASS=TOP>FILE SIZE</TD></TR>
773    
774  <?php  <?php
775          if (sizeof($fileList) > 0) {          if (sizeof($fileList) > 0) {
776            sort($fileList) ;            sort($fileList) ;
777            while (list($key,$file) = each($fileList)) {              while (list($key,$file) = each($fileList)) {  
778              $path = $fsDir."/".$file ;                  $path = $fsDir."/".$file ;
779              $mod  = filemtime($path) ;                  $mod  = filemtime($path) ;
780              $sz   = filesize($path) ;                  $sz   = filesize($path) ;
781    
782              if ($sz >= 10240) {                  if ($sz >= 10240) {
783                $sz = (int)(($sz+1023)/1024) . " k" ;                          $sz = (int)(($sz+1023)/1024) . " k" ;
784              }                  } else {
785              else {                          $sz .= " " ;
786                $sz .= " " ;                  } // end size
787              } // end size  
788                    $a = $b = "" ;
789              $a = $b = "" ;  
790                    $info_url=$self."?A=E&F=".urlencode($file)."&D=".urlencode($relDir);
791              if ( ($mod + 30*86400) > time() ) {  
792                $a  = "<SPAN CLASS=RED TITLE=\"Newer" ;                  if ( ($mod + $gblModDays*86400) > time() ) {
793                $a .= " than 30 days\"> * </SPAN>" ;                          $a  = "<SPAN CLASS=RED TITLE=\"Newer" ;
794              }                          $a .= " than $gblModDays days\"> * </SPAN>" ;
795                    }
796              $tstr = $webRoot . $relDir . "/" . $file ;  
797              $tstr  = "<A HREF=\"" . $tstr . "\">" ;                  $file_lock=CheckLock($path);
798              $tstr .= $file . "</A>" . $a ;  
799                    $file_url_html="<A HREF=\"$self?A=V&F=".urlencode($file);
800              $ext = strtolower(strrchr($file,".")) ;                  $file_url_html.="&D=".urlencode($relDir);
801              if ( $ext=="" ||                  $file_url_html.="\" TITLE=\"View file\">" ;
802                   strstr(join(" ",$gblEditable),$ext) )  
803              {                    if (substr($file,0,5) != ".del/") {
804                $b  = "<A HREF=\"" . $self . "?A=C&F=" ;                          $file_url_html .= $file . "</A>" . $a ;
805                $b .= urlencode($file) . "&D=" . urlencode($relDir) ;                  } else {
806                $b .= "\" TITLE=\"List contents\">" ;                          $file_url_html .= substr($file,5,strlen($file)-5) . "</a> <SPAN CLASS=RED TITLE=\"deleted\"> <a href=\"$info_url#undelete\">deleted</a> </span>";
807                $b .= $gblIcon("view") . "</A>" ;                  }
808              }  
809                    $note_html="<a href=\"$info_url#note\">".$gblIcon("note")."</a>".ReadNote($path);
810    
811                    $ext = strtolower(strrchr($file,".")) ;
812    
813                    if ($file_lock) {
814                            if ($file_lock == $GLOBALS[gblUserName]) {
815                                    $b.="<A HREF=\"$self?A=Ci&F=".urlencode($file);
816                                    $b.="&D=".urlencode($relDir);
817                                    $b.="\" TITLE=\"Checkin (update) file on server\">" ;
818                                    $file_url_html=$b;
819                                    $b.=$gblIcon("checkin")."</A>" ;
820                                    $b.= $gblIcon("blank");
821                                    $file_url_html.="$file</a> $a";
822                                    $note_html = $gblIcon("blank")."<b>Please check-in (update) this file</b>";
823                            } else {
824                                    $b = $gblIcon("locked");
825                                    $b.= $gblIcon("blank");
826                                    $note_html = $gblIcon("blank")."<b>File locked by $file_lock</b>";
827                                    $file_url_html = "$file $a";
828                            }
829                    } else {
830                            $b.="<A HREF=\"$self?A=Co&F=".urlencode($file);
831                            $b.="&D=".urlencode($relDir);
832                            $b.="\" TITLE=\"Checkout file for edit\">" ;
833                            $b.=$gblIcon("checkout")."</A>" ;
834    
835                            if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) {  
836                                    $b.="<A HREF=\"$self?A=C&F=".urlencode($file);
837                                    $b.="&D=".urlencode($relDir);
838                                    $b.="\" TITLE=\"List contents\">" ;
839                                    $b.=$gblIcon("view")."</A>" ;
840                            } else {
841                                    $b.= $gblIcon("blank");
842                            }
843                    }
844    
845    
846  ?>  ?>
847    
848  <TR><TD>  <TR><TD>
849  <A HREF="<?php echo $self ?>?A=E&F=<?php echo urlencode($file)  <A HREF="<?= $info_url ?>" TITLE="View/Edit">
850  ?>&D=<?php echo urlencode($relDir) ?>" TITLE="View/Edit">  <?= $gblIcon($ext) ?></A></TD>
851  <?php echo $gblIcon($ext) ?></A></TD>  <TD CLASS=LST><?= $file_url_html ?></TD>
852  <TD CLASS=LST><?php echo $tstr ?></TD>  <TD CLASS=LST ALIGN=center><?= $b ?></TD>
853  <TD CLASS=LST ALIGN=center><?php echo $b ?></TD>  <TD CLASS=LST ALIGN=left><?= $note_html ?></TD>
854  <TD CLASS=LST><?php echo date("d/M/y G:i:s",$mod) ?></TD>  <TD CLASS=LST><?= date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]",$mod) ?></TD>
855  <TD CLASS=LST><?php echo $sz ?>Bytes</TD></TR>  <TD CLASS=LST><?= $sz ?>Bytes</TD></TR>
856    
857  <?php  <?php
858            }  // iterate over files            }  // iterate over files
859          }  // end if no files          } else {  // end if no files
860    ?>
861     <TR><TD></TD><TD COLSPAN=5 CLASS=LST>
862      No files in this directory
863     </TD></TR>
864    <?
865            }
866    
867          if ($emptyDir) {          if ($emptyDir && $relDir != "") {
868  ?>  ?>
869    
870  <FORM METHOD="POST" ACTION="<?php echo $self ?>">  <FORM METHOD="POST" ACTION="<?= $self ?>">
871   <TR><TD></TD><TD COLSPAN=4 CLASS=BAR>   <TR><TD></TD><TD COLSPAN=5 CLASS=BAR>
872    <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ?>">    <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">
873    OK TO DELETE THIS EMPTY FOLDER?    OK TO DELETE THIS EMPTY FOLDER?
874    <INPUT TYPE="CHECKBOX" NAME="CONFIRM">    <INPUT TYPE="CHECKBOX" NAME="CONFIRM">
875    <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="DELETE">    <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="DELETE">
# Line 630  function Navigate($fsRoot,$relDir) { Line 880  function Navigate($fsRoot,$relDir) {
880          } // end if emptyDir          } // end if emptyDir
881  ?>  ?>
882    
883  <TR><TD></TD><TD COLSPAN=4><HR></TD></TR>  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>
884    
885  <FORM METHOD="POST" ACTION="<?php echo $self ?>">  <?
886  <TR><TD></TD><TD COLSPAN=4 CLASS=BAR>CREATE NEW  if (file_exists(".info.inc")) {
887            print "<TR><TD></TD><TD COLSPAN=5>";
888            include(".info.inc");
889            print "</TD></TR>
890            <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>";
891    }
892    ?>
893    
894    <FORM METHOD="POST" ACTION="<?= $self ?>">
895    <TR><TD></TD><TD COLSPAN=5 CLASS=BAR>CREATE NEW
896   <INPUT TYPE="RADIO" NAME="T" VALUE="D" CHECKED>DIRECTORY -OR-   <INPUT TYPE="RADIO" NAME="T" VALUE="D" CHECKED>DIRECTORY -OR-
897   <INPUT TYPE="RADIO" NAME="T" VALUE="F">FILE : &nbsp;&nbsp;   <INPUT TYPE="RADIO" NAME="T" VALUE="F">FILE : &nbsp;&nbsp;
898   <NOBR>NAME <INPUT TYPE="TEXT" NAME="FN" SIZE=14>   <NOBR>NAME <INPUT TYPE="TEXT" NAME="FN" SIZE=14>
899   <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE">   <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE">
900   <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ?>">   <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">
901   <INPUT TYPE="SUBMIT" VALUE="CREATE"></NOBR>   <INPUT TYPE="SUBMIT" VALUE="CREATE" NAME="CREATE">
902   <NOBR>OR <A HREF="<?php echo $self   </NOBR>
903          ?>?A=U&D=<?php echo urlencode($relDir) ?>">UPLOAD</A> A FILE   <NOBR>OR <A HREF="<?= $self ?>?A=U&D=<?= urlencode($relDir) ?>">UPLOAD</A> A FILE</NOBR>
  </NOBR>  
904  </TD></TR>  </TD></TR>
905  </FORM>  </FORM>
906  </TABLE>  </TABLE>
# Line 653  function Navigate($fsRoot,$relDir) { Line 911  function Navigate($fsRoot,$relDir) {
911    
912  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
913    
914  function UploadPage($fsRoot, $relDir) {  function UploadPage($fsRoot, $relDir, $filename="") {
915    
916          $self = $GLOBALS["PHP_SELF"] ;          $self = $GLOBALS["PHP_SELF"] ;
917          if ($relDir == "") $relDir = "/" ;          if ($relDir == "") $relDir = "/" ;
# Line 661  function UploadPage($fsRoot, $relDir) { Line 919  function UploadPage($fsRoot, $relDir) {
919    
920  <P><TABLE BORDER=0 CELLPADDING=5><TR><TD WIDTH=5></TD><TD CLASS=BAR>  <P><TABLE BORDER=0 CELLPADDING=5><TR><TD WIDTH=5></TD><TD CLASS=BAR>
921  <FORM ENCTYPE="multipart/form-data" METHOD="POST"  <FORM ENCTYPE="multipart/form-data" METHOD="POST"
922   ACTION="<?php echo $self ?>">   ACTION="<?= $self ?>">
923  DESTINATION DIRECTORY:<B><?php echo " " . $relDir ?></B>  DESTINATION DIRECTORY:<B><?= " " . $relDir ?></B>
924    <? if (isset($filename) && $filename!="") { ?>
925    <br>DESTINATION FILE:<B><?= " " . $filename ?></B>
926    <INPUT TYPE="HIDDEN" NAME="FILENAME" VALUE="<?= $filename ?>">
927    <? } ?>
928  <P>PATHNAME OF LOCAL FILE<BR>  <P>PATHNAME OF LOCAL FILE<BR>
929  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ?>">  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">
930  <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="UPLOAD">  <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="UPLOAD">
931  <INPUT SIZE=30 TYPE="FILE" NAME="FN"></P>  <INPUT SIZE=30 TYPE="FILE" NAME="FN"></P>
932  <P><INPUT TYPE="SUBMIT" VALUE="UPLOAD"></P>  <P><INPUT TYPE="SUBMIT" VALUE="UPLOAD"></P>
933  <P>If the <B>[BROWSE...]</B> button is not displayed,<BR>  <P>If the <B>[BROWSE...]</B> button is not displayed,<BR>
934  you must upgrade to an RFC1867-compliant browser.</P>  you must upgrade to an RFC1867-compliant browser.</P>
935  <P>Your browser:<BR><?php echo $GLOBALS["HTTP_USER_AGENT"] ?></P>  <P>Your browser:<BR><?= $GLOBALS["HTTP_USER_AGENT"] ?></P>
936  </FORM>  </FORM>
937  </TD></TR>  </TD></TR>
938  <TR><TD></TD><TD>  <TR><TD></TD><TD>
939  <FORM METHOD="POST" ACTION="<?php echo $self ?>">  <FORM METHOD="POST" ACTION="<?= $self ?>">
940  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ?>"><BR>  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"><BR>
941  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL">  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL">
942  </FORM>  </FORM>
943  </TD></TR></TABLE></P>  </TD></TR></TABLE></P>
# Line 694  function Error($title,$text="") { Line 956  function Error($title,$text="") {
956    
957  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
958    
959  function Writeable($path) {  function NoEntry() {
         // fix by -mat- filid brandy, brandy@ecrc.de, 07/JUL/99  
960    
961          clearstatcache ;          $user = $GLOBALS["PHP_AUTH_USER"] ;
962          $perms = @fileperms($path) ;          $pw   = $GLOBALS["PHP_AUTH_PW"] ;      
963          $owner = @fileowner($path) ;          $self = $GLOBALS["PHP_SELF"] ;
         exec("id",$id) ;  
         eregi( "^uid=([0-9]*)",$id[0], $regs) ;  
         $apacheuid = $regs[1] ;  
         $perms = 0777 & $perms ;  
         if ( $apacheuid != $owner ) {  
                 return (06 == (06 & $perms)) ?  1 : 0 ;  
         }  
         else {  
                 return (0600 == (0600 & $perms)) ? 1 : 0 ;  
         }  
   
 } // end function Writable  
964    
965  //////////////////////////////////////////////////////////////////          $title = "(401 Unauthorized)" ;
966            $text  = "No trespassing !" ;
967    
968            global $PHP_AUTH_USER,$PHP_AUTH_PW,$gblPw,$relogin;
969            StartHTML($title,$text) ;
970    
 function CreateHash($user, $pw) {  
   
         global $gblHash ;  // hash function to use  
   
         if ($user == "" || $pw == "") {  
                 $text = "either no password or no username supplied" ;  
                 Error("Create Hash",$text) ;  
         }  
         $title = "(Create Hash)" ;  
         StartHTML($title) ;  
         echo "<P ALIGN=center>" ;  
         echo "<BLOCKQUOTE>Copy the value below and paste it " ;  
         echo "into the<BR>value for \$gblPw in the source of " ;  
         echo "this file<BR><BR><B>" . $gblHash($user.$pw) ;  
         echo "</B><BR><BR>Hash function: " . $gblHash ;  
         echo "</BLOCKQUOTE></P>" ;  
971          EndHTML() ;          EndHTML() ;
972          exit ;          exit ;
973    }
974    
975    //////////////////////////////////////////////////////////////////
976    
977    function LogIt($target,$msg) {
978    
979            $dir=dirname($target);
980            if (! file_exists($dir."/.log")) {
981                    mkdir($dir."/.log",0700);
982            }
983            $file=basename($target);
984    
985            $log=fopen("$dir/.log/$file","a+");
986            fputs($log,date("$GLOBALS[gblDateFmt]\t$GLOBALS[gblTimeFmt]").
987                    "\t$GLOBALS[gblUserName]\t$msg\n");
988            fclose($log);
989    
990    }
991    
 } // end function CreateHash  
992    
993  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
994    
995  function NoEntry() {  function WriteNote($target,$msg) {
996    
997          $user = $GLOBALS["PHP_AUTH_USER"] ;          $target=stripSlashes($target);
998          $pw   = $GLOBALS["PHP_AUTH_PW"] ;                $dir=dirname($target);
999          $self = $GLOBALS["PHP_SELF"] ;          if (! file_exists($dir."/.note")) {
1000                    mkdir($dir."/.note",0700);
1001            }
1002            $file=basename($target);
1003    
1004          $title = "(401 Unauthorized)" ;          $note=fopen("$dir/.note/$file","w");
1005          $text  = "No trespassing !" ;          fputs($note,"$msg\n");
1006          StartHTML($title,$text) ;          fclose($note);
 ?>  
1007    
1008  <FORM ACTION="<?php echo $self ?>?HASH=create" METHOD="POST">          Logit($target,"added note $msg");
 <INPUT TYPE="HIDDEN" NAME="USER" VALUE="<?php echo $user ?>">  
 <INPUT TYPE="HIDDEN" NAME="PW" VALUE="<?php echo $pw ?>">  
   
 <BLOCKQUOTE><B>If you are a site administrator:</B><BR><BR>  
 Click below to <B>generate a password hash</B><BR>from  
 the username-password pair you just<BR>entered. Then include the hash in  
 the source<BR>of this file.<BR><BR>  
 <INPUT TYPE="SUBMIT" VALUE="CREATE HASH">  
 </BLOCKQUOTE></FORM>  
1009    
 <?php  
         EndHTML() ;  
         exit ;  
1010  }  }
1011    
1012    function ReadNote($target) {
1013    
1014            $target=stripSlashes($target);
1015            $dir=dirname($target);
1016            $file=basename($target);
1017            $msg="";
1018            if (file_exists($dir."/.note/$file")) {
1019                    $note=fopen("$dir/.note/$file","r");
1020                    $msg=fgets($note,4096);
1021                    fclose($note);
1022            }
1023            return HtmlSpecialChars(StripSlashes($msg));
1024    
1025    }
1026    
1027    //////////////////////////////////////////////////////////////////
1028    
1029    function MoveTo($source,$folder) {
1030    
1031            $source=stripSlashes($source);
1032            $file=basename($source);
1033            if (! file_exists($folder)) {
1034                    mkdir($folder,0700);
1035            }
1036            if (file_exists($source)) {
1037                    rename($source,"$folder/$file");
1038            }
1039    }
1040    
1041    //////////////////////////////////////////////////////////////////
1042    
1043    function Lock($target) {
1044    
1045            $target=stripSlashes($target);
1046            $dir=dirname($target);
1047            if (! file_exists($dir."/.lock")) {
1048                    mkdir($dir."/.lock",0700);
1049            }
1050            $file=basename($target);
1051    
1052            if (file_exists("$dir/.lock/$file")) {
1053                    Logit($target,"attempt to locked allready locked file!");
1054            } else {
1055                    $lock=fopen("$dir/.lock/$file","w");
1056                    fputs($lock,"$GLOBALS[gblUserName]\n");
1057                    fclose($lock);
1058    
1059                    Logit($target,"file locked");
1060            }
1061    
1062    }
1063    
1064    function CheckLock($target) {
1065    
1066            $target=stripSlashes($target);
1067            $dir=dirname($target);
1068            $file=basename($target);
1069            $msg=0;
1070            if (file_exists($dir."/.lock/$file")) {
1071                    $lock=fopen("$dir/.lock/$file","r");
1072                    $msg=fgets($lock,4096);
1073                    fclose($lock);
1074            }
1075            return chop($msg);
1076    
1077    }
1078    
1079    function Unlock($target) {
1080    
1081            $target=stripSlashes($target);
1082            $dir=dirname($target);
1083            $file=basename($target);
1084            if (file_exists($dir."/.lock/$file")) {
1085                    unlink("$dir/.lock/$file");
1086                    Logit($target,"file unlocked");
1087            } else {
1088                    Logit($target,"attempt to unlocked non-locked file!");
1089            }
1090    
1091    }
1092    
1093    //////////////////////////////////////////////////////////////////
1094    
1095    function urlpath($url) {
1096            $url=urlencode(StripSlashes("$url"));
1097            $url=str_replace("%2F","/",$url);
1098            $url=str_replace("+","%20",$url);
1099            return($url);
1100    }
1101    
1102    //////////////////////////////////////////////////////////////////
1103    
1104    function safe_rename($fromdir,$fromfile,$tofile) {
1105            function try_rename($from,$to) {
1106    #               print "$from -> $to\n";
1107                    if (file_exists($from) && is_writeable(dirname($to))) {
1108                            rename($from,$to);
1109                    }
1110            }
1111    
1112            function try_dir($todir) {
1113                    if (! file_exists($todir)) {
1114                            mkdir($todir,0700);
1115                    }
1116            }
1117    
1118            $to="$fromdir/$tofile";
1119            $todir=dirname($to);
1120            $tofile=basename($to);
1121    
1122    #       print "<pre>$fromdir / $fromfile -> $todir / $tofile\n\n";
1123    
1124            try_rename("$fromdir/$fromfile","$todir/$tofile");
1125            try_dir("$todir/.log");
1126            try_rename("$fromdir/.log/$fromfile","$todir/.log/$tofile");
1127            try_dir("$todir/.note");
1128            try_rename("$fromdir/.note/$fromfile","$todir/.note/$tofile");
1129            try_dir("$todir/.lock");
1130            try_rename("$fromdir/.lock/$fromfile","$todir/.lock/$tofile");
1131            try_dir("$todir/.bak");
1132            for($i=0;$i<=$GLOBALS[gblNumBackups];$i++) {
1133                    try_rename("$fromdir/.bak/$i/$fromfile","$todir/.bak/$i/$tofile");
1134            }
1135    }
1136    
1137    
1138    //////////////////////////////////////////////////////////////////
1139    
1140    // recursivly delete directory
1141    
1142    function rrmdir($dir) {
1143            $handle=opendir($dir);
1144            while ($file = readdir($handle)) {
1145                    if ($file != "." && $file != "..") {
1146                            if (is_dir("$dir/$file"))
1147                                    rrmdir("$dir/$file");
1148                            else
1149                                    if (! @unlink("$dir/$file")) return(0);
1150                    }
1151            }
1152            closedir($handle);
1153            return @rmdir($dir);
1154    }
1155    
1156    //////////////////////////////////////////////////////////////////
1157    
1158    function ChangeLog($target,$msg) {
1159    
1160            global $gblFsRoot;
1161            $log=fopen("$gblFsRoot/.changelog","a+");
1162            if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot)
1163                    $target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot));
1164            $msg=str_replace("\t"," ",$msg);
1165            fputs($log,time()."\t$target\t$GLOBALS[gblUserName]\t$msg\n");
1166            fclose($log);
1167    
1168    }
1169    
1170    function DisplayChangeLog($day) {
1171    
1172            global $gblFsRoot;
1173            if (!file_exists("$gblFsRoot/.changelog")) return;
1174            $log=fopen("$gblFsRoot/.changelog","r");
1175            $logarr = array();
1176            while($line = fgetcsv($log,512,"\t")) {
1177                    while (sizeof($line) > 4) {
1178                            $tmp = array_pop($line);
1179                            $line.=" $tmp";
1180                    }
1181                    if ($day!=1 || ($day==1 && (time()-$line[0] < 24*60*60))) {
1182                            array_unshift($logarr,array($line[0],$line[1],$line[2],$line[3]));
1183                    }
1184            }
1185            fclose($log);
1186            $cl1=" class=LST"; $cl2="";
1187            print "<table border=0 width=100%>\n";
1188            while ($e = array_shift($logarr)) {
1189                    $cl=$cl1; $cl1=$cl2; $cl2=$cl;
1190                    $date = date("$GLOBALS[gblDateFmt]", $e[0]);
1191                    $time = date("$GLOBALS[gblTimeFmt]", $e[0]);
1192                    $dir = dirname($e[1]);
1193                    $file = basename($e[1]);
1194                    print "<tr><td$cl>$date</td><td$cl>$time</td><td$cl><a href=\"$GLOBALS[PHP_SELF]?D=".urlencode($dir)."\">$dir</a>/$file</td><td$cl>$e[2]</td><td$cl>$e[3]</td></tr>\n";
1195            }
1196            print "</table>";
1197            print "<p>".GifIcon(up)." Back to <a href=$GLOBALS[PHP_SELF]>front page</a>.</p>";
1198    }
1199    
1200    //////////////////////////////////////////////////////////////////
1201    
1202    function Download($path) {
1203            global $HTTP_USER_AGENT;
1204            $file=basename($path);
1205            $size = filesize($path);
1206            //header("Content-Type: application/octet-stream");
1207            header("Content-Type: application/force-download");
1208            header("Content-Length: $size");
1209            // IE5.5 just downloads index.php if we don't do this
1210            if(preg_match("/MSIE 5.5/", $HTTP_USER_AGENT)) {
1211                    header("Content-Disposition: filename=$file");
1212            } else {
1213                    header("Content-Disposition: attachment; filename=$file");
1214            }
1215            header("Content-Transfer-Encoding: binary");
1216            $fh = fopen($path, "r");
1217            fpassthru($fh);
1218    }
1219    
1220    
1221  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1222    
1223    function chopsl($path) {
1224            if (substr($path,strlen($path)-1,1) == "/") $path=substr($path,0,strlen($path)-1);
1225            $path=str_replace("//","/",$path);
1226            return $path;
1227    }
1228    
1229    //////////////////////////////////////////////////////////////////
1230  // MAIN PROGRAM  // MAIN PROGRAM
1231  // ============  // ============
1232  // query parameters: capital letters  // query parameters: capital letters
1233  // local functions : begin with capital letters  // local functions : begin with capital letters
1234  // global constants: begin with gbl  // global constants: begin with gbl
1235    
1236          $gblFilePerms = "644" ;         // default for new files          $gblFilePerms = 0640 ;         // default for new files
1237          $gblDirPerms  = 0755 ;          // default for new dirs          $gblDirPerms  = 0750 ;          // default for new dirs
1238    
1239          // phpinfo() ;          // phpinfo() ;
1240          // exit ;          // exit ;
1241    
1242          // forks before authentication: style sheet and hash          // forks before authentication: style sheet and hash
1243          // creation if password not yet set.          // creation if password not yet set.
1244          if ($STYLE == "get") { CSS() ; exit ; }          if (isset($STYLE) && $STYLE == "get") { CSS() ; exit ; }
1245          if ($HASH != "") {  
1246                  CreateHash($USER, $PW) ;          $fsScriptDir  = dirname($SCRIPT_FILENAME) ;    
1247                  exit ;          // i.e. /home/httpd/html/docman
1248    
1249            // read user-defined configuration
1250            if (file_exists("$fsScriptDir/.docman.conf")) {
1251                    include("$fsScriptDir/.docman.conf");
1252            }
1253    
1254            // where do we get users from?
1255            if (file_exists("$gblIncDir/$gblUsers.php")) {
1256                    include("$gblIncDir/$gblUsers.php");
1257            } else {
1258                    Error("Configuration error","Can't find user handling module at <tt>$gblIncDir/$gblUsers.php</tt> ! Please fix <tt>$fsScriptDir/.docman.conf</tt>");
1259            }
1260    
1261            // if no password, or empty password logout
1262            if (
1263                    isset($PHP_AUTH_USER) && (
1264                            !isset($relogin) || (
1265                                    isset($relogin) && $relogin != md5($PHP_AUTH_USER.$PHP_AUTH_PW)
1266                            )
1267                    ) && (
1268                            $PHP_AUTH_PW == "" || !isset($PHP_AUTH_PW)
1269                    ) && !isset($force_login)
1270               ) {
1271                    StartHTML("Logout completed","Your login credentials has been erased") ;
1272                    EndHTML() ;
1273                    exit ;
1274          }          }
1275    
1276          // authentication if $gblAuth == true          // authentication failure
1277          if ( $gblAuth &&          if ( md5($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ||
1278               $gblHash($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ) {                  isset($relogin) && $gblPw == $relogin) {
1279                  header("WWW-authenticate: basic realm=\"$SERVER_NAME\"") ;                  $realm="$HTTP_HOST";
1280                    header("WWW-authenticate: basic realm=\"$realm\"") ;
1281                  header("HTTP/1.0 401 Unauthorized") ;                  header("HTTP/1.0 401 Unauthorized") ;
1282                  NoEntry() ;                  NoEntry() ;
1283                  exit ;                  exit ;
# Line 802  the source<BR>of this file.<BR><BR> Line 1289  the source<BR>of this file.<BR><BR>
1289                  $relDir = urldecode($D) ;  // then use GET                  $relDir = urldecode($D) ;  // then use GET
1290          }                }      
1291    
1292            $relDir=stripSlashes($relDir);
1293    
1294          if ($relDir == "/") $relDir = "" ;                if ($relDir == "/") $relDir = "" ;      
1295          // default : website root = ""          // default : website root = ""
1296    
# Line 813  the source<BR>of this file.<BR><BR> Line 1302  the source<BR>of this file.<BR><BR>
1302          // i.e. below $gblFsRoot.          // i.e. below $gblFsRoot.
1303    
1304          $relScriptDir = dirname($SCRIPT_NAME) ;                  $relScriptDir = dirname($SCRIPT_NAME) ;        
1305          // i.e. /siteman          // i.e. /docman
   
         $fsScriptDir  = dirname($SCRIPT_FILENAME) ;      
         // i.e. /home/httpd/html/siteman  
1306    
1307          $gblFsRoot = substr($fsScriptDir,0,          // start on server root
1308            strlen($fsScriptDir)-strlen($relScriptDir)) ;  //      $gblFsRoot = substr($fsScriptDir,0, strlen($fsScriptDir)-strlen($relScriptDir)) ;
1309            // or on script root
1310            $gblFsRoot = $fsScriptDir;
1311          // i.e. /home/httpd/html          // i.e. /home/httpd/html
1312    
1313          $fsDir = $gblFsRoot . $relDir ; // current directory          $fsDir = $gblFsRoot . $relDir ; // current directory
1314          if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ;          if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ;
1315            
1316            if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") {
1317                    $webRoot  = "https://";
1318            } else {
1319                    $webRoot  = "http://";
1320            }
1321            $webRoot .= $GLOBALS["HTTP_HOST"] . $relScriptDir;
1322    
1323            $FN=stripSlashes($FN);
1324    
1325    
1326          switch ($POSTACTION) {          switch ($POSTACTION) {
1327          case "UPLOAD" :          case "UPLOAD" :
1328                  if (!Writeable($fsDir)) Error("Write denied",$relDir) ;                  if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;
1329                  if (strstr($FN_name,"/"))                  if (strstr($FN_name,"/"))
1330                          Error("Non-conforming filename") ;                          Error("Non-conforming filename") ;
1331                  // TODO : should rather check for escapeshellcmds                  // TODO : should rather check for escapeshellcmds
1332                  // but maybe RFC 18xx asserts safe filenames ....                  // but maybe RFC 18xx asserts safe filenames ....
1333                  $source = $FN ;                  $source = $FN ;
1334                  $target = $fsDir . "/" . $FN_name ;                  if (! file_exists($source)) {
1335                  exec("cp $source $target") ;                          Error("You must select file with browse to upload it!");
1336                  exec("chmod $gblFilePerms $target") ;                  }
1337                    if (! isset($FILENAME)) {       // from update file
1338                            $target = "$fsDir/$FN_name" ;
1339                    } else {
1340                            $target = "$fsDir/$FILENAME";
1341                    }
1342    
1343                    // backup old files first
1344                    $dir=dirname($target);
1345                    if (! file_exists($dir."/.bak")) {
1346                            mkdir($dir."/.bak",0700);
1347                    }
1348                    if (! file_exists($dir."/.bak/$GLOBALS[gblNumBackups]")) {
1349                            mkdir($dir."/.bak/$GLOBALS[gblNumBackups]",0700);
1350                    }
1351                    $file=basename($target);
1352                    for($i=$GLOBALS[gblNumBackups]-1;$i>0;$i--) {
1353                            MoveTo("$dir/.bak/$i/$file","$dir/.bak/".($i+1)."/");
1354                    }
1355                    MoveTo($target,$dir."/.bak/1/");
1356    
1357                    copy($source,$target) ;
1358                    chmod($target,$gblFilePerms) ;
1359                  clearstatcache() ;                  clearstatcache() ;
1360                    Logit($target,"uploaded");
1361                    if (isset($FILENAME)) {
1362                            Unlock($target);
1363                    }
1364                    ChangeLog($target,"updated");
1365                  break ;                  break ;
1366    
1367          case "SAVE" :          case "SAVE" :
1368                  $path = $gblFsRoot . escapeshellcmd($RELPATH) ;                  $path = $gblFsRoot . $RELPATH ;
1369                  $writable = Writeable($path) ;                  $path=stripSlashes($path);
1370                  $legaldir = Writeable(dirname($path)) ;                  $writable = is_writeable($path) ;
1371                    $legaldir = is_writeable(dirname($path)) ;
1372                  $exists   = (file_exists($path)) ? 1 : 0 ;                  $exists   = (file_exists($path)) ? 1 : 0 ;
1373  // check for legal extension here as well  // check for legal extension here as well
1374                  if (!($writable || (!$exists && $legaldir)))                  if (!($writable || (!$exists && $legaldir)))
1375                          Error("Write denied",$RELPATH) ;                          Error("Write denied",$RELPATH) ;
1376                  $fh = fopen($path, "w") ;                  $fh = fopen($path, "w") ;
1377                    $FILEDATA=stripSlashes($FILEDATA);
1378                  fwrite($fh,$FILEDATA) ;                  fwrite($fh,$FILEDATA) ;
1379                  fclose($fh) ;                  fclose($fh) ;
1380                  clearstatcache() ;                  clearstatcache() ;
1381                    Logit($path,"saved changes");
1382                    ChangeLog($path,"saved changes");
1383                  break ;                  break ;
1384    
1385          case "CREATE" :          case "CREATE" :
1386                  // we know $fsDir exists                  // we know $fsDir exists
1387                  if (!Writeable($fsDir)) Error("Write denied",$relDir) ;                  if ($FN == "") break;           // no filename!
1388                    if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;
1389                  $path = $fsDir . "/" . $FN ;  // file or dir to create                  $path = $fsDir . "/" . $FN ;  // file or dir to create
1390                  $relPath = $relDir . "/" . $FN ;                  $relPath = $relDir . "/" . $FN ;
1391                  switch ( $T ) {                  switch ( $T ) {
1392                  case "D" :  // create a directory                  case "D" :  // create a directory
1393                    if ( ! @mkdir($path,$gblDirPerms) )                          if ( ! @mkdir($path,$gblDirPerms) )
1394                      Error("Mkdir failed",$relPath) ; // eg. if it exists                                  Error("Mkdir failed",$relPath) ; // eg. if it exists
1395                    clearstatcache() ;                          clearstatcache() ;
1396                    break ;                          break ;
1397                  case "F" :  // create a new file                  case "F" :  // create a new file
1398  // this functionality is doubled in DetailView().  // this functionality is doubled in DetailView().
1399  // better keep it here altogether  // better keep it here altogether
1400  // chmod perms to $gblFilePerms  // chmod perms to $gblFilePerms
1401                    if ( file_exists($path) && !Writable($path) )                          if ( file_exists($path) && !is_writeable($path) )
1402                      Error("File not writable", $relPath) ;                                  Error("File not writable", $relPath) ;
1403                    $tstr = $PHP_SELF . "?A=E&D=" . $relDir . "&F=" . $FN ;                          $fh = fopen($path, "w+") ;
1404                    header("Location: " . $tstr) ;                          if ($fh) {
1405                    exit ;                                  fputs($fh,"\n");
1406                                    fclose($fh) ;
1407                                    LogIt($path,"file created");
1408                            } else {
1409                                    Error("Creation of file $relPath failed -- $path");
1410                            }
1411                            $tstr = "$PHP_SELF?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ;
1412                            header("Location: " . $tstr) ;
1413                            ChangeLog($target,"created");
1414                            exit ;
1415                  }                  }
1416                  break ;                  break ;
1417    
# Line 883  the source<BR>of this file.<BR><BR> Line 1422  the source<BR>of this file.<BR><BR>
1422                  $tstr .= "insufficient privileges: " ;                  $tstr .= "insufficient privileges: " ;
1423    
1424                  if ( $FN != "") {  // delete file                  if ( $FN != "") {  // delete file
1425                    $path =  $fsDir . "/" . $FN ;                          $path =  $fsDir . "/" . $FN ;
1426                    if ( ! @unlink($path) ) {                  
1427                      Error("File delete failed", $tstr . $path) ;                          $dir=dirname($path);
1428                      exit ;                          $file=basename($path);
1429                    }                                              if (! file_exists("$dir/.del")) {
1430                                    mkdir("$dir/.del",0700);
1431                            }
1432    
1433    //                      if ( ! @unlink($path) ) {
1434                            if ( ! rename($path,"$dir/.del/$file") ) {
1435                                    Error("File delete failed", $tstr . $path) ;
1436                                    Logit($path,"file delete failed");
1437                                    exit ;
1438                            } else {
1439                                    Logit($path,"file deleted");
1440                                    MoveTo("$dir/.log/$file","$dir/.del/.log/");
1441                                    MoveTo("$dir/.note/$file","$dir/.del/.note/");
1442                                    MoveTo("$dir/.lock/$file","$dir/.del/.lock/");
1443                            }
1444                  }                  }
1445                  else {  // delete directory                  else {  // delete directory
1446                    if ( ! @rmdir($fsDir) ) {                    if ( ! @rrmdir($fsDir) ) {
1447                      Error("Rmdir failed", $tstr . $fsDir) ;                      Error("Rmdir failed", $tstr . $fsDir) ;
1448                    }                    }
1449                    else {                    else {
# Line 899  the source<BR>of this file.<BR><BR> Line 1452  the source<BR>of this file.<BR><BR>
1452                  }                  }
1453                  break ;                  break ;
1454    
1455            case "UNDELETE" :  
1456                    if ( $CONFIRM != "on" ) break ;
1457    
1458                    if (substr($FN,0,4) != ".del") break ;
1459                    $file=substr($FN,4,strlen($FN)-4);
1460    
1461                    Logit("$fsDir/.del/$file","undeleted");
1462                    MoveTo("$fsDir/.del/$file","$fsDir/");
1463                    MoveTo("$fsDir/.del/.log/$file","$fsDir/.log/");
1464                    MoveTo("$fsDir/.del/.note/$file","$fsDir/.note/");
1465                    MoveTo("$fsDir/.del/.lock/$file","$fsDir/.lock/");
1466    
1467                    break ;
1468    
1469            case "RENAME" :  
1470                    if ( $CONFIRM != "on" ) break ;
1471    
1472                    Logit("$fsDir/$FN","renamed $FN to $NEWNAME");
1473                    safe_rename($fsDir,$FN,$NEWNAME);
1474                    break ;
1475    
1476            case "NOTE" :  
1477                    WriteNote("$fsDir/$FN","$NOTE");
1478                    break ;
1479    
1480            case "UNLOCK" :  
1481                    if ( $CONFIRM != "on" ) break ;
1482                    Unlock("$fsDir/$FN");
1483                    break ;
1484    
1485          default :          default :
1486                  // user hit "CANCEL" or undefined action                  // user hit "CANCEL" or undefined action
1487          }          }
# Line 914  the source<BR>of this file.<BR><BR> Line 1497  the source<BR>of this file.<BR><BR>
1497          // $A=U : upload to path given in $D          // $A=U : upload to path given in $D
1498          // $A=E : display detail of file $D/$F and edit          // $A=E : display detail of file $D/$F and edit
1499          // $A=C : display code in file $D/$F          // $A=C : display code in file $D/$F
1500            // $A=Co : checkout file $D/$F
1501            // $A=Ci : checkin file $D/$F
1502            // $A=V : view file (do nothing except log)
1503            // $A=I : include file .$F.php from $gblFsRoot
1504          // default : display directory $D          // default : display directory $D
1505            
1506          switch ($A) {          switch ($A) {
1507          case "U" :          case "U" :
1508                  // upload to $relDir                  // upload to $relDir
1509                  if (!Writeable($gblFsRoot . $relDir))                  if (!is_writeable($gblFsRoot . $relDir))
1510                          Error("Write access denied",$relDir) ;                          Error("Write access denied",$relDir) ;
1511                  $text  = "Use this page to upload a single " ;                  $text  = "Use this page to upload a single " ;
1512                  $text .= "file to <B>$SERVER_NAME</B>." ;                  $text .= "file to <B>$HTTP_HOST</B>." ;
1513                  StartHTML("(Upload Page)", $text) ;                  StartHTML("(Upload Page)", $text) ;
1514                  UploadPage($gblFsRoot, $relDir) ;                  UploadPage($gblFsRoot, $relDir) ;
1515                  EndHTML() ;                  EndHTML() ;
1516                  exit ;                  exit ;
1517          case "E" :          case "E" :
1518                    $F=stripSlashes($F);
1519                  // detail of $relDir/$F                  // detail of $relDir/$F
1520                  DetailPage($gblFsRoot, $relDir, $F) ;                  if (is_file("$gblFsRoot/$relDir/$F") || is_dir("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ;
1521                  exit ;                  exit ;
1522          case "C" :          case "C" :
1523                    $F=stripSlashes($F);
1524                  // listing of $relDir/$F                  // listing of $relDir/$F
1525                  DisplayCode($gblFsRoot, $relDir, $F) ;                  DisplayCode($gblFsRoot, $relDir, $F) ;
1526                  exit ;                  exit ;
1527            case "Co" :
1528                    // checkout
1529                    Lock("$gblFsRoot/$relDir/$F");
1530                    Download("$gblFsRoot/$relDir/$F");
1531                    exit;
1532            case "Ci" :
1533                    $F=stripSlashes($F);
1534                    // upload && update to $relDir
1535                    if (!is_writeable($gblFsRoot . $relDir))
1536                            Error("Write access denied",$relDir) ;
1537                    $text  = "Use this page to update a single " ;
1538                    $text .= "file to <B>$HTTP_HOST</B>." ;
1539                    StartHTML("(Update file Page)", $text) ;
1540                    UploadPage($gblFsRoot, $relDir, $F) ;
1541                    EndHTML() ;
1542                    exit ;
1543            case "V" :
1544                    // view
1545                    LogIt("$gblFsRoot/$relDir/$F","viewed");
1546                    if ($gblForceDownload) {
1547                            Download("$gblFsRoot/$relDir/$F");
1548                    } else {
1549                            header("Content-Disposition: attachment; filename=$F" );
1550                            Header("Location: $webRoot".urlpath("$relDir/$F"));
1551                    }
1552                    exit;
1553            case "Ch" :
1554                    StartHTML("(File changes)","All changes chronologicaly...");
1555                    DisplayChangeLog(0);    // all
1556                    EndHTML() ;
1557                    exit;
1558            case "Ch1" :
1559                    StartHTML("(File changes)","Changes to files in last day...");
1560                    DisplayChangeLog(1);
1561                    EndHTML() ;
1562                    exit;
1563            case "I" :
1564                    $F=stripSlashes($F);
1565                    $inc_file="${gblFsRoot}/.${F}.php";
1566                    if (!isset($F) || $F == "" || !file_exists($inc_file)) Error("Fatal error $inc_file"); // can't find file to include
1567                    if (!is_readable($inc_file))
1568                            Error("Read access to include file denied",".${F}.php");
1569                    $text  = "Your include file should define \$text variable which holds this text and \$title variable which is page title";
1570                    $title = "You should define \$title variable with page title";
1571                    include($inc_file);
1572                    StartHTML($title, $text) ;
1573                    print "<p>".GifIcon(up)." Back to <a href=$GLOBALS[PHP_SELF]>front page</a>.</p>";
1574                    EndHTML() ;
1575                    exit ;
1576          }          }
1577    
1578          // default: display directory $relDir          // default: display directory $relDir

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

  ViewVC Help
Powered by ViewVC 1.1.26