/[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.30 by dpavlin, Fri Jan 26 12:39:57 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) {          $htusers_file=dirname($SCRIPT_FILENAME)."/.htusers";
87                  $htusers_file=dirname($SCRIPT_FILENAME)."/.htusers";          if (! file_exists($htusers_file)) {
88                  if (! file_exists($htusers_file)) {                  $htusers=fopen($htusers_file,"a+");
89                          $htusers=fopen($htusers_file,"a+");                  fputs($htusers,"# Change owner of $htusers_file to root !!\n");
90                          fputs($htusers,"# Change owner of $htusers_file to root !!\n");                  fputs($htusers,"demo:full name:[md5_hash|auth_*]:e-mail\n");
91                          fputs($htusers,"demo:full name:md5_hash\n");                  fclose($htusers);
92                          fclose($htusers);          }
93                  }          $htusers=fopen($htusers_file,"r");
94                  $htusers=fopen($htusers_file,"r");          while($user = fgetcsv($htusers,255,":")) {
95                  while($user = fgetcsv($htusers,255,":")) {                  if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) {
96                          if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) {                          $gblUserName=$user[1];
97                                  $gblUserName=$user[1];                          $gblPw=$user[2];
98                                  $gblPw=$user[2];                          if (substr($gblPw,0,5) == "auth_" && file_exists("$gblIncDir/$gblPw.php")) {
99                                  continue ;                                  require("$gblIncDir/$gblPw.php");
100                                    if ($gblPw($user)) {
101                                            $gblPw=md5($PHP_AUTH_USER.$PHP_AUTH_PW);
102                                    } else {
103                                            $gblPw="error".md5($PHP_AUTH_USER.$PHP_AUTH_PW);
104                                    }
105                          }                          }
106                            $gblEmail=$user[3];
107                            continue ;
108                  }                  }
                 fclose($htusers);  
109          }          }
110            fclose($htusers);
111    
112            // date format
113  //      $gblDateFmt="D, F d, Y";  //      $gblDateFmt="D, F d, Y";
 //      $gblTimeFmt="g:i:sA";  
   
114          $gblDateFmt="Y-m-d";          $gblDateFmt="Y-m-d";
115    
116            // time format
117    //      $gblTimeFmt="g:i:sA";
118          $gblTimeFmt="H:i:s";          $gblTimeFmt="H:i:s";
119    
120  // Number of backup files to keep          // Number of backup files to keep
121          $gblNumBackups=5;          $gblNumBackups=3;
122    
123            // show red star if newer than ... days
124            $gblModDays=1;
125    
126          // choose GifIcon below unless you have the M$          // choose GifIcon below unless you have the M$
127          // WingDings font installed on your system          // WingDings font installed on your system
128    
129          $gblIcon = "GifIcon" ;          // MockIcon or GifIcon          $gblIcon="GifIcon";             // MockIcon or GifIcon
130    
131          // the directory below should be /icons/ or /icons/small/          // the directory below should be /icons/ or /icons/small/
132          // on Apache; a set of icons is included in the distribution          // on Apache; a set of icons is included in the distribution
133    
134          $gblIconLocation = "/icons/" ;          $gblIconLocation="/icons/";
135    
136          // files you want to be able to edit in text mode          // files you want to be able to edit in text mode
137          // and view with (primitive) syntax highlighting          // and view with (primitive) syntax highlighting
# Line 150  TODO: Line 150  TODO:
150    
151  function StartHTML($title,$text="") {  function StartHTML($title,$text="") {
152    
153          $title = "Site Manager " . $title ;          $title = "Document Manager " . $title ;
154          $host  = $GLOBALS["HTTP_HOST"] ;          $host  = $GLOBALS["HTTP_HOST"] ;
155          $self  = $GLOBALS["PHP_SELF"] ;          $self  = $GLOBALS["PHP_SELF"] ;
156  ?>  ?>
# Line 184  function EndHTML() { Line 184  function EndHTML() {
184  <B><?= date($GLOBALS[gblDateFmt]) ?> -  <B><?= date($GLOBALS[gblDateFmt]) ?> -
185  <?= date($GLOBALS[gblTimeFmt]) ?> -  <?= date($GLOBALS[gblTimeFmt]) ?> -
186  <?= $GLOBALS[gblUserName] ?>  <?= $GLOBALS[gblUserName] ?>
187  <small> [<a href="<?= $PHP_SELF ?>?relogin=<?= $GLOBALS[gblPw] ?>">logout</a>]</small>  <small> [<a href="<?= $GLOBALS["PHP_SELF"] ?>?relogin=<?= $GLOBALS[gblPw] ?>">logout</a>]</small>
188  </B>  </B>
189  <BR>ANYPORTAL(php) Site Manager  <BR>ANYPORTAL(php) Site Manager
190  <br><small>  <br><small>
# Line 194  function EndHTML() { Line 194  function EndHTML() {
194  </small>  </small>
195  </P>  </P>
196  <BR>  <BR>
197  <? include(".debug.inc") ?>  <? //include(".debug.inc") ?>
198  <BR><BR></BODY></HTML>  <BR><BR></BODY></HTML>
199    
200  <?php  <?php
# Line 240  function DetailPage($fsRoot,$relDir,$fn) Line 240  function DetailPage($fsRoot,$relDir,$fn)
240          $ext      = strtolower(strrchr($relPath,".")) ;          $ext      = strtolower(strrchr($relPath,".")) ;
241          $editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) ;          $editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) ;
242          $writable = is_writeable($fsPath) ;          $writable = is_writeable($fsPath) ;
243            $file_lock = CheckLock($fsPath);
244    
245          if (!$editable && !$exists)          if (!$editable && !$exists)
246                  Error("Creation unsupported for type",$relPath) ;                  Error("Creation unsupported for type",$relPath) ;
# Line 268  function DetailPage($fsRoot,$relDir,$fn) Line 269  function DetailPage($fsRoot,$relDir,$fn)
269    
270          }          }
271    
272          if ( $editable && ($writable || !$exists) ) {          if ( $editable && ($writable || !$exists) && !$file_lock ) {
273                  $fh = fopen($fsPath,"a+") ;                  $fh = fopen($fsPath,"a+") ;
274                  rewind($fh) ;                  rewind($fh) ;
275                  $fstr = fread($fh,filesize($fsPath)) ;                  $fstr = fread($fh,filesize($fsPath)) ;
# Line 294  echo($fstr) ; ?></TEXTAREA> Line 295  echo($fstr) ; ?></TEXTAREA>
295    
296  <?php  <?php
297          }          }
298          else if ( strstr( join(" ",$gblImages), $ext ) ) {            if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) {  
299            $info  = getimagesize($fsPath) ;                  $info  = getimagesize($fsPath) ;
300            $tstr  = "<IMG SRC=\"". $relPath . "\" BORDER=0 " ;                  $tstr = "<IMG SRC=\"".urlpath($relPath)."\" BORDER=0 " ;
301            $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;                  $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;
302            $tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ;                  $tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ;
303            echo htmlentities($tstr) . "<BR><BR>" . $tstr ;  //              echo htmlentities($tstr) . "<BR><BR>" . $tstr ;
304                    echo $tstr ;
305          }          }
306    
307  ?>  ?>
308    
309  <FORM ACTION="<?= $self ; ?>" METHOD="POST">  <FORM ACTION="<?= $self ; ?>" METHOD="POST">
# Line 309  echo($fstr) ; ?></TEXTAREA> Line 312  echo($fstr) ; ?></TEXTAREA>
312  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR>  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR>
313    
314  <?php  <?php
315    
316            if ($file_lock) {
317    ?>
318    <hr>
319    <SPAN TITLE="Check OK and click UNLOCK to remove lock on file.">
320    <B>OK TO FORCE LOCK REMOVAL ON "<?= $fn ; ?>" HELD BY <?= $file_lock ?>? </B></SPAN>
321    <INPUT TYPE="CHECKBOX" NAME="CONFIRM">
322    <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="UNLOCK">
323    <?
324            } // file_lock
325    
326          if (substr($fn,0,4) == ".del") {          if (substr($fn,0,4) == ".del") {
327                  $action="UNDELETE";                  $action="UNDELETE";
328                  $desc="undelete previously deleted file";                  $desc="undelete previously deleted file";
# Line 336  echo($fstr) ; ?></TEXTAREA> Line 350  echo($fstr) ; ?></TEXTAREA>
350  <INPUT TYPE="CHECKBOX" NAME="CONFIRM">  <INPUT TYPE="CHECKBOX" NAME="CONFIRM">
351  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="RENAME">  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="RENAME">
352    
353    <?php
354            }       // exists && writable
355    ?>
356  <HR>  <HR>
357  <a name="note">  <a name="note">
358  <B>NOTE FOR "<?= $fn ; ?>":  <B>NOTE FOR "<?= $fn ; ?>":
# Line 343  echo($fstr) ; ?></TEXTAREA> Line 360  echo($fstr) ; ?></TEXTAREA>
360  </B></SPAN>  </B></SPAN>
361  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="NOTE">  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="NOTE">
362    
363    </FORM>
364    
365  <?php  <?php
         }  
         echo "</FORM>" ;  
366    
367          $logname=dirname("$fsDir/$fn")."/.log/".basename("$fsDir/$fn");          $name=basename("$fsDir/$fn");
368            $logname=dirname("$fsDir/$fn")."/.log/$name";
369            $bakdir=dirname("$fsDir/$fn")."/.bak";
370          if (file_exists($logname)) {          if (file_exists($logname)) {
                 print "<hr><br><b>CHANGES TO THIS FILE</b><br><table border=0 width=100%>\n";  
371                  $log=fopen($logname,"r");                  $log=fopen($logname,"r");
372                  $cl1=" class=lst"; $cl2="";                  $cl1=" class=LST"; $cl2="";
373                    $logarr = array();
374                  while($line = fgetcsv($log,255,"\t")) {                  while($line = fgetcsv($log,255,"\t")) {
375                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;
376                          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]));
377                  }                  }
378                  fclose($log);                  fclose($log);
379                    print "<hr><br><b>CHANGES TO THIS FILE</b><br><table border=0 width=100%>\n";
380                    $bakcount = 0;  // start from 0, skip fist backup (it's current)
381                    while ($e = array_shift($logarr)) {
382                            if (strstr($e[4],"upload")) {
383                                    if (file_exists("$bakdir/$bakcount/$name")) {
384                                            $e[4]="<a href=\"".urlpath(dirname($relPath)."/.bak/$bakcount/$name")."\">$e[4]</a>";
385                                    }
386                                    $bakcount++;
387                            }
388                            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";
389                    }
390                  print "</table>";                  print "</table>";
391          }          }
392    
# Line 590  function GifIcon($txt) { Line 620  function GifIcon($txt) {
620                  $d = "blank.gif" ;                  $d = "blank.gif" ;
621                  break ;                  break ;
622          case "checkout":          case "checkout":
623                  $d = "down.gif";                  $d = "box2.gif";
624                  break;                  break;
625          case "checkin":          case "checkin":
626                  $d = "up.gif";                  $d = "hand.up.gif";
627                    break;
628            case "locked":
629                    $d = "screw2.gif";
630                  break;                  break;
631          case "note":          case "note":
632                  $d = "quill.gif";                  $d = "quill.gif";
# Line 609  function GifIcon($txt) { Line 642  function GifIcon($txt) {
642    
643  function Navigate($fsRoot,$relDir) {  function Navigate($fsRoot,$relDir) {
644    
645          global $gblEditable, $gblIcon ;          global $gblEditable, $gblIcon, $gblModDays ;
646    
647          $self     = $GLOBALS["PHP_SELF"] ;          $self     = $GLOBALS["PHP_SELF"] ;
648          if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") {          if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") {
649                  $webRoot  = "https://" . $GLOBALS["SERVER_NAME"] ;                  $webRoot  = "https://" . $GLOBALS["HTTP_HOST"] ;
650          } else {          } else {
651                  $webRoot  = "http://" . $GLOBALS["SERVER_NAME"] ;                  $webRoot  = "http://" . $GLOBALS["HTTP_HOST"] ;
652          }          }
653          $fsDir    = $fsRoot . $relDir . "/" ; // current directory          $fsDir    = $fsRoot . $relDir . "/" ; // current directory
654    
# Line 655  function Navigate($fsRoot,$relDir) { Line 688  function Navigate($fsRoot,$relDir) {
688          // start navigation page          // start navigation page
689          $text  = "Use this page to add, delete";          $text  = "Use this page to add, delete";
690          if (! isset($show_deleted)) {          if (! isset($show_deleted)) {
691                  $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>";
692          }          }
693          $text .= " or revise files on this web site." ;          $text .= " or revise files on this web site." ;
694            $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>.";
695          StartHTML("(Navigate)",$text) ;          StartHTML("(Navigate)",$text) ;
696    
697          echo "<TABLE BORDER=0 CELLPADDING=2          echo "<TABLE BORDER=0 CELLPADDING=2
# Line 702  function Navigate($fsRoot,$relDir) { Line 736  function Navigate($fsRoot,$relDir) {
736  <TR><TD></TD><TD COLSPAN=5><HR><B><?= $webRoot . $relDir ?>  <TR><TD></TD><TD COLSPAN=5><HR><B><?= $webRoot . $relDir ?>
737  </B></TD></TR>  </B></TD></TR>
738  <TR><TD></TD><TD CLASS=TOP>DOCUMENT NAME</TD>  <TR><TD></TD><TD CLASS=TOP>DOCUMENT NAME</TD>
739  <TD><?= $gblIcon("blank") ?></TD>  <TD><?= $gblIcon("blank").$gblIcon("blank") ?></TD>
740  <TD CLASS=TOP>NOTE</TD>  <TD CLASS=TOP>NOTE</TD>
741  <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>
742    
# Line 724  function Navigate($fsRoot,$relDir) { Line 758  function Navigate($fsRoot,$relDir) {
758    
759                  $info_url=$self."?A=E&F=".urlencode($file)."&D=".urlencode($relDir);                  $info_url=$self."?A=E&F=".urlencode($file)."&D=".urlencode($relDir);
760    
761                  if ( ($mod + 30*86400) > time() ) {                  if ( ($mod + $gblModDays*86400) > time() ) {
762                          $a  = "<SPAN CLASS=RED TITLE=\"Newer" ;                          $a  = "<SPAN CLASS=RED TITLE=\"Newer" ;
763                          $a .= " than 30 days\"> * </SPAN>" ;                          $a .= " than $gblModDays days\"> * </SPAN>" ;
764                  }                  }
765    
766                  $tstr = $webRoot . $relDir . "/" . $file ;                  $file_lock=CheckLock($path);
767                  $tstr  = "<A HREF=\"" . $tstr . "\">" ;  
768                    $file_url_html="<A HREF=\"$self?A=V&F=".urlencode($file);
769                    $file_url_html.="&D=".urlencode($relDir);
770                    $file_url_html.="\" TITLE=\"View file\">" ;
771    
772                  if (substr($file,0,5) != ".del/") {                  if (substr($file,0,5) != ".del/") {
773                          $tstr .= $file . "</A>" . $a ;                          $file_url_html .= $file . "</A>" . $a ;
774                  } else {                  } else {
775                          $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>";
776                  }                  }
777    
778  //              $b = $gblIcon("checkout");                  $note_html="<a href=\"$info_url#note\">".$gblIcon("note")."</a>".ReadNote($path);
 //              $b .= $gblIcon("checkin");  
779    
780                  $ext = strtolower(strrchr($file,".")) ;                  $ext = strtolower(strrchr($file,".")) ;
781                  if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) {    
782                          $b .= "<A HREF=\"" . $self . "?A=C&F=" ;                  if ($file_lock) {
783                          $b .= urlencode($file) . "&D=" . urlencode($relDir) ;                          if ($file_lock == $GLOBALS[gblUserName]) {
784                          $b .= "\" TITLE=\"List contents\">" ;                                  $b.="<A HREF=\"$self?A=Ci&F=".urlencode($file);
785                          $b .= $gblIcon("view") . "</A>" ;                                  $b.="&D=".urlencode($relDir);
786                                    $b.="\" TITLE=\"Checkin (update) file on server\">" ;
787                                    $file_url_html=$b;
788                                    $b.=$gblIcon("checkin")."</A>" ;
789                                    $b.= $gblIcon("blank");
790                                    $file_url_html.="$file</a> $a";
791                                    $note_html = $gblIcon("blank")."<b>Please check-in (update) this file</b>";
792                            } else {
793                                    $b = $gblIcon("locked");
794                                    $b.= $gblIcon("blank");
795                                    $note_html = $gblIcon("blank")."<b>File locked by $file_lock</b>";
796                                    $file_url_html = "$file $a";
797                            }
798                  } else {                  } else {
799                          $b .= $gblIcon("blank");                          $b.="<A HREF=\"$self?A=Co&F=".urlencode($file);
800                            $b.="&D=".urlencode($relDir);
801                            $b.="\" TITLE=\"Checkout file for edit\">" ;
802                            $b.=$gblIcon("checkout")."</A>" ;
803    
804                            if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) {  
805                                    $b.="<A HREF=\"$self?A=C&F=".urlencode($file);
806                                    $b.="&D=".urlencode($relDir);
807                                    $b.="\" TITLE=\"List contents\">" ;
808                                    $b.=$gblIcon("view")."</A>" ;
809                            } else {
810                                    $b.= $gblIcon("blank");
811                            }
812                  }                  }
813    
814    
# Line 757  function Navigate($fsRoot,$relDir) { Line 817  function Navigate($fsRoot,$relDir) {
817  <TR><TD>  <TR><TD>
818  <A HREF="<?= $info_url ?>" TITLE="View/Edit">  <A HREF="<?= $info_url ?>" TITLE="View/Edit">
819  <?= $gblIcon($ext) ?></A></TD>  <?= $gblIcon($ext) ?></A></TD>
820  <TD CLASS=LST><?= $tstr ?></TD>  <TD CLASS=LST><?= $file_url_html ?></TD>
821  <TD CLASS=LST ALIGN=center><?= $b ?></TD>  <TD CLASS=LST ALIGN=center><?= $b ?></TD>
822  <TD CLASS=LST ALIGN=left><a href="<?= $info_url ?>#note"><?= $gblIcon("note") ?></a><?= ReadNote($path) ?></TD>  <TD CLASS=LST ALIGN=left><?= $note_html ?></TD>
823  <TD CLASS=LST><?= date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]",$mod) ?></TD>  <TD CLASS=LST><?= date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]",$mod) ?></TD>
824  <TD CLASS=LST><?= $sz ?>Bytes</TD></TR>  <TD CLASS=LST><?= $sz ?>Bytes</TD></TR>
825    
826  <?php  <?php
827            }  // iterate over files            }  // iterate over files
828          }  // end if no files          } else {  // end if no files
829    ?>
830     <TR><TD></TD><TD COLSPAN=5 CLASS=LST>
831      No files in this directory
832     </TD></TR>
833    <?
834            }
835    
836          if ($emptyDir) {          if ($emptyDir) {
837  ?>  ?>
# Line 785  function Navigate($fsRoot,$relDir) { Line 851  function Navigate($fsRoot,$relDir) {
851    
852  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>
853    
854    <?
855    if (file_exists(".info.inc")) {
856            print "<TR><TD></TD><TD COLSPAN=5>";
857            include(".info.inc");
858            print "</TD></TR>
859            <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>";
860    }
861    ?>
862    
863  <FORM METHOD="POST" ACTION="<?= $self ?>">  <FORM METHOD="POST" ACTION="<?= $self ?>">
864  <TR><TD></TD><TD COLSPAN=5 CLASS=BAR>CREATE NEW  <TR><TD></TD><TD COLSPAN=5 CLASS=BAR>CREATE NEW
865   <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 868  function Navigate($fsRoot,$relDir) {
868   <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE">   <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE">
869   <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">   <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">
870   <INPUT TYPE="SUBMIT" VALUE="CREATE"></NOBR>   <INPUT TYPE="SUBMIT" VALUE="CREATE"></NOBR>
871   <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  
872   </NOBR>   </NOBR>
873  </TD></TR>  </TD></TR>
874  </FORM>  </FORM>
# Line 806  function Navigate($fsRoot,$relDir) { Line 880  function Navigate($fsRoot,$relDir) {
880    
881  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
882    
883  function UploadPage($fsRoot, $relDir) {  function UploadPage($fsRoot, $relDir, $filename="") {
884    
885          $self = $GLOBALS["PHP_SELF"] ;          $self = $GLOBALS["PHP_SELF"] ;
886          if ($relDir == "") $relDir = "/" ;          if ($relDir == "") $relDir = "/" ;
# Line 816  function UploadPage($fsRoot, $relDir) { Line 890  function UploadPage($fsRoot, $relDir) {
890  <FORM ENCTYPE="multipart/form-data" METHOD="POST"  <FORM ENCTYPE="multipart/form-data" METHOD="POST"
891   ACTION="<?= $self ?>">   ACTION="<?= $self ?>">
892  DESTINATION DIRECTORY:<B><?= " " . $relDir ?></B>  DESTINATION DIRECTORY:<B><?= " " . $relDir ?></B>
893    <? if (isset($filename) && $filename!="") { ?>
894    <br>DESTINATION FILE:<B><?= " " . $filename ?></B>
895    <INPUT TYPE="HIDDEN" NAME="FILENAME" VALUE="<?= $filename ?>">
896    <? } ?>
897  <P>PATHNAME OF LOCAL FILE<BR>  <P>PATHNAME OF LOCAL FILE<BR>
898  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">
899  <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="UPLOAD">  <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="UPLOAD">
# Line 847  function Error($title,$text="") { Line 925  function Error($title,$text="") {
925    
926  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
927    
 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  
   
 //////////////////////////////////////////////////////////////////  
   
928  function NoEntry() {  function NoEntry() {
929    
930          $user = $GLOBALS["PHP_AUTH_USER"] ;          $user = $GLOBALS["PHP_AUTH_USER"] ;
# Line 879  function NoEntry() { Line 934  function NoEntry() {
934          $title = "(401 Unauthorized)" ;          $title = "(401 Unauthorized)" ;
935          $text  = "No trespassing !" ;          $text  = "No trespassing !" ;
936          StartHTML($title,$text) ;          StartHTML($title,$text) ;
 ?>  
   
 <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>  
937    
 <?php  
938          EndHTML() ;          EndHTML() ;
939          exit ;          exit ;
940  }  }
941    
942  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
943    
944  function Logit($target,$msg) {  function LogIt($target,$msg) {
945    
946          $dir=dirname($target);          $dir=dirname($target);
947          if (! file_exists($dir."/.log")) {          if (! file_exists($dir."/.log")) {
# Line 919  function Logit($target,$msg) { Line 961  function Logit($target,$msg) {
961    
962  function WriteNote($target,$msg) {  function WriteNote($target,$msg) {
963    
964            $target=stripSlashes($target);
965          $dir=dirname($target);          $dir=dirname($target);
966          if (! file_exists($dir."/.note")) {          if (! file_exists($dir."/.note")) {
967                  mkdir($dir."/.note",0700);                  mkdir($dir."/.note",0700);
# Line 935  function WriteNote($target,$msg) { Line 978  function WriteNote($target,$msg) {
978    
979  function ReadNote($target) {  function ReadNote($target) {
980    
981            $target=stripSlashes($target);
982          $dir=dirname($target);          $dir=dirname($target);
983          $file=basename($target);          $file=basename($target);
984          $msg="";          $msg="";
# Line 943  function ReadNote($target) { Line 987  function ReadNote($target) {
987                  $msg=fgets($note,4096);                  $msg=fgets($note,4096);
988                  fclose($note);                  fclose($note);
989          }          }
990          return $msg;          return StripSlashes($msg);
991    
992  }  }
993    
# Line 951  function ReadNote($target) { Line 995  function ReadNote($target) {
995    
996  function MoveTo($source,$folder) {  function MoveTo($source,$folder) {
997    
998            $source=stripSlashes($source);
999          $file=basename($source);          $file=basename($source);
1000          if (! file_exists($folder)) {          if (! file_exists($folder)) {
1001                  mkdir($folder,0700);                  mkdir($folder,0700);
# Line 962  function MoveTo($source,$folder) { Line 1007  function MoveTo($source,$folder) {
1007    
1008  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1009    
1010    function Lock($target) {
1011    
1012            $target=stripSlashes($target);
1013            $dir=dirname($target);
1014            if (! file_exists($dir."/.lock")) {
1015                    mkdir($dir."/.lock",0700);
1016            }
1017            $file=basename($target);
1018    
1019            if (file_exists("$dir/.lock/$file")) {
1020                    Logit($target,"attempt to locked allready locked file!");
1021            } else {
1022                    $lock=fopen("$dir/.lock/$file","w");
1023                    fputs($lock,"$GLOBALS[gblUserName]\n");
1024                    fclose($lock);
1025    
1026                    Logit($target,"file locked");
1027            }
1028    
1029    }
1030    
1031    function CheckLock($target) {
1032    
1033            $target=stripSlashes($target);
1034            $dir=dirname($target);
1035            $file=basename($target);
1036            $msg=0;
1037            if (file_exists($dir."/.lock/$file")) {
1038                    $lock=fopen("$dir/.lock/$file","r");
1039                    $msg=fgets($lock,4096);
1040                    fclose($lock);
1041            }
1042            return chop($msg);
1043    
1044    }
1045    
1046    function Unlock($target) {
1047    
1048            $target=stripSlashes($target);
1049            $dir=dirname($target);
1050            $file=basename($target);
1051            if (file_exists($dir."/.lock/$file")) {
1052                    unlink("$dir/.lock/$file");
1053                    Logit($target,"file unlocked");
1054            } else {
1055                    Logit($target,"attempt to unlocked non-locked file!");
1056            }
1057    
1058    }
1059    
1060    //////////////////////////////////////////////////////////////////
1061    
1062    function urlpath($url) {
1063            $url=urlencode(StripSlashes("$url"));
1064            $url=str_replace("%2F","/",$url);
1065            $url=str_replace("+","%20",$url);
1066            return($url);
1067    }
1068    
1069    //////////////////////////////////////////////////////////////////
1070    
1071    function safe_rename($from,$to) {
1072            if (file_exists($from) && is_writable(dirname($to))) {
1073                    rename($from,$to);
1074            }
1075    }
1076    
1077    //////////////////////////////////////////////////////////////////
1078    
1079    // recursivly delete directory
1080    
1081    function rrmdir($dir) {
1082            $handle=opendir($dir);
1083            while ($file = readdir($handle)) {
1084                    if ($file != "." && $file != "..") {
1085                            if (is_dir("$dir/$file"))
1086                                    rrmdir("$dir/$file");
1087                            else
1088                                    if (! @unlink("$dir/$file")) return(0);
1089                    }
1090            }
1091            closedir($handle);
1092            return @rmdir($dir);
1093    }
1094    
1095    //////////////////////////////////////////////////////////////////
1096    
1097    function ChangeLog($target,$msg) {
1098    
1099            global $gblFsRoot;
1100            $log=fopen("$gblFsRoot/.changelog","a+");
1101            if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot)
1102                    $target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot));
1103            fputs($log,time()."\t$target\t$GLOBALS[gblUserName]\t$msg\n");
1104            fclose($log);
1105    
1106    }
1107    
1108    function DisplayChangeLog($day) {
1109    
1110            global $gblFsRoot;
1111            if (!file_exists("$gblFsRoot/.changelog")) return;
1112            $log=fopen("$gblFsRoot/.changelog","r");
1113            $logarr = array();
1114            while($line = fgetcsv($log,255,"\t")) {
1115                    if ($day!=1 || ($day==1 && (time()-$line[0] < 24*60*60))) {
1116                            array_unshift($logarr,array($line[0],$line[1],$line[2],$line[3]));
1117                    }
1118            }
1119            fclose($log);
1120            $cl1=" class=LST"; $cl2="";
1121            print "<table border=0 width=100%>\n";
1122            while ($e = array_shift($logarr)) {
1123                    $cl=$cl1; $cl1=$cl2; $cl2=$cl;
1124                    $date = date("$GLOBALS[gblDateFmt]", $e[0]);
1125                    $time = date("$GLOBALS[gblTimeFmt]", $e[0]);
1126                    $dir = dirname($e[1]);
1127                    $file = basename($e[1]);
1128                    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";
1129            }
1130            print "</table>";
1131            print "<p>".GifIcon(up)." Back to <a href=$GLOBALS[PHP_SELF]>front page</a>.</p>";
1132    }
1133    
1134    //////////////////////////////////////////////////////////////////
1135    
1136  // MAIN PROGRAM  // MAIN PROGRAM
1137  // ============  // ============
1138  // query parameters: capital letters  // query parameters: capital letters
# Line 977  function MoveTo($source,$folder) { Line 1148  function MoveTo($source,$folder) {
1148          // forks before authentication: style sheet and hash          // forks before authentication: style sheet and hash
1149          // creation if password not yet set.          // creation if password not yet set.
1150          if ($STYLE == "get") { CSS() ; exit ; }          if ($STYLE == "get") { CSS() ; exit ; }
         if ($HASH != "") {  
                 CreateHash($USER, $PW) ;  
                 exit ;  
         }  
1151    
1152          // authentication if $gblAuth == true          // authentication failure
1153          if ( $gblAuth && $gblHash($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ||          if ( md5($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ||
1154                  isset($relogin) && $gblPw == $relogin ) {                  isset($relogin) && $gblPw == $relogin ) {
1155                  header("WWW-authenticate: basic realm=\"$SERVER_NAME\"") ;                  header("WWW-authenticate: basic realm=\"$HTTP_HOST\"") ;
1156                  header("HTTP/1.0 401 Unauthorized") ;                  header("HTTP/1.0 401 Unauthorized") ;
1157                  NoEntry() ;                  NoEntry() ;
1158                  exit ;                  exit ;
# Line 1008  function MoveTo($source,$folder) { Line 1175  function MoveTo($source,$folder) {
1175          // i.e. below $gblFsRoot.          // i.e. below $gblFsRoot.
1176    
1177          $relScriptDir = dirname($SCRIPT_NAME) ;                  $relScriptDir = dirname($SCRIPT_NAME) ;        
1178          // i.e. /siteman          // i.e. /docman
1179    
1180          $fsScriptDir  = dirname($SCRIPT_FILENAME) ;              $fsScriptDir  = dirname($SCRIPT_FILENAME) ;    
1181          // i.e. /home/httpd/html/siteman          // i.e. /home/httpd/html/docman
1182    
1183          $gblFsRoot = substr($fsScriptDir,0,          // start on server root
1184            strlen($fsScriptDir)-strlen($relScriptDir)) ;  //      $gblFsRoot = substr($fsScriptDir,0, strlen($fsScriptDir)-strlen($relScriptDir)) ;
1185            // or on script root
1186            $gblFsRoot = $fsScriptDir;
1187          // i.e. /home/httpd/html          // i.e. /home/httpd/html
1188    
1189          $fsDir = $gblFsRoot . $relDir ; // current directory          $fsDir = $gblFsRoot . $relDir ; // current directory
1190          if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ;          if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ;
1191            
1192            $FN=stripSlashes($FN);
1193    
1194          switch ($POSTACTION) {          switch ($POSTACTION) {
1195          case "UPLOAD" :          case "UPLOAD" :
1196                  if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;                  if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;
# Line 1028  function MoveTo($source,$folder) { Line 1199  function MoveTo($source,$folder) {
1199                  // TODO : should rather check for escapeshellcmds                  // TODO : should rather check for escapeshellcmds
1200                  // but maybe RFC 18xx asserts safe filenames ....                  // but maybe RFC 18xx asserts safe filenames ....
1201                  $source = $FN ;                  $source = $FN ;
1202                  $target = $fsDir . "/" . $FN_name ;                  if (! file_exists($source)) {
1203                            Error("You must select file with browse to upload it!");
1204                    }
1205                    if (! isset($FILENAME)) {       // from update file
1206                            $target = "$fsDir/$FN_name" ;
1207                    } else {
1208                            $target = "$fsDir/$FILENAME";
1209                    }
1210    
1211                  // backup old files first                  // backup old files first
1212                  $dir=dirname($target);                  $dir=dirname($target);
# Line 1042  function MoveTo($source,$folder) { Line 1220  function MoveTo($source,$folder) {
1220                  for($i=$GLOBALS[gblNumBackups]-1;$i>0;$i--) {                  for($i=$GLOBALS[gblNumBackups]-1;$i>0;$i--) {
1221                          MoveTo("$dir/.bak/$i/$file","$dir/.bak/".($i+1)."/");                          MoveTo("$dir/.bak/$i/$file","$dir/.bak/".($i+1)."/");
1222                  }                  }
1223                  MoveTo($target,$dir."/.bak/1/".$file);                  MoveTo($target,$dir."/.bak/1/");
1224    
1225                  copy($source,$target) ;                  copy($source,$target) ;
1226                  chmod($target,$gblFilePerms) ;                  chmod($target,$gblFilePerms) ;
1227                  clearstatcache() ;                  clearstatcache() ;
1228                  Logit($target,"uploaded");                  Logit($target,"uploaded");
1229                    if (isset($FILENAME)) {
1230                            Unlock($target);
1231                    }
1232                    ChangeLog($target,"updated");
1233                  break ;                  break ;
1234    
1235          case "SAVE" :          case "SAVE" :
1236                  $path = $gblFsRoot . escapeshellcmd($RELPATH) ;                  $path = $gblFsRoot . $RELPATH ;
1237                    $path=stripSlashes($path);
1238                  $writable = is_writeable($path) ;                  $writable = is_writeable($path) ;
1239                  $legaldir = is_writeable(dirname($path)) ;                  $legaldir = is_writeable(dirname($path)) ;
1240                  $exists   = (file_exists($path)) ? 1 : 0 ;                  $exists   = (file_exists($path)) ? 1 : 0 ;
# Line 1059  function MoveTo($source,$folder) { Line 1242  function MoveTo($source,$folder) {
1242                  if (!($writable || (!$exists && $legaldir)))                  if (!($writable || (!$exists && $legaldir)))
1243                          Error("Write denied",$RELPATH) ;                          Error("Write denied",$RELPATH) ;
1244                  $fh = fopen($path, "w") ;                  $fh = fopen($path, "w") ;
1245                    $FILEDATA=stripSlashes($FILEDATA);
1246                  fwrite($fh,$FILEDATA) ;                  fwrite($fh,$FILEDATA) ;
1247                  fclose($fh) ;                  fclose($fh) ;
1248                  clearstatcache() ;                  clearstatcache() ;
1249                  Logit($path,"saved changes");                  Logit($path,"saved changes");
1250                    ChangeLog($path,"saved changes");
1251                  break ;                  break ;
1252    
1253          case "CREATE" :          case "CREATE" :
# Line 1073  function MoveTo($source,$folder) { Line 1258  function MoveTo($source,$folder) {
1258                  $relPath = $relDir . "/" . $FN ;                  $relPath = $relDir . "/" . $FN ;
1259                  switch ( $T ) {                  switch ( $T ) {
1260                  case "D" :  // create a directory                  case "D" :  // create a directory
1261                    if ( ! @mkdir($path,$gblDirPerms) )                          if ( ! @mkdir($path,$gblDirPerms) )
1262                      Error("Mkdir failed",$relPath) ; // eg. if it exists                                  Error("Mkdir failed",$relPath) ; // eg. if it exists
1263                    clearstatcache() ;                          clearstatcache() ;
1264                    break ;                          break ;
1265                  case "F" :  // create a new file                  case "F" :  // create a new file
1266  // this functionality is doubled in DetailView().  // this functionality is doubled in DetailView().
1267  // better keep it here altogether  // better keep it here altogether
1268  // chmod perms to $gblFilePerms  // chmod perms to $gblFilePerms
1269                    if ( file_exists($path) && !is_writable($path) )                          if ( file_exists($path) && !is_writable($path) )
1270                      Error("File not writable", $relPath) ;                                  Error("File not writable", $relPath) ;
1271                    $tstr = $PHP_SELF . "?A=E&D=" . $relDir . "&F=" . $FN ;                          $fh = fopen($path, "w+") ;
1272                    header("Location: " . $tstr) ;                          if ($fh) {
1273                    exit ;                                  fputs($fh,"\n");
1274                                    fclose($fh) ;
1275                                    LogIt($path,"file created");
1276                            } else {
1277                                    Error("Creation of file $relPath failed -- $path");
1278                            }
1279                            $tstr = "$PHP_SELF?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ;
1280                            header("Location: " . $tstr) ;
1281                            ChangeLog($target,"created");
1282                            exit ;
1283                  }                  }
1284                  break ;                  break ;
1285    
# Line 1111  function MoveTo($source,$folder) { Line 1305  function MoveTo($source,$folder) {
1305                                  exit ;                                  exit ;
1306                          } else {                          } else {
1307                                  Logit($path,"file deleted");                                  Logit($path,"file deleted");
                                 if (! file_exists("$dir/.del/.log")) {  
                                         mkdir("$dir/.del/.log",0700);  
                                 }  
1308                                  MoveTo("$dir/.log/$file","$dir/.del/.log/");                                  MoveTo("$dir/.log/$file","$dir/.del/.log/");
1309                                  MoveTo("$dir/.note/$file","$dir/.del/.note/");                                  MoveTo("$dir/.note/$file","$dir/.del/.note/");
1310                                    MoveTo("$dir/.lock/$file","$dir/.del/.lock/");
1311                          }                          }
1312                  }                  }
1313                  else {  // delete directory                  else {  // delete directory
1314                    if ( ! @rmdir($fsDir) ) {                    if ( ! @rrmdir($fsDir) ) {
1315                      Error("Rmdir failed", $tstr . $fsDir) ;                      Error("Rmdir failed", $tstr . $fsDir) ;
1316                    }                    }
1317                    else {                    else {
# Line 1138  function MoveTo($source,$folder) { Line 1330  function MoveTo($source,$folder) {
1330                  MoveTo("$fsDir/.del/$file","$fsDir/");                  MoveTo("$fsDir/.del/$file","$fsDir/");
1331                  MoveTo("$fsDir/.del/.log/$file","$fsDir/.log/");                  MoveTo("$fsDir/.del/.log/$file","$fsDir/.log/");
1332                  MoveTo("$fsDir/.del/.note/$file","$fsDir/.note/");                  MoveTo("$fsDir/.del/.note/$file","$fsDir/.note/");
1333                    MoveTo("$fsDir/.del/.lock/$file","$fsDir/.lock/");
1334    
1335                  break ;                  break ;
1336    
# Line 1145  function MoveTo($source,$folder) { Line 1338  function MoveTo($source,$folder) {
1338                  if ( $CONFIRM != "on" ) break ;                  if ( $CONFIRM != "on" ) break ;
1339    
1340                  Logit("$fsDir/$FN","renamed $FN to $NEWNAME");                  Logit("$fsDir/$FN","renamed $FN to $NEWNAME");
1341                  rename("$fsDir/$FN","$fsDir/$NEWNAME");                  safe_rename("$fsDir/$FN","$fsDir/$NEWNAME");
1342                  rename("$fsDir/.log/$FN","$fsDir/.log/$NEWNAME");                  safe_rename("$fsDir/.log/$FN","$fsDir/.log/$NEWNAME");
1343                    safe_rename("$fsDir/.note/$FN","$fsDir/.note/$NEWNAME");
1344                    safe_rename("$fsDir/.lock/$FN","$fsDir/.lock/$NEWNAME");
1345                    for($i=0;$i<=$GLOBALS[gblNumBackups];$i++) {
1346                            safe_rename("$fsDir/.bak/$i/$FN","$fsDir/.bak/$i/$NEWNAME");
1347                    }
1348    
1349                  break ;                  break ;
1350    
# Line 1154  function MoveTo($source,$folder) { Line 1352  function MoveTo($source,$folder) {
1352                  WriteNote("$fsDir/$FN","$NOTE");                  WriteNote("$fsDir/$FN","$NOTE");
1353                  break ;                  break ;
1354    
1355            case "UNLOCK" :  
1356                    if ( $CONFIRM != "on" ) break ;
1357                    Unlock("$fsDir/$FN");
1358                    break ;
1359    
1360          default :          default :
1361                  // user hit "CANCEL" or undefined action                  // user hit "CANCEL" or undefined action
1362          }          }
# Line 1169  function MoveTo($source,$folder) { Line 1372  function MoveTo($source,$folder) {
1372          // $A=U : upload to path given in $D          // $A=U : upload to path given in $D
1373          // $A=E : display detail of file $D/$F and edit          // $A=E : display detail of file $D/$F and edit
1374          // $A=C : display code in file $D/$F          // $A=C : display code in file $D/$F
1375            // $A=Co : checkout file $D/$F
1376            // $A=Ci : checkin file $D/$F
1377            // $A=V : view file (do nothing except log)
1378          // default : display directory $D          // default : display directory $D
1379            
1380          switch ($A) {          switch ($A) {
1381          case "U" :          case "U" :
1382                  // upload to $relDir                  // upload to $relDir
1383                  if (!is_writeable($gblFsRoot . $relDir))                  if (!is_writeable($gblFsRoot . $relDir))
1384                          Error("Write access denied",$relDir) ;                          Error("Write access denied",$relDir) ;
1385                  $text  = "Use this page to upload a single " ;                  $text  = "Use this page to upload a single " ;
1386                  $text .= "file to <B>$SERVER_NAME</B>." ;                  $text .= "file to <B>$HTTP_HOST</B>." ;
1387                  StartHTML("(Upload Page)", $text) ;                  StartHTML("(Upload Page)", $text) ;
1388                  UploadPage($gblFsRoot, $relDir) ;                  UploadPage($gblFsRoot, $relDir) ;
1389                  EndHTML() ;                  EndHTML() ;
1390                  exit ;                  exit ;
1391          case "E" :          case "E" :
1392                    $F=stripSlashes($F);
1393                  // detail of $relDir/$F                  // detail of $relDir/$F
1394                  if (is_file("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ;                  if (is_file("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ;
1395                  exit ;                  exit ;
1396          case "C" :          case "C" :
1397                    $F=stripSlashes($F);
1398                  // listing of $relDir/$F                  // listing of $relDir/$F
1399                  DisplayCode($gblFsRoot, $relDir, $F) ;                  DisplayCode($gblFsRoot, $relDir, $F) ;
1400                  exit ;                  exit ;
1401            case "Co" :
1402                    // checkout
1403                    Lock("$gblFsRoot/$relDir/$F");
1404                    header("Content-Disposition: attachment; filename=$F" );
1405                    Header("Location: ".urlpath("$relDir/$F"));
1406                    exit;
1407            case "Ci" :
1408                    $F=stripSlashes($F);
1409                    // upload && update to $relDir
1410                    if (!is_writeable($gblFsRoot . $relDir))
1411                            Error("Write access denied",$relDir) ;
1412                    $text  = "Use this page to update a single " ;
1413                    $text .= "file to <B>$HTTP_HOST</B>." ;
1414                    StartHTML("(Update file Page)", $text) ;
1415                    UploadPage($gblFsRoot, $relDir, $F) ;
1416                    EndHTML() ;
1417                    exit ;
1418            case "V" :
1419                    // view
1420                    LogIt("$gblFsRoot/$relDir/$F","viewed");
1421                    header("Content-Disposition: attachment; filename=$F" );
1422                    Header("Location: ".urlpath("$relDir/$F"));
1423                    exit;
1424            case "Ch" :
1425                    StartHTML("(File changes)","All changes chronologicaly...");
1426                    DisplayChangeLog(0);    // all
1427                    EndHTML() ;
1428                    exit;
1429            case "Ch1" :
1430                    StartHTML("(File changes)","Changes to files in last day...");
1431                    DisplayChangeLog(1);
1432                    EndHTML() ;
1433                    exit;
1434          }          }
1435    
1436          // default: display directory $relDir          // default: display directory $relDir

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

  ViewVC Help
Powered by ViewVC 1.1.26