/[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.3 by dpavlin, Thu Aug 3 19:35:44 2000 UTC revision 1.26 by dpavlin, Thu Dec 21 08:25:06 2000 UTC
# Line 35  Line 35 
35  /*             existent address after file modifications.       */  /*             existent address after file modifications.       */
36    
37  /*  /*
         2000-07-25 Dobrica Pavlinusic <dpavlin@rot13.org>  
38    
39          nuked exec calls (unsecure)          This project is now called Directory Manager.
         nuked writeable function (replaced by php is_writeable)  
         added support for https (tested with apache+mod_ssl)  
         added users file  
         date format user-selectable  
         cycle backup files in bak directory  
         support links as directoryes (for now)  
         support of file history logging  
         undelete capabilities (delete moves to .del directory)  
40    
41          2000-07-26 DbP          For more info, please see web pages at
42            http://www.rot13.org/~dpavlin/docman.html
43    
44          added more checking on entered filename (when creating file/dir)          It's relased under GPL by
45          added rename option          Dobrica Pavlinusic <dpavlin@rot13.org>
46    
47    
48  IMPORTANT INSTALLATION NOTE:  IMPORTANT INSTALLATION NOTE:
# Line 65  IMPORTANT INSTALLATION NOTE: Line 57  IMPORTANT INSTALLATION NOTE:
57  TODO:  TODO:
58          mixed file/directory output (add type to each entry,          mixed file/directory output (add type to each entry,
59                  real support for links)                  real support for links)
60          add more content-management (like cms.sourceforge.net):          access controll
61                  check-out/check-in/reserve  
                 comments to files  
62  */  */
63    
64  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
# Line 80  TODO: Line 71  TODO:
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    
# Line 108  TODO: Line 99  TODO:
99                          if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) {                          if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) {
100                                  $gblUserName=$user[1];                                  $gblUserName=$user[1];
101                                  $gblPw=$user[2];                                  $gblPw=$user[2];
102                                    $gblEmail=$user[3];
103                                  continue ;                                  continue ;
104                          }                          }
105                  }                  }
# Line 120  TODO: Line 112  TODO:
112          $gblDateFmt="Y-m-d";          $gblDateFmt="Y-m-d";
113          $gblTimeFmt="H:i:s";          $gblTimeFmt="H:i:s";
114    
115  // Number of backup files to keep          // Number of backup files to keep
116          $gblNumBackups=5;          $gblNumBackups=3;
117    
118            // show red star if newer than ... days
119            $gblModDays=1;
120    
121          // choose GifIcon below unless you have the M$          // choose GifIcon below unless you have the M$
122          // WingDings font installed on your system          // WingDings font installed on your system
# Line 157  function StartHTML($title,$text="") { Line 152  function StartHTML($title,$text="") {
152    
153  <HTML>  <HTML>
154  <HEAD>  <HEAD>
155   <TITLE><?php echo $host . " " . $title ?></TITLE>   <TITLE><?= $host . " " . $title ?></TITLE>
156   <META NAME="description" CONTENT="PHP port of AnyPortal Site Manager">   <META NAME="description" CONTENT="PHP port of AnyPortal Site Manager">
157   <META NAME="keywords" CONTENT="site manager, web site maintenance">   <META NAME="keywords" CONTENT="site manager, web site maintenance">
158   <META NAME="robots" CONTENT="noindex">   <META NAME="robots" CONTENT="noindex">
159   <META HTTP-EQUIV="expires" CONTENT="0">   <META HTTP-EQUIV="expires" CONTENT="0">
160   <LINK REL="stylesheet" TYPE="text/css"   <LINK REL="stylesheet" TYPE="text/css"
161          HREF="<?php echo $self ?>?STYLE=get">          HREF="<?= $self ?>?STYLE=get">
162  </HEAD>  </HEAD>
163  <BODY BGCOLOR="#FFFFFF">  <BODY BGCOLOR="#FFFFFF">
164   <H3 ALIGN="RIGHT"><?php echo $host ?></H3>   <H3 ALIGN="RIGHT"><?= $host ?></H3>
165  <TABLE BORDER=0 WIDTH="100%"><TR>  <TABLE BORDER=0 WIDTH="100%"><TR>
166   <TD CLASS=INV><?php echo $title ?></TD></TR></TABLE>   <TD CLASS=INV><?= $title ?></TD></TR></TABLE>
167   <P><?php echo $text ?></P>   <P><?= $text ?></P>
168    
169  <?php  <?php
170  } // end function StartHTML  } // end function StartHTML
# Line 184  function EndHTML() { Line 179  function EndHTML() {
179  <B><?= date($GLOBALS[gblDateFmt]) ?> -  <B><?= date($GLOBALS[gblDateFmt]) ?> -
180  <?= date($GLOBALS[gblTimeFmt]) ?> -  <?= date($GLOBALS[gblTimeFmt]) ?> -
181  <?= $GLOBALS[gblUserName] ?>  <?= $GLOBALS[gblUserName] ?>
182  <small> [<a href="<?= $PHP_SELF ?>?relogin=<?= $GLOBALS[gblPw] ?>">logout</a>]</small>  <small> [<a href="<?= $GLOBALS["PHP_SELF"] ?>?relogin=<?= $GLOBALS[gblPw] ?>">logout</a>]</small>
183  </B>  </B>
184  <BR>ANYPORTAL(php) Site Manager  <BR>ANYPORTAL(php) Site Manager
185  <br><small>  <br><small>
# Line 194  function EndHTML() { Line 189  function EndHTML() {
189  </small>  </small>
190  </P>  </P>
191  <BR>  <BR>
192  <? //include("../debug.inc") ?>  <? //include(".debug.inc") ?>
193  <BR><BR></BODY></HTML>  <BR><BR></BODY></HTML>
194    
195  <?php  <?php
# Line 240  function DetailPage($fsRoot,$relDir,$fn) Line 235  function DetailPage($fsRoot,$relDir,$fn)
235          $ext      = strtolower(strrchr($relPath,".")) ;          $ext      = strtolower(strrchr($relPath,".")) ;
236          $editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) ;          $editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) ;
237          $writable = is_writeable($fsPath) ;          $writable = is_writeable($fsPath) ;
238            $file_lock = CheckLock($fsPath);
239    
240          if (!$editable && !$exists)          if (!$editable && !$exists)
241                  Error("Creation unsupported for type",$relPath) ;                  Error("Creation unsupported for type",$relPath) ;
# Line 254  function DetailPage($fsRoot,$relDir,$fn) Line 250  function DetailPage($fsRoot,$relDir,$fn)
250    
251          echo "<H3>" . $relDir . "/" . $fn . "</H3>" ;          echo "<H3>" . $relDir . "/" . $fn . "</H3>" ;
252          if ($exists) {  // get file info          if ($exists) {  // get file info
253            $fsize = filesize($fsPath) ;                  $fsize = filesize($fsPath) ;
254            $fmodified = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", filemtime($fsPath)) ;                  $fmodified = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", filemtime($fsPath)) ;
255            $faccessed = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", fileatime($fsPath)) ;                  $faccessed = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", fileatime($fsPath)) ;
256            echo "<PRE>    file size: " . $fsize . " Bytes<BR>" ;                  echo "<PRE>    file size: " . $fsize . " Bytes<BR>" ;
257            echo "last modified: <B>" . $fmodified . "</B><BR>" ;                  echo "last modified: <B>" . $fmodified . "</B><BR>" ;
258            echo "last accessed: <B>" . $faccessed . "</B><BR>" ;                  echo "last accessed: <B>" . $faccessed . "</B><BR>" ;
259            echo "        owner: <B>" . fileowner($fsPath) . "</B><BR>" ;                  echo "        owner: <B>" . fileowner($fsPath) . "</B><BR>" ;
260            echo "        group: <B>" . filegroup($fsPath) . "</B><BR>" ;                  echo "        group: <B>" . filegroup($fsPath) . "</B><BR>" ;
261            echo "  permissions: <B>" ;                  echo "  permissions: <B>" ;
262            echo printf( "%o", fileperms($fsPath) ) . "</B>" ;                  echo printf( "%o", fileperms($fsPath) ) . "</B>" ;
263            echo "</PRE>" ;                  echo "</PRE>" ;
264    
265          }          }
266    
267          if ( $editable && ($writable || !$exists) ) {          if ( $editable && ($writable || !$exists) && !$file_lock ) {
268                  $fh = fopen($fsPath,"a+") ;                  $fh = fopen($fsPath,"a+") ;
269                  rewind($fh) ;                  rewind($fh) ;
270                  $fstr = fread($fh,filesize($fsPath)) ;                  $fstr = fread($fh,filesize($fsPath)) ;
# Line 276  function DetailPage($fsRoot,$relDir,$fn) Line 272  function DetailPage($fsRoot,$relDir,$fn)
272                  $fstr = htmlentities( $fstr ) ;                  $fstr = htmlentities( $fstr ) ;
273  ?>  ?>
274    
275  <FORM ACTION="<?php echo $self ; ?>" METHOD="POST">  <FORM ACTION="<?= $self ; ?>" METHOD="POST">
276  <SPAN TITLE="Click [SAVE] to store updated contents.">  <SPAN TITLE="Click [SAVE] to store updated contents.">
277          <B>DOCUMENT CONTENTS</B>          <B>DOCUMENT CONTENTS</B>
278  </SPAN><BR>  </SPAN><BR>
279  <TEXTAREA NAME="FILEDATA" ROWS=18 COLS=70 WRAP="OFF"><?php  <TEXTAREA NAME="FILEDATA" ROWS=18 COLS=70 WRAP="OFF"><?php
280  echo($fstr) ; ?></TEXTAREA>  echo($fstr) ; ?></TEXTAREA>
281  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ; ?>">  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ; ?>">
282  <INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?php echo $fn ; ?>">  <INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?= $fn ; ?>">
283  <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="SAVE">  <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="SAVE">
284  <INPUT TYPE="HIDDEN" SIZE=48 MAXLENGTH=255 NAME="RELPATH"  <INPUT TYPE="HIDDEN" SIZE=48 MAXLENGTH=255 NAME="RELPATH"
285          VALUE="<?php echo $relPath ; ?>">          VALUE="<?= $relPath ; ?>">
286  <br>  <br>
287  <INPUT TYPE="RESET" VALUE="UNDO ALL CHANGES">  <INPUT TYPE="RESET" VALUE="UNDO ALL CHANGES">
288  <INPUT TYPE="SUBMIT" VALUE="SAVE">  <INPUT TYPE="SUBMIT" VALUE="SAVE">
# Line 294  echo($fstr) ; ?></TEXTAREA> Line 290  echo($fstr) ; ?></TEXTAREA>
290    
291  <?php  <?php
292          }          }
293          else if ( strstr( join(" ",$gblImages), $ext ) ) {            if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) {  
294            $info  = getimagesize($fsPath) ;                  $info  = getimagesize($fsPath) ;
295            $tstr  = "<IMG SRC=\"". $relPath . "\" BORDER=0 " ;                  $tstr = "<IMG SRC=\"".urlpath($relPath)."\" BORDER=0 " ;
296            $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;                  $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;
297            $tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ;                  $tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ;
298            echo htmlentities($tstr) . "<BR><BR>" . $tstr ;  //              echo htmlentities($tstr) . "<BR><BR>" . $tstr ;
299                    echo $tstr ;
300          }          }
301    
302  ?>  ?>
303    
304  <FORM ACTION="<?php echo $self ; ?>" METHOD="POST">  <FORM ACTION="<?= $self ; ?>" METHOD="POST">
305  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ; ?>">  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ; ?>">
306  <INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?php echo $fn ; ?>">  <INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?= $fn ; ?>">
307  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR>  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR>
308    
309  <?php  <?php
310    
311            if ($file_lock) {
312    ?>
313    <hr>
314    <SPAN TITLE="Check OK and click UNLOCK to remove lock on file.">
315    <B>OK TO FORCE LOCK REMOVAL ON "<?= $fn ; ?>" HELD BY <?= $file_lock ?>? </B></SPAN>
316    <INPUT TYPE="CHECKBOX" NAME="CONFIRM">
317    <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="UNLOCK">
318    <?
319            } // file_lock
320    
321          if (substr($fn,0,4) == ".del") {          if (substr($fn,0,4) == ".del") {
322                  $action="UNDELETE";                  $action="UNDELETE";
323                  $desc="undelete previously deleted file";                  $desc="undelete previously deleted file";
# Line 320  echo($fstr) ; ?></TEXTAREA> Line 329  echo($fstr) ; ?></TEXTAREA>
329          if ($exists && $writable) {          if ($exists && $writable) {
330  ?>  ?>
331    
332  <HR><SPAN TITLE="Check OK and click [<?= $action ?>] to <?= $desc ?>.">  <HR>
333  <B>OK TO <?= $action ?> "<?php echo $fn ; ?>"? </B></SPAN>  <a name="undelete">
334    <SPAN TITLE="Check OK and click [<?= $action ?>] to <?= $desc ?>.">
335    <B>OK TO <?= $action ?> "<?= $fn ; ?>"? </B></SPAN>
336  <INPUT TYPE="CHECKBOX" NAME="CONFIRM">  <INPUT TYPE="CHECKBOX" NAME="CONFIRM">
337  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="<?= $action ?>">  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="<?= $action ?>">
338    
339  <HR><SPAN TITLE="Check OK and click [RENAME] to rename.">  <HR>
340  <B>OK TO RENAME "<?php echo $fn ; ?>" TO  <a name="rename">
341    <SPAN TITLE="Check OK and click [RENAME] to rename.">
342    <B>OK TO RENAME "<?= $fn ; ?>" TO
343  <INPUT TYPE="TEXT" SIZE=24 MAXLENGTH=255 NAME="NEWNAME" VALUE="<?= $fn ?>">  <INPUT TYPE="TEXT" SIZE=24 MAXLENGTH=255 NAME="NEWNAME" VALUE="<?= $fn ?>">
344  ? </B></SPAN>  ? </B></SPAN>
345  <INPUT TYPE="CHECKBOX" NAME="CONFIRM">  <INPUT TYPE="CHECKBOX" NAME="CONFIRM">
346  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="RENAME">  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="RENAME">
347    
348  <?php  <?php
349          }          }       // exists && writable
350          echo "</FORM>" ;  ?>
351    <HR>
352    <a name="note">
353    <B>NOTE FOR "<?= $fn ; ?>":
354    <INPUT TYPE="TEXT" SIZE=50 MAXLENGTH=255 NAME="NOTE" VALUE="<?= ReadNote($fsPath) ?>">
355    </B></SPAN>
356    <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="NOTE">
357    
358    </FORM>
359    
360    <?php
361    
362          $logname=dirname("$fsDir/$fn")."/.log/".basename("$fsDir/$fn");          $name=basename("$fsDir/$fn");
363            $logname=dirname("$fsDir/$fn")."/.log/$name";
364            $bakdir=dirname("$fsDir/$fn")."/.bak";
365          if (file_exists($logname)) {          if (file_exists($logname)) {
                 print "<hr><br><b>CHANGES TO THIS FILE</b><br><table border=0 width=100%>\n";  
366                  $log=fopen($logname,"r");                  $log=fopen($logname,"r");
367                  $cl1=" class=lst"; $cl2="";                  $cl1=" class=lst"; $cl2="";
368                    $logarr = array();
369                  while($line = fgetcsv($log,255,"\t")) {                  while($line = fgetcsv($log,255,"\t")) {
370                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;
371                          print "<tr><td$cl>$line[0]</td><td$cl>$line[1]</td><td$cl>$line[2]</td><td$cl>$line[3]</td></tr>\n";                          array_unshift($logarr,array($cl,$line[0],$line[1],$line[2],$line[3]));
372                  }                  }
373                  fclose($log);                  fclose($log);
374                    print "<hr><br><b>CHANGES TO THIS FILE</b><br><table border=0 width=100%>\n";
375                    $bakcount = 0;  // start from 0, skip fist backup (it's current)
376                    while ($e = array_shift($logarr)) {
377                            if (strstr($e[4],"upload")) {
378                                    if (file_exists("$bakdir/$bakcount/$name")) {
379                                            $e[4]="<a href=\"".dirname($relPath)."/.bak/$bakcount/$name\">$e[4]</a>";
380                                    }
381                                    $bakcount++;
382                            }
383                            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";
384                    }
385                  print "</table>";                  print "</table>";
386          }          }
387    
# Line 578  function GifIcon($txt) { Line 614  function GifIcon($txt) {
614          case "blank" :          case "blank" :
615                  $d = "blank.gif" ;                  $d = "blank.gif" ;
616                  break ;                  break ;
617            case "checkout":
618                    $d = "box2.gif";
619                    break;
620            case "checkin":
621                    $d = "hand.up.gif";
622                    break;
623            case "locked":
624                    $d = "screw2.gif";
625                    break;
626            case "note":
627                    $d = "quill.gif";
628                    break;
629          default :          default :
630                  $d = "generic.gif" ;                  $d = "generic.gif" ;
631          }          }
# Line 589  function GifIcon($txt) { Line 637  function GifIcon($txt) {
637    
638  function Navigate($fsRoot,$relDir) {  function Navigate($fsRoot,$relDir) {
639    
640          global $gblEditable, $gblIcon ;          global $gblEditable, $gblIcon, $gblModDays ;
641    
642          $self     = $GLOBALS["PHP_SELF"] ;          $self     = $GLOBALS["PHP_SELF"] ;
643          if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") {          if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") {
644                  $webRoot  = "https://" . $GLOBALS["SERVER_NAME"] ;                  $webRoot  = "https://" . $GLOBALS["HTTP_HOST"] ;
645          } else {          } else {
646                  $webRoot  = "http://" . $GLOBALS["SERVER_NAME"] ;                  $webRoot  = "http://" . $GLOBALS["HTTP_HOST"] ;
647          }          }
648          $fsDir    = $fsRoot . $relDir . "/" ; // current directory          $fsDir    = $fsRoot . $relDir . "/" ; // current directory
649    
# Line 635  function Navigate($fsRoot,$relDir) { Line 683  function Navigate($fsRoot,$relDir) {
683          // start navigation page          // start navigation page
684          $text  = "Use this page to add, delete";          $text  = "Use this page to add, delete";
685          if (! isset($show_deleted)) {          if (! isset($show_deleted)) {
686                  $text .= ", <a href=".$GLOBALS[PHP_SELF]."?D=".urlencode($relDir)."&show_deleted=1>undelete</a>";                  $text .= ", <a href=$self?D=".urlencode($relDir)."&show_deleted=1>undelete</a>";
687          }          }
688          $text .= " or revise files on this web site." ;          $text .= " or revise files on this web site." ;
689            $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>.";
690          StartHTML("(Navigate)",$text) ;          StartHTML("(Navigate)",$text) ;
691    
692          echo "<TABLE BORDER=0 CELLPADDING=2          echo "<TABLE BORDER=0 CELLPADDING=2
# Line 649  function Navigate($fsRoot,$relDir) { Line 698  function Navigate($fsRoot,$relDir) {
698                  if ($parent == "") $parent = "/" ;                  if ($parent == "") $parent = "/" ;
699  ?>  ?>
700    
701  <TR><TD><?php echo $gblIcon("up") ?></TD><TD COLSPAN=4 CLASS=LST>  <TR><TD><?= $gblIcon("up") ?></TD><TD COLSPAN=5 CLASS=LST>
702  <A HREF="<?php echo $self ?>?D=<?php echo urlencode($parent) ?>">  <A HREF="<?= $self ?>?D=<?= urlencode($parent) ?>">
703  <B><?php echo $parent ?></B></A></TD></TR>  <B><?= $parent ?></B></A></TD></TR>
704    
705  <?php  <?php
706          }          }
# Line 661  function Navigate($fsRoot,$relDir) { Line 710  function Navigate($fsRoot,$relDir) {
710                  sort($dirList) ;                  sort($dirList) ;
711  ?>  ?>
712    
713  <TR><TD></TD><TD COLSPAN=4 CLASS=TOP><HR>DIRECTORY NAME</TD></TR>  <TR><TD></TD><TD COLSPAN=5 CLASS=TOP><HR>DIRECTORY NAME</TD></TR>
714    
715  <?php  <?php
716                  while (list($key,$dir) = each($dirList)) {                  while (list($key,$dir) = each($dirList)) {
# Line 671  function Navigate($fsRoot,$relDir) { Line 720  function Navigate($fsRoot,$relDir) {
720                          $tstr .= "\">" . $dir . "/</A>" ;                          $tstr .= "\">" . $dir . "/</A>" ;
721  ?>  ?>
722    
723  <TR><TD><?php echo $gblIcon("fldr") ?></TD>  <TR><TD><?= $gblIcon("fldr") ?></TD>
724  <TD COLSPAN=4 CLASS=LST><?php echo $tstr ?></TD></TR>  <TD COLSPAN=5 CLASS=LST><?= $tstr ?></TD></TR>
725    
726  <?php  <?php
727                  }  // iterate over dirs                  }  // iterate over dirs
728          }  // end if no dirs          }  // end if no dirs
729  ?>  ?>
730    
731  <TR><TD></TD><TD COLSPAN=4><HR><B><?php echo $webRoot . $relDir ?>  <TR><TD></TD><TD COLSPAN=5><HR><B><?= $webRoot . $relDir ?>
732  </B></TD></TR>  </B></TD></TR>
733  <TR><TD></TD><TD CLASS=TOP>DOCUMENT NAME</TD>  <TR><TD></TD><TD CLASS=TOP>DOCUMENT NAME</TD>
734  <TD><?php echo $gblIcon("blank") ?></TD>  <TD><?= $gblIcon("blank").$gblIcon("blank") ?></TD>
735    <TD CLASS=TOP>NOTE</TD>
736  <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>
737    
738  <?php  <?php
739          if (sizeof($fileList) > 0) {          if (sizeof($fileList) > 0) {
740            sort($fileList) ;            sort($fileList) ;
741            while (list($key,$file) = each($fileList)) {              while (list($key,$file) = each($fileList)) {  
742              $path = $fsDir."/".$file ;                  $path = $fsDir."/".$file ;
743              $mod  = filemtime($path) ;                  $mod  = filemtime($path) ;
744              $sz   = filesize($path) ;                  $sz   = filesize($path) ;
   
             if ($sz >= 10240) {  
               $sz = (int)(($sz+1023)/1024) . " k" ;  
             }  
             else {  
               $sz .= " " ;  
             } // end size  
   
             $a = $b = "" ;  
   
             if ( ($mod + 30*86400) > time() ) {  
               $a  = "<SPAN CLASS=RED TITLE=\"Newer" ;  
               $a .= " than 30 days\"> * </SPAN>" ;  
             }  
745    
746              $tstr = $webRoot . $relDir . "/" . $file ;                  if ($sz >= 10240) {
747              $tstr  = "<A HREF=\"" . $tstr . "\">" ;                          $sz = (int)(($sz+1023)/1024) . " k" ;
748                    } else {
749                            $sz .= " " ;
750                    } // end size
751    
752                    $a = $b = "" ;
753    
754                    $info_url=$self."?A=E&F=".urlencode($file)."&D=".urlencode($relDir);
755    
756                    if ( ($mod + $gblModDays*86400) > time() ) {
757                            $a  = "<SPAN CLASS=RED TITLE=\"Newer" ;
758                            $a .= " than $gblModDays days\"> * </SPAN>" ;
759                    }
760    
761                    $file_lock=CheckLock($path);
762    
763                    $file_url_html="<A HREF=\"$self?A=V&F=".urlencode($file);
764                    $file_url_html.="&D=".urlencode($relDir);
765                    $file_url_html.="\" TITLE=\"View file\">" ;
766    
767                  if (substr($file,0,5) != ".del/") {                  if (substr($file,0,5) != ".del/") {
768                          $tstr .= $file . "</A>" . $a ;                          $file_url_html .= $file . "</A>" . $a ;
769                    } else {
770                            $file_url_html .= substr($file,5,strlen($file)-5) . "</a> <SPAN CLASS=RED TITLE=\"deleted\"> <a href=\"$info_url#undelete\">deleted</a> </span>";
771                    }
772    
773                    $note_html="<a href=\"$info_url#note\">".$gblIcon("note")."</a>".ReadNote($path);
774    
775                    $ext = strtolower(strrchr($file,".")) ;
776    
777                    if ($file_lock) {
778                            if ($file_lock == $GLOBALS[gblUserName]) {
779                                    $b.="<A HREF=\"$self?A=Ci&F=".urlencode($file);
780                                    $b.="&D=".urlencode($relDir);
781                                    $b.="\" TITLE=\"Checkin (update) file on server\">" ;
782                                    $file_url_html=$b;
783                                    $b.=$gblIcon("checkin")."</A>" ;
784                                    $b.= $gblIcon("blank");
785                                    $file_url_html.="$file</a> $a";
786                                    $note_html = $gblIcon("blank")."<b>Please check-in (update) this file</b>";
787                            } else {
788                                    $b = $gblIcon("locked");
789                                    $b.= $gblIcon("blank");
790                                    $note_html = $gblIcon("blank")."<b>File locked by $file_lock</b>";
791                                    $file_url_html = "$file $a";
792                            }
793                  } else {                  } else {
794                          $tstr .= substr($file,5,strlen($file)-5) . "</a> <SPAN CLASS=RED TITLE=\"deleted\"> deleted </span>";                          $b.="<A HREF=\"$self?A=Co&F=".urlencode($file);
795                            $b.="&D=".urlencode($relDir);
796                            $b.="\" TITLE=\"Checkout file for edit\">" ;
797                            $b.=$gblIcon("checkout")."</A>" ;
798    
799                            if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) {  
800                                    $b.="<A HREF=\"$self?A=C&F=".urlencode($file);
801                                    $b.="&D=".urlencode($relDir);
802                                    $b.="\" TITLE=\"List contents\">" ;
803                                    $b.=$gblIcon("view")."</A>" ;
804                            } else {
805                                    $b.= $gblIcon("blank");
806                            }
807                  }                  }
808    
             $ext = strtolower(strrchr($file,".")) ;  
             if ( $ext=="" ||  
                  strstr(join(" ",$gblEditable),$ext) )  
             {    
               $b  = "<A HREF=\"" . $self . "?A=C&F=" ;  
               $b .= urlencode($file) . "&D=" . urlencode($relDir) ;  
               $b .= "\" TITLE=\"List contents\">" ;  
               $b .= $gblIcon("view") . "</A>" ;  
             }  
809    
810  ?>  ?>
811    
812  <TR><TD>  <TR><TD>
813  <A HREF="<?php echo $self ?>?A=E&F=<?php echo urlencode($file)  <A HREF="<?= $info_url ?>" TITLE="View/Edit">
814  ?>&D=<?php echo urlencode($relDir) ?>" TITLE="View/Edit">  <?= $gblIcon($ext) ?></A></TD>
815  <?php echo $gblIcon($ext) ?></A></TD>  <TD CLASS=LST><?= $file_url_html ?></TD>
816  <TD CLASS=LST><?php echo $tstr ?></TD>  <TD CLASS=LST ALIGN=center><?= $b ?></TD>
817  <TD CLASS=LST ALIGN=center><?php echo $b ?></TD>  <TD CLASS=LST ALIGN=left><?= $note_html ?></TD>
818  <TD CLASS=LST><?php echo date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]",$mod) ?></TD>  <TD CLASS=LST><?= date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]",$mod) ?></TD>
819  <TD CLASS=LST><?php echo $sz ?>Bytes</TD></TR>  <TD CLASS=LST><?= $sz ?>Bytes</TD></TR>
820    
821  <?php  <?php
822            }  // iterate over files            }  // iterate over files
823          }  // end if no files          } else {  // end if no files
824    ?>
825     <TR><TD></TD><TD COLSPAN=5 CLASS=LST>
826      No files in this directory
827     </TD></TR>
828    <?
829            }
830    
831          if ($emptyDir) {          if ($emptyDir) {
832  ?>  ?>
833    
834  <FORM METHOD="POST" ACTION="<?php echo $self ?>">  <FORM METHOD="POST" ACTION="<?= $self ?>">
835   <TR><TD></TD><TD COLSPAN=4 CLASS=BAR>   <TR><TD></TD><TD COLSPAN=5 CLASS=BAR>
836    <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ?>">    <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">
837    OK TO DELETE THIS EMPTY FOLDER?    OK TO DELETE THIS EMPTY FOLDER?
838    <INPUT TYPE="CHECKBOX" NAME="CONFIRM">    <INPUT TYPE="CHECKBOX" NAME="CONFIRM">
839    <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="DELETE">    <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="DELETE">
# Line 757  function Navigate($fsRoot,$relDir) { Line 844  function Navigate($fsRoot,$relDir) {
844          } // end if emptyDir          } // end if emptyDir
845  ?>  ?>
846    
847  <TR><TD></TD><TD COLSPAN=4><HR></TD></TR>  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>
848    
849  <FORM METHOD="POST" ACTION="<?php echo $self ?>">  <?
850  <TR><TD></TD><TD COLSPAN=4 CLASS=BAR>CREATE NEW  if (file_exists(".info.inc")) {
851            print "<TR><TD></TD><TD COLSPAN=5>";
852            include(".info.inc");
853            print "</TD></TR>
854            <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>";
855    }
856    ?>
857    
858    <FORM METHOD="POST" ACTION="<?= $self ?>">
859    <TR><TD></TD><TD COLSPAN=5 CLASS=BAR>CREATE NEW
860   <INPUT TYPE="RADIO" NAME="T" VALUE="D" CHECKED>DIRECTORY -OR-   <INPUT TYPE="RADIO" NAME="T" VALUE="D" CHECKED>DIRECTORY -OR-
861   <INPUT TYPE="RADIO" NAME="T" VALUE="F">FILE : &nbsp;&nbsp;   <INPUT TYPE="RADIO" NAME="T" VALUE="F">FILE : &nbsp;&nbsp;
862   <NOBR>NAME <INPUT TYPE="TEXT" NAME="FN" SIZE=14>   <NOBR>NAME <INPUT TYPE="TEXT" NAME="FN" SIZE=14>
863   <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE">   <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE">
864   <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ?>">   <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">
865   <INPUT TYPE="SUBMIT" VALUE="CREATE"></NOBR>   <INPUT TYPE="SUBMIT" VALUE="CREATE"></NOBR>
866   <NOBR>OR <A HREF="<?php echo $self   <NOBR>OR <A HREF="<?= $self ?>?A=U&D=<?= urlencode($relDir) ?>">UPLOAD</A> A FILE
         ?>?A=U&D=<?php echo urlencode($relDir) ?>">UPLOAD</A> A FILE  
867   </NOBR>   </NOBR>
868  </TD></TR>  </TD></TR>
869  </FORM>  </FORM>
# Line 780  function Navigate($fsRoot,$relDir) { Line 875  function Navigate($fsRoot,$relDir) {
875    
876  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
877    
878  function UploadPage($fsRoot, $relDir) {  function UploadPage($fsRoot, $relDir, $filename="") {
879    
880          $self = $GLOBALS["PHP_SELF"] ;          $self = $GLOBALS["PHP_SELF"] ;
881          if ($relDir == "") $relDir = "/" ;          if ($relDir == "") $relDir = "/" ;
# Line 788  function UploadPage($fsRoot, $relDir) { Line 883  function UploadPage($fsRoot, $relDir) {
883    
884  <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>
885  <FORM ENCTYPE="multipart/form-data" METHOD="POST"  <FORM ENCTYPE="multipart/form-data" METHOD="POST"
886   ACTION="<?php echo $self ?>">   ACTION="<?= $self ?>">
887  DESTINATION DIRECTORY:<B><?php echo " " . $relDir ?></B>  DESTINATION DIRECTORY:<B><?= " " . $relDir ?></B>
888    <? if (isset($filename) && $filename!="") { ?>
889    <br>DESTINATION FILE:<B><?= " " . $filename ?></B>
890    <INPUT TYPE="HIDDEN" NAME="FILENAME" VALUE="<?= $filename ?>">
891    <? } ?>
892  <P>PATHNAME OF LOCAL FILE<BR>  <P>PATHNAME OF LOCAL FILE<BR>
893  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ?>">  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">
894  <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="UPLOAD">  <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="UPLOAD">
895  <INPUT SIZE=30 TYPE="FILE" NAME="FN"></P>  <INPUT SIZE=30 TYPE="FILE" NAME="FN"></P>
896  <P><INPUT TYPE="SUBMIT" VALUE="UPLOAD"></P>  <P><INPUT TYPE="SUBMIT" VALUE="UPLOAD"></P>
897  <P>If the <B>[BROWSE...]</B> button is not displayed,<BR>  <P>If the <B>[BROWSE...]</B> button is not displayed,<BR>
898  you must upgrade to an RFC1867-compliant browser.</P>  you must upgrade to an RFC1867-compliant browser.</P>
899  <P>Your browser:<BR><?php echo $GLOBALS["HTTP_USER_AGENT"] ?></P>  <P>Your browser:<BR><?= $GLOBALS["HTTP_USER_AGENT"] ?></P>
900  </FORM>  </FORM>
901  </TD></TR>  </TD></TR>
902  <TR><TD></TD><TD>  <TR><TD></TD><TD>
903  <FORM METHOD="POST" ACTION="<?php echo $self ?>">  <FORM METHOD="POST" ACTION="<?= $self ?>">
904  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?php echo $relDir ?>"><BR>  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"><BR>
905  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL">  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL">
906  </FORM>  </FORM>
907  </TD></TR></TABLE></P>  </TD></TR></TABLE></P>
# Line 855  function NoEntry() { Line 954  function NoEntry() {
954          StartHTML($title,$text) ;          StartHTML($title,$text) ;
955  ?>  ?>
956    
957  <FORM ACTION="<?php echo $self ?>?HASH=create" METHOD="POST">  <FORM ACTION="<?= $self ?>?HASH=create" METHOD="POST">
958  <INPUT TYPE="HIDDEN" NAME="USER" VALUE="<?php echo $user ?>">  <INPUT TYPE="HIDDEN" NAME="USER" VALUE="<?= $user ?>">
959  <INPUT TYPE="HIDDEN" NAME="PW" VALUE="<?php echo $pw ?>">  <INPUT TYPE="HIDDEN" NAME="PW" VALUE="<?= $pw ?>">
960    
961  <BLOCKQUOTE><B>If you are a site administrator:</B><BR><BR>  <BLOCKQUOTE><B>If you are a site administrator:</B><BR><BR>
962  Click below to <B>generate a password hash</B><BR>from  Click below to <B>generate a password hash</B><BR>from
# Line 873  the source<BR>of this file.<BR><BR> Line 972  the source<BR>of this file.<BR><BR>
972    
973  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
974    
975  function Logit($target,$msg) {  function LogIt($target,$msg) {
976    
977          $dir=dirname($target);          $dir=dirname($target);
978          if (! file_exists($dir."/.log")) {          if (! file_exists($dir."/.log")) {
# Line 889  function Logit($target,$msg) { Line 988  function Logit($target,$msg) {
988  }  }
989    
990    
991    //////////////////////////////////////////////////////////////////
992    
993    function WriteNote($target,$msg) {
994    
995            $target=stripSlashes($target);
996            $dir=dirname($target);
997            if (! file_exists($dir."/.note")) {
998                    mkdir($dir."/.note",0700);
999            }
1000            $file=basename($target);
1001    
1002            $note=fopen("$dir/.note/$file","w");
1003            fputs($note,"$msg\n");
1004            fclose($note);
1005    
1006            Logit($target,"added note $msg");
1007    
1008    }
1009    
1010    function ReadNote($target) {
1011    
1012            $target=stripSlashes($target);
1013            $dir=dirname($target);
1014            $file=basename($target);
1015            $msg="";
1016            if (file_exists($dir."/.note/$file")) {
1017                    $note=fopen("$dir/.note/$file","r");
1018                    $msg=fgets($note,4096);
1019                    fclose($note);
1020            }
1021            return StripSlashes($msg);
1022    
1023    }
1024    
1025    //////////////////////////////////////////////////////////////////
1026    
1027    function MoveTo($source,$folder) {
1028    
1029            $source=stripSlashes($source);
1030            $file=basename($source);
1031            if (! file_exists($folder)) {
1032                    mkdir($folder,0700);
1033            }
1034            if (file_exists($source)) {
1035                    rename($source,"$folder/$file");
1036            }
1037    }
1038    
1039    //////////////////////////////////////////////////////////////////
1040    
1041    function Lock($target) {
1042    
1043            $target=stripSlashes($target);
1044            $dir=dirname($target);
1045            if (! file_exists($dir."/.lock")) {
1046                    mkdir($dir."/.lock",0700);
1047            }
1048            $file=basename($target);
1049    
1050            if (file_exists("$dir/.lock/$file")) {
1051                    Logit($target,"attempt to locked allready locked file!");
1052            } else {
1053                    $lock=fopen("$dir/.lock/$file","w");
1054                    fputs($lock,"$GLOBALS[gblUserName]\n");
1055                    fclose($lock);
1056    
1057                    Logit($target,"file locked");
1058            }
1059    
1060    }
1061    
1062    function CheckLock($target) {
1063    
1064            $target=stripSlashes($target);
1065            $dir=dirname($target);
1066            $file=basename($target);
1067            $msg=0;
1068            if (file_exists($dir."/.lock/$file")) {
1069                    $lock=fopen("$dir/.lock/$file","r");
1070                    $msg=fgets($lock,4096);
1071                    fclose($lock);
1072            }
1073            return chop($msg);
1074    
1075    }
1076    
1077    function Unlock($target) {
1078    
1079            $target=stripSlashes($target);
1080            $dir=dirname($target);
1081            $file=basename($target);
1082            if (file_exists($dir."/.lock/$file")) {
1083                    unlink("$dir/.lock/$file");
1084                    Logit($target,"file unlocked");
1085            } else {
1086                    Logit($target,"attempt to unlocked non-locked file!");
1087            }
1088    
1089    }
1090    
1091    //////////////////////////////////////////////////////////////////
1092    
1093    function urlpath($url) {
1094            $url=urlencode(StripSlashes("$url"));
1095            $url=str_replace("%2F","/",$url);
1096            $url=str_replace("+","%20",$url);
1097            return($url);
1098    }
1099    
1100    //////////////////////////////////////////////////////////////////
1101    
1102    function safe_rename($from,$to) {
1103            if (file_exists($from) && is_writable(dirname($to))) {
1104                    rename($from,$to);
1105            }
1106    }
1107    
1108    //////////////////////////////////////////////////////////////////
1109    
1110    // recursivly delete directory
1111    
1112    function rrmdir($dir) {
1113            $handle=opendir($dir);
1114            while ($file = readdir($handle)) {
1115                    if ($file != "." && $file != "..") {
1116                            if (is_dir("$dir/$file"))
1117                                    rrmdir("$dir/$file");
1118                            else
1119                                    if (! @unlink("$dir/$file")) return(0);
1120                    }
1121            }
1122            closedir($handle);
1123            return @rmdir($dir);
1124    }
1125    
1126    //////////////////////////////////////////////////////////////////
1127    
1128    function ChangeLog($target,$msg) {
1129    
1130            global $gblFsRoot;
1131            $log=fopen("$gblFsRoot/.changelog","a+");
1132            if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot)
1133                    $target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot));
1134            fputs($log,time()."\t$target\t$GLOBALS[gblUserName]\t$msg\n");
1135            fclose($log);
1136    
1137    }
1138    
1139    function DisplayChangeLog($day) {
1140    
1141            global $gblFsRoot;
1142            if (!file_exists("$gblFsRoot/.changelog")) return;
1143            $log=fopen("$gblFsRoot/.changelog","r");
1144            $logarr = array();
1145            while($line = fgetcsv($log,255,"\t")) {
1146                    if ($day!=1 || ($day==1 && (time()-$line[0] < 24*60*60))) {
1147                            array_unshift($logarr,array($line[0],$line[1],$line[2],$line[3]));
1148                    }
1149            }
1150            fclose($log);
1151            $cl1=" class=lst"; $cl2="";
1152            print "<table border=0 width=100%>\n";
1153            while ($e = array_shift($logarr)) {
1154                    $cl=$cl1; $cl1=$cl2; $cl2=$cl;
1155                    $date = date("$GLOBALS[gblDateFmt]", $e[0]);
1156                    $time = date("$GLOBALS[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=\"$GLOBALS[PHP_SELF]?D=".urlencode($dir)."\">$dir</a>/$file</td><td$cl>$e[2]</td><td$cl>$e[3]</td></tr>\n";
1160            }
1161            print "</table>";
1162            print "<p>".GifIcon(up)." Back to <a href=$GLOBALS[PHP_SELF]>front page</a>.</p>";
1163    }
1164    
1165  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1166    
# Line 915  function Logit($target,$msg) { Line 1187  function Logit($target,$msg) {
1187          // authentication if $gblAuth == true          // authentication if $gblAuth == true
1188          if ( $gblAuth && $gblHash($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ||          if ( $gblAuth && $gblHash($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ||
1189                  isset($relogin) && $gblPw == $relogin ) {                  isset($relogin) && $gblPw == $relogin ) {
1190                  header("WWW-authenticate: basic realm=\"$SERVER_NAME\"") ;                  header("WWW-authenticate: basic realm=\"$HTTP_HOST\"") ;
1191                  header("HTTP/1.0 401 Unauthorized") ;                  header("HTTP/1.0 401 Unauthorized") ;
1192                  NoEntry() ;                  NoEntry() ;
1193                  exit ;                  exit ;
# Line 938  function Logit($target,$msg) { Line 1210  function Logit($target,$msg) {
1210          // i.e. below $gblFsRoot.          // i.e. below $gblFsRoot.
1211    
1212          $relScriptDir = dirname($SCRIPT_NAME) ;                  $relScriptDir = dirname($SCRIPT_NAME) ;        
1213          // i.e. /siteman          // i.e. /docman
1214    
1215          $fsScriptDir  = dirname($SCRIPT_FILENAME) ;              $fsScriptDir  = dirname($SCRIPT_FILENAME) ;    
1216          // i.e. /home/httpd/html/siteman          // i.e. /home/httpd/html/docman
1217    
1218          $gblFsRoot = substr($fsScriptDir,0,          // start on server root
1219            strlen($fsScriptDir)-strlen($relScriptDir)) ;  //      $gblFsRoot = substr($fsScriptDir,0, strlen($fsScriptDir)-strlen($relScriptDir)) ;
1220            // or on script root
1221            $gblFsRoot = $fsScriptDir;
1222          // i.e. /home/httpd/html          // i.e. /home/httpd/html
1223    
1224          $fsDir = $gblFsRoot . $relDir ; // current directory          $fsDir = $gblFsRoot . $relDir ; // current directory
1225          if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ;          if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ;
1226            
1227            $FN=stripSlashes($FN);
1228    
1229          switch ($POSTACTION) {          switch ($POSTACTION) {
1230          case "UPLOAD" :          case "UPLOAD" :
1231                  if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;                  if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;
# Line 958  function Logit($target,$msg) { Line 1234  function Logit($target,$msg) {
1234                  // TODO : should rather check for escapeshellcmds                  // TODO : should rather check for escapeshellcmds
1235                  // but maybe RFC 18xx asserts safe filenames ....                  // but maybe RFC 18xx asserts safe filenames ....
1236                  $source = $FN ;                  $source = $FN ;
1237                  $target = $fsDir . "/" . $FN_name ;                  if (! file_exists($source)) {
1238                            Error("You must select file with browse to upload it!");
1239                    }
1240                    if (! isset($FILENAME)) {       // from update file
1241                            $target = "$fsDir/$FN_name" ;
1242                    } else {
1243                            $target = "$fsDir/$FILENAME";
1244                    }
1245    
1246                  // backup old files first                  // backup old files first
1247                  $dir=dirname($target);                  $dir=dirname($target);
# Line 970  function Logit($target,$msg) { Line 1253  function Logit($target,$msg) {
1253                  }                  }
1254                  $file=basename($target);                  $file=basename($target);
1255                  for($i=$GLOBALS[gblNumBackups]-1;$i>0;$i--) {                  for($i=$GLOBALS[gblNumBackups]-1;$i>0;$i--) {
1256                          if (! file_exists($dir."/.bak/".$i)) {                          MoveTo("$dir/.bak/$i/$file","$dir/.bak/".($i+1)."/");
                                 mkdir($dir."/.bak/".$i,0700);  
                         }  
                         if (file_exists($dir."/.bak/".$i."/".$file)) {  
                                 rename($dir."/.bak/".$i."/".$file,  
                                         $dir."/.bak/".($i+1)."/".$file);  
                         }  
                 }  
                 if (file_exists($target)) {  
                         rename($target,$dir."/.bak/1/".$file);  
1257                  }                  }
1258                    MoveTo($target,$dir."/.bak/1/");
1259    
1260                  copy($source,$target) ;                  copy($source,$target) ;
1261                  chmod($target,$gblFilePerms) ;                  chmod($target,$gblFilePerms) ;
1262                  clearstatcache() ;                  clearstatcache() ;
1263                  Logit($target,"uploaded");                  Logit($target,"uploaded");
1264                    if (isset($FILENAME)) {
1265                            Unlock($target);
1266                    }
1267                    ChangeLog($target,"updated");
1268                  break ;                  break ;
1269    
1270          case "SAVE" :          case "SAVE" :
1271                  $path = $gblFsRoot . escapeshellcmd($RELPATH) ;                  $path = $gblFsRoot . $RELPATH ;
1272                    $path=stripSlashes($path);
1273                  $writable = is_writeable($path) ;                  $writable = is_writeable($path) ;
1274                  $legaldir = is_writeable(dirname($path)) ;                  $legaldir = is_writeable(dirname($path)) ;
1275                  $exists   = (file_exists($path)) ? 1 : 0 ;                  $exists   = (file_exists($path)) ? 1 : 0 ;
# Line 997  function Logit($target,$msg) { Line 1277  function Logit($target,$msg) {
1277                  if (!($writable || (!$exists && $legaldir)))                  if (!($writable || (!$exists && $legaldir)))
1278                          Error("Write denied",$RELPATH) ;                          Error("Write denied",$RELPATH) ;
1279                  $fh = fopen($path, "w") ;                  $fh = fopen($path, "w") ;
1280                    $FILEDATA=stripSlashes($FILEDATA);
1281                  fwrite($fh,$FILEDATA) ;                  fwrite($fh,$FILEDATA) ;
1282                  fclose($fh) ;                  fclose($fh) ;
1283                  clearstatcache() ;                  clearstatcache() ;
1284                  Logit($path,"saved changes");                  Logit($path,"saved changes");
1285                    ChangeLog($path,"saved changes");
1286                  break ;                  break ;
1287    
1288          case "CREATE" :          case "CREATE" :
# Line 1011  function Logit($target,$msg) { Line 1293  function Logit($target,$msg) {
1293                  $relPath = $relDir . "/" . $FN ;                  $relPath = $relDir . "/" . $FN ;
1294                  switch ( $T ) {                  switch ( $T ) {
1295                  case "D" :  // create a directory                  case "D" :  // create a directory
1296                    if ( ! @mkdir($path,$gblDirPerms) )                          if ( ! @mkdir($path,$gblDirPerms) )
1297                      Error("Mkdir failed",$relPath) ; // eg. if it exists                                  Error("Mkdir failed",$relPath) ; // eg. if it exists
1298                    clearstatcache() ;                          clearstatcache() ;
1299                    break ;                          break ;
1300                  case "F" :  // create a new file                  case "F" :  // create a new file
1301  // this functionality is doubled in DetailView().  // this functionality is doubled in DetailView().
1302  // better keep it here altogether  // better keep it here altogether
1303  // chmod perms to $gblFilePerms  // chmod perms to $gblFilePerms
1304                    if ( file_exists($path) && !is_writable($path) )                          if ( file_exists($path) && !is_writable($path) )
1305                      Error("File not writable", $relPath) ;                                  Error("File not writable", $relPath) ;
1306                    $tstr = $PHP_SELF . "?A=E&D=" . $relDir . "&F=" . $FN ;                          $fh = fopen($path, "w+") ;
1307                    header("Location: " . $tstr) ;                          if ($fh) {
1308                    exit ;                                  fputs($fh,"\n");
1309                                    fclose($fh) ;
1310                                    LogIt($path,"file created");
1311                            } else {
1312                                    Error("Creation of file $relPath failed -- $path");
1313                            }
1314                            $tstr = "$PHP_SELF?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ;
1315                            header("Location: " . $tstr) ;
1316                            ChangeLog($target,"created");
1317                            exit ;
1318                  }                  }
1319                  break ;                  break ;
1320    
# Line 1049  function Logit($target,$msg) { Line 1340  function Logit($target,$msg) {
1340                                  exit ;                                  exit ;
1341                          } else {                          } else {
1342                                  Logit($path,"file deleted");                                  Logit($path,"file deleted");
1343                                  if (! file_exists("$dir/.del/.log")) {                                  MoveTo("$dir/.log/$file","$dir/.del/.log/");
1344                                          mkdir("$dir/.del/.log",0700);                                  MoveTo("$dir/.note/$file","$dir/.del/.note/");
1345                                  }                                  MoveTo("$dir/.lock/$file","$dir/.del/.lock/");
                                 rename("$dir/.log/$file","$dir/.del/.log/$file");  
1346                          }                          }
1347                  }                  }
1348                  else {  // delete directory                  else {  // delete directory
1349                    if ( ! @rmdir($fsDir) ) {                    if ( ! @rrmdir($fsDir) ) {
1350                      Error("Rmdir failed", $tstr . $fsDir) ;                      Error("Rmdir failed", $tstr . $fsDir) ;
1351                    }                    }
1352                    else {                    else {
# Line 1072  function Logit($target,$msg) { Line 1362  function Logit($target,$msg) {
1362                  $file=substr($FN,4,strlen($FN)-4);                  $file=substr($FN,4,strlen($FN)-4);
1363    
1364                  Logit("$fsDir/.del/$file","undeleted");                  Logit("$fsDir/.del/$file","undeleted");
1365                  rename("$fsDir/.del/$file","$fsDir/$file");                  MoveTo("$fsDir/.del/$file","$fsDir/");
1366                  rename("$fsDir/.del/.log/$file","$fsDir/.log/$file");                  MoveTo("$fsDir/.del/.log/$file","$fsDir/.log/");
1367                    MoveTo("$fsDir/.del/.note/$file","$fsDir/.note/");
1368                    MoveTo("$fsDir/.del/.lock/$file","$fsDir/.lock/");
1369    
1370                  break ;                  break ;
1371    
# Line 1081  function Logit($target,$msg) { Line 1373  function Logit($target,$msg) {
1373                  if ( $CONFIRM != "on" ) break ;                  if ( $CONFIRM != "on" ) break ;
1374    
1375                  Logit("$fsDir/$FN","renamed $FN to $NEWNAME");                  Logit("$fsDir/$FN","renamed $FN to $NEWNAME");
1376                  rename("$fsDir/$FN","$fsDir/$NEWNAME");                  safe_rename("$fsDir/$FN","$fsDir/$NEWNAME");
1377                  rename("$fsDir/.log/$FN","$fsDir/.log/$NEWNAME");                  safe_rename("$fsDir/.log/$FN","$fsDir/.log/$NEWNAME");
1378                    safe_rename("$fsDir/.note/$FN","$fsDir/.note/$NEWNAME");
1379                    safe_rename("$fsDir/.lock/$FN","$fsDir/.lock/$NEWNAME");
1380                    for($i=0;$i<=$GLOBALS[gblNumBackups];$i++) {
1381                            safe_rename("$fsDir/.bak/$i/$FN","$fsDir/.bak/$i/$NEWNAME");
1382                    }
1383    
1384                    break ;
1385    
1386            case "NOTE" :  
1387                    WriteNote("$fsDir/$FN","$NOTE");
1388                    break ;
1389    
1390            case "UNLOCK" :  
1391                    if ( $CONFIRM != "on" ) break ;
1392                    Unlock("$fsDir/$FN");
1393                  break ;                  break ;
1394    
1395          default :          default :
# Line 1101  function Logit($target,$msg) { Line 1407  function Logit($target,$msg) {
1407          // $A=U : upload to path given in $D          // $A=U : upload to path given in $D
1408          // $A=E : display detail of file $D/$F and edit          // $A=E : display detail of file $D/$F and edit
1409          // $A=C : display code in file $D/$F          // $A=C : display code in file $D/$F
1410            // $A=Co : checkout file $D/$F
1411            // $A=Ci : checkin file $D/$F
1412            // $A=V : view file (do nothing except log)
1413          // default : display directory $D          // default : display directory $D
1414            
1415          switch ($A) {          switch ($A) {
1416          case "U" :          case "U" :
1417                  // upload to $relDir                  // upload to $relDir
1418                  if (!is_writeable($gblFsRoot . $relDir))                  if (!is_writeable($gblFsRoot . $relDir))
1419                          Error("Write access denied",$relDir) ;                          Error("Write access denied",$relDir) ;
1420                  $text  = "Use this page to upload a single " ;                  $text  = "Use this page to upload a single " ;
1421                  $text .= "file to <B>$SERVER_NAME</B>." ;                  $text .= "file to <B>$HTTP_HOST</B>." ;
1422                  StartHTML("(Upload Page)", $text) ;                  StartHTML("(Upload Page)", $text) ;
1423                  UploadPage($gblFsRoot, $relDir) ;                  UploadPage($gblFsRoot, $relDir) ;
1424                  EndHTML() ;                  EndHTML() ;
1425                  exit ;                  exit ;
1426          case "E" :          case "E" :
1427                    $F=stripSlashes($F);
1428                  // detail of $relDir/$F                  // detail of $relDir/$F
1429                  if (is_file("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ;                  if (is_file("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ;
1430                  exit ;                  exit ;
1431          case "C" :          case "C" :
1432                    $F=stripSlashes($F);
1433                  // listing of $relDir/$F                  // listing of $relDir/$F
1434                  DisplayCode($gblFsRoot, $relDir, $F) ;                  DisplayCode($gblFsRoot, $relDir, $F) ;
1435                  exit ;                  exit ;
1436            case "Co" :
1437                    // checkout
1438                    Lock("$gblFsRoot/$relDir/$F");
1439                    header("Content-Disposition: attachment; filename=$F" );
1440                    Header("Location: ".urlpath("$relDir/$F"));
1441                    exit;
1442            case "Ci" :
1443                    $F=stripSlashes($F);
1444                    // upload && update to $relDir
1445                    if (!is_writeable($gblFsRoot . $relDir))
1446                            Error("Write access denied",$relDir) ;
1447                    $text  = "Use this page to update a single " ;
1448                    $text .= "file to <B>$HTTP_HOST</B>." ;
1449                    StartHTML("(Update file Page)", $text) ;
1450                    UploadPage($gblFsRoot, $relDir, $F) ;
1451                    EndHTML() ;
1452                    exit ;
1453            case "V" :
1454                    // view
1455                    LogIt("$gblFsRoot/$relDir/$F","viewed");
1456                    header("Content-Disposition: attachment; filename=$F" );
1457                    Header("Location: ".urlpath("$relDir/$F"));
1458                    exit;
1459            case "Ch" :
1460                    StartHTML("(File changes)","All changes chronologicaly...");
1461                    DisplayChangeLog(0);    // all
1462                    EndHTML() ;
1463                    exit;
1464            case "Ch1" :
1465                    StartHTML("(File changes)","Changes to files in last day...");
1466                    DisplayChangeLog(1);
1467                    EndHTML() ;
1468                    exit;
1469          }          }
1470    
1471          // default: display directory $relDir          // default: display directory $relDir

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.26

  ViewVC Help
Powered by ViewVC 1.1.26