/[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.4 by dpavlin, Thu Aug 3 20:54:27 2000 UTC revision 1.31 by dpavlin, Tue Jan 30 16:48:36 2001 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 59  IMPORTANT INSTALLATION NOTE: Line 51  IMPORTANT INSTALLATION NOTE:
51          deleted files!          deleted files!
52    
53          .htusers is in form:          .htusers is in form:
54          login:Real Name:md5(loginpassword)          login:Real Name:[md5(loginpassword)|auth_*]:email@host.dom
55    
56    
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    
78            // from where to include auth_*.php modules?
79            $gblIncDir = "/home/httpd/docman";
80    
81          // username/password should not be system          // username/password should not be system
82          // usernames/passwords !!          // usernames/passwords !!
83    
 //      $gblPw    = "hash_of_your_username_and_password" ;  
   
 //      $gblAuth  = false ;             // use builtin authentication  
         $gblAuth  = true ;             // use builtin authentication  
         $gblHash  = "md5" ;             // hash function to use  
   
84          $gblPw    = "";          $gblPw    = "";
85    
86          if ($gblAuth) {          // date format
                 $htusers_file=dirname($SCRIPT_FILENAME)."/.htusers";  
                 if (! file_exists($htusers_file)) {  
                         $htusers=fopen($htusers_file,"a+");  
                         fputs($htusers,"# Change owner of $htusers_file to root !!\n");  
                         fputs($htusers,"demo:full name:md5_hash\n");  
                         fclose($htusers);  
                 }  
                 $htusers=fopen($htusers_file,"r");  
                 while($user = fgetcsv($htusers,255,":")) {  
                         if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) {  
                                 $gblUserName=$user[1];  
                                 $gblPw=$user[2];  
                                 continue ;  
                         }  
                 }  
                 fclose($htusers);  
         }  
   
87  //      $gblDateFmt="D, F d, Y";  //      $gblDateFmt="D, F d, Y";
 //      $gblTimeFmt="g:i:sA";  
   
88          $gblDateFmt="Y-m-d";          $gblDateFmt="Y-m-d";
89    
90            // time format
91    //      $gblTimeFmt="g:i:sA";
92          $gblTimeFmt="H:i:s";          $gblTimeFmt="H:i:s";
93    
94  // Number of backup files to keep          // Number of backup files to keep
95          $gblNumBackups=5;          $gblNumBackups=3;
96    
97            // show red star if newer than ... days
98            $gblModDays=1;
99    
100          // choose GifIcon below unless you have the M$          // choose GifIcon below unless you have the M$
101          // WingDings font installed on your system          // WingDings font installed on your system
102    
103          $gblIcon = "GifIcon" ;          // MockIcon or GifIcon          $gblIcon="GifIcon";             // MockIcon or GifIcon
104    
105          // the directory below should be /icons/ or /icons/small/          // the directory below should be /icons/ or /icons/small/
106          // on Apache; a set of icons is included in the distribution          // on Apache; a set of icons is included in the distribution
107    
108          $gblIconLocation = "/icons/" ;          $gblIconLocation="/icons/";
109    
110          // files you want to be able to edit in text mode          // files you want to be able to edit in text mode
111          // and view with (primitive) syntax highlighting          // and view with (primitive) syntax highlighting
# Line 150  TODO: Line 124  TODO:
124    
125  function StartHTML($title,$text="") {  function StartHTML($title,$text="") {
126    
127          $title = "Site Manager " . $title ;          $title = "Document Manager " . $title ;
128          $host  = $GLOBALS["HTTP_HOST"] ;          $host  = $GLOBALS["HTTP_HOST"] ;
129          $self  = $GLOBALS["PHP_SELF"] ;          $self  = $GLOBALS["PHP_SELF"] ;
130  ?>  ?>
# Line 184  function EndHTML() { Line 158  function EndHTML() {
158  <B><?= date($GLOBALS[gblDateFmt]) ?> -  <B><?= date($GLOBALS[gblDateFmt]) ?> -
159  <?= date($GLOBALS[gblTimeFmt]) ?> -  <?= date($GLOBALS[gblTimeFmt]) ?> -
160  <?= $GLOBALS[gblUserName] ?>  <?= $GLOBALS[gblUserName] ?>
161  <small> [<a href="<?= $PHP_SELF ?>?relogin=<?= $GLOBALS[gblPw] ?>">logout</a>]</small>  <small> [<a href="<?= $GLOBALS["PHP_SELF"] ?>?relogin=<?= $GLOBALS[gblPw] ?>">logout</a>]</small>
162  </B>  </B>
163  <BR>ANYPORTAL(php) Site Manager  <BR>ANYPORTAL(php) Site Manager
164  <br><small>  <br><small>
# Line 194  function EndHTML() { Line 168  function EndHTML() {
168  </small>  </small>
169  </P>  </P>
170  <BR>  <BR>
171  <? include(".debug.inc") ?>  <? //include(".debug.inc") ?>
172  <BR><BR></BODY></HTML>  <BR><BR></BODY></HTML>
173    
174  <?php  <?php
# Line 229  A:HOVER { color:red; } Line 203  A:HOVER { color:red; }
203    
204  function DetailPage($fsRoot,$relDir,$fn) {  function DetailPage($fsRoot,$relDir,$fn) {
205                    
206          global $gblEditable, $gblImages ;          global $gblEditable, $gblImages, $webRoot ;
207          $self = $GLOBALS["PHP_SELF"] ;          $self = $GLOBALS["PHP_SELF"] ;
208    
209          $relPath  = $relDir . "/" . $fn ;          $relPath  = $relDir . "/" . $fn ;
# Line 240  function DetailPage($fsRoot,$relDir,$fn) Line 214  function DetailPage($fsRoot,$relDir,$fn)
214          $ext      = strtolower(strrchr($relPath,".")) ;          $ext      = strtolower(strrchr($relPath,".")) ;
215          $editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) ;          $editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) ;
216          $writable = is_writeable($fsPath) ;          $writable = is_writeable($fsPath) ;
217            $file_lock = CheckLock($fsPath);
218    
219          if (!$editable && !$exists)          if (!$editable && !$exists)
220                  Error("Creation unsupported for type",$relPath) ;                  Error("Creation unsupported for type",$relPath) ;
# Line 268  function DetailPage($fsRoot,$relDir,$fn) Line 243  function DetailPage($fsRoot,$relDir,$fn)
243    
244          }          }
245    
246          if ( $editable && ($writable || !$exists) ) {          if ( $editable && ($writable || !$exists) && !$file_lock ) {
247                  $fh = fopen($fsPath,"a+") ;                  $fh = fopen($fsPath,"a+") ;
248                  rewind($fh) ;                  rewind($fh) ;
249                  $fstr = fread($fh,filesize($fsPath)) ;                  $fstr = fread($fh,filesize($fsPath)) ;
# Line 294  echo($fstr) ; ?></TEXTAREA> Line 269  echo($fstr) ; ?></TEXTAREA>
269    
270  <?php  <?php
271          }          }
272          else if ( strstr( join(" ",$gblImages), $ext ) ) {            if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) {  
273            $info  = getimagesize($fsPath) ;                  $info  = getimagesize($fsPath) ;
274            $tstr  = "<IMG SRC=\"". $relPath . "\" BORDER=0 " ;                  $tstr = "<IMG SRC=\"$webRoot".urlpath($relPath)."\" BORDER=0 " ;
275            $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;                  $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;
276            $tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ;                  $tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ;
277            echo htmlentities($tstr) . "<BR><BR>" . $tstr ;  //              echo htmlentities($tstr) . "<BR><BR>" . $tstr ;
278                    echo $tstr ;
279          }          }
280    
281  ?>  ?>
282    
283  <FORM ACTION="<?= $self ; ?>" METHOD="POST">  <FORM ACTION="<?= $self ; ?>" METHOD="POST">
# Line 309  echo($fstr) ; ?></TEXTAREA> Line 286  echo($fstr) ; ?></TEXTAREA>
286  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR>  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR>
287    
288  <?php  <?php
289    
290            if ($file_lock) {
291    ?>
292    <hr>
293    <SPAN TITLE="Check OK and click UNLOCK to remove lock on file.">
294    <B>OK TO FORCE LOCK REMOVAL ON "<?= $fn ; ?>" HELD BY <?= $file_lock ?>? </B></SPAN>
295    <INPUT TYPE="CHECKBOX" NAME="CONFIRM">
296    <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="UNLOCK">
297    <?
298            } // file_lock
299    
300          if (substr($fn,0,4) == ".del") {          if (substr($fn,0,4) == ".del") {
301                  $action="UNDELETE";                  $action="UNDELETE";
302                  $desc="undelete previously deleted file";                  $desc="undelete previously deleted file";
# Line 336  echo($fstr) ; ?></TEXTAREA> Line 324  echo($fstr) ; ?></TEXTAREA>
324  <INPUT TYPE="CHECKBOX" NAME="CONFIRM">  <INPUT TYPE="CHECKBOX" NAME="CONFIRM">
325  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="RENAME">  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="RENAME">
326    
327    <?php
328            }       // exists && writable
329    ?>
330  <HR>  <HR>
331  <a name="note">  <a name="note">
332  <B>NOTE FOR "<?= $fn ; ?>":  <B>NOTE FOR "<?= $fn ; ?>":
# Line 343  echo($fstr) ; ?></TEXTAREA> Line 334  echo($fstr) ; ?></TEXTAREA>
334  </B></SPAN>  </B></SPAN>
335  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="NOTE">  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="NOTE">
336    
337    </FORM>
338    
339  <?php  <?php
         }  
         echo "</FORM>" ;  
340    
341          $logname=dirname("$fsDir/$fn")."/.log/".basename("$fsDir/$fn");          $name=basename("$fsDir/$fn");
342            $logname=dirname("$fsDir/$fn")."/.log/$name";
343            $bakdir=dirname("$fsDir/$fn")."/.bak";
344          if (file_exists($logname)) {          if (file_exists($logname)) {
                 print "<hr><br><b>CHANGES TO THIS FILE</b><br><table border=0 width=100%>\n";  
345                  $log=fopen($logname,"r");                  $log=fopen($logname,"r");
346                  $cl1=" class=lst"; $cl2="";                  $cl1=" class=LST"; $cl2="";
347                    $logarr = array();
348                  while($line = fgetcsv($log,255,"\t")) {                  while($line = fgetcsv($log,255,"\t")) {
349                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;
350                          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]));
351                  }                  }
352                  fclose($log);                  fclose($log);
353                    print "<hr><br><b>CHANGES TO THIS FILE</b><br><table border=0 width=100%>\n";
354                    $bakcount = 0;  // start from 0, skip fist backup (it's current)
355                    while ($e = array_shift($logarr)) {
356                            if (strstr($e[4],"upload")) {
357                                    if (file_exists("$bakdir/$bakcount/$name")) {
358                                            $e[4]="<a href=\"$webRoot".urlpath(dirname($relPath)."/.bak/$bakcount/$name")."\">$e[4]</a>";
359                                    }
360                                    $bakcount++;
361                            }
362                            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";
363                    }
364                  print "</table>";                  print "</table>";
365          }          }
366    
# Line 590  function GifIcon($txt) { Line 594  function GifIcon($txt) {
594                  $d = "blank.gif" ;                  $d = "blank.gif" ;
595                  break ;                  break ;
596          case "checkout":          case "checkout":
597                  $d = "down.gif";                  $d = "box2.gif";
598                  break;                  break;
599          case "checkin":          case "checkin":
600                  $d = "up.gif";                  $d = "hand.up.gif";
601                    break;
602            case "locked":
603                    $d = "screw2.gif";
604                  break;                  break;
605          case "note":          case "note":
606                  $d = "quill.gif";                  $d = "quill.gif";
# Line 609  function GifIcon($txt) { Line 616  function GifIcon($txt) {
616    
617  function Navigate($fsRoot,$relDir) {  function Navigate($fsRoot,$relDir) {
618    
619          global $gblEditable, $gblIcon ;          global $gblEditable, $gblIcon, $gblModDays, $webRoot ;
620    
621          $self     = $GLOBALS["PHP_SELF"] ;          $self     = $GLOBALS["PHP_SELF"] ;
622          if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") {  
623                  $webRoot  = "https://" . $GLOBALS["SERVER_NAME"] ;          $fsDir = $fsRoot . $relDir . "/" ; // current directory
         } else {  
                 $webRoot  = "http://" . $GLOBALS["SERVER_NAME"] ;  
         }  
         $fsDir    = $fsRoot . $relDir . "/" ; // current directory  
624    
625          if (!is_dir($fsDir)) Error("Dir not found",$relDir) ;          if (!is_dir($fsDir)) Error("Dir not found",$relDir) ;
626    
# Line 655  function Navigate($fsRoot,$relDir) { Line 658  function Navigate($fsRoot,$relDir) {
658          // start navigation page          // start navigation page
659          $text  = "Use this page to add, delete";          $text  = "Use this page to add, delete";
660          if (! isset($show_deleted)) {          if (! isset($show_deleted)) {
661                  $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>";
662          }          }
663          $text .= " or revise files on this web site." ;          $text .= " or revise files on this web site." ;
664            $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>.";
665          StartHTML("(Navigate)",$text) ;          StartHTML("(Navigate)",$text) ;
666    
667          echo "<TABLE BORDER=0 CELLPADDING=2          echo "<TABLE BORDER=0 CELLPADDING=2
# Line 702  function Navigate($fsRoot,$relDir) { Line 706  function Navigate($fsRoot,$relDir) {
706  <TR><TD></TD><TD COLSPAN=5><HR><B><?= $webRoot . $relDir ?>  <TR><TD></TD><TD COLSPAN=5><HR><B><?= $webRoot . $relDir ?>
707  </B></TD></TR>  </B></TD></TR>
708  <TR><TD></TD><TD CLASS=TOP>DOCUMENT NAME</TD>  <TR><TD></TD><TD CLASS=TOP>DOCUMENT NAME</TD>
709  <TD><?= $gblIcon("blank") ?></TD>  <TD><?= $gblIcon("blank").$gblIcon("blank") ?></TD>
710  <TD CLASS=TOP>NOTE</TD>  <TD CLASS=TOP>NOTE</TD>
711  <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>
712    
# Line 724  function Navigate($fsRoot,$relDir) { Line 728  function Navigate($fsRoot,$relDir) {
728    
729                  $info_url=$self."?A=E&F=".urlencode($file)."&D=".urlencode($relDir);                  $info_url=$self."?A=E&F=".urlencode($file)."&D=".urlencode($relDir);
730    
731                  if ( ($mod + 30*86400) > time() ) {                  if ( ($mod + $gblModDays*86400) > time() ) {
732                          $a  = "<SPAN CLASS=RED TITLE=\"Newer" ;                          $a  = "<SPAN CLASS=RED TITLE=\"Newer" ;
733                          $a .= " than 30 days\"> * </SPAN>" ;                          $a .= " than $gblModDays days\"> * </SPAN>" ;
734                  }                  }
735    
736                  $tstr = $webRoot . $relDir . "/" . $file ;                  $file_lock=CheckLock($path);
737                  $tstr  = "<A HREF=\"" . $tstr . "\">" ;  
738                    $file_url_html="<A HREF=\"$self?A=V&F=".urlencode($file);
739                    $file_url_html.="&D=".urlencode($relDir);
740                    $file_url_html.="\" TITLE=\"View file\">" ;
741    
742                  if (substr($file,0,5) != ".del/") {                  if (substr($file,0,5) != ".del/") {
743                          $tstr .= $file . "</A>" . $a ;                          $file_url_html .= $file . "</A>" . $a ;
744                  } else {                  } else {
745                          $tstr .= substr($file,5,strlen($file)-5) . "</a> <SPAN CLASS=RED TITLE=\"deleted\"> <a href=\"$info_url#undelete\">deleted</a> </span>";                          $file_url_html .= substr($file,5,strlen($file)-5) . "</a> <SPAN CLASS=RED TITLE=\"deleted\"> <a href=\"$info_url#undelete\">deleted</a> </span>";
746                  }                  }
747    
748  //              $b = $gblIcon("checkout");                  $note_html="<a href=\"$info_url#note\">".$gblIcon("note")."</a>".ReadNote($path);
 //              $b .= $gblIcon("checkin");  
749    
750                  $ext = strtolower(strrchr($file,".")) ;                  $ext = strtolower(strrchr($file,".")) ;
751                  if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) {    
752                          $b .= "<A HREF=\"" . $self . "?A=C&F=" ;                  if ($file_lock) {
753                          $b .= urlencode($file) . "&D=" . urlencode($relDir) ;                          if ($file_lock == $GLOBALS[gblUserName]) {
754                          $b .= "\" TITLE=\"List contents\">" ;                                  $b.="<A HREF=\"$self?A=Ci&F=".urlencode($file);
755                          $b .= $gblIcon("view") . "</A>" ;                                  $b.="&D=".urlencode($relDir);
756                                    $b.="\" TITLE=\"Checkin (update) file on server\">" ;
757                                    $file_url_html=$b;
758                                    $b.=$gblIcon("checkin")."</A>" ;
759                                    $b.= $gblIcon("blank");
760                                    $file_url_html.="$file</a> $a";
761                                    $note_html = $gblIcon("blank")."<b>Please check-in (update) this file</b>";
762                            } else {
763                                    $b = $gblIcon("locked");
764                                    $b.= $gblIcon("blank");
765                                    $note_html = $gblIcon("blank")."<b>File locked by $file_lock</b>";
766                                    $file_url_html = "$file $a";
767                            }
768                  } else {                  } else {
769                          $b .= $gblIcon("blank");                          $b.="<A HREF=\"$self?A=Co&F=".urlencode($file);
770                            $b.="&D=".urlencode($relDir);
771                            $b.="\" TITLE=\"Checkout file for edit\">" ;
772                            $b.=$gblIcon("checkout")."</A>" ;
773    
774                            if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) {  
775                                    $b.="<A HREF=\"$self?A=C&F=".urlencode($file);
776                                    $b.="&D=".urlencode($relDir);
777                                    $b.="\" TITLE=\"List contents\">" ;
778                                    $b.=$gblIcon("view")."</A>" ;
779                            } else {
780                                    $b.= $gblIcon("blank");
781                            }
782                  }                  }
783    
784    
# Line 757  function Navigate($fsRoot,$relDir) { Line 787  function Navigate($fsRoot,$relDir) {
787  <TR><TD>  <TR><TD>
788  <A HREF="<?= $info_url ?>" TITLE="View/Edit">  <A HREF="<?= $info_url ?>" TITLE="View/Edit">
789  <?= $gblIcon($ext) ?></A></TD>  <?= $gblIcon($ext) ?></A></TD>
790  <TD CLASS=LST><?= $tstr ?></TD>  <TD CLASS=LST><?= $file_url_html ?></TD>
791  <TD CLASS=LST ALIGN=center><?= $b ?></TD>  <TD CLASS=LST ALIGN=center><?= $b ?></TD>
792  <TD CLASS=LST ALIGN=left><a href="<?= $info_url ?>#note"><?= $gblIcon("note") ?></a><?= ReadNote($path) ?></TD>  <TD CLASS=LST ALIGN=left><?= $note_html ?></TD>
793  <TD CLASS=LST><?= date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]",$mod) ?></TD>  <TD CLASS=LST><?= date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]",$mod) ?></TD>
794  <TD CLASS=LST><?= $sz ?>Bytes</TD></TR>  <TD CLASS=LST><?= $sz ?>Bytes</TD></TR>
795    
796  <?php  <?php
797            }  // iterate over files            }  // iterate over files
798          }  // end if no files          } else {  // end if no files
799    ?>
800     <TR><TD></TD><TD COLSPAN=5 CLASS=LST>
801      No files in this directory
802     </TD></TR>
803    <?
804            }
805    
806          if ($emptyDir) {          if ($emptyDir) {
807  ?>  ?>
# Line 785  function Navigate($fsRoot,$relDir) { Line 821  function Navigate($fsRoot,$relDir) {
821    
822  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>
823    
824    <?
825    if (file_exists(".info.inc")) {
826            print "<TR><TD></TD><TD COLSPAN=5>";
827            include(".info.inc");
828            print "</TD></TR>
829            <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>";
830    }
831    ?>
832    
833  <FORM METHOD="POST" ACTION="<?= $self ?>">  <FORM METHOD="POST" ACTION="<?= $self ?>">
834  <TR><TD></TD><TD COLSPAN=5 CLASS=BAR>CREATE NEW  <TR><TD></TD><TD COLSPAN=5 CLASS=BAR>CREATE NEW
835   <INPUT TYPE="RADIO" NAME="T" VALUE="D" CHECKED>DIRECTORY -OR-   <INPUT TYPE="RADIO" NAME="T" VALUE="D" CHECKED>DIRECTORY -OR-
# Line 793  function Navigate($fsRoot,$relDir) { Line 838  function Navigate($fsRoot,$relDir) {
838   <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE">   <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE">
839   <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">   <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">
840   <INPUT TYPE="SUBMIT" VALUE="CREATE"></NOBR>   <INPUT TYPE="SUBMIT" VALUE="CREATE"></NOBR>
841   <NOBR>OR <A HREF="<?= $self   <NOBR>OR <A HREF="<?= $self ?>?A=U&D=<?= urlencode($relDir) ?>">UPLOAD</A> A FILE
         ?>?A=U&D=<?= urlencode($relDir) ?>">UPLOAD</A> A FILE  
842   </NOBR>   </NOBR>
843  </TD></TR>  </TD></TR>
844  </FORM>  </FORM>
# Line 806  function Navigate($fsRoot,$relDir) { Line 850  function Navigate($fsRoot,$relDir) {
850    
851  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
852    
853  function UploadPage($fsRoot, $relDir) {  function UploadPage($fsRoot, $relDir, $filename="") {
854    
855          $self = $GLOBALS["PHP_SELF"] ;          $self = $GLOBALS["PHP_SELF"] ;
856          if ($relDir == "") $relDir = "/" ;          if ($relDir == "") $relDir = "/" ;
# Line 816  function UploadPage($fsRoot, $relDir) { Line 860  function UploadPage($fsRoot, $relDir) {
860  <FORM ENCTYPE="multipart/form-data" METHOD="POST"  <FORM ENCTYPE="multipart/form-data" METHOD="POST"
861   ACTION="<?= $self ?>">   ACTION="<?= $self ?>">
862  DESTINATION DIRECTORY:<B><?= " " . $relDir ?></B>  DESTINATION DIRECTORY:<B><?= " " . $relDir ?></B>
863    <? if (isset($filename) && $filename!="") { ?>
864    <br>DESTINATION FILE:<B><?= " " . $filename ?></B>
865    <INPUT TYPE="HIDDEN" NAME="FILENAME" VALUE="<?= $filename ?>">
866    <? } ?>
867  <P>PATHNAME OF LOCAL FILE<BR>  <P>PATHNAME OF LOCAL FILE<BR>
868  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">
869  <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="UPLOAD">  <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="UPLOAD">
# Line 847  function Error($title,$text="") { Line 895  function Error($title,$text="") {
895    
896  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
897    
 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>" ;  
         EndHTML() ;  
         exit ;  
   
 } // end function CreateHash  
   
 //////////////////////////////////////////////////////////////////  
   
898  function NoEntry() {  function NoEntry() {
899    
900          $user = $GLOBALS["PHP_AUTH_USER"] ;          $user = $GLOBALS["PHP_AUTH_USER"] ;
# Line 879  function NoEntry() { Line 904  function NoEntry() {
904          $title = "(401 Unauthorized)" ;          $title = "(401 Unauthorized)" ;
905          $text  = "No trespassing !" ;          $text  = "No trespassing !" ;
906          StartHTML($title,$text) ;          StartHTML($title,$text) ;
 ?>  
907    
 <FORM ACTION="<?= $self ?>?HASH=create" METHOD="POST">  
 <INPUT TYPE="HIDDEN" NAME="USER" VALUE="<?= $user ?>">  
 <INPUT TYPE="HIDDEN" NAME="PW" VALUE="<?= $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>  
   
 <?php  
908          EndHTML() ;          EndHTML() ;
909          exit ;          exit ;
910  }  }
911    
912  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
913    
914  function Logit($target,$msg) {  function LogIt($target,$msg) {
915    
916          $dir=dirname($target);          $dir=dirname($target);
917          if (! file_exists($dir."/.log")) {          if (! file_exists($dir."/.log")) {
# Line 919  function Logit($target,$msg) { Line 931  function Logit($target,$msg) {
931    
932  function WriteNote($target,$msg) {  function WriteNote($target,$msg) {
933    
934            $target=stripSlashes($target);
935          $dir=dirname($target);          $dir=dirname($target);
936          if (! file_exists($dir."/.note")) {          if (! file_exists($dir."/.note")) {
937                  mkdir($dir."/.note",0700);                  mkdir($dir."/.note",0700);
# Line 935  function WriteNote($target,$msg) { Line 948  function WriteNote($target,$msg) {
948    
949  function ReadNote($target) {  function ReadNote($target) {
950    
951            $target=stripSlashes($target);
952          $dir=dirname($target);          $dir=dirname($target);
953          $file=basename($target);          $file=basename($target);
954          $msg="";          $msg="";
# Line 943  function ReadNote($target) { Line 957  function ReadNote($target) {
957                  $msg=fgets($note,4096);                  $msg=fgets($note,4096);
958                  fclose($note);                  fclose($note);
959          }          }
960          return $msg;          return StripSlashes($msg);
961    
962  }  }
963    
# Line 951  function ReadNote($target) { Line 965  function ReadNote($target) {
965    
966  function MoveTo($source,$folder) {  function MoveTo($source,$folder) {
967    
968            $source=stripSlashes($source);
969          $file=basename($source);          $file=basename($source);
970          if (! file_exists($folder)) {          if (! file_exists($folder)) {
971                  mkdir($folder,0700);                  mkdir($folder,0700);
# Line 962  function MoveTo($source,$folder) { Line 977  function MoveTo($source,$folder) {
977    
978  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
979    
980    function Lock($target) {
981    
982            $target=stripSlashes($target);
983            $dir=dirname($target);
984            if (! file_exists($dir."/.lock")) {
985                    mkdir($dir."/.lock",0700);
986            }
987            $file=basename($target);
988    
989            if (file_exists("$dir/.lock/$file")) {
990                    Logit($target,"attempt to locked allready locked file!");
991            } else {
992                    $lock=fopen("$dir/.lock/$file","w");
993                    fputs($lock,"$GLOBALS[gblUserName]\n");
994                    fclose($lock);
995    
996                    Logit($target,"file locked");
997            }
998    
999    }
1000    
1001    function CheckLock($target) {
1002    
1003            $target=stripSlashes($target);
1004            $dir=dirname($target);
1005            $file=basename($target);
1006            $msg=0;
1007            if (file_exists($dir."/.lock/$file")) {
1008                    $lock=fopen("$dir/.lock/$file","r");
1009                    $msg=fgets($lock,4096);
1010                    fclose($lock);
1011            }
1012            return chop($msg);
1013    
1014    }
1015    
1016    function Unlock($target) {
1017    
1018            $target=stripSlashes($target);
1019            $dir=dirname($target);
1020            $file=basename($target);
1021            if (file_exists($dir."/.lock/$file")) {
1022                    unlink("$dir/.lock/$file");
1023                    Logit($target,"file unlocked");
1024            } else {
1025                    Logit($target,"attempt to unlocked non-locked file!");
1026            }
1027    
1028    }
1029    
1030    //////////////////////////////////////////////////////////////////
1031    
1032    function urlpath($url) {
1033            $url=urlencode(StripSlashes("$url"));
1034            $url=str_replace("%2F","/",$url);
1035            $url=str_replace("+","%20",$url);
1036            return($url);
1037    }
1038    
1039    //////////////////////////////////////////////////////////////////
1040    
1041    function safe_rename($from,$to) {
1042            if (file_exists($from) && is_writable(dirname($to))) {
1043                    rename($from,$to);
1044            }
1045    }
1046    
1047    //////////////////////////////////////////////////////////////////
1048    
1049    // recursivly delete directory
1050    
1051    function rrmdir($dir) {
1052            $handle=opendir($dir);
1053            while ($file = readdir($handle)) {
1054                    if ($file != "." && $file != "..") {
1055                            if (is_dir("$dir/$file"))
1056                                    rrmdir("$dir/$file");
1057                            else
1058                                    if (! @unlink("$dir/$file")) return(0);
1059                    }
1060            }
1061            closedir($handle);
1062            return @rmdir($dir);
1063    }
1064    
1065    //////////////////////////////////////////////////////////////////
1066    
1067    function ChangeLog($target,$msg) {
1068    
1069            global $gblFsRoot;
1070            $log=fopen("$gblFsRoot/.changelog","a+");
1071            if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot)
1072                    $target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot));
1073            fputs($log,time()."\t$target\t$GLOBALS[gblUserName]\t$msg\n");
1074            fclose($log);
1075    
1076    }
1077    
1078    function DisplayChangeLog($day) {
1079    
1080            global $gblFsRoot;
1081            if (!file_exists("$gblFsRoot/.changelog")) return;
1082            $log=fopen("$gblFsRoot/.changelog","r");
1083            $logarr = array();
1084            while($line = fgetcsv($log,255,"\t")) {
1085                    if ($day!=1 || ($day==1 && (time()-$line[0] < 24*60*60))) {
1086                            array_unshift($logarr,array($line[0],$line[1],$line[2],$line[3]));
1087                    }
1088            }
1089            fclose($log);
1090            $cl1=" class=LST"; $cl2="";
1091            print "<table border=0 width=100%>\n";
1092            while ($e = array_shift($logarr)) {
1093                    $cl=$cl1; $cl1=$cl2; $cl2=$cl;
1094                    $date = date("$GLOBALS[gblDateFmt]", $e[0]);
1095                    $time = date("$GLOBALS[gblTimeFmt]", $e[0]);
1096                    $dir = dirname($e[1]);
1097                    $file = basename($e[1]);
1098                    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";
1099            }
1100            print "</table>";
1101            print "<p>".GifIcon(up)." Back to <a href=$GLOBALS[PHP_SELF]>front page</a>.</p>";
1102    }
1103    
1104    //////////////////////////////////////////////////////////////////
1105    
1106  // MAIN PROGRAM  // MAIN PROGRAM
1107  // ============  // ============
1108  // query parameters: capital letters  // query parameters: capital letters
# Line 977  function MoveTo($source,$folder) { Line 1118  function MoveTo($source,$folder) {
1118          // forks before authentication: style sheet and hash          // forks before authentication: style sheet and hash
1119          // creation if password not yet set.          // creation if password not yet set.
1120          if ($STYLE == "get") { CSS() ; exit ; }          if ($STYLE == "get") { CSS() ; exit ; }
1121          if ($HASH != "") {  
1122                  CreateHash($USER, $PW) ;          $htusers_file=dirname($SCRIPT_FILENAME)."/.htusers";
1123                  exit ;          if (! file_exists($htusers_file)) {
1124                    if (is_writable($htuser_file)) {
1125                            $htusers=fopen($htusers_file,"a+");
1126                            fputs($htusers,"# Change owner of $htusers_file to root !!\n");
1127                            fputs($htusers,"demo:full name:[md5_hash|auth_*]:e-mail\n");
1128                            fclose($htusers);
1129                    } else {
1130                            Error("Can't create proto user file!","Please make directory <tt>".dirname($htusers_file)."</tt> writable or create <tt>.htusers</tt> file by hand using <tt>adduser.pl</tt> script!");
1131                            exit;
1132                    }
1133          }          }
1134            $htusers=fopen($htusers_file,"r");
1135            while($user = fgetcsv($htusers,255,":")) {
1136                    if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) {
1137                            $gblUserName=$user[1];
1138                            $gblPw=$user[2];
1139                            if (substr($gblPw,0,5) == "auth_" && file_exists("$gblIncDir/$gblPw.php")) {
1140                                    require("$gblIncDir/$gblPw.php");
1141                                    if ($gblPw($user)) {
1142                                            $gblPw=md5($PHP_AUTH_USER.$PHP_AUTH_PW);
1143                                    } else {
1144                                            $gblPw="error".md5($PHP_AUTH_USER.$PHP_AUTH_PW);
1145                                    }
1146                            }
1147                            $gblEmail=$user[3];
1148                            continue ;
1149                    }
1150            }
1151            fclose($htusers);
1152    
1153          // authentication if $gblAuth == true          // authentication failure
1154          if ( $gblAuth && $gblHash($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ||          if ( md5($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ||
1155                  isset($relogin) && $gblPw == $relogin ) {                  isset($relogin) && $gblPw == $relogin ) {
1156                  header("WWW-authenticate: basic realm=\"$SERVER_NAME\"") ;                  header("WWW-authenticate: basic realm=\"$HTTP_HOST\"") ;
1157                  header("HTTP/1.0 401 Unauthorized") ;                  header("HTTP/1.0 401 Unauthorized") ;
1158                  NoEntry() ;                  NoEntry() ;
1159                  exit ;                  exit ;
# Line 1008  function MoveTo($source,$folder) { Line 1176  function MoveTo($source,$folder) {
1176          // i.e. below $gblFsRoot.          // i.e. below $gblFsRoot.
1177    
1178          $relScriptDir = dirname($SCRIPT_NAME) ;                  $relScriptDir = dirname($SCRIPT_NAME) ;        
1179          // i.e. /siteman          // i.e. /docman
1180    
1181          $fsScriptDir  = dirname($SCRIPT_FILENAME) ;              $fsScriptDir  = dirname($SCRIPT_FILENAME) ;    
1182          // i.e. /home/httpd/html/siteman          // i.e. /home/httpd/html/docman
1183    
1184          $gblFsRoot = substr($fsScriptDir,0,          // start on server root
1185            strlen($fsScriptDir)-strlen($relScriptDir)) ;  //      $gblFsRoot = substr($fsScriptDir,0, strlen($fsScriptDir)-strlen($relScriptDir)) ;
1186            // or on script root
1187            $gblFsRoot = $fsScriptDir;
1188          // i.e. /home/httpd/html          // i.e. /home/httpd/html
1189    
1190          $fsDir = $gblFsRoot . $relDir ; // current directory          $fsDir = $gblFsRoot . $relDir ; // current directory
1191          if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ;          if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ;
1192            
1193            if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") {
1194                    $webRoot  = "https://";
1195            } else {
1196                    $webRoot  = "http://";
1197            }
1198            $webRoot .= $GLOBALS["HTTP_HOST"] . $relScriptDir;
1199    
1200            $FN=stripSlashes($FN);
1201    
1202          switch ($POSTACTION) {          switch ($POSTACTION) {
1203          case "UPLOAD" :          case "UPLOAD" :
1204                  if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;                  if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;
# Line 1028  function MoveTo($source,$folder) { Line 1207  function MoveTo($source,$folder) {
1207                  // TODO : should rather check for escapeshellcmds                  // TODO : should rather check for escapeshellcmds
1208                  // but maybe RFC 18xx asserts safe filenames ....                  // but maybe RFC 18xx asserts safe filenames ....
1209                  $source = $FN ;                  $source = $FN ;
1210                  $target = $fsDir . "/" . $FN_name ;                  if (! file_exists($source)) {
1211                            Error("You must select file with browse to upload it!");
1212                    }
1213                    if (! isset($FILENAME)) {       // from update file
1214                            $target = "$fsDir/$FN_name" ;
1215                    } else {
1216                            $target = "$fsDir/$FILENAME";
1217                    }
1218    
1219                  // backup old files first                  // backup old files first
1220                  $dir=dirname($target);                  $dir=dirname($target);
# Line 1042  function MoveTo($source,$folder) { Line 1228  function MoveTo($source,$folder) {
1228                  for($i=$GLOBALS[gblNumBackups]-1;$i>0;$i--) {                  for($i=$GLOBALS[gblNumBackups]-1;$i>0;$i--) {
1229                          MoveTo("$dir/.bak/$i/$file","$dir/.bak/".($i+1)."/");                          MoveTo("$dir/.bak/$i/$file","$dir/.bak/".($i+1)."/");
1230                  }                  }
1231                  MoveTo($target,$dir."/.bak/1/".$file);                  MoveTo($target,$dir."/.bak/1/");
1232    
1233                  copy($source,$target) ;                  copy($source,$target) ;
1234                  chmod($target,$gblFilePerms) ;                  chmod($target,$gblFilePerms) ;
1235                  clearstatcache() ;                  clearstatcache() ;
1236                  Logit($target,"uploaded");                  Logit($target,"uploaded");
1237                    if (isset($FILENAME)) {
1238                            Unlock($target);
1239                    }
1240                    ChangeLog($target,"updated");
1241                  break ;                  break ;
1242    
1243          case "SAVE" :          case "SAVE" :
1244                  $path = $gblFsRoot . escapeshellcmd($RELPATH) ;                  $path = $gblFsRoot . $RELPATH ;
1245                    $path=stripSlashes($path);
1246                  $writable = is_writeable($path) ;                  $writable = is_writeable($path) ;
1247                  $legaldir = is_writeable(dirname($path)) ;                  $legaldir = is_writeable(dirname($path)) ;
1248                  $exists   = (file_exists($path)) ? 1 : 0 ;                  $exists   = (file_exists($path)) ? 1 : 0 ;
# Line 1059  function MoveTo($source,$folder) { Line 1250  function MoveTo($source,$folder) {
1250                  if (!($writable || (!$exists && $legaldir)))                  if (!($writable || (!$exists && $legaldir)))
1251                          Error("Write denied",$RELPATH) ;                          Error("Write denied",$RELPATH) ;
1252                  $fh = fopen($path, "w") ;                  $fh = fopen($path, "w") ;
1253                    $FILEDATA=stripSlashes($FILEDATA);
1254                  fwrite($fh,$FILEDATA) ;                  fwrite($fh,$FILEDATA) ;
1255                  fclose($fh) ;                  fclose($fh) ;
1256                  clearstatcache() ;                  clearstatcache() ;
1257                  Logit($path,"saved changes");                  Logit($path,"saved changes");
1258                    ChangeLog($path,"saved changes");
1259                  break ;                  break ;
1260    
1261          case "CREATE" :          case "CREATE" :
# Line 1073  function MoveTo($source,$folder) { Line 1266  function MoveTo($source,$folder) {
1266                  $relPath = $relDir . "/" . $FN ;                  $relPath = $relDir . "/" . $FN ;
1267                  switch ( $T ) {                  switch ( $T ) {
1268                  case "D" :  // create a directory                  case "D" :  // create a directory
1269                    if ( ! @mkdir($path,$gblDirPerms) )                          if ( ! @mkdir($path,$gblDirPerms) )
1270                      Error("Mkdir failed",$relPath) ; // eg. if it exists                                  Error("Mkdir failed",$relPath) ; // eg. if it exists
1271                    clearstatcache() ;                          clearstatcache() ;
1272                    break ;                          break ;
1273                  case "F" :  // create a new file                  case "F" :  // create a new file
1274  // this functionality is doubled in DetailView().  // this functionality is doubled in DetailView().
1275  // better keep it here altogether  // better keep it here altogether
1276  // chmod perms to $gblFilePerms  // chmod perms to $gblFilePerms
1277                    if ( file_exists($path) && !is_writable($path) )                          if ( file_exists($path) && !is_writable($path) )
1278                      Error("File not writable", $relPath) ;                                  Error("File not writable", $relPath) ;
1279                    $tstr = $PHP_SELF . "?A=E&D=" . $relDir . "&F=" . $FN ;                          $fh = fopen($path, "w+") ;
1280                    header("Location: " . $tstr) ;                          if ($fh) {
1281                    exit ;                                  fputs($fh,"\n");
1282                                    fclose($fh) ;
1283                                    LogIt($path,"file created");
1284                            } else {
1285                                    Error("Creation of file $relPath failed -- $path");
1286                            }
1287                            $tstr = "$PHP_SELF?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ;
1288                            header("Location: " . $tstr) ;
1289                            ChangeLog($target,"created");
1290                            exit ;
1291                  }                  }
1292                  break ;                  break ;
1293    
# Line 1111  function MoveTo($source,$folder) { Line 1313  function MoveTo($source,$folder) {
1313                                  exit ;                                  exit ;
1314                          } else {                          } else {
1315                                  Logit($path,"file deleted");                                  Logit($path,"file deleted");
                                 if (! file_exists("$dir/.del/.log")) {  
                                         mkdir("$dir/.del/.log",0700);  
                                 }  
1316                                  MoveTo("$dir/.log/$file","$dir/.del/.log/");                                  MoveTo("$dir/.log/$file","$dir/.del/.log/");
1317                                  MoveTo("$dir/.note/$file","$dir/.del/.note/");                                  MoveTo("$dir/.note/$file","$dir/.del/.note/");
1318                                    MoveTo("$dir/.lock/$file","$dir/.del/.lock/");
1319                          }                          }
1320                  }                  }
1321                  else {  // delete directory                  else {  // delete directory
1322                    if ( ! @rmdir($fsDir) ) {                    if ( ! @rrmdir($fsDir) ) {
1323                      Error("Rmdir failed", $tstr . $fsDir) ;                      Error("Rmdir failed", $tstr . $fsDir) ;
1324                    }                    }
1325                    else {                    else {
# Line 1138  function MoveTo($source,$folder) { Line 1338  function MoveTo($source,$folder) {
1338                  MoveTo("$fsDir/.del/$file","$fsDir/");                  MoveTo("$fsDir/.del/$file","$fsDir/");
1339                  MoveTo("$fsDir/.del/.log/$file","$fsDir/.log/");                  MoveTo("$fsDir/.del/.log/$file","$fsDir/.log/");
1340                  MoveTo("$fsDir/.del/.note/$file","$fsDir/.note/");                  MoveTo("$fsDir/.del/.note/$file","$fsDir/.note/");
1341                    MoveTo("$fsDir/.del/.lock/$file","$fsDir/.lock/");
1342    
1343                  break ;                  break ;
1344    
# Line 1145  function MoveTo($source,$folder) { Line 1346  function MoveTo($source,$folder) {
1346                  if ( $CONFIRM != "on" ) break ;                  if ( $CONFIRM != "on" ) break ;
1347    
1348                  Logit("$fsDir/$FN","renamed $FN to $NEWNAME");                  Logit("$fsDir/$FN","renamed $FN to $NEWNAME");
1349                  rename("$fsDir/$FN","$fsDir/$NEWNAME");                  safe_rename("$fsDir/$FN","$fsDir/$NEWNAME");
1350                  rename("$fsDir/.log/$FN","$fsDir/.log/$NEWNAME");                  safe_rename("$fsDir/.log/$FN","$fsDir/.log/$NEWNAME");
1351                    safe_rename("$fsDir/.note/$FN","$fsDir/.note/$NEWNAME");
1352                    safe_rename("$fsDir/.lock/$FN","$fsDir/.lock/$NEWNAME");
1353                    for($i=0;$i<=$GLOBALS[gblNumBackups];$i++) {
1354                            safe_rename("$fsDir/.bak/$i/$FN","$fsDir/.bak/$i/$NEWNAME");
1355                    }
1356    
1357                  break ;                  break ;
1358    
# Line 1154  function MoveTo($source,$folder) { Line 1360  function MoveTo($source,$folder) {
1360                  WriteNote("$fsDir/$FN","$NOTE");                  WriteNote("$fsDir/$FN","$NOTE");
1361                  break ;                  break ;
1362    
1363            case "UNLOCK" :  
1364                    if ( $CONFIRM != "on" ) break ;
1365                    Unlock("$fsDir/$FN");
1366                    break ;
1367    
1368          default :          default :
1369                  // user hit "CANCEL" or undefined action                  // user hit "CANCEL" or undefined action
1370          }          }
# Line 1169  function MoveTo($source,$folder) { Line 1380  function MoveTo($source,$folder) {
1380          // $A=U : upload to path given in $D          // $A=U : upload to path given in $D
1381          // $A=E : display detail of file $D/$F and edit          // $A=E : display detail of file $D/$F and edit
1382          // $A=C : display code in file $D/$F          // $A=C : display code in file $D/$F
1383            // $A=Co : checkout file $D/$F
1384            // $A=Ci : checkin file $D/$F
1385            // $A=V : view file (do nothing except log)
1386          // default : display directory $D          // default : display directory $D
1387            
1388          switch ($A) {          switch ($A) {
1389          case "U" :          case "U" :
1390                  // upload to $relDir                  // upload to $relDir
1391                  if (!is_writeable($gblFsRoot . $relDir))                  if (!is_writeable($gblFsRoot . $relDir))
1392                          Error("Write access denied",$relDir) ;                          Error("Write access denied",$relDir) ;
1393                  $text  = "Use this page to upload a single " ;                  $text  = "Use this page to upload a single " ;
1394                  $text .= "file to <B>$SERVER_NAME</B>." ;                  $text .= "file to <B>$HTTP_HOST</B>." ;
1395                  StartHTML("(Upload Page)", $text) ;                  StartHTML("(Upload Page)", $text) ;
1396                  UploadPage($gblFsRoot, $relDir) ;                  UploadPage($gblFsRoot, $relDir) ;
1397                  EndHTML() ;                  EndHTML() ;
1398                  exit ;                  exit ;
1399          case "E" :          case "E" :
1400                    $F=stripSlashes($F);
1401                  // detail of $relDir/$F                  // detail of $relDir/$F
1402                  if (is_file("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ;                  if (is_file("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ;
1403                  exit ;                  exit ;
1404          case "C" :          case "C" :
1405                    $F=stripSlashes($F);
1406                  // listing of $relDir/$F                  // listing of $relDir/$F
1407                  DisplayCode($gblFsRoot, $relDir, $F) ;                  DisplayCode($gblFsRoot, $relDir, $F) ;
1408                  exit ;                  exit ;
1409            case "Co" :
1410                    // checkout
1411                    Lock("$gblFsRoot/$relDir/$F");
1412                    header("Content-Disposition: attachment; filename=$F" );
1413                    Header("Location: $webRoot".urlpath("$relDir/$F"));
1414                    exit;
1415            case "Ci" :
1416                    $F=stripSlashes($F);
1417                    // upload && update to $relDir
1418                    if (!is_writeable($gblFsRoot . $relDir))
1419                            Error("Write access denied",$relDir) ;
1420                    $text  = "Use this page to update a single " ;
1421                    $text .= "file to <B>$HTTP_HOST</B>." ;
1422                    StartHTML("(Update file Page)", $text) ;
1423                    UploadPage($gblFsRoot, $relDir, $F) ;
1424                    EndHTML() ;
1425                    exit ;
1426            case "V" :
1427                    // view
1428                    LogIt("$gblFsRoot/$relDir/$F","viewed");
1429                    header("Content-Disposition: attachment; filename=$F" );
1430                    Header("Location: $webRoot".urlpath("$relDir/$F"));
1431                    exit;
1432            case "Ch" :
1433                    StartHTML("(File changes)","All changes chronologicaly...");
1434                    DisplayChangeLog(0);    // all
1435                    EndHTML() ;
1436                    exit;
1437            case "Ch1" :
1438                    StartHTML("(File changes)","Changes to files in last day...");
1439                    DisplayChangeLog(1);
1440                    EndHTML() ;
1441                    exit;
1442          }          }
1443    
1444          // default: display directory $relDir          // default: display directory $relDir

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.31

  ViewVC Help
Powered by ViewVC 1.1.26