/[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.14 by dpavlin, Wed Sep 6 11:00:14 2000 UTC
# Line 65  IMPORTANT INSTALLATION NOTE: Line 65  IMPORTANT INSTALLATION NOTE:
65  TODO:  TODO:
66          mixed file/directory output (add type to each entry,          mixed file/directory output (add type to each entry,
67                  real support for links)                  real support for links)
68          add more content-management (like cms.sourceforge.net):          retrieve old versions of files (overwritten)
69                  check-out/check-in/reserve          show last lock date
70                  comments to files          
71  */  */
72    
73  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
# Line 108  TODO: Line 108  TODO:
108                          if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) {                          if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) {
109                                  $gblUserName=$user[1];                                  $gblUserName=$user[1];
110                                  $gblPw=$user[2];                                  $gblPw=$user[2];
111                                    $gblEmail=$user[3];
112                                  continue ;                                  continue ;
113                          }                          }
114                  }                  }
# Line 120  TODO: Line 121  TODO:
121          $gblDateFmt="Y-m-d";          $gblDateFmt="Y-m-d";
122          $gblTimeFmt="H:i:s";          $gblTimeFmt="H:i:s";
123    
124  // Number of backup files to keep          // Number of backup files to keep
125          $gblNumBackups=5;          $gblNumBackups=3;
126    
127            // show red star if newer than ... days
128            $gblModDays=1;
129    
130          // choose GifIcon below unless you have the M$          // choose GifIcon below unless you have the M$
131          // WingDings font installed on your system          // WingDings font installed on your system
# Line 184  function EndHTML() { Line 188  function EndHTML() {
188  <B><?= date($GLOBALS[gblDateFmt]) ?> -  <B><?= date($GLOBALS[gblDateFmt]) ?> -
189  <?= date($GLOBALS[gblTimeFmt]) ?> -  <?= date($GLOBALS[gblTimeFmt]) ?> -
190  <?= $GLOBALS[gblUserName] ?>  <?= $GLOBALS[gblUserName] ?>
191  <small> [<a href="<?= $PHP_SELF ?>?relogin=<?= $GLOBALS[gblPw] ?>">logout</a>]</small>  <small> [<a href="<?= $GLOBALS["PHP_SELF"] ?>?relogin=<?= $GLOBALS[gblPw] ?>">logout</a>]</small>
192  </B>  </B>
193  <BR>ANYPORTAL(php) Site Manager  <BR>ANYPORTAL(php) Site Manager
194  <br><small>  <br><small>
# Line 194  function EndHTML() { Line 198  function EndHTML() {
198  </small>  </small>
199  </P>  </P>
200  <BR>  <BR>
201  <? include(".debug.inc") ?>  <? //include(".debug.inc") ?>
202  <BR><BR></BODY></HTML>  <BR><BR></BODY></HTML>
203    
204  <?php  <?php
# Line 240  function DetailPage($fsRoot,$relDir,$fn) Line 244  function DetailPage($fsRoot,$relDir,$fn)
244          $ext      = strtolower(strrchr($relPath,".")) ;          $ext      = strtolower(strrchr($relPath,".")) ;
245          $editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) ;          $editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) ;
246          $writable = is_writeable($fsPath) ;          $writable = is_writeable($fsPath) ;
247            $file_lock = CheckLock($fsPath);
248    
249          if (!$editable && !$exists)          if (!$editable && !$exists)
250                  Error("Creation unsupported for type",$relPath) ;                  Error("Creation unsupported for type",$relPath) ;
# Line 268  function DetailPage($fsRoot,$relDir,$fn) Line 273  function DetailPage($fsRoot,$relDir,$fn)
273    
274          }          }
275    
276          if ( $editable && ($writable || !$exists) ) {          if ( $editable && ($writable || !$exists) && !$file_lock ) {
277                  $fh = fopen($fsPath,"a+") ;                  $fh = fopen($fsPath,"a+") ;
278                  rewind($fh) ;                  rewind($fh) ;
279                  $fstr = fread($fh,filesize($fsPath)) ;                  $fstr = fread($fh,filesize($fsPath)) ;
# Line 294  echo($fstr) ; ?></TEXTAREA> Line 299  echo($fstr) ; ?></TEXTAREA>
299    
300  <?php  <?php
301          }          }
302          else if ( strstr( join(" ",$gblImages), $ext ) ) {            if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) {  
303            $info  = getimagesize($fsPath) ;                  $info  = getimagesize($fsPath) ;
304            $tstr  = "<IMG SRC=\"". $relPath . "\" BORDER=0 " ;                  $tstr = "<IMG SRC=\"".urlpath($relPath)."\" BORDER=0 " ;
305            $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;                  $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;
306            $tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ;                  $tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ;
307            echo htmlentities($tstr) . "<BR><BR>" . $tstr ;  //              echo htmlentities($tstr) . "<BR><BR>" . $tstr ;
308                    echo $tstr ;
309          }          }
310    
311  ?>  ?>
312    
313  <FORM ACTION="<?= $self ; ?>" METHOD="POST">  <FORM ACTION="<?= $self ; ?>" METHOD="POST">
# Line 309  echo($fstr) ; ?></TEXTAREA> Line 316  echo($fstr) ; ?></TEXTAREA>
316  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR>  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR>
317    
318  <?php  <?php
319    
320            if ($file_lock) {
321    ?>
322    <hr>
323    <SPAN TITLE="Check OK and click UNLOCK to remove lock on file.">
324    <B>OK TO FORCE LOCK REMOVAL ON "<?= $fn ; ?>" HELD BY <?= $file_lock ?>? </B></SPAN>
325    <INPUT TYPE="CHECKBOX" NAME="CONFIRM">
326    <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="UNLOCK">
327    <?
328            } // file_lock
329    
330          if (substr($fn,0,4) == ".del") {          if (substr($fn,0,4) == ".del") {
331                  $action="UNDELETE";                  $action="UNDELETE";
332                  $desc="undelete previously deleted file";                  $desc="undelete previously deleted file";
# Line 336  echo($fstr) ; ?></TEXTAREA> Line 354  echo($fstr) ; ?></TEXTAREA>
354  <INPUT TYPE="CHECKBOX" NAME="CONFIRM">  <INPUT TYPE="CHECKBOX" NAME="CONFIRM">
355  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="RENAME">  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="RENAME">
356    
357    <?php
358            }       // exists && writable
359    ?>
360  <HR>  <HR>
361  <a name="note">  <a name="note">
362  <B>NOTE FOR "<?= $fn ; ?>":  <B>NOTE FOR "<?= $fn ; ?>":
# Line 343  echo($fstr) ; ?></TEXTAREA> Line 364  echo($fstr) ; ?></TEXTAREA>
364  </B></SPAN>  </B></SPAN>
365  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="NOTE">  <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="NOTE">
366    
367  <?php  </FORM>
         }  
         echo "</FORM>" ;  
368    
369          $logname=dirname("$fsDir/$fn")."/.log/".basename("$fsDir/$fn");  <?php
370            
371            $name=basename("$fsDir/$fn");
372            $logname=dirname("$fsDir/$fn")."/.log/$name";
373            $bakdir=dirname("$fsDir/$fn")."/.bak";
374          if (file_exists($logname)) {          if (file_exists($logname)) {
                 print "<hr><br><b>CHANGES TO THIS FILE</b><br><table border=0 width=100%>\n";  
375                  $log=fopen($logname,"r");                  $log=fopen($logname,"r");
376                  $cl1=" class=lst"; $cl2="";                  $cl1=" class=lst"; $cl2="";
377                    $logarr = array();
378                  while($line = fgetcsv($log,255,"\t")) {                  while($line = fgetcsv($log,255,"\t")) {
379                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;
380                          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]));
381                  }                  }
382                  fclose($log);                  fclose($log);
383                    print "<hr><br><b>CHANGES TO THIS FILE</b><br><table border=0 width=100%>\n";
384                    $bakcount = 0;  // start from 0, skip fist backup (it's current)
385                    while ($e = array_shift($logarr)) {
386                            if (strstr($e[4],"upload")) {
387                                    if (file_exists("$bakdir/$bakcount/$name")) {
388                                            $e[4]="<a href=\"".dirname($relPath)."/.bak/$bakcount/$name\">$e[4]</a>";
389                                    }
390                                    $bakcount++;
391                            }
392                            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";
393                    }
394                  print "</table>";                  print "</table>";
395          }          }
396    
# Line 590  function GifIcon($txt) { Line 624  function GifIcon($txt) {
624                  $d = "blank.gif" ;                  $d = "blank.gif" ;
625                  break ;                  break ;
626          case "checkout":          case "checkout":
627                  $d = "down.gif";                  $d = "box2.gif";
628                  break;                  break;
629          case "checkin":          case "checkin":
630                  $d = "up.gif";                  $d = "hand.up.gif";
631                    break;
632            case "locked":
633                    $d = "screw2.gif";
634                  break;                  break;
635          case "note":          case "note":
636                  $d = "quill.gif";                  $d = "quill.gif";
# Line 655  function Navigate($fsRoot,$relDir) { Line 692  function Navigate($fsRoot,$relDir) {
692          // start navigation page          // start navigation page
693          $text  = "Use this page to add, delete";          $text  = "Use this page to add, delete";
694          if (! isset($show_deleted)) {          if (! isset($show_deleted)) {
695                  $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>";
696          }          }
697          $text .= " or revise files on this web site." ;          $text .= " or revise files on this web site." ;
698          StartHTML("(Navigate)",$text) ;          StartHTML("(Navigate)",$text) ;
# Line 702  function Navigate($fsRoot,$relDir) { Line 739  function Navigate($fsRoot,$relDir) {
739  <TR><TD></TD><TD COLSPAN=5><HR><B><?= $webRoot . $relDir ?>  <TR><TD></TD><TD COLSPAN=5><HR><B><?= $webRoot . $relDir ?>
740  </B></TD></TR>  </B></TD></TR>
741  <TR><TD></TD><TD CLASS=TOP>DOCUMENT NAME</TD>  <TR><TD></TD><TD CLASS=TOP>DOCUMENT NAME</TD>
742  <TD><?= $gblIcon("blank") ?></TD>  <TD><?= $gblIcon("blank").$gblIcon("blank") ?></TD>
743  <TD CLASS=TOP>NOTE</TD>  <TD CLASS=TOP>NOTE</TD>
744  <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>
745    
# Line 724  function Navigate($fsRoot,$relDir) { Line 761  function Navigate($fsRoot,$relDir) {
761    
762                  $info_url=$self."?A=E&F=".urlencode($file)."&D=".urlencode($relDir);                  $info_url=$self."?A=E&F=".urlencode($file)."&D=".urlencode($relDir);
763    
764                  if ( ($mod + 30*86400) > time() ) {                  if ( ($mod + $gblModDays*86400) > time() ) {
765                          $a  = "<SPAN CLASS=RED TITLE=\"Newer" ;                          $a  = "<SPAN CLASS=RED TITLE=\"Newer" ;
766                          $a .= " than 30 days\"> * </SPAN>" ;                          $a .= " than $gblModDays days\"> * </SPAN>" ;
767                  }                  }
768    
769                  $tstr = $webRoot . $relDir . "/" . $file ;                  $file_lock=CheckLock($path);
770                  $tstr  = "<A HREF=\"" . $tstr . "\">" ;  
771                    $file_url_html="<A HREF=\"$self?A=V&F=".urlencode($file);
772                    $file_url_html.="&D=".urlencode($relDir);
773                    $file_url_html.="\" TITLE=\"View file\">" ;
774    
775                  if (substr($file,0,5) != ".del/") {                  if (substr($file,0,5) != ".del/") {
776                          $tstr .= $file . "</A>" . $a ;                          $file_url_html .= $file . "</A>" . $a ;
777                  } else {                  } else {
778                          $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>";
779                  }                  }
780    
781  //              $b = $gblIcon("checkout");                  $note_html="<a href=\"$info_url#note\">".$gblIcon("note")."</a>".ReadNote($path);
 //              $b .= $gblIcon("checkin");  
782    
783                  $ext = strtolower(strrchr($file,".")) ;                  $ext = strtolower(strrchr($file,".")) ;
784                  if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) {    
785                          $b .= "<A HREF=\"" . $self . "?A=C&F=" ;                  if ($file_lock) {
786                          $b .= urlencode($file) . "&D=" . urlencode($relDir) ;                          if ($file_lock == $GLOBALS[gblUserName]) {
787                          $b .= "\" TITLE=\"List contents\">" ;                                  $b.="<A HREF=\"$self?A=Ci&F=".urlencode($file);
788                          $b .= $gblIcon("view") . "</A>" ;                                  $b.="&D=".urlencode($relDir);
789                                    $b.="\" TITLE=\"Checkin (update) file on server\">" ;
790                                    $file_url_html=$b;
791                                    $b.=$gblIcon("checkin")."</A>" ;
792                                    $b.= $gblIcon("blank");
793                                    $file_url_html.="$file</a> $a";
794                                    $note_html = $gblIcon("blank")."<b>Please check-in (update) this file</b>";
795                            } else {
796                                    $b = $gblIcon("locked");
797                                    $b.= $gblIcon("blank");
798                                    $note_html = $gblIcon("blank")."<b>File locked by $file_lock</b>";
799                                    $file_url_html = "$file $a";
800                            }
801                  } else {                  } else {
802                          $b .= $gblIcon("blank");                          $b.="<A HREF=\"$self?A=Co&F=".urlencode($file);
803                            $b.="&D=".urlencode($relDir);
804                            $b.="\" TITLE=\"Checkout file for edit\">" ;
805                            $b.=$gblIcon("checkout")."</A>" ;
806    
807                            if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) {  
808                                    $b.="<A HREF=\"$self?A=C&F=".urlencode($file);
809                                    $b.="&D=".urlencode($relDir);
810                                    $b.="\" TITLE=\"List contents\">" ;
811                                    $b.=$gblIcon("view")."</A>" ;
812                            } else {
813                                    $b.= $gblIcon("blank");
814                            }
815                  }                  }
816    
817    
# Line 757  function Navigate($fsRoot,$relDir) { Line 820  function Navigate($fsRoot,$relDir) {
820  <TR><TD>  <TR><TD>
821  <A HREF="<?= $info_url ?>" TITLE="View/Edit">  <A HREF="<?= $info_url ?>" TITLE="View/Edit">
822  <?= $gblIcon($ext) ?></A></TD>  <?= $gblIcon($ext) ?></A></TD>
823  <TD CLASS=LST><?= $tstr ?></TD>  <TD CLASS=LST><?= $file_url_html ?></TD>
824  <TD CLASS=LST ALIGN=center><?= $b ?></TD>  <TD CLASS=LST ALIGN=center><?= $b ?></TD>
825  <TD CLASS=LST ALIGN=left><a href="<?= $info_url ?>#note"><?= $gblIcon("note") ?></a><?= ReadNote($path) ?></TD>  <TD CLASS=LST ALIGN=left><?= $note_html ?></TD>
826  <TD CLASS=LST><?= date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]",$mod) ?></TD>  <TD CLASS=LST><?= date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]",$mod) ?></TD>
827  <TD CLASS=LST><?= $sz ?>Bytes</TD></TR>  <TD CLASS=LST><?= $sz ?>Bytes</TD></TR>
828    
# Line 785  function Navigate($fsRoot,$relDir) { Line 848  function Navigate($fsRoot,$relDir) {
848    
849  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>
850    
851    <TR><TD></TD><TD COLSPAN=5>
852    <?
853    if (file_exists(".info.inc")) {
854            include(".info.inc");
855    }
856    ?>
857    </TD></TR>
858    
859    <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>
860    
861  <FORM METHOD="POST" ACTION="<?= $self ?>">  <FORM METHOD="POST" ACTION="<?= $self ?>">
862  <TR><TD></TD><TD COLSPAN=5 CLASS=BAR>CREATE NEW  <TR><TD></TD><TD COLSPAN=5 CLASS=BAR>CREATE NEW
863   <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 866  function Navigate($fsRoot,$relDir) {
866   <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE">   <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE">
867   <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">   <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">
868   <INPUT TYPE="SUBMIT" VALUE="CREATE"></NOBR>   <INPUT TYPE="SUBMIT" VALUE="CREATE"></NOBR>
869   <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  
870   </NOBR>   </NOBR>
871  </TD></TR>  </TD></TR>
872  </FORM>  </FORM>
# Line 806  function Navigate($fsRoot,$relDir) { Line 878  function Navigate($fsRoot,$relDir) {
878    
879  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
880    
881  function UploadPage($fsRoot, $relDir) {  function UploadPage($fsRoot, $relDir, $filename) {
882    
883          $self = $GLOBALS["PHP_SELF"] ;          $self = $GLOBALS["PHP_SELF"] ;
884          if ($relDir == "") $relDir = "/" ;          if ($relDir == "") $relDir = "/" ;
# Line 816  function UploadPage($fsRoot, $relDir) { Line 888  function UploadPage($fsRoot, $relDir) {
888  <FORM ENCTYPE="multipart/form-data" METHOD="POST"  <FORM ENCTYPE="multipart/form-data" METHOD="POST"
889   ACTION="<?= $self ?>">   ACTION="<?= $self ?>">
890  DESTINATION DIRECTORY:<B><?= " " . $relDir ?></B>  DESTINATION DIRECTORY:<B><?= " " . $relDir ?></B>
891    <? if (isset($filename)) { ?>
892    <br>DESTINATION FILE:<B><?= " " . $filename ?></B>
893    <INPUT TYPE="HIDDEN" NAME="FILENAME" VALUE="<?= $filename ?>">
894    <? } ?>
895  <P>PATHNAME OF LOCAL FILE<BR>  <P>PATHNAME OF LOCAL FILE<BR>
896  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">  <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">
897  <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="UPLOAD">  <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="UPLOAD">
# Line 943  function ReadNote($target) { Line 1019  function ReadNote($target) {
1019                  $msg=fgets($note,4096);                  $msg=fgets($note,4096);
1020                  fclose($note);                  fclose($note);
1021          }          }
1022          return $msg;          return StripSlashes($msg);
1023    
1024  }  }
1025    
# Line 962  function MoveTo($source,$folder) { Line 1038  function MoveTo($source,$folder) {
1038    
1039  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1040    
1041    function Lock($target) {
1042    
1043            $dir=dirname($target);
1044            if (! file_exists($dir."/.lock")) {
1045                    mkdir($dir."/.lock",0700);
1046            }
1047            $file=basename($target);
1048    
1049            if (file_exists("$dir/.lock/$file")) {
1050                    Logit($target,"attempt to locked allready locked file!");
1051            } else {
1052                    $lock=fopen("$dir/.lock/$file","w");
1053                    fputs($lock,"$GLOBALS[gblUserName]\n");
1054                    fclose($lock);
1055    
1056                    Logit($target,"file locked");
1057            }
1058    
1059    }
1060    
1061    function CheckLock($target) {
1062    
1063            $dir=dirname($target);
1064            $file=basename($target);
1065            $msg=0;
1066            if (file_exists($dir."/.lock/$file")) {
1067                    $lock=fopen("$dir/.lock/$file","r");
1068                    $msg=fgets($lock,4096);
1069                    fclose($lock);
1070            }
1071            return chop($msg);
1072    
1073    }
1074    
1075    function Unlock($target) {
1076    
1077            $dir=dirname($target);
1078            $file=basename($target);
1079            if (file_exists($dir."/.lock/$file")) {
1080                    unlink("$dir/.lock/$file");
1081                    Logit($target,"file unlocked");
1082            } else {
1083                    Logit($target,"attempt to unlocked non-locked file!");
1084            }
1085    
1086    }
1087    
1088    //////////////////////////////////////////////////////////////////
1089    
1090    function urlpath($url) {
1091            $url=urlencode(StripSlashes("$url"));
1092            $url=str_replace("%2F","/",$url);
1093            $url=str_replace("+","%20",$url);
1094            return($url);
1095    }
1096    
1097    //////////////////////////////////////////////////////////////////
1098    
1099    function safe_rename($from,$to) {
1100            if (file_exists($from) && is_writable(dirname($to))) {
1101                    rename($from,$to);
1102            }
1103    }
1104    
1105    //////////////////////////////////////////////////////////////////
1106    
1107  // MAIN PROGRAM  // MAIN PROGRAM
1108  // ============  // ============
1109  // query parameters: capital letters  // query parameters: capital letters
# Line 1028  function MoveTo($source,$folder) { Line 1170  function MoveTo($source,$folder) {
1170                  // TODO : should rather check for escapeshellcmds                  // TODO : should rather check for escapeshellcmds
1171                  // but maybe RFC 18xx asserts safe filenames ....                  // but maybe RFC 18xx asserts safe filenames ....
1172                  $source = $FN ;                  $source = $FN ;
1173                  $target = $fsDir . "/" . $FN_name ;                  if (! isset($FILENAME)) {       // from update file
1174                            $target = "$fsDir/$FN_name" ;
1175                    } else {
1176                            $target = "$fsDir/$FILENAME";
1177                    }
1178    
1179                  // backup old files first                  // backup old files first
1180                  $dir=dirname($target);                  $dir=dirname($target);
# Line 1042  function MoveTo($source,$folder) { Line 1188  function MoveTo($source,$folder) {
1188                  for($i=$GLOBALS[gblNumBackups]-1;$i>0;$i--) {                  for($i=$GLOBALS[gblNumBackups]-1;$i>0;$i--) {
1189                          MoveTo("$dir/.bak/$i/$file","$dir/.bak/".($i+1)."/");                          MoveTo("$dir/.bak/$i/$file","$dir/.bak/".($i+1)."/");
1190                  }                  }
1191                  MoveTo($target,$dir."/.bak/1/".$file);                  MoveTo($target,$dir."/.bak/1/");
1192    
1193                  copy($source,$target) ;                  copy($source,$target) ;
1194                  chmod($target,$gblFilePerms) ;                  chmod($target,$gblFilePerms) ;
1195                  clearstatcache() ;                  clearstatcache() ;
1196                  Logit($target,"uploaded");                  Logit($target,"uploaded");
1197                    if (isset($FILENAME)) {
1198                            Unlock($target);
1199                    }
1200                  break ;                  break ;
1201    
1202          case "SAVE" :          case "SAVE" :
# Line 1073  function MoveTo($source,$folder) { Line 1222  function MoveTo($source,$folder) {
1222                  $relPath = $relDir . "/" . $FN ;                  $relPath = $relDir . "/" . $FN ;
1223                  switch ( $T ) {                  switch ( $T ) {
1224                  case "D" :  // create a directory                  case "D" :  // create a directory
1225                    if ( ! @mkdir($path,$gblDirPerms) )                          if ( ! @mkdir($path,$gblDirPerms) )
1226                      Error("Mkdir failed",$relPath) ; // eg. if it exists                                  Error("Mkdir failed",$relPath) ; // eg. if it exists
1227                    clearstatcache() ;                          clearstatcache() ;
1228                    break ;                          break ;
1229                  case "F" :  // create a new file                  case "F" :  // create a new file
1230  // this functionality is doubled in DetailView().  // this functionality is doubled in DetailView().
1231  // better keep it here altogether  // better keep it here altogether
1232  // chmod perms to $gblFilePerms  // chmod perms to $gblFilePerms
1233                    if ( file_exists($path) && !is_writable($path) )                          if ( file_exists($path) && !is_writable($path) )
1234                      Error("File not writable", $relPath) ;                                  Error("File not writable", $relPath) ;
1235                    $tstr = $PHP_SELF . "?A=E&D=" . $relDir . "&F=" . $FN ;                          $fh = fopen($path, "w+") ;
1236                    header("Location: " . $tstr) ;                          if ($fh) {
1237                    exit ;                                  fputs($fh,"\n");
1238                                    fclose($fh) ;
1239                                    LogIt($path,"file created");
1240                            } else {
1241                                    Error("Creation of file $relPath failed -- $path");
1242                            }
1243                            $tstr = "$PHP_SELF?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ;
1244                            header("Location: " . $tstr) ;
1245                            exit ;
1246                  }                  }
1247                  break ;                  break ;
1248    
# Line 1111  function MoveTo($source,$folder) { Line 1268  function MoveTo($source,$folder) {
1268                                  exit ;                                  exit ;
1269                          } else {                          } else {
1270                                  Logit($path,"file deleted");                                  Logit($path,"file deleted");
                                 if (! file_exists("$dir/.del/.log")) {  
                                         mkdir("$dir/.del/.log",0700);  
                                 }  
1271                                  MoveTo("$dir/.log/$file","$dir/.del/.log/");                                  MoveTo("$dir/.log/$file","$dir/.del/.log/");
1272                                  MoveTo("$dir/.note/$file","$dir/.del/.note/");                                  MoveTo("$dir/.note/$file","$dir/.del/.note/");
1273                                    MoveTo("$dir/.lock/$file","$dir/.del/.lock/");
1274                          }                          }
1275                  }                  }
1276                  else {  // delete directory                  else {  // delete directory
# Line 1138  function MoveTo($source,$folder) { Line 1293  function MoveTo($source,$folder) {
1293                  MoveTo("$fsDir/.del/$file","$fsDir/");                  MoveTo("$fsDir/.del/$file","$fsDir/");
1294                  MoveTo("$fsDir/.del/.log/$file","$fsDir/.log/");                  MoveTo("$fsDir/.del/.log/$file","$fsDir/.log/");
1295                  MoveTo("$fsDir/.del/.note/$file","$fsDir/.note/");                  MoveTo("$fsDir/.del/.note/$file","$fsDir/.note/");
1296                    MoveTo("$fsDir/.del/.lock/$file","$fsDir/.lock/");
1297    
1298                  break ;                  break ;
1299    
# Line 1145  function MoveTo($source,$folder) { Line 1301  function MoveTo($source,$folder) {
1301                  if ( $CONFIRM != "on" ) break ;                  if ( $CONFIRM != "on" ) break ;
1302    
1303                  Logit("$fsDir/$FN","renamed $FN to $NEWNAME");                  Logit("$fsDir/$FN","renamed $FN to $NEWNAME");
1304                  rename("$fsDir/$FN","$fsDir/$NEWNAME");                  safe_rename("$fsDir/$FN","$fsDir/$NEWNAME");
1305                  rename("$fsDir/.log/$FN","$fsDir/.log/$NEWNAME");                  safe_rename("$fsDir/.log/$FN","$fsDir/.log/$NEWNAME");
1306                    safe_rename("$fsDir/.note/$FN","$fsDir/.note/$NEWNAME");
1307                    safe_rename("$fsDir/.lock/$FN","$fsDir/.lock/$NEWNAME");
1308                    for($i=0;$i<=$GLOBALS[gblNumBackups];$i++) {
1309                            safe_rename("$fsDir/.bak/$i/$FN","$fsDir/.bak/$i/$NEWNAME");
1310                    }
1311    
1312                  break ;                  break ;
1313    
# Line 1154  function MoveTo($source,$folder) { Line 1315  function MoveTo($source,$folder) {
1315                  WriteNote("$fsDir/$FN","$NOTE");                  WriteNote("$fsDir/$FN","$NOTE");
1316                  break ;                  break ;
1317    
1318            case "UNLOCK" :  
1319                    if ( $CONFIRM != "on" ) break ;
1320                    Unlock("$fsDir/$FN");
1321                    break ;
1322    
1323          default :          default :
1324                  // user hit "CANCEL" or undefined action                  // user hit "CANCEL" or undefined action
1325          }          }
# Line 1169  function MoveTo($source,$folder) { Line 1335  function MoveTo($source,$folder) {
1335          // $A=U : upload to path given in $D          // $A=U : upload to path given in $D
1336          // $A=E : display detail of file $D/$F and edit          // $A=E : display detail of file $D/$F and edit
1337          // $A=C : display code in file $D/$F          // $A=C : display code in file $D/$F
1338            // $A=Co : checkout file $D/$F
1339            // $A=Ci : checkin file $D/$F
1340            // $A=V : view file (do nothing except log)
1341          // default : display directory $D          // default : display directory $D
1342                    
1343          switch ($A) {          switch ($A) {
# Line 1190  function MoveTo($source,$folder) { Line 1359  function MoveTo($source,$folder) {
1359                  // listing of $relDir/$F                  // listing of $relDir/$F
1360                  DisplayCode($gblFsRoot, $relDir, $F) ;                  DisplayCode($gblFsRoot, $relDir, $F) ;
1361                  exit ;                  exit ;
1362            case "Co" :
1363                    // checkout
1364                    Lock("$gblFsRoot/$relDir/$F");
1365                    header("Content-Disposition: attachment; filename=$F" );
1366                    Header("Location: ".urlpath("$relDir/$F"));
1367                    exit;
1368            case "Ci" :
1369                    // upload && update to $relDir
1370                    if (!is_writeable($gblFsRoot . $relDir))
1371                            Error("Write access denied",$relDir) ;
1372                    $text  = "Use this page to update a single " ;
1373                    $text .= "file to <B>$SERVER_NAME</B>." ;
1374                    StartHTML("(Update file Page)", $text) ;
1375                    UploadPage($gblFsRoot, $relDir, $F) ;
1376                    EndHTML() ;
1377                    exit ;
1378            case "V" :
1379                    // view
1380                    LogIt("$gblFsRoot/$relDir/$F","viewed");
1381                    header("Content-Disposition: attachment; filename=$F" );
1382                    Header("Location: ".urlpath("$relDir/$F"));
1383                    exit;
1384          }          }
1385    
1386          // default: display directory $relDir          // default: display directory $relDir

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

  ViewVC Help
Powered by ViewVC 1.1.26