/[docman2]/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.3 by dpavlin, Sat Jul 27 14:45:30 2002 UTC revision 1.12 by dpavlin, Sat Jul 27 22:26:30 2002 UTC
# Line 25  Line 25 
25          // from where to include auth_*.php modules?          // from where to include auth_*.php modules?
26          $gblIncDir = "/data/docman2";          $gblIncDir = "/data/docman2";
27    
28          // force download (so it won't open in associated application)          // force download on view (so it won't open in associated application)
29          $gblForceDownload = 1;          $gblForceDownload = 0;
30    
31          // date format          // date format
32          $gblDateFmt="Y-m-d";          $gblDateFmt="Y-m-d";
# Line 84  Line 84 
84          LoadLanguage($HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"]);          LoadLanguage($HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"]);
85    
86          // for security and configuration          // for security and configuration
87          $realm="$HTTP_HOST";    // FIX          $realm=$HTTP_SERVER_VARS[HTTP_HOST];
88    
89          $fsDocumentRoot = dirname($HTTP_SERVER_VARS[SCRIPT_FILENAME]);          $fsDocumentRoot = dirname($HTTP_SERVER_VARS[SCRIPT_FILENAME]);
90          if ($fsDocumentRoot == "") Error("Configuration error","Can't get SCRIPT_FILENAME from your web server. Please set <tt>\$fsDocumentRoot</tt> in <tt>\$</tt>",1);          if ($fsDocumentRoot == "") Error("Configuration error","Can't get SCRIPT_FILENAME from your web server. Please set <tt>\$fsDocumentRoot</tt> in <tt>\$</tt>",1);
91    
92          // globals for later          // globals for later
93          $gblLogin = $PHP_AUTH_USER;          $gblLogin = $HTTP_SERVER_VARS[PHP_AUTH_USER];
94          $gblPasswd = $PHP_AUTH_PW;          $gblPasswd = $HTTP_SERVER_VARS[PHP_AUTH_PW];
95    
96  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
97    
# Line 109  function LoadLanguage($lang) { Line 109  function LoadLanguage($lang) {
109    
110  function StartHTML($title,$text="") {  function StartHTML($title,$text="") {
111    
112          global $html,$fsDocumentRoot;          global $html,$fsDocumentRoot,$HTTP_SERVER_VARS;
113    
114          $title = $gblTitle." ".$title ;          $title = $gblTitle." ".$title ;
115          $host  = $GLOBALS["HTTP_HOST"] ;          $host  = $HTTP_SERVER_VARS["HTTP_HOST"] ;
116          $self  = $GLOBALS["PHP_SELF"] ;          $self  = $HTTP_SERVER_VARS["PHP_SELF"] ;
117    
118          if (file_exists("$fsDocumentRoot/docman.css")) {          if (file_exists("$fsDocumentRoot/docman.css")) {
119                  $css=dirname($self)."/docman.css";                  $css=dirname($self)."/docman.css";
120          } else {          } else {
121                  $css=$self."?STYLE=get&css=$css";                  $css=$self."?STYLE=get";
122          }          }
123    
124          include("$html/head.html");          include("$html/head.html");
# Line 145  function EndHTML() { Line 145  function EndHTML() {
145                  $url_title="relogin";                  $url_title="relogin";
146          }          }
147          include("$html/footer.html");          include("$html/footer.html");
         //phpinfo();  
148  } // end function EndHTML  } // end function EndHTML
149    
150  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
151    
152  function DetailPage($fsRoot,$relDir,$fn) {  function DetailPage($fsRoot,$relDir,$fn) {
153                    
154          global $gblEditable, $gblImages, $webRoot, $html ;          global $gblEditable, $gblImages, $webRoot, $html, $HTTP_SERVER_VARS ;
155          $self = $GLOBALS["PHP_SELF"] ;          $self = $HTTP_SERVER_VARS["PHP_SELF"] ;
156    
157          $relPath  = $relDir . "/" . $fn ;          $relPath  = $relDir . "/" . $fn ;
158          $fsPath   = $fsRoot . $relPath ;          $fsPath   = $fsRoot . $relPath ;
# Line 572  function GifIcon($txt) { Line 571  function GifIcon($txt) {
571  function Navigate($fsRoot,$relDir) {  function Navigate($fsRoot,$relDir) {
572    
573          global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide,          global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide,
574                  $HTTP_GET_VARS, $html;                  $gblIgnoreUnknownFileType, $gblRepositoryDir,
575                    $fsRealmDir, $realm, $realm_sep,
576                    $HTTP_GET_VARS, $html, $realm_config;
577    
578          $self     = $GLOBALS["PHP_SELF"] ;          $self     = $HTTP_SERVER_VARS["PHP_SELF"] ;
579    
580          if ($relDir == "") $relDir = "/";          if ($relDir == "") $relDir = "/";
581    
# Line 584  function Navigate($fsRoot,$relDir) { Line 585  function Navigate($fsRoot,$relDir) {
585    
586          $hide_items=",$gblHide,";          $hide_items=",$gblHide,";
587    
 #display_all_trustee();  
 print "-- $fsDir --";  
   
588          // read directory contents          // read directory contents
589          if ( !($dir = @opendir($fsDir)) )          if ( !($dir = @opendir($fsDir)) )
590                  Error("Read Access denied",$relDir) ;                  Error("Read Access denied",$relDir,1) ;
591          while ($item = readdir($dir)) {          while ($item = readdir($dir)) {
 print "$item, ";  
592                  if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") ) continue ;                  if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") ) continue ;
593                  if ((is_dir($fsDir.$item) || is_link ($fsDir.$item)) && check_perm($relDir.$item,trperm_b)) {                  if (is_dir($fsDir.$item) || is_link ($fsDir.$item)) {
594                          $dirList[$item] = $item ;                          if (check_perm($relDir.$item,trperm_b)) {
595                          $dirNote[$item] = ReadNote($fsDir.$item);                                  $dirList[$item] = $item ;
596                  } else if ( is_file($fsDir.$item) && check_perm($relDir.$item,trperm_r) ) {                                  $dirNote[$item] = ReadNote($fsDir.$item);
597                          $fileList[$item] = $item ;                                        }
598                          $fileDate[$item] = filemtime($fsDir.$item) ;                  } else if (is_file($fsDir.$item)) {
599                          $fileSize[$item] = filesize($fsDir.$item) ;                          if (check_perm($relDir.$item,trperm_r)) {
600                          $fileNote[$item] = ReadNote($fsDir.$item);                                  $fileList[$item] = $item ;              
601                                    $fileDate[$item] = filemtime($fsDir.$item) ;
602                                    $fileSize[$item] = filesize($fsDir.$item) ;
603                                    $fileNote[$item] = ReadNote($fsDir.$item);
604                            }
605                  } else {                  } else {
606                    // unknown file type                          if (! $gblIgnoreUnknownFileType) Error("File Type Error", "Item <tt>".$fsDir.$item."</tt> is not file, directory or link. If you want to ignore errors like this, set <tt>\$gblIgnoreUnknownFileType = 1</tt> in <tt>$realm_config</tt>.",1);
                   // $text = "Could not determine file type of " ;  
                   // Error("File Error", $text.$relDir."/".$item) ;  
                   // exit ;  
607                  }                  }
608          }          }
609          closedir($dir) ;          closedir($dir) ;
610    
611          // scan deleted files          // scan deleted files
612          if ( $GLOBALS[show_deleted] == 1 && ($dir = @opendir("$fsDir/.del")) ) {          if ( $HTTP_GET_VARS["show_deleted"] == 1 && ($dir = @opendir("$fsDir/.del")) ) {
613                  while ($item = readdir($dir)) {                  while ($item = readdir($dir)) {
614                          if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") || !check_perm($relDir.$item,trperm_w) ) continue ;                          if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") || !check_perm($relDir.$item,trperm_w) ) continue ;
615                          $fileList[$item] = ".del/$item" ;                                        $fileList[$item] = ".del/$item" ;              
# Line 626  print "$item, "; Line 624  print "$item, ";
624    
625          // start navigation page          // start navigation page
626          $text  = "Use this page to add, delete";          $text  = "Use this page to add, delete";
627          if (! isset($show_deleted)) {          if (! isset($HTTP_GET_VARS[show_deleted])) {
628                  $text .= ", <a href=$self?D=".urlencode($relDir)."&show_deleted=1>undelete</a>";                  $text .= ", <a href=$self?D=".urlencode($relDir)."&show_deleted=1>undelete</a>";
629          }          }
630          $text .= " or revise files on this web site." ;          $text .= " or revise files on this web site." ;
# Line 788  print "$item, "; Line 786  print "$item, ";
786    
787                  $file_lock=CheckLock($path);                  $file_lock=CheckLock($path);
788    
789                  $file_url_html="<A HREF=\"$self?A=V&F=".urlencode($file);                  $file_url_html="<A HREF=\"$self?A=V&D=".urlencode($relDir)."&F=".urlencode($file);
                 $file_url_html.="&D=".urlencode($relDir);  
790                  $file_url_html.="\" TITLE=\"View file\">" ;                  $file_url_html.="\" TITLE=\"View file\">" ;
791    
792                  if (substr($file,0,5) != ".del/") {                  if (substr($file,0,5) != ".del/") {
# Line 804  print "$item, "; Line 801  print "$item, ";
801    
802                  if ($file_lock) {                  if ($file_lock) {
803                          if ($file_lock == $GLOBALS[gblUserName]) {                          if ($file_lock == $GLOBALS[gblUserName]) {
804                                  $b.="<A HREF=\"$self?A=Ci&F=".urlencode($file);                                  $b.="<A HREF=\"$self?A=Ci&D=".urlencode($relDir)."&F=".urlencode($file);
                                 $b.="&D=".urlencode($relDir);  
805                                  $b.="\" TITLE=\"Checkin (update) file on server\">" ;                                  $b.="\" TITLE=\"Checkin (update) file on server\">" ;
806                                  $file_url_html=$b;                                  $file_url_html=$b;
807                                  $b.=$gblIcon("checkin")."</A>" ;                                  $b.=$gblIcon("checkin")."</A>" ;
# Line 819  print "$item, "; Line 815  print "$item, ";
815                                  $file_url_html = "$file $a";                                  $file_url_html = "$file $a";
816                          }                          }
817                  } else {                  } else {
818                          $b.="<A HREF=\"$self?A=Co&F=".urlencode($file);                          $b.="<A HREF=\"$self?A=Co&D=".urlencode($relDir)."&F=".urlencode($file);
                         $b.="&D=".urlencode($relDir);  
819                          $b.="\" TITLE=\"Checkout file for edit\">" ;                          $b.="\" TITLE=\"Checkout file for edit\">" ;
820                          $b.=$gblIcon("checkout")."</A>" ;                          $b.=$gblIcon("checkout")."</A>";
821    
822                          if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) {                            if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) {  
823                                  $b.="<A HREF=\"$self?A=C&F=".urlencode($file);                                  $b.="<A HREF=\"$self?A=C&D=".urlencode($relDir)."&F=".urlencode($file);
                                 $b.="&D=".urlencode($relDir);  
824                                  $b.="\" TITLE=\"List contents\">" ;                                  $b.="\" TITLE=\"List contents\">" ;
825                                  $b.=$gblIcon("view")."</A>" ;                                  $b.=$gblIcon("view")."</A>" ;
826                          } else {                          } else {
# Line 866  print "$item, "; Line 860  print "$item, ";
860  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>
861    
862  <?  <?
863  if (file_exists(".info.inc")) {  
864    if (file_exists("$fsRealmDir/$realm".$realm_sep."info.inc")) {
865          print "<TR><TD></TD><TD COLSPAN=5>";          print "<TR><TD></TD><TD COLSPAN=5>";
866          include(".info.inc");          include("$fsRealmDir/$realm".$realm_sep."info.inc");
867          print "</TD></TR>          print "</TD></TR><TR><TD></TD><TD COLSPAN=5><HR></TD></TR>";
868          <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>";  } elseif (file_exists("$gblRepositoryDir/.info.inc")) {
869            print "<TR><TD></TD><TD COLSPAN=5>";
870            include("$gblRepositoryDir/.info.inc");
871            print "</TD></TR><TR><TD></TD><TD COLSPAN=5><HR></TD></TR>";
872  }  }
873    
874    
875  ?>  ?>
876    
877  <FORM METHOD="POST" ACTION="<?= $self ?>">  <FORM METHOD="POST" ACTION="<?= $self ?>">
# Line 896  if (file_exists(".info.inc")) { Line 896  if (file_exists(".info.inc")) {
896    
897  function UploadPage($fsRoot, $relDir, $filename="") {  function UploadPage($fsRoot, $relDir, $filename="") {
898    
899          $self = $GLOBALS["PHP_SELF"] ;          global $html, $HTTP_SERVER_VARS;
900    
901            $self = $HTTP_SERVER_VARS["PHP_SELF"] ;
902          if ($relDir == "") $relDir = "/" ;          if ($relDir == "") $relDir = "/" ;
 ?>  
903    
904  <P><TABLE BORDER=0 CELLPADDING=5><TR><TD WIDTH=5></TD><TD CLASS=BAR>          include("$html/UploadPage.html");
 <FORM ENCTYPE="multipart/form-data" METHOD="POST"  
  ACTION="<?= $self ?>">  
 DESTINATION DIRECTORY:<B><?= " " . $relDir ?></B>  
 <? if (isset($filename) && $filename!="") { ?>  
 <br>DESTINATION FILE:<B><?= " " . $filename ?></B>  
 <INPUT TYPE="HIDDEN" NAME="FILENAME" VALUE="<?= $filename ?>">  
 <? } ?>  
 <P>PATHNAME OF LOCAL FILE<BR>  
 <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">  
 <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="UPLOAD">  
 <INPUT SIZE=30 TYPE="FILE" NAME="FN"></P>  
 <P><INPUT TYPE="SUBMIT" VALUE="UPLOAD"></P>  
 <P>If the <B>[BROWSE...]</B> button is not displayed,<BR>  
 you must upgrade to an RFC1867-compliant browser.</P>  
 <P>Your browser:<BR><?= $GLOBALS["HTTP_USER_AGENT"] ?></P>  
 </FORM>  
 </TD></TR>  
 <TR><TD></TD><TD>  
 <FORM METHOD="POST" ACTION="<?= $self ?>">  
 <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"><BR>  
 <INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL">  
 </FORM>  
 </TD></TR></TABLE></P>  
905    
 <?php    
906  } // end function UploadPage  } // end function UploadPage
907    
908  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
# Line 933  you must upgrade to an RFC1867-compliant Line 910  you must upgrade to an RFC1867-compliant
910  // Error with sysadmin flag are reported to error_log or hidden from  // Error with sysadmin flag are reported to error_log or hidden from
911  // users  // users
912    
913  function Error($title,$text="",$sysadmin=0) {  function Error($title,$text="",$sysadmin=0,$no_404=0) {
914          global $gblSeparateAdminMessages,          global $gblSeparateAdminMessages,
915                  $gblMailAdminMessages,$realm,                  $gblMailAdminMessages,$realm,
916                  $HTTP_SERVER_VARS;                  $HTTP_SERVER_VARS;
917            if (! headers_sent() && ! $no_404) header("HTTP/1.0 404 Not Found");
918          if ($sysadmin) {          if ($sysadmin) {
919                  if ($gblSeparateAdminMessages) {                  if ($gblSeparateAdminMessages) {
920                          $user="Your administrator ";                          $user="Your administrator ";
# Line 1105  function safe_rename($fromdir,$fromfile, Line 1083  function safe_rename($fromdir,$fromfile,
1083          function try_rename($from,$to) {          function try_rename($from,$to) {
1084  #               print "$from -> $to\n";  #               print "$from -> $to\n";
1085                  if (file_exists($from) && is_writeable(dirname($to))) {                  if (file_exists($from) && is_writeable(dirname($to))) {
1086                          rename($from,$to);                          return rename($from,$to);
1087                    } else {
1088                            return 0;
1089                  }                  }
1090          }          }
1091    
1092          function try_dir($todir) {          function try_dir($todir) {
1093                  if (! file_exists($todir)) {                  if (! file_exists($todir)) {
1094                          mkdir($todir,0700);                          @mkdir($todir,0700);
1095                  }                  }
1096          }          }
1097    
# Line 1121  function safe_rename($fromdir,$fromfile, Line 1101  function safe_rename($fromdir,$fromfile,
1101    
1102  #       print "<pre>$fromdir / $fromfile -> $todir / $tofile\n\n";  #       print "<pre>$fromdir / $fromfile -> $todir / $tofile\n\n";
1103    
1104          try_rename("$fromdir/$fromfile","$todir/$tofile");          if (! try_rename("$fromdir/$fromfile","$todir/$tofile")) Error("Rename error","Can't rename file <tt>$fromfile</tt> to <tt>$tofile</tt>",1);
1105          try_dir("$todir/.log");          try_dir("$todir/.log");
1106          try_rename("$fromdir/.log/$fromfile","$todir/.log/$tofile");          try_rename("$fromdir/.log/$fromfile","$todir/.log/$tofile");
1107          try_dir("$todir/.note");          try_dir("$todir/.note");
# Line 1157  function rrmdir($dir) { Line 1137  function rrmdir($dir) {
1137    
1138  function DisplayChangeLog($day) {  function DisplayChangeLog($day) {
1139    
1140          global $gblFsRoot;          global $gblFsRoot,$HTTP_SERVER_VARS;
1141    
1142          if (!file_exists("$gblFsRoot/.changelog")) return;          if (!file_exists("$gblFsRoot/.changelog")) return;
1143          $log=fopen("$gblFsRoot/.changelog","r");          $log=fopen("$gblFsRoot/.changelog","r");
1144          $logarr = array();          $logarr = array();
# Line 1179  function DisplayChangeLog($day) { Line 1160  function DisplayChangeLog($day) {
1160                  $time = date("$GLOBALS[gblTimeFmt]", $e[0]);                  $time = date("$GLOBALS[gblTimeFmt]", $e[0]);
1161                  $dir = dirname($e[1]);                  $dir = dirname($e[1]);
1162                  $file = basename($e[1]);                  $file = basename($e[1]);
1163                  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";                  print "<tr><td$cl>$date</td><td$cl>$time</td><td$cl><a href=\"$HTTP_SERVER_VARS[PHP_SELF]?D=".urlencode($dir)."\">$dir</a>/$file</td><td$cl>$e[2]</td><td$cl>$e[3]</td></tr>\n";
1164          }          }
1165          print "</table>";          print "</table>";
1166          print "<p>".GifIcon(up)." Back to <a href=$GLOBALS[PHP_SELF]>front page</a>.</p>";          print "<p>".GifIcon(up)." Back to <a href=$HTTP_SERVER_VARS[PHP_SELF]>front page</a>.</p>";
1167  }  }
1168    
1169  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1170    
1171  function Download($path) {  function Download($path,$force=0) {
1172          global $HTTP_USER_AGENT;          global $HTTP_SERVER_VARS,$mime_type;
1173          $file=basename($path);  
1174            // default transfer-encoding
1175            $encoding = "binary";
1176    
1177            // known transfer encodings
1178            $encoding_ext = array(
1179                    "gz" => "x-gzip",
1180                    "Z" => "x-compress",
1181            );
1182    
1183            $file = basename($path);
1184          $size = filesize($path);          $size = filesize($path);
1185          //header("Content-Type: application/octet-stream");  
1186          header("Content-Type: application/force-download");          $ext_arr = explode(".",$file);
1187          header("Content-Length: $size");          $ext = array_pop($ext_arr);
1188            if ($encoding_ext[$ext]) {
1189                    $encoding = $encoding_ext[$ext];
1190                    $ext = array_pop($ext_arr);
1191            }
1192    
1193            if ($force || !isset($mime_type[$ext])) {
1194                    header("Content-Type: application/force-download");
1195            } else {
1196                    header("Content-Type: $mime_type[$ext]");
1197            }
1198    
1199          // IE5.5 just downloads index.php if we don't do this          // IE5.5 just downloads index.php if we don't do this
1200          if(preg_match("/MSIE 5.5/", $HTTP_USER_AGENT)) {          if(preg_match("/MSIE 5.5/", $HTTP_SERVER_VARS[HTTP_USER_AGENT])) {
1201                  header("Content-Disposition: filename=$file");                  header("Content-Disposition: filename=$file");
1202          } else {          } else {
1203                  header("Content-Disposition: attachment; filename=$file");                  header("Content-Disposition: attachment; filename=$file");
1204          }          }
1205          header("Content-Transfer-Encoding: binary");  
1206            header("Content-Transfer-Encoding: $encoding");
1207          $fh = fopen($path, "r");          $fh = fopen($path, "r");
1208          fpassthru($fh);          fpassthru($fh);
1209  }  }
# Line 1447  print " return: $return<br>\n"; Line 1450  print " return: $return<br>\n";
1450          return($return);          return($return);
1451  }  }
1452    
1453    //////////////////////////////////////////////////////////////////
1454    
1455    function readMime() {
1456            global $mime_type;
1457    
1458            if (! isset($gblMimeTypes)) {
1459                    $gblMimeTypes = "/etc/mime.types";
1460            }
1461    
1462            $mime = @fopen($gblMimeTypes,"r");
1463    
1464            if (! $mime) Error("Can't read MIME types","<tt>$gblMimeTypes</tt> file not found. You can setup other <tt>mime.types</tt> file using <tt>\$gblMimeTypes</tt> in <tt>$realm_config</tt>");
1465    
1466            while($line = fgets($mime,80)) {
1467                    if (substr($line,0,1) == "#") continue; // skip comment
1468                    $arr = preg_split("/[\s\t]+/",$line);
1469                    $type = array_shift($arr);
1470                    while ($ext = array_shift($arr)) {
1471                            $mime_type[$ext] = $type;
1472                    }
1473            }
1474    
1475            fclose($mime);
1476    }
1477    
1478  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1479  // MAIN PROGRAM  // MAIN PROGRAM
# Line 1454  print " return: $return<br>\n"; Line 1481  print " return: $return<br>\n";
1481          $gblFilePerms = 0640 ;         // default for new files          $gblFilePerms = 0640 ;         // default for new files
1482          $gblDirPerms  = 0750 ;          // default for new dirs          $gblDirPerms  = 0750 ;          // default for new dirs
1483    
1484            $STYLE = $HTTP_GET_VARS[STYLE];
1485          if (isset($STYLE) && $STYLE == "get") {          if (isset($STYLE) && $STYLE == "get") {
1486                  include("$html/docman.css");                  include("$html/docman.css");
1487                  exit;                  exit;
# Line 1472  print " return: $return<br>\n"; Line 1500  print " return: $return<br>\n";
1500          if (! isset($fsRealmDir)) {          if (! isset($fsRealmDir)) {
1501                  $fsRealmDir = "$gblIncDir/realm";                  $fsRealmDir = "$gblIncDir/realm";
1502          }          }
1503          $realm_config = "$fsRealmDir/$realm.conf";  
1504            // try to add dir to script name to realm var
1505            if (is_dir("$fsRealmDir/$realm/".dirname($HTTP_SERVER_VARS[SCRIPT_NAME]))) {
1506                    $realm .= "/".dirname($HTTP_SERVER_VARS[SCRIPT_NAME]);
1507                    $realm_sep = "/";
1508            } else {
1509                    $realm_sep = ".";
1510            }
1511    
1512            $realm_config = $fsRealmDir."/".$realm.$realm_sep."conf";
1513    
1514          // read user-defined configuration          // read user-defined configuration
1515          if (file_exists($realm_config)) {          if (file_exists($realm_config)) {
# Line 1508  print " return: $return<br>\n"; Line 1545  print " return: $return<br>\n";
1545          if (!is_dir($gblRepositoryDir)) Error("Repository dir not found","Can't find repository directory <tt>$gblRepositoryDir</tt>. Please fix that in <tt>$realm_config</tt> variable <tt>\$gblRepositoryDir</tt>.",1);          if (!is_dir($gblRepositoryDir)) Error("Repository dir not found","Can't find repository directory <tt>$gblRepositoryDir</tt>. Please fix that in <tt>$realm_config</tt> variable <tt>\$gblRepositoryDir</tt>.",1);
1546    
1547          // trustee (ACL) file configuration          // trustee (ACL) file configuration
1548          $trustee_conf="$gblIncDir/realm/$realm.trustee";          $trustee_conf="$fsRealmDir/$realm".$realm_sep."trustee";
1549          // compiled version of trustee file          // compiled version of trustee file
1550          $trustee_php="$gblRepositoryDir/.trustee.php";          $trustee_php="$gblRepositoryDir/.trustee.php";
1551          // get ACL informations          // get ACL informations
# Line 1529  print " return: $return<br>\n"; Line 1566  print " return: $return<br>\n";
1566                  isset($relogin) && $secHash == $relogin) {                  isset($relogin) && $secHash == $relogin) {
1567                  header("WWW-authenticate: basic realm=\"$realm\"") ;                  header("WWW-authenticate: basic realm=\"$realm\"") ;
1568                  header("HTTP/1.0 401 Unauthorized") ;                  header("HTTP/1.0 401 Unauthorized") ;
1569                  Error("401 Unauthorized","No trespassing !");                  Error("401 Unauthorized","No trespassing !",0,1);
                 exit ;  
1570          }          }
1571    
1572            // read mime.types
1573            readMime();
1574    
1575          // get current directory relative to $gblFsRoot          // get current directory relative to $gblFsRoot
1576          $relDir = $DIR ;        // from POST          $relDir = $DIR ;        // from POST
1577          if ($relDir == "") {    // not defined in POST ?          if ($relDir == "") {    // not defined in POST ?
# Line 1561  print " return: $return<br>\n"; Line 1600  print " return: $return<br>\n";
1600          $fsDir = $gblFsRoot . $relDir ; // current directory          $fsDir = $gblFsRoot . $relDir ; // current directory
1601          if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ;          if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ;
1602    
1603          if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") {          if (isset($HTTP_SERVER_VARS["HTTPS"]) && $HTTP_SERVER_VARS["HTTPS"] == "on") {
1604                  $webRoot  = "https://";                  $webRoot  = "https://";
1605          } else {          } else {
1606                  $webRoot  = "http://";                  $webRoot  = "http://";
1607          }          }
1608          $webRoot .= $GLOBALS["HTTP_HOST"] . $relScriptDir;          $webRoot .= $HTTP_SERVER_VARS["HTTP_HOST"] . $relScriptDir;
1609    
1610          $FN=stripSlashes($FN);          // take variables from server
1611            $FN=stripSlashes($HTTP_POST_VARS["FN"]);
1612            $DIR=stripSlashes($HTTP_POST_VARS["DIR"]);
1613            $RELPATH=stripSlashes($HTTP_POST_VARS["RELPATH"]);
1614            $T=stripSlashes($HTTP_POST_VARS["T"]);
1615            $CONFIRM=stripSlashes($HTTP_POST_VARS["CONFIRM"]);
1616    
1617            // get
1618            $A=stripSlashes($HTTP_GET_VARS["A"]);
1619            $D=stripSlashes($HTTP_GET_VARS["D"]);
1620    
1621    //      if (isset($F)) Error("Document manager system error","variable $F shouldn't be set here (re-check old code)",1);
1622    //      $F=stripSlashes($HTTP_SERVER_VARS["PATH_INFO"]);
1623            $F=stripSlashes($HTTP_GET_VARS["F"]);
1624    
1625          switch ($POSTACTION) {          switch ($HTTP_POST_VARS["POSTACTION"]) {
1626          case "UPLOAD" :          case "UPLOAD" :
1627                    $FN_name=stripSlashes($HTTP_POST_FILES["FN"]["tmp_name"]);
1628                    $FN=stripSlashes($HTTP_POST_FILES["FN"]["name"]);
1629                  if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;                  if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;
1630                  if (strstr($FN_name,"/"))  
1631                          Error("Non-conforming filename") ;                  $source = $FN_name ;
                 // TODO : should rather check for escapeshellcmds  
                 // but maybe RFC 18xx asserts safe filenames ....  
                 $source = $FN ;  
1632                  if (! file_exists($source)) {                  if (! file_exists($source)) {
1633                          Error("You must select file with browse to upload it!");                          Error("You must select file with browse to upload it!");
1634                  }                  }
1635    
1636                    $FILENAME = $HTTP_POST_VARS["FILENAME"];
1637                    if (strstr($FILENAME,"/"))
1638                            Error("Upload error","Non-conforming filename. Filename <tt>$FILENAME</tt> has slashes (<tt>/</tt>) in it.") ;
1639                  if (! isset($FILENAME)) {       // from update file                  if (! isset($FILENAME)) {       // from update file
1640                          $target = "$fsDir/$FN_name" ;                          $target = "$fsDir/".basename($FN);
1641                  } else {                  } else {
1642                          $target = "$fsDir/$FILENAME";                          $target = "$fsDir/$FILENAME";
1643                  }                  }
# Line 1680  print " return: $return<br>\n"; Line 1735  print " return: $return<br>\n";
1735    
1736  //                      if ( ! @unlink($path) ) {  //                      if ( ! @unlink($path) ) {
1737                          if ( ! rename($path,"$dir/.del/$file") ) {                          if ( ! rename($path,"$dir/.del/$file") ) {
                                 Error("File delete failed", $tstr . $path) ;  
1738                                  LogIt($path,"file delete failed");                                  LogIt($path,"file delete failed");
1739                                  exit ;                                  Error("File delete failed", $tstr . $path) ;
1740                          } else {                          } else {
1741                                  LogIt($path,"file deleted",trperm_w);                                  LogIt($path,"file deleted",trperm_w);
1742                                  MoveTo("$dir/.log/$file","$dir/.del/.log/");                                  MoveTo("$dir/.log/$file","$dir/.del/.log/");
# Line 1716  print " return: $return<br>\n"; Line 1770  print " return: $return<br>\n";
1770          case "RENAME" :            case "RENAME" :  
1771                  if ( $CONFIRM != "on" ) break ;                  if ( $CONFIRM != "on" ) break ;
1772    
1773                    $NEWNAME=stripSlashes($HTTP_POST_VARS["NEWNAME"]);
1774                  LogIt("$fsDir/$FN","renamed $FN to $NEWNAME",trperm_r);                  LogIt("$fsDir/$FN","renamed $FN to $NEWNAME",trperm_r);
1775                  safe_rename($fsDir,$FN,$NEWNAME);                  safe_rename($fsDir,$FN,$NEWNAME);
1776                  break ;                  break ;
1777    
1778          case "NOTE" :            case "NOTE" :  
1779                    $NOTE=stripSlashes($HTTP_POST_VARS["NOTE"]);
1780                  WriteNote("$fsDir/$FN","$NOTE");                  WriteNote("$fsDir/$FN","$NOTE");
1781                  break ;                  break ;
1782    
# Line 1756  print " return: $return<br>\n"; Line 1812  print " return: $return<br>\n";
1812                  if (!is_writeable($gblFsRoot . $relDir))                  if (!is_writeable($gblFsRoot . $relDir))
1813                          Error("Write access denied",$relDir) ;                          Error("Write access denied",$relDir) ;
1814                  $text  = "Use this page to upload a single " ;                  $text  = "Use this page to upload a single " ;
1815                  $text .= "file to <B>$HTTP_HOST</B>." ;                  $text .= "file to <B>$realm</B>." ;
1816                  StartHTML("(Upload Page)", $text) ;                  StartHTML("(Upload Page)", $text) ;
1817                  UploadPage($gblFsRoot, $relDir) ;                  UploadPage($gblFsRoot, $relDir) ;
1818                  EndHTML() ;                  EndHTML() ;
1819                  exit ;                  exit ;
1820          case "E" :          case "E" :
                 $F=stripSlashes($F);  
1821                  // detail of $relDir/$F                  // detail of $relDir/$F
1822                  if (is_file("$gblFsRoot/$relDir/$F") || is_dir("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ;                  if (is_file("$gblFsRoot/$relDir/$F") || is_dir("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ;
1823                  exit ;                  exit ;
# Line 1774  print " return: $return<br>\n"; Line 1829  print " return: $return<br>\n";
1829          case "Co" :          case "Co" :
1830                  // checkout                  // checkout
1831                  Lock("$gblFsRoot/$relDir/$F");                  Lock("$gblFsRoot/$relDir/$F");
1832                  Download("$gblFsRoot/$relDir/$F");                  Download("$gblFsRoot/$relDir/$F",1);
1833                  exit;                  exit;
1834          case "Ci" :          case "Ci" :
1835                  $F=stripSlashes($F);                  $F=stripSlashes($F);
# Line 1782  print " return: $return<br>\n"; Line 1837  print " return: $return<br>\n";
1837                  if (!is_writeable($gblFsRoot . $relDir))                  if (!is_writeable($gblFsRoot . $relDir))
1838                          Error("Write access denied",$relDir) ;                          Error("Write access denied",$relDir) ;
1839                  $text  = "Use this page to update a single " ;                  $text  = "Use this page to update a single " ;
1840                  $text .= "file to <B>$HTTP_HOST</B>." ;                  $text .= "file to <B>$realm</B>." ;
1841                  StartHTML("(Update file Page)", $text) ;                  StartHTML("(Update file Page)", $text) ;
1842                  UploadPage($gblFsRoot, $relDir, $F) ;                  UploadPage($gblFsRoot, $relDir, $F) ;
1843                  EndHTML() ;                  EndHTML() ;
# Line 1790  print " return: $return<br>\n"; Line 1845  print " return: $return<br>\n";
1845          case "V" :          case "V" :
1846                  // view                  // view
1847                  LogIt("$gblFsRoot/$relDir/$F","viewed");                  LogIt("$gblFsRoot/$relDir/$F","viewed");
1848                  if ($gblForceDownload) {                  Download("$gblFsRoot/$relDir/$F",$gblForceDownload);
                         Download("$gblFsRoot/$relDir/$F");  
                 } else {  
                         header("Content-Disposition: attachment; filename=$F" );  
                         Header("Location: $webRoot".urlpath("$relDir/$F"));  
                 }  
1849                  exit;                  exit;
1850          case "Ch" :          case "Ch" :
1851                  StartHTML("(File changes)","All changes chronologicaly...");                  StartHTML("(File changes)","All changes chronologicaly...");
# Line 1817  print " return: $return<br>\n"; Line 1867  print " return: $return<br>\n";
1867                  $title = "You should define \$title variable with page title";                  $title = "You should define \$title variable with page title";
1868                  include($inc_file);                  include($inc_file);
1869                  StartHTML($title, $text) ;                  StartHTML($title, $text) ;
1870                  print "<p>".GifIcon(up)." Back to <a href=$GLOBALS[PHP_SELF]>front page</a>.</p>";                  print "<p>".GifIcon(up)." Back to <a href=$HTTP_SERVER_VARS[PHP_SELF]>front page</a>.</p>";
1871                  EndHTML() ;                  EndHTML() ;
1872                  exit ;                  exit ;
1873          }          }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.12

  ViewVC Help
Powered by ViewVC 1.1.26