/[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.25 by dpavlin, Thu Dec 21 07:30:04 2000 UTC revision 1.37 by dpavlin, Mon Mar 12 13:30:44 2001 UTC
# Line 51  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:
# Line 75  TODO: Line 75  TODO:
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];  
                                 $gblEmail=$user[3];  
                                 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
# Line 121  TODO: Line 100  TODO:
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 145  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 224  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 243  function DetailPage($fsRoot,$relDir,$fn) Line 222  function DetailPage($fsRoot,$relDir,$fn)
222                  Error("Creation denied",$relDir) ;                  Error("Creation denied",$relDir) ;
223    
224          $text  = "Use this page to view, modify or " ;          $text  = "Use this page to view, modify or " ;
225          $text .= "delete a single document on this " ;          if (is_dir($fsPath)) {
226                    $text .="delete a directory on this " ;
227            } else {
228                    $text .= "delete a single document on this " ;
229            };
230          $text .= "web site." ;            $text .= "web site." ;  
231          $title = "(Detail Page)" ;          $title = "(Detail Page)" ;
232          StartHTML($title, $text) ;          StartHTML($title, $text) ;
# Line 253  function DetailPage($fsRoot,$relDir,$fn) Line 236  function DetailPage($fsRoot,$relDir,$fn)
236                  $fsize = filesize($fsPath) ;                  $fsize = filesize($fsPath) ;
237                  $fmodified = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", filemtime($fsPath)) ;                  $fmodified = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", filemtime($fsPath)) ;
238                  $faccessed = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", fileatime($fsPath)) ;                  $faccessed = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", fileatime($fsPath)) ;
239                  echo "<PRE>    file size: " . $fsize . " Bytes<BR>" ;                  $fuid=fileowner($fsPath);
240                    $fgid=filegroup($fsPath);
241                    $userinfo = posix_getpwuid($fuid);
242                    $grpinfo = posix_getgrgid($fgid);
243                    echo "<PRE>";
244                    if (!is_dir($fsPath)) echo "    file size: " . $fsize . " Bytes<BR>" ;
245                  echo "last modified: <B>" . $fmodified . "</B><BR>" ;                  echo "last modified: <B>" . $fmodified . "</B><BR>" ;
246                  echo "last accessed: <B>" . $faccessed . "</B><BR>" ;                  echo "last accessed: <B>" . $faccessed . "</B><BR>" ;
247                  echo "        owner: <B>" . fileowner($fsPath) . "</B><BR>" ;                  echo "        owner: <B>" . $userinfo["name"] . " [$fuid]</B><BR>" ;
248                  echo "        group: <B>" . filegroup($fsPath) . "</B><BR>" ;                  echo "        group: <B>" . $grpinfo["name"] . " [$fgid]</B><BR>" ;
249                  echo "  permissions: <B>" ;                  echo "  permissions: <B>" ;
250                  echo printf( "%o", fileperms($fsPath) ) . "</B>" ;                  echo printf( "%o", fileperms($fsPath) ) . "</B>" ;
251                  echo "</PRE>" ;                  echo "</PRE>" ;
252    
253          }          }
254    
255          if ( $editable && ($writable || !$exists) && !$file_lock ) {          if ( !is_dir($fsPath) && $editable && ($writable || !$exists) && !$file_lock ) {
256                  $fh = fopen($fsPath,"a+") ;                  $fh = fopen($fsPath,"a+") ;
257                  rewind($fh) ;                  rewind($fh) ;
258                  $fstr = fread($fh,filesize($fsPath)) ;                  $fstr = fread($fh,filesize($fsPath)) ;
# Line 292  echo($fstr) ; ?></TEXTAREA> Line 280  echo($fstr) ; ?></TEXTAREA>
280          }          }
281          if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) {            if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) {  
282                  $info  = getimagesize($fsPath) ;                  $info  = getimagesize($fsPath) ;
283                  $tstr = "<IMG SRC=\"".urlpath($relPath)."\" BORDER=0 " ;                  $tstr = "<IMG SRC=\"$webRoot".urlpath($relPath)."\" BORDER=0 " ;
284                  $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;                  $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;
285                  $tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ;                  $tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ;
286  //              echo htmlentities($tstr) . "<BR><BR>" . $tstr ;  //              echo htmlentities($tstr) . "<BR><BR>" . $tstr ;
# Line 364  echo($fstr) ; ?></TEXTAREA> Line 352  echo($fstr) ; ?></TEXTAREA>
352          $bakdir=dirname("$fsDir/$fn")."/.bak";          $bakdir=dirname("$fsDir/$fn")."/.bak";
353          if (file_exists($logname)) {          if (file_exists($logname)) {
354                  $log=fopen($logname,"r");                  $log=fopen($logname,"r");
355                  $cl1=" class=lst"; $cl2="";                  $cl1=" class=LST"; $cl2="";
356                  $logarr = array();                  $logarr = array();
357                  while($line = fgetcsv($log,255,"\t")) {                  while($line = fgetcsv($log,255,"\t")) {
358                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;
359                          array_unshift($logarr,array($cl,$line[0],$line[1],$line[2],$line[3]));                          array_unshift($logarr,array($cl,$line[0],$line[1],$line[2],$line[3]));
360                  }                  }
361                  fclose($log);                  fclose($log);
362                  print "<hr><br><b>CHANGES TO THIS FILE</b><br><table border=0 width=100%>\n";                  if (is_dir("$fsDir/$fn")) {
363                            $whatis="DIRECTORY";
364                    } else {
365                            $whatis="FILE";
366                    }
367                    print "<hr><br><b>CHANGES TO THIS $whatis</b><br><table border=0 width=100%>\n";
368                  $bakcount = 0;  // start from 0, skip fist backup (it's current)                  $bakcount = 0;  // start from 0, skip fist backup (it's current)
369                  while ($e = array_shift($logarr)) {                  while ($e = array_shift($logarr)) {
370                          if (strstr($e[4],"upload")) {                          if (strstr($e[4],"upload")) {
371                                  if (file_exists("$bakdir/$bakcount/$name")) {                                  if (file_exists("$bakdir/$bakcount/$name")) {
372                                          $e[4]="<a href=\"".dirname($relPath)."/.bak/$bakcount/$name\">$e[4]</a>";                                          $e[4]="<a href=\"$webRoot".urlpath(dirname($relPath)."/.bak/$bakcount/$name")."\">$e[4]</a>";
373                                  }                                  }
374                                  $bakcount++;                                  $bakcount++;
375                          }                          }
# Line 637  function GifIcon($txt) { Line 630  function GifIcon($txt) {
630    
631  function Navigate($fsRoot,$relDir) {  function Navigate($fsRoot,$relDir) {
632    
633          global $gblEditable, $gblIcon, $gblModDays ;          global $gblEditable, $gblIcon, $gblModDays, $webRoot ;
634    
635          $self     = $GLOBALS["PHP_SELF"] ;          $self     = $GLOBALS["PHP_SELF"] ;
636          if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") {  
637                  $webRoot  = "https://" . $GLOBALS["HTTP_HOST"] ;          $fsDir = $fsRoot . $relDir . "/" ; // current directory
         } else {  
                 $webRoot  = "http://" . $GLOBALS["HTTP_HOST"] ;  
         }  
         $fsDir    = $fsRoot . $relDir . "/" ; // current directory  
638    
639          if (!is_dir($fsDir)) Error("Dir not found",$relDir) ;          if (!is_dir($fsDir)) Error("Dir not found",$relDir) ;
640    
# Line 710  function Navigate($fsRoot,$relDir) { Line 699  function Navigate($fsRoot,$relDir) {
699                  sort($dirList) ;                  sort($dirList) ;
700  ?>  ?>
701    
702  <TR><TD></TD><TD COLSPAN=5 CLASS=TOP><HR>DIRECTORY NAME</TD></TR>  <TR><TD></TD><TD COLSPAN=2 CLASS=TOP>DIRECTORY NAME</TD><TD COLSPAN=3 CLASS=TOP>DIRECTORY NOTE</TR>
703    
704  <?php  <?php
705                  while (list($key,$dir) = each($dirList)) {                  while (list($key,$dir) = each($dirList)) {
706    
707                            $info_url=$self."?A=E&F=".urlencode($dir)."&D=".urlencode($relDir);
708                          $tstr = "<A HREF=\"" . $self . "?D=" ;                          $tstr = "<A HREF=\"" . $self . "?D=" ;
709                          $tstr .= urlencode($relDir."/".$dir) ;                          $tstr .= urlencode($relDir."/".$dir) ;
710                          $tstr .= "\">" . $dir . "/</A>" ;                          $tstr .= "\">" . $dir . "/</A>" ;
711                            $note_html="<a href=\"$info_url#note\">".$gblIcon("note")."</a>".ReadNote($fsDir.$dir);
712  ?>  ?>
713    
714  <TR><TD><?= $gblIcon("fldr") ?></TD>  <TR><TD>
715  <TD COLSPAN=5 CLASS=LST><?= $tstr ?></TD></TR>  <A HREF="<?= $info_url ?>" TITLE="View/Edit">
716    <?= $gblIcon("fldr") ?></A></TD>
717    <TD COLSPAN=2 CLASS=LST><?= $tstr ?></TD>
718    <TD COLSPAN=3 CLASS=LST><?= $note_html ?></TD></TR>
719    
720  <?php  <?php
721                  }  // iterate over dirs                  }  // iterate over dirs
# Line 875  if (file_exists(".info.inc")) { Line 869  if (file_exists(".info.inc")) {
869    
870  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
871    
872  function UploadPage($fsRoot, $relDir, $filename) {  function UploadPage($fsRoot, $relDir, $filename="") {
873    
874          $self = $GLOBALS["PHP_SELF"] ;          $self = $GLOBALS["PHP_SELF"] ;
875          if ($relDir == "") $relDir = "/" ;          if ($relDir == "") $relDir = "/" ;
# Line 885  function UploadPage($fsRoot, $relDir, $f Line 879  function UploadPage($fsRoot, $relDir, $f
879  <FORM ENCTYPE="multipart/form-data" METHOD="POST"  <FORM ENCTYPE="multipart/form-data" METHOD="POST"
880   ACTION="<?= $self ?>">   ACTION="<?= $self ?>">
881  DESTINATION DIRECTORY:<B><?= " " . $relDir ?></B>  DESTINATION DIRECTORY:<B><?= " " . $relDir ?></B>
882  <? if (isset($filename)) { ?>  <? if (isset($filename) && $filename!="") { ?>
883  <br>DESTINATION FILE:<B><?= " " . $filename ?></B>  <br>DESTINATION FILE:<B><?= " " . $filename ?></B>
884  <INPUT TYPE="HIDDEN" NAME="FILENAME" VALUE="<?= $filename ?>">  <INPUT TYPE="HIDDEN" NAME="FILENAME" VALUE="<?= $filename ?>">
885  <? } ?>  <? } ?>
# Line 920  function Error($title,$text="") { Line 914  function Error($title,$text="") {
914    
915  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
916    
 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  
   
 //////////////////////////////////////////////////////////////////  
   
917  function NoEntry() {  function NoEntry() {
918    
919          $user = $GLOBALS["PHP_AUTH_USER"] ;          $user = $GLOBALS["PHP_AUTH_USER"] ;
# Line 952  function NoEntry() { Line 923  function NoEntry() {
923          $title = "(401 Unauthorized)" ;          $title = "(401 Unauthorized)" ;
924          $text  = "No trespassing !" ;          $text  = "No trespassing !" ;
925          StartHTML($title,$text) ;          StartHTML($title,$text) ;
 ?>  
926    
 <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  
927          EndHTML() ;          EndHTML() ;
928          exit ;          exit ;
929  }  }
# Line 1099  function urlpath($url) { Line 1057  function urlpath($url) {
1057    
1058  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1059    
1060  function safe_rename($from,$to) {  function safe_rename($fromdir,$fromfile,$tofile) {
1061          if (file_exists($from) && is_writable(dirname($to))) {          function try_rename($from,$to) {
1062                  rename($from,$to);                  print "$from -> $to\n";
1063                    if (file_exists($from) && is_writeable(dirname($to))) {
1064                            rename($from,$to);
1065                    }
1066            }
1067    
1068            function try_dir($todir) {
1069                    if (! file_exists($todir)) {
1070                            mkdir($todir,0700);
1071                    }
1072            }
1073    
1074            $to="$fromdir/$tofile";
1075            $todir=dirname($to);
1076            $tofile=basename($to);
1077    
1078            print "<pre>$fromdir / $fromfile -> $todir / $tofile\n\n";
1079    
1080            try_rename("$fromdir/$fromfile","$todir/$tofile");
1081            try_dir("$todir/.log");
1082            try_rename("$fromdir/.log/$fromfile","$todir/.log/$tofile");
1083            try_dir("$todir/.note");
1084            try_rename("$fromdir/.note/$fromfile","$todir/.note/$tofile");
1085            try_dir("$todir/.lock");
1086            try_rename("$fromdir/.lock/$fromfile","$todir/.lock/$tofile");
1087            try_dir("$todir/.bak");
1088            for($i=0;$i<=$GLOBALS[gblNumBackups];$i++) {
1089                    try_rename("$fromdir/.bak/$i/$fromfile","$todir/.bak/$i/$tofile");
1090          }          }
1091  }  }
1092    
1093    
1094  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1095    
1096  // recursivly delete directory  // recursivly delete directory
# Line 1148  function DisplayChangeLog($day) { Line 1134  function DisplayChangeLog($day) {
1134                  }                  }
1135          }          }
1136          fclose($log);          fclose($log);
1137          $cl1=" class=lst"; $cl2="";          $cl1=" class=LST"; $cl2="";
1138          print "<table border=0 width=100%>\n";          print "<table border=0 width=100%>\n";
1139          while ($e = array_shift($logarr)) {          while ($e = array_shift($logarr)) {
1140                  $cl=$cl1; $cl1=$cl2; $cl2=$cl;                  $cl=$cl1; $cl1=$cl2; $cl2=$cl;
# Line 1179  function DisplayChangeLog($day) { Line 1165  function DisplayChangeLog($day) {
1165          // forks before authentication: style sheet and hash          // forks before authentication: style sheet and hash
1166          // creation if password not yet set.          // creation if password not yet set.
1167          if ($STYLE == "get") { CSS() ; exit ; }          if ($STYLE == "get") { CSS() ; exit ; }
1168          if ($HASH != "") {  
1169                  CreateHash($USER, $PW) ;          $htusers_file=dirname($SCRIPT_FILENAME)."/.htusers";
1170                  exit ;          if (! file_exists($htusers_file)) {
1171                    if (is_writeable(dirname($SCRIPT_FILENAME))) {
1172                            $htusers=fopen($htusers_file,"a+");
1173                            fputs($htusers,"# Change owner of $htusers_file to root !!\n");
1174                            fputs($htusers,"demo:full name:[md5_hash|auth_*]:e-mail\n");
1175                            fclose($htusers);
1176                            Error("Proto user file created!","Please edit <tt>$htusers_file</tt> and set it correct permissions (<B>not writable by web server as it is now!</b>). You can add users using <tt>adduser.pl</tt> script!");
1177                            exit;
1178                    } else {
1179                            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!");
1180                            exit;
1181                    }
1182          }          }
1183            $htusers=fopen($htusers_file,"r");
1184            while($user = fgetcsv($htusers,255,":")) {
1185                    if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) {
1186                            $gblUserName=$user[1];
1187                            $gblPw=$user[2];
1188                            if (substr($gblPw,0,5) == "auth_" && file_exists("$gblIncDir/$gblPw.php")) {
1189                                    require("$gblIncDir/$gblPw.php");
1190                                    if ($gblPw($user)) {
1191                                            $gblPw=md5($PHP_AUTH_USER.$PHP_AUTH_PW);
1192                                    } else {
1193                                            $gblPw="error".md5($PHP_AUTH_USER.$PHP_AUTH_PW);
1194                                    }
1195                            }
1196                            $gblEmail=$user[3];
1197                            continue ;
1198                    }
1199            }
1200            fclose($htusers);
1201    
1202          // authentication if $gblAuth == true          // authentication failure
1203          if ( $gblAuth && $gblHash($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ||          if ( md5($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ||
1204                  isset($relogin) && $gblPw == $relogin ) {                  isset($relogin) && $gblPw == $relogin ) {
1205                  header("WWW-authenticate: basic realm=\"$HTTP_HOST\"") ;                  header("WWW-authenticate: basic realm=\"$HTTP_HOST\"") ;
1206                  header("HTTP/1.0 401 Unauthorized") ;                  header("HTTP/1.0 401 Unauthorized") ;
# Line 1199  function DisplayChangeLog($day) { Line 1214  function DisplayChangeLog($day) {
1214                  $relDir = urldecode($D) ;  // then use GET                  $relDir = urldecode($D) ;  // then use GET
1215          }                }      
1216    
1217            $relDir=stripSlashes($relDir);
1218    
1219          if ($relDir == "/") $relDir = "" ;                if ($relDir == "/") $relDir = "" ;      
1220          // default : website root = ""          // default : website root = ""
1221    
# Line 1224  function DisplayChangeLog($day) { Line 1241  function DisplayChangeLog($day) {
1241          $fsDir = $gblFsRoot . $relDir ; // current directory          $fsDir = $gblFsRoot . $relDir ; // current directory
1242          if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ;          if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ;
1243    
1244            if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") {
1245                    $webRoot  = "https://";
1246            } else {
1247                    $webRoot  = "http://";
1248            }
1249            $webRoot .= $GLOBALS["HTTP_HOST"] . $relScriptDir;
1250    
1251          $FN=stripSlashes($FN);          $FN=stripSlashes($FN);
1252    
1253          switch ($POSTACTION) {          switch ($POSTACTION) {
# Line 1234  function DisplayChangeLog($day) { Line 1258  function DisplayChangeLog($day) {
1258                  // TODO : should rather check for escapeshellcmds                  // TODO : should rather check for escapeshellcmds
1259                  // but maybe RFC 18xx asserts safe filenames ....                  // but maybe RFC 18xx asserts safe filenames ....
1260                  $source = $FN ;                  $source = $FN ;
1261                    if (! file_exists($source)) {
1262                            Error("You must select file with browse to upload it!");
1263                    }
1264                  if (! isset($FILENAME)) {       // from update file                  if (! isset($FILENAME)) {       // from update file
1265                          $target = "$fsDir/$FN_name" ;                          $target = "$fsDir/$FN_name" ;
1266                  } else {                  } else {
# Line 1298  function DisplayChangeLog($day) { Line 1325  function DisplayChangeLog($day) {
1325  // this functionality is doubled in DetailView().  // this functionality is doubled in DetailView().
1326  // better keep it here altogether  // better keep it here altogether
1327  // chmod perms to $gblFilePerms  // chmod perms to $gblFilePerms
1328                          if ( file_exists($path) && !is_writable($path) )                          if ( file_exists($path) && !is_writeable($path) )
1329                                  Error("File not writable", $relPath) ;                                  Error("File not writable", $relPath) ;
1330                          $fh = fopen($path, "w+") ;                          $fh = fopen($path, "w+") ;
1331                          if ($fh) {                          if ($fh) {
# Line 1370  function DisplayChangeLog($day) { Line 1397  function DisplayChangeLog($day) {
1397                  if ( $CONFIRM != "on" ) break ;                  if ( $CONFIRM != "on" ) break ;
1398    
1399                  Logit("$fsDir/$FN","renamed $FN to $NEWNAME");                  Logit("$fsDir/$FN","renamed $FN to $NEWNAME");
1400                  safe_rename("$fsDir/$FN","$fsDir/$NEWNAME");                  safe_rename($fsDir,$FN,$NEWNAME);
                 safe_rename("$fsDir/.log/$FN","$fsDir/.log/$NEWNAME");  
                 safe_rename("$fsDir/.note/$FN","$fsDir/.note/$NEWNAME");  
                 safe_rename("$fsDir/.lock/$FN","$fsDir/.lock/$NEWNAME");  
                 for($i=0;$i<=$GLOBALS[gblNumBackups];$i++) {  
                         safe_rename("$fsDir/.bak/$i/$FN","$fsDir/.bak/$i/$NEWNAME");  
                 }  
   
1401                  break ;                  break ;
1402    
1403          case "NOTE" :            case "NOTE" :  
# Line 1423  function DisplayChangeLog($day) { Line 1443  function DisplayChangeLog($day) {
1443          case "E" :          case "E" :
1444                  $F=stripSlashes($F);                  $F=stripSlashes($F);
1445                  // detail of $relDir/$F                  // detail of $relDir/$F
1446                  if (is_file("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ;                  if (is_file("$gblFsRoot/$relDir/$F") || is_dir("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ;
1447                  exit ;                  exit ;
1448          case "C" :          case "C" :
1449                  $F=stripSlashes($F);                  $F=stripSlashes($F);
# Line 1434  function DisplayChangeLog($day) { Line 1454  function DisplayChangeLog($day) {
1454                  // checkout                  // checkout
1455                  Lock("$gblFsRoot/$relDir/$F");                  Lock("$gblFsRoot/$relDir/$F");
1456                  header("Content-Disposition: attachment; filename=$F" );                  header("Content-Disposition: attachment; filename=$F" );
1457                  Header("Location: ".urlpath("$relDir/$F"));                  Header("Location: $webRoot".urlpath("$relDir/$F"));
1458                  exit;                  exit;
1459          case "Ci" :          case "Ci" :
1460                  $F=stripSlashes($F);                  $F=stripSlashes($F);
# Line 1451  function DisplayChangeLog($day) { Line 1471  function DisplayChangeLog($day) {
1471                  // view                  // view
1472                  LogIt("$gblFsRoot/$relDir/$F","viewed");                  LogIt("$gblFsRoot/$relDir/$F","viewed");
1473                  header("Content-Disposition: attachment; filename=$F" );                  header("Content-Disposition: attachment; filename=$F" );
1474                  Header("Location: ".urlpath("$relDir/$F"));                  Header("Location: $webRoot".urlpath("$relDir/$F"));
1475                  exit;                  exit;
1476          case "Ch" :          case "Ch" :
1477                  StartHTML("(File changes)","All changes chronologicaly...");                  StartHTML("(File changes)","All changes chronologicaly...");

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.37

  ViewVC Help
Powered by ViewVC 1.1.26