/[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.17 by dpavlin, Wed Sep 6 14:25:15 2000 UTC revision 1.32 by dpavlin, Thu Feb 15 21:20:53 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          retrieve old versions of files (overwritten)          access controll
61          show last lock date  
           
62  */  */
63    
64  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
# Line 80  TODO: Line 71  TODO:
71    
72  // GLOBAL PARAMETERS  // GLOBAL PARAMETERS
73  // =================  // =================
74  // Make modifications here to suit siteman to your needs  // Make modifications here to suit docman to your needs
75    
76  //      error_reporting(4) ;            // how verbose ?  //      error_reporting(4) ;            // how verbose ?
77    
78            // from where to include auth_*.php modules?
79            $gblIncDir = "/home/httpd/docman";
80    
81          // username/password should not be system          // username/password should not be system
82          // usernames/passwords !!          // usernames/passwords !!
83    
 //      $gblPw    = "hash_of_your_username_and_password" ;  
   
 //      $gblAuth  = false ;             // use builtin authentication  
         $gblAuth  = true ;             // use builtin authentication  
         $gblHash  = "md5" ;             // hash function to use  
   
84          $gblPw    = "";          $gblPw    = "";
85    
86          if ($gblAuth) {          // date format
                 $htusers_file=dirname($SCRIPT_FILENAME)."/.htusers";  
                 if (! file_exists($htusers_file)) {  
                         $htusers=fopen($htusers_file,"a+");  
                         fputs($htusers,"# Change owner of $htusers_file to root !!\n");  
                         fputs($htusers,"demo:full name:md5_hash\n");  
                         fclose($htusers);  
                 }  
                 $htusers=fopen($htusers_file,"r");  
                 while($user = fgetcsv($htusers,255,":")) {  
                         if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) {  
                                 $gblUserName=$user[1];  
                                 $gblPw=$user[2];  
                                 $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 130  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 154  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 233  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 301  echo($fstr) ; ?></TEXTAREA> Line 271  echo($fstr) ; ?></TEXTAREA>
271          }          }
272          if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) {            if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) {  
273                  $info  = getimagesize($fsPath) ;                  $info  = getimagesize($fsPath) ;
274                  $tstr = "<IMG SRC=\"".urlpath($relPath)."\" BORDER=0 " ;                  $tstr = "<IMG SRC=\"$webRoot".urlpath($relPath)."\" BORDER=0 " ;
275                  $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;                  $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;
276                  $tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ;                  $tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ;
277  //              echo htmlentities($tstr) . "<BR><BR>" . $tstr ;  //              echo htmlentities($tstr) . "<BR><BR>" . $tstr ;
# Line 367  echo($fstr) ; ?></TEXTAREA> Line 337  echo($fstr) ; ?></TEXTAREA>
337  </FORM>  </FORM>
338    
339  <?php  <?php
340            
341          $name=basename("$fsDir/$fn");          $name=basename("$fsDir/$fn");
342          $logname=dirname("$fsDir/$fn")."/.log/$name";          $logname=dirname("$fsDir/$fn")."/.log/$name";
343          $bakdir=dirname("$fsDir/$fn")."/.bak";          $bakdir=dirname("$fsDir/$fn")."/.bak";
344          if (file_exists($logname)) {          if (file_exists($logname)) {
345                  $log=fopen($logname,"r");                  $log=fopen($logname,"r");
346                  $cl1=" class=lst"; $cl2="";                  $cl1=" class=LST"; $cl2="";
347                  $logarr = array();                  $logarr = array();
348                  while($line = fgetcsv($log,255,"\t")) {                  while($line = fgetcsv($log,255,"\t")) {
349                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;
# Line 385  echo($fstr) ; ?></TEXTAREA> Line 355  echo($fstr) ; ?></TEXTAREA>
355                  while ($e = array_shift($logarr)) {                  while ($e = array_shift($logarr)) {
356                          if (strstr($e[4],"upload")) {                          if (strstr($e[4],"upload")) {
357                                  if (file_exists("$bakdir/$bakcount/$name")) {                                  if (file_exists("$bakdir/$bakcount/$name")) {
358                                          $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>";
359                                  }                                  }
360                                  $bakcount++;                                  $bakcount++;
361                          }                          }
# Line 646  function GifIcon($txt) { Line 616  function GifIcon($txt) {
616    
617  function Navigate($fsRoot,$relDir) {  function Navigate($fsRoot,$relDir) {
618    
619          global $gblEditable, $gblIcon, $gblModDays ;          global $gblEditable, $gblIcon, $gblModDays, $webRoot ;
620    
621          $self     = $GLOBALS["PHP_SELF"] ;          $self     = $GLOBALS["PHP_SELF"] ;
622          if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") {  
623                  $webRoot  = "https://" . $GLOBALS["SERVER_NAME"] ;          $fsDir = $fsRoot . $relDir . "/" ; // current directory
         } else {  
                 $webRoot  = "http://" . $GLOBALS["SERVER_NAME"] ;  
         }  
         $fsDir    = $fsRoot . $relDir . "/" ; // current directory  
624    
625          if (!is_dir($fsDir)) Error("Dir not found",$relDir) ;          if (!is_dir($fsDir)) Error("Dir not found",$relDir) ;
626    
# Line 695  function Navigate($fsRoot,$relDir) { Line 661  function Navigate($fsRoot,$relDir) {
661                  $text .= ", <a href=$self?D=".urlencode($relDir)."&show_deleted=1>undelete</a>";                  $text .= ", <a href=$self?D=".urlencode($relDir)."&show_deleted=1>undelete</a>";
662          }          }
663          $text .= " or revise files on this web site." ;          $text .= " or revise files on this web site." ;
664            $text .= "<br>Examine list of files <a href=\"$self?A=Ch1\">changed in last day</a> or <a href=\"$self?A=Ch\">all changes</a>.";
665          StartHTML("(Navigate)",$text) ;          StartHTML("(Navigate)",$text) ;
666    
667          echo "<TABLE BORDER=0 CELLPADDING=2          echo "<TABLE BORDER=0 CELLPADDING=2
# Line 828  function Navigate($fsRoot,$relDir) { Line 795  function Navigate($fsRoot,$relDir) {
795    
796  <?php  <?php
797            }  // iterate over files            }  // iterate over files
798          }  // end if no files          } else {  // end if no files
799    ?>
800     <TR><TD></TD><TD COLSPAN=5 CLASS=LST>
801      No files in this directory
802     </TD></TR>
803    <?
804            }
805    
806          if ($emptyDir) {          if ($emptyDir) {
807  ?>  ?>
# Line 848  function Navigate($fsRoot,$relDir) { Line 821  function Navigate($fsRoot,$relDir) {
821    
822  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>
823    
 <TR><TD></TD><TD COLSPAN=5>  
824  <?  <?
825  if (file_exists(".info.inc")) {  if (file_exists(".info.inc")) {
826            print "<TR><TD></TD><TD COLSPAN=5>";
827          include(".info.inc");          include(".info.inc");
828            print "</TD></TR>
829            <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>";
830  }  }
831  ?>  ?>
 </TD></TR>  
   
 <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>  
832    
833  <FORM METHOD="POST" ACTION="<?= $self ?>">  <FORM METHOD="POST" ACTION="<?= $self ?>">
834  <TR><TD></TD><TD COLSPAN=5 CLASS=BAR>CREATE NEW  <TR><TD></TD><TD COLSPAN=5 CLASS=BAR>CREATE NEW
# Line 878  if (file_exists(".info.inc")) { Line 850  if (file_exists(".info.inc")) {
850    
851  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
852    
853  function UploadPage($fsRoot, $relDir, $filename) {  function UploadPage($fsRoot, $relDir, $filename="") {
854    
855          $self = $GLOBALS["PHP_SELF"] ;          $self = $GLOBALS["PHP_SELF"] ;
856          if ($relDir == "") $relDir = "/" ;          if ($relDir == "") $relDir = "/" ;
# Line 888  function UploadPage($fsRoot, $relDir, $f Line 860  function UploadPage($fsRoot, $relDir, $f
860  <FORM ENCTYPE="multipart/form-data" METHOD="POST"  <FORM ENCTYPE="multipart/form-data" METHOD="POST"
861   ACTION="<?= $self ?>">   ACTION="<?= $self ?>">
862  DESTINATION DIRECTORY:<B><?= " " . $relDir ?></B>  DESTINATION DIRECTORY:<B><?= " " . $relDir ?></B>
863  <? if (isset($filename)) { ?>  <? if (isset($filename) && $filename!="") { ?>
864  <br>DESTINATION FILE:<B><?= " " . $filename ?></B>  <br>DESTINATION FILE:<B><?= " " . $filename ?></B>
865  <INPUT TYPE="HIDDEN" NAME="FILENAME" VALUE="<?= $filename ?>">  <INPUT TYPE="HIDDEN" NAME="FILENAME" VALUE="<?= $filename ?>">
866  <? } ?>  <? } ?>
# Line 923  function Error($title,$text="") { Line 895  function Error($title,$text="") {
895    
896  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
897    
 function CreateHash($user, $pw) {  
   
         global $gblHash ;  // hash function to use  
   
         if ($user == "" || $pw == "") {  
                 $text = "either no password or no username supplied" ;  
                 Error("Create Hash",$text) ;  
         }  
         $title = "(Create Hash)" ;  
         StartHTML($title) ;  
         echo "<P ALIGN=center>" ;  
         echo "<BLOCKQUOTE>Copy the value below and paste it " ;  
         echo "into the<BR>value for \$gblPw in the source of " ;  
         echo "this file<BR><BR><B>" . $gblHash($user.$pw) ;  
         echo "</B><BR><BR>Hash function: " . $gblHash ;  
         echo "</BLOCKQUOTE></P>" ;  
         EndHTML() ;  
         exit ;  
   
 } // end function CreateHash  
   
 //////////////////////////////////////////////////////////////////  
   
898  function NoEntry() {  function NoEntry() {
899    
900          $user = $GLOBALS["PHP_AUTH_USER"] ;          $user = $GLOBALS["PHP_AUTH_USER"] ;
# Line 955  function NoEntry() { Line 904  function NoEntry() {
904          $title = "(401 Unauthorized)" ;          $title = "(401 Unauthorized)" ;
905          $text  = "No trespassing !" ;          $text  = "No trespassing !" ;
906          StartHTML($title,$text) ;          StartHTML($title,$text) ;
 ?>  
   
 <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>  
907    
 <?php  
908          EndHTML() ;          EndHTML() ;
909          exit ;          exit ;
910  }  }
911    
912  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
913    
914  function Logit($target,$msg) {  function LogIt($target,$msg) {
915    
916          $dir=dirname($target);          $dir=dirname($target);
917          if (! file_exists($dir."/.log")) {          if (! file_exists($dir."/.log")) {
# Line 995  function Logit($target,$msg) { Line 931  function Logit($target,$msg) {
931    
932  function WriteNote($target,$msg) {  function WriteNote($target,$msg) {
933    
934            $target=stripSlashes($target);
935          $dir=dirname($target);          $dir=dirname($target);
936          if (! file_exists($dir."/.note")) {          if (! file_exists($dir."/.note")) {
937                  mkdir($dir."/.note",0700);                  mkdir($dir."/.note",0700);
# Line 1011  function WriteNote($target,$msg) { Line 948  function WriteNote($target,$msg) {
948    
949  function ReadNote($target) {  function ReadNote($target) {
950    
951            $target=stripSlashes($target);
952          $dir=dirname($target);          $dir=dirname($target);
953          $file=basename($target);          $file=basename($target);
954          $msg="";          $msg="";
# Line 1027  function ReadNote($target) { Line 965  function ReadNote($target) {
965    
966  function MoveTo($source,$folder) {  function MoveTo($source,$folder) {
967    
968            $source=stripSlashes($source);
969          $file=basename($source);          $file=basename($source);
970          if (! file_exists($folder)) {          if (! file_exists($folder)) {
971                  mkdir($folder,0700);                  mkdir($folder,0700);
# Line 1040  function MoveTo($source,$folder) { Line 979  function MoveTo($source,$folder) {
979    
980  function Lock($target) {  function Lock($target) {
981    
982            $target=stripSlashes($target);
983          $dir=dirname($target);          $dir=dirname($target);
984          if (! file_exists($dir."/.lock")) {          if (! file_exists($dir."/.lock")) {
985                  mkdir($dir."/.lock",0700);                  mkdir($dir."/.lock",0700);
# Line 1060  function Lock($target) { Line 1000  function Lock($target) {
1000    
1001  function CheckLock($target) {  function CheckLock($target) {
1002    
1003            $target=stripSlashes($target);
1004          $dir=dirname($target);          $dir=dirname($target);
1005          $file=basename($target);          $file=basename($target);
1006          $msg=0;          $msg=0;
# Line 1074  function CheckLock($target) { Line 1015  function CheckLock($target) {
1015    
1016  function Unlock($target) {  function Unlock($target) {
1017    
1018            $target=stripSlashes($target);
1019          $dir=dirname($target);          $dir=dirname($target);
1020          $file=basename($target);          $file=basename($target);
1021          if (file_exists($dir."/.lock/$file")) {          if (file_exists($dir."/.lock/$file")) {
# Line 1122  function rrmdir($dir) { Line 1064  function rrmdir($dir) {
1064    
1065  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1066    
1067    function ChangeLog($target,$msg) {
1068    
1069            global $gblFsRoot;
1070            $log=fopen("$gblFsRoot/.changelog","a+");
1071            if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot)
1072                    $target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot));
1073            fputs($log,time()."\t$target\t$GLOBALS[gblUserName]\t$msg\n");
1074            fclose($log);
1075    
1076    }
1077    
1078    function DisplayChangeLog($day) {
1079    
1080            global $gblFsRoot;
1081            if (!file_exists("$gblFsRoot/.changelog")) return;
1082            $log=fopen("$gblFsRoot/.changelog","r");
1083            $logarr = array();
1084            while($line = fgetcsv($log,255,"\t")) {
1085                    if ($day!=1 || ($day==1 && (time()-$line[0] < 24*60*60))) {
1086                            array_unshift($logarr,array($line[0],$line[1],$line[2],$line[3]));
1087                    }
1088            }
1089            fclose($log);
1090            $cl1=" class=LST"; $cl2="";
1091            print "<table border=0 width=100%>\n";
1092            while ($e = array_shift($logarr)) {
1093                    $cl=$cl1; $cl1=$cl2; $cl2=$cl;
1094                    $date = date("$GLOBALS[gblDateFmt]", $e[0]);
1095                    $time = date("$GLOBALS[gblTimeFmt]", $e[0]);
1096                    $dir = dirname($e[1]);
1097                    $file = basename($e[1]);
1098                    print "<tr><td$cl>$date</td><td$cl>$time</td><td$cl><a href=\"$GLOBALS[PHP_SELF]?D=".urlencode($dir)."\">$dir</a>/$file</td><td$cl>$e[2]</td><td$cl>$e[3]</td></tr>\n";
1099            }
1100            print "</table>";
1101            print "<p>".GifIcon(up)." Back to <a href=$GLOBALS[PHP_SELF]>front page</a>.</p>";
1102    }
1103    
1104    //////////////////////////////////////////////////////////////////
1105    
1106  // MAIN PROGRAM  // MAIN PROGRAM
1107  // ============  // ============
1108  // query parameters: capital letters  // query parameters: capital letters
# Line 1137  function rrmdir($dir) { Line 1118  function rrmdir($dir) {
1118          // forks before authentication: style sheet and hash          // forks before authentication: style sheet and hash
1119          // creation if password not yet set.          // creation if password not yet set.
1120          if ($STYLE == "get") { CSS() ; exit ; }          if ($STYLE == "get") { CSS() ; exit ; }
1121          if ($HASH != "") {  
1122                  CreateHash($USER, $PW) ;          $htusers_file=dirname($SCRIPT_FILENAME)."/.htusers";
1123                  exit ;          if (! file_exists($htusers_file)) {
1124                    if (is_writable(dirname($SCRIPT_FILENAME))) {
1125                            $htusers=fopen($htusers_file,"a+");
1126                            fputs($htusers,"# Change owner of $htusers_file to root !!\n");
1127                            fputs($htusers,"demo:full name:[md5_hash|auth_*]:e-mail\n");
1128                            fclose($htusers);
1129                            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!");
1130                            exit;
1131                    } else {
1132                            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!");
1133                            exit;
1134                    }
1135            }
1136            $htusers=fopen($htusers_file,"r");
1137            while($user = fgetcsv($htusers,255,":")) {
1138                    if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) {
1139                            $gblUserName=$user[1];
1140                            $gblPw=$user[2];
1141                            if (substr($gblPw,0,5) == "auth_" && file_exists("$gblIncDir/$gblPw.php")) {
1142                                    require("$gblIncDir/$gblPw.php");
1143                                    if ($gblPw($user)) {
1144                                            $gblPw=md5($PHP_AUTH_USER.$PHP_AUTH_PW);
1145                                    } else {
1146                                            $gblPw="error".md5($PHP_AUTH_USER.$PHP_AUTH_PW);
1147                                    }
1148                            }
1149                            $gblEmail=$user[3];
1150                            continue ;
1151                    }
1152          }          }
1153            fclose($htusers);
1154    
1155          // authentication if $gblAuth == true          // authentication failure
1156          if ( $gblAuth && $gblHash($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ||          if ( md5($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ||
1157                  isset($relogin) && $gblPw == $relogin ) {                  isset($relogin) && $gblPw == $relogin ) {
1158                  header("WWW-authenticate: basic realm=\"$SERVER_NAME\"") ;                  header("WWW-authenticate: basic realm=\"$HTTP_HOST\"") ;
1159                  header("HTTP/1.0 401 Unauthorized") ;                  header("HTTP/1.0 401 Unauthorized") ;
1160                  NoEntry() ;                  NoEntry() ;
1161                  exit ;                  exit ;
# Line 1168  function rrmdir($dir) { Line 1178  function rrmdir($dir) {
1178          // i.e. below $gblFsRoot.          // i.e. below $gblFsRoot.
1179    
1180          $relScriptDir = dirname($SCRIPT_NAME) ;                  $relScriptDir = dirname($SCRIPT_NAME) ;        
1181          // i.e. /siteman          // i.e. /docman
1182    
1183          $fsScriptDir  = dirname($SCRIPT_FILENAME) ;              $fsScriptDir  = dirname($SCRIPT_FILENAME) ;    
1184          // i.e. /home/httpd/html/siteman          // i.e. /home/httpd/html/docman
1185    
1186          $gblFsRoot = substr($fsScriptDir,0,          // start on server root
1187            strlen($fsScriptDir)-strlen($relScriptDir)) ;  //      $gblFsRoot = substr($fsScriptDir,0, strlen($fsScriptDir)-strlen($relScriptDir)) ;
1188            // or on script root
1189            $gblFsRoot = $fsScriptDir;
1190          // i.e. /home/httpd/html          // i.e. /home/httpd/html
1191    
1192          $fsDir = $gblFsRoot . $relDir ; // current directory          $fsDir = $gblFsRoot . $relDir ; // current directory
1193          if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ;          if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ;
1194            
1195            if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") {
1196                    $webRoot  = "https://";
1197            } else {
1198                    $webRoot  = "http://";
1199            }
1200            $webRoot .= $GLOBALS["HTTP_HOST"] . $relScriptDir;
1201    
1202            $FN=stripSlashes($FN);
1203    
1204          switch ($POSTACTION) {          switch ($POSTACTION) {
1205          case "UPLOAD" :          case "UPLOAD" :
1206                  if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;                  if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;
# Line 1188  function rrmdir($dir) { Line 1209  function rrmdir($dir) {
1209                  // TODO : should rather check for escapeshellcmds                  // TODO : should rather check for escapeshellcmds
1210                  // but maybe RFC 18xx asserts safe filenames ....                  // but maybe RFC 18xx asserts safe filenames ....
1211                  $source = $FN ;                  $source = $FN ;
1212                    if (! file_exists($source)) {
1213                            Error("You must select file with browse to upload it!");
1214                    }
1215                  if (! isset($FILENAME)) {       // from update file                  if (! isset($FILENAME)) {       // from update file
1216                          $target = "$fsDir/$FN_name" ;                          $target = "$fsDir/$FN_name" ;
1217                  } else {                  } else {
# Line 1215  function rrmdir($dir) { Line 1239  function rrmdir($dir) {
1239                  if (isset($FILENAME)) {                  if (isset($FILENAME)) {
1240                          Unlock($target);                          Unlock($target);
1241                  }                  }
1242                    ChangeLog($target,"updated");
1243                  break ;                  break ;
1244    
1245          case "SAVE" :          case "SAVE" :
1246                  $path = $gblFsRoot . $RELPATH ;                  $path = $gblFsRoot . $RELPATH ;
1247                    $path=stripSlashes($path);
1248                  $writable = is_writeable($path) ;                  $writable = is_writeable($path) ;
1249                  $legaldir = is_writeable(dirname($path)) ;                  $legaldir = is_writeable(dirname($path)) ;
1250                  $exists   = (file_exists($path)) ? 1 : 0 ;                  $exists   = (file_exists($path)) ? 1 : 0 ;
# Line 1226  function rrmdir($dir) { Line 1252  function rrmdir($dir) {
1252                  if (!($writable || (!$exists && $legaldir)))                  if (!($writable || (!$exists && $legaldir)))
1253                          Error("Write denied",$RELPATH) ;                          Error("Write denied",$RELPATH) ;
1254                  $fh = fopen($path, "w") ;                  $fh = fopen($path, "w") ;
1255                    $FILEDATA=stripSlashes($FILEDATA);
1256                  fwrite($fh,$FILEDATA) ;                  fwrite($fh,$FILEDATA) ;
1257                  fclose($fh) ;                  fclose($fh) ;
1258                  clearstatcache() ;                  clearstatcache() ;
1259                  Logit($path,"saved changes");                  Logit($path,"saved changes");
1260                    ChangeLog($path,"saved changes");
1261                  break ;                  break ;
1262    
1263          case "CREATE" :          case "CREATE" :
# Line 1260  function rrmdir($dir) { Line 1288  function rrmdir($dir) {
1288                          }                          }
1289                          $tstr = "$PHP_SELF?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ;                          $tstr = "$PHP_SELF?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ;
1290                          header("Location: " . $tstr) ;                          header("Location: " . $tstr) ;
1291                            ChangeLog($target,"created");
1292                          exit ;                          exit ;
1293                  }                  }
1294                  break ;                  break ;
# Line 1357  function rrmdir($dir) { Line 1386  function rrmdir($dir) {
1386          // $A=Ci : checkin file $D/$F          // $A=Ci : checkin file $D/$F
1387          // $A=V : view file (do nothing except log)          // $A=V : view file (do nothing except log)
1388          // default : display directory $D          // default : display directory $D
1389            
1390          switch ($A) {          switch ($A) {
1391          case "U" :          case "U" :
1392                  // upload to $relDir                  // upload to $relDir
1393                  if (!is_writeable($gblFsRoot . $relDir))                  if (!is_writeable($gblFsRoot . $relDir))
1394                          Error("Write access denied",$relDir) ;                          Error("Write access denied",$relDir) ;
1395                  $text  = "Use this page to upload a single " ;                  $text  = "Use this page to upload a single " ;
1396                  $text .= "file to <B>$SERVER_NAME</B>." ;                  $text .= "file to <B>$HTTP_HOST</B>." ;
1397                  StartHTML("(Upload Page)", $text) ;                  StartHTML("(Upload Page)", $text) ;
1398                  UploadPage($gblFsRoot, $relDir) ;                  UploadPage($gblFsRoot, $relDir) ;
1399                  EndHTML() ;                  EndHTML() ;
1400                  exit ;                  exit ;
1401          case "E" :          case "E" :
1402                    $F=stripSlashes($F);
1403                  // detail of $relDir/$F                  // detail of $relDir/$F
1404                  if (is_file("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ;                  if (is_file("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ;
1405                  exit ;                  exit ;
1406          case "C" :          case "C" :
1407                    $F=stripSlashes($F);
1408                  // listing of $relDir/$F                  // listing of $relDir/$F
1409                  DisplayCode($gblFsRoot, $relDir, $F) ;                  DisplayCode($gblFsRoot, $relDir, $F) ;
1410                  exit ;                  exit ;
# Line 1381  function rrmdir($dir) { Line 1412  function rrmdir($dir) {
1412                  // checkout                  // checkout
1413                  Lock("$gblFsRoot/$relDir/$F");                  Lock("$gblFsRoot/$relDir/$F");
1414                  header("Content-Disposition: attachment; filename=$F" );                  header("Content-Disposition: attachment; filename=$F" );
1415                  Header("Location: ".urlpath("$relDir/$F"));                  Header("Location: $webRoot".urlpath("$relDir/$F"));
1416                  exit;                  exit;
1417          case "Ci" :          case "Ci" :
1418                    $F=stripSlashes($F);
1419                  // upload && update to $relDir                  // upload && update to $relDir
1420                  if (!is_writeable($gblFsRoot . $relDir))                  if (!is_writeable($gblFsRoot . $relDir))
1421                          Error("Write access denied",$relDir) ;                          Error("Write access denied",$relDir) ;
1422                  $text  = "Use this page to update a single " ;                  $text  = "Use this page to update a single " ;
1423                  $text .= "file to <B>$SERVER_NAME</B>." ;                  $text .= "file to <B>$HTTP_HOST</B>." ;
1424                  StartHTML("(Update file Page)", $text) ;                  StartHTML("(Update file Page)", $text) ;
1425                  UploadPage($gblFsRoot, $relDir, $F) ;                  UploadPage($gblFsRoot, $relDir, $F) ;
1426                  EndHTML() ;                  EndHTML() ;
# Line 1397  function rrmdir($dir) { Line 1429  function rrmdir($dir) {
1429                  // view                  // view
1430                  LogIt("$gblFsRoot/$relDir/$F","viewed");                  LogIt("$gblFsRoot/$relDir/$F","viewed");
1431                  header("Content-Disposition: attachment; filename=$F" );                  header("Content-Disposition: attachment; filename=$F" );
1432                  Header("Location: ".urlpath("$relDir/$F"));                  Header("Location: $webRoot".urlpath("$relDir/$F"));
1433                    exit;
1434            case "Ch" :
1435                    StartHTML("(File changes)","All changes chronologicaly...");
1436                    DisplayChangeLog(0);    // all
1437                    EndHTML() ;
1438                    exit;
1439            case "Ch1" :
1440                    StartHTML("(File changes)","Changes to files in last day...");
1441                    DisplayChangeLog(1);
1442                    EndHTML() ;
1443                  exit;                  exit;
1444          }          }
1445    

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.32

  ViewVC Help
Powered by ViewVC 1.1.26