/[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.12 by dpavlin, Sat Jul 27 22:26:30 2002 UTC revision 1.22 by dpavlin, Sun Jul 28 18:56:49 2002 UTC
# Line 20  Line 20 
20  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
21  // CONFIGURATION OPTIONS  // CONFIGURATION OPTIONS
22    
23  //      error_reporting(4) ;            // how verbose ?          error_reporting(E_ALL) ;                // how verbose ?
24    
25          // from where to include auth_*.php modules?          // from where to include auth_*.php modules?
26          $gblIncDir = "/data/docman2";          $gblIncDir = "/data/docman2";
# 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_SERVER_VARS[HTTP_HOST];          $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 = $HTTP_SERVER_VARS[PHP_AUTH_USER];          $gblLogin = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
94          $gblPasswd = $HTTP_SERVER_VARS[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,$HTTP_SERVER_VARS;          global $html,$fsDocumentRoot,$gblTitle,$HTTP_SERVER_VARS;
113    
         $title = $gblTitle." ".$title ;  
114          $host  = $HTTP_SERVER_VARS["HTTP_HOST"] ;          $host  = $HTTP_SERVER_VARS["HTTP_HOST"] ;
115          $self  = $HTTP_SERVER_VARS["PHP_SELF"] ;          $self  = $HTTP_SERVER_VARS["PHP_SELF"] ;
116    
# Line 138  function EndHTML() { Line 137  function EndHTML() {
137          } else {          } else {
138                  $url .= md5($gblLogin.$gblPasswd);                  $url .= md5($gblLogin.$gblPasswd);
139          }          }
140          if (isset($gblLogin) && $gblLogin != "" && ($gblPasswd == "" || !isset($gblPasswd))) {          if ( (  (isset($gblLogin) && $gblLogin != "") ||
141                    (!isset($gblLogin) || $gblLogin == "")
142                 ) && ($gblPasswd == "" || !isset($gblPasswd))) {
143                  $url_title="login";                  $url_title="login";
144                  $url .= "&force_login=1";                  $url .= "&force_login=1";
145          } else {          } else {
146                  $url_title="relogin";                  $url_title="relogin";
147          }          }
148          include("$html/footer.html");          include("$html/footer.html");
149    
150            global $debug;
151            if ($debug) print $debug;
152  } // end function EndHTML  } // end function EndHTML
153    
154  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
155    
156  function DetailPage($fsRoot,$relDir,$fn) {  function DetailPage($fsRoot,$relDir,$fn) {
157                    
158          global $gblEditable, $gblImages, $webRoot, $html, $HTTP_SERVER_VARS ;          global $gblEditable, $gblImages,
159                    $gblDateFmt, $gblTimeFmt,
160                    $webRoot, $html,
161                    $HTTP_SERVER_VARS ;
162          $self = $HTTP_SERVER_VARS["PHP_SELF"] ;          $self = $HTTP_SERVER_VARS["PHP_SELF"] ;
163    
164          $relPath  = $relDir . "/" . $fn ;          $relPath  = $relDir . "/" . $fn ;
# Line 160  function DetailPage($fsRoot,$relDir,$fn) Line 167  function DetailPage($fsRoot,$relDir,$fn)
167    
168          $exists   = file_exists($fsPath) ;          $exists   = file_exists($fsPath) ;
169          $ext      = strtolower(strrchr($relPath,".")) ;          $ext      = strtolower(strrchr($relPath,".")) ;
170          $editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) ;          $editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) &&
171          $writable = is_writeable($fsPath) ;                  check_perm($relPath,trperm_w);
172            $writable = is_writeable($fsPath) && check_perm($relPath,trperm_w) ;
173            $writable_dir = is_writeable($fsDir) && check_perm($relDir,trperm_w) ;
174          $file_lock = CheckLock($fsPath);          $file_lock = CheckLock($fsPath);
175    
176          if (!$editable && !$exists)          if (!$editable && !$exists)
177                  Error("Creation unsupported for type",$relPath) ;                  Error("Creation denied","Can't create <tt>$relPath</tt>") ;
178          if (!exists && !is_writeable($fsDir) )          if (!$exists && !$writable_dir )
179                  Error("Creation denied",$relDir) ;                  Error("Creation denied","Can't write in directory <tt>$relDir</tt> while creating <tt>$relPath</tt>for which user has permissions.",1);
180    
181          $text  = _("Use this page to view, modify or ") ;          $text  = _("Use this page to view, modify or ") ;
182          if (is_dir($fsPath)) {          if (is_dir($fsPath)) {
# Line 182  function DetailPage($fsRoot,$relDir,$fn) Line 191  function DetailPage($fsRoot,$relDir,$fn)
191          echo "<H3>" . $relDir . "/" . $fn . "</H3>" ;          echo "<H3>" . $relDir . "/" . $fn . "</H3>" ;
192          if ($exists) {  // get file info          if ($exists) {  // get file info
193                  $fsize = filesize($fsPath) ;                  $fsize = filesize($fsPath) ;
194                  $fmodified = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", filemtime($fsPath)) ;                  $fmodified = date("$gblDateFmt $gblTimeFmt", filemtime($fsPath)) ;
195                  $faccessed = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]", fileatime($fsPath)) ;                  $faccessed = date("$gblDateFmt $gblTimeFmt", fileatime($fsPath)) ;
196                  $fuid=fileowner($fsPath);                  $fuid=fileowner($fsPath);
197                  $fgid=filegroup($fsPath);                  $fgid=filegroup($fsPath);
198                  $userinfo = posix_getpwuid($fuid);                  $userinfo = posix_getpwuid($fuid);
# Line 200  function DetailPage($fsRoot,$relDir,$fn) Line 209  function DetailPage($fsRoot,$relDir,$fn)
209                  $fstr = htmlentities( $fstr ) ;                  $fstr = htmlentities( $fstr ) ;
210  ?>  ?>
211    
212  <FORM ACTION="<?= $self ; ?>" METHOD="POST">  <FORM ACTION="<?= $self ?>" METHOD="POST">
213  <SPAN TITLE="Click [SAVE] to store updated contents.">  <SPAN TITLE="Click [SAVE] to store updated contents.">
214          <B>DOCUMENT CONTENTS</B>          <B>DOCUMENT CONTENTS</B>
215  </SPAN><BR>  </SPAN><BR>
# Line 572  function Navigate($fsRoot,$relDir) { Line 581  function Navigate($fsRoot,$relDir) {
581    
582          global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide,          global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide,
583                  $gblIgnoreUnknownFileType, $gblRepositoryDir,                  $gblIgnoreUnknownFileType, $gblRepositoryDir,
584                    $gblLogin, $gblUserName,
585                  $fsRealmDir, $realm, $realm_sep,                  $fsRealmDir, $realm, $realm_sep,
586                  $HTTP_GET_VARS, $html, $realm_config;                  $html, $realm_config,
587                    $HTTP_GET_VARS, $HTTP_SERVER_VARS;
588            
589          $self     = $HTTP_SERVER_VARS["PHP_SELF"] ;          $self     = $HTTP_SERVER_VARS["PHP_SELF"] ;
590    
591          if ($relDir == "") $relDir = "/";          $relDir = chopsl($relDir)."/";
592            $fsDir = $fsRoot.$relDir;       // current directory
593    
594          $fsDir = $fsRoot.$relDir."/";   // current directory          if (!is_dir($fsDir)) Error("Dir not found","Directory <tt>$relDir<tt> not found on filesystem at <tt>$fsDir</tt>",1) ;
595    
596          if (!is_dir($fsDir)) Error("Dir not found",$relDir) ;          global $debug;
597            $debug .= "[$gblLogin|$relDir] before >";
598    
599            if (! check_perm($relDir,trperm_b))
600                    Error("Access denied","User <tt>$gblLogin</tt> tried to access <tt>$relDir</tt> without valid trustee.",1);
601            $debug .= "< afeter";
602    
603          $hide_items=",$gblHide,";          $hide_items=",$gblHide,";
604    
605            $dirList = array();
606            $fileList = array();
607    
608          // read directory contents          // read directory contents
609          if ( !($dir = @opendir($fsDir)) )          if ( !($dir = @opendir($fsDir)) )
610                  Error("Read Access denied",$relDir,1) ;                  Error("Read Access denied",$relDir,1) ;
# Line 609  function Navigate($fsRoot,$relDir) { Line 629  function Navigate($fsRoot,$relDir) {
629          closedir($dir) ;          closedir($dir) ;
630    
631          // scan deleted files          // scan deleted files
632          if ( $HTTP_GET_VARS["show_deleted"] == 1 && ($dir = @opendir("$fsDir/.del")) ) {          if ( HTTP_GET_VAR("show_deleted") == 1 && ($dir = @opendir("$fsDir/.del")) ) {
633                  while ($item = readdir($dir)) {                  while ($item = readdir($dir)) {
634                          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 ;
635                          $fileList[$item] = ".del/$item" ;                                        $fileList[$item] = ".del/$item" ;              
# Line 624  function Navigate($fsRoot,$relDir) { Line 644  function Navigate($fsRoot,$relDir) {
644    
645          // start navigation page          // start navigation page
646          $text  = "Use this page to add, delete";          $text  = "Use this page to add, delete";
647          if (! isset($HTTP_GET_VARS[show_deleted])) {          if (! isset($HTTP_GET_VARS["show_deleted"])) {
648                  $text .= ", <a href=$self?D=".urlencode($relDir)."&show_deleted=1>undelete</a>";                  $text .= ", <a href=$self?D=".urlencode($relDir)."&show_deleted=1>undelete</a>";
649          }          }
650          $text .= " or revise files on this web site." ;          $text .= " or revise files on this web site." ;
# Line 634  function Navigate($fsRoot,$relDir) { Line 654  function Navigate($fsRoot,$relDir) {
654          echo "<TABLE BORDER=0 CELLPADDING=2          echo "<TABLE BORDER=0 CELLPADDING=2
655                  CELLSPACING=3 WIDTH=\"100%\">" ;                  CELLSPACING=3 WIDTH=\"100%\">" ;
656    
657          // updir bar              // updir (parent) bar  
658          if (chopsl($fsDir) != chopsl($fsRoot)) {          if (chopsl($fsDir) != chopsl($fsRoot)) {
659                  $parent = dirname($relDir) ;                  $parent = dirname($relDir) ;
660                  if ($parent == "") $parent = "/" ;                  if ($parent == "") $parent = "/" ;
# Line 650  function Navigate($fsRoot,$relDir) { Line 670  function Navigate($fsRoot,$relDir) {
670                  return $out;                  return $out;
671          }          }
672    
673          $dsort = $HTTP_GET_VARS[dsort];          if (! HTTP_GET_VAR("dsort")) $dsort = "name"; // default directory sort
         if (! isset($dsort)) $dsort = "name";   // default directory sort  
674    
675          $dsort_arr = array(          $dsort_arr = array(
676                  "name" => array ("rname", "note"),                  "name" => array ("rname", "note"),
# Line 660  function Navigate($fsRoot,$relDir) { Line 679  function Navigate($fsRoot,$relDir) {
679                  "rnote" => array ("name", "note")                  "rnote" => array ("name", "note")
680                  );                  );
681    
682          $fsort = $HTTP_GET_VARS[fsort];          if (! HTTP_GET_VAR("fsort")) $fsort = "name"; // default directory sort
         if (! isset($fsort)) $fsort = "name";   // default directory sort  
683    
684          $fsort_arr = array(          $fsort_arr = array(
685                  "name" => array ("rname", "note", "date", "size"),                  "name" => array ("rname", "note", "date", "size"),
# Line 677  function Navigate($fsRoot,$relDir) { Line 695  function Navigate($fsRoot,$relDir) {
695          $D="D=".urlencode($relDir);          $D="D=".urlencode($relDir);
696    
697          function self_args($arr = array()) {          function self_args($arr = array()) {
698                    global $self;
699                  $arg = implode("&",$arr);                  $arg = implode("&",$arr);
700                  if ($arg) {                  if ($arg) {
701                          return $self."?".$arg;                          return $self."?".$arg;
# Line 714  function Navigate($fsRoot,$relDir) { Line 733  function Navigate($fsRoot,$relDir) {
733                          $dir = $dirList[$key];                          $dir = $dirList[$key];
734    
735                          $info_url=self_args(array("A"=>"A=E", "F"=>"F=".urlencode($dir), "D"=>$D));                          $info_url=self_args(array("A"=>"A=E", "F"=>"F=".urlencode($dir), "D"=>$D));
736                          $dir_url=$self."?D=".urlencode($relDir."/".$dir);                          $dir_url=$self."?D=".urlencode(chopsl($relDir)."/".$dir);
737                          include("$html/Navigate-dirEntry.html");                          include("$html/Navigate-dirEntry.html");
738    
739                  }  // iterate over dirs                  }  // iterate over dirs
# Line 800  function Navigate($fsRoot,$relDir) { Line 819  function Navigate($fsRoot,$relDir) {
819                  $ext = strtolower(strrchr($file,".")) ;                  $ext = strtolower(strrchr($file,".")) ;
820    
821                  if ($file_lock) {                  if ($file_lock) {
822                          if ($file_lock == $GLOBALS[gblUserName]) {                          if ($file_lock == $gblUserName) {
823                                  $b.="<A HREF=\"$self?A=Ci&D=".urlencode($relDir)."&F=".urlencode($file);                                  $b.="<A HREF=\"$self?A=Ci&D=".urlencode($relDir)."&F=".urlencode($file);
824                                  $b.="\" TITLE=\"Checkin (update) file on server\">" ;                                  $b.="\" TITLE=\"Checkin (update) file on server\">" ;
825                                  $file_url_html=$b;                                  $file_url_html=$b;
# Line 828  function Navigate($fsRoot,$relDir) { Line 847  function Navigate($fsRoot,$relDir) {
847                          }                          }
848                  }                  }
849    
850                  $mod = date("$GLOBALS[gblDateFmt] $GLOBALS[gblTimeFmt]",$mod);                  $mod = date("$gblDateFmt $gblTimeFmt",$mod);
851    
852                  include("$html/Navigate-fileEntry.html");                  include("$html/Navigate-fileEntry.html");
853    
# Line 899  function UploadPage($fsRoot, $relDir, $f Line 918  function UploadPage($fsRoot, $relDir, $f
918          global $html, $HTTP_SERVER_VARS;          global $html, $HTTP_SERVER_VARS;
919    
920          $self = $HTTP_SERVER_VARS["PHP_SELF"] ;          $self = $HTTP_SERVER_VARS["PHP_SELF"] ;
         if ($relDir == "") $relDir = "/" ;  
   
921          include("$html/UploadPage.html");          include("$html/UploadPage.html");
922    
923  } // end function UploadPage  } // end function UploadPage
# Line 942  function Error($title,$text="",$sysadmin Line 959  function Error($title,$text="",$sysadmin
959    
960  function LogIt($target,$msg, $changelog=0) {  function LogIt($target,$msg, $changelog=0) {
961    
962            global $gblDateFmt, $gblTimeFmt, $gblUserName, $gblFsRoot;
963    
964          $dir=dirname($target);          $dir=dirname($target);
965          if (! file_exists($dir."/.log")) {          if (! file_exists($dir."/.log")) {
966                  if (! @mkdir($dir."/.log",0700)) Error("docman installation problem","can't create log directory <tt>$dir/.log</tt>",1);                  if (! @mkdir($dir."/.log",0700)) Error("docman installation problem","can't create log directory <tt>$dir/.log</tt>",1);
# Line 949  function LogIt($target,$msg, $changelog= Line 968  function LogIt($target,$msg, $changelog=
968          $file=basename($target);          $file=basename($target);
969    
970          $log=fopen("$dir/.log/$file","a+");          $log=fopen("$dir/.log/$file","a+");
971          fputs($log,date("$GLOBALS[gblDateFmt]\t$GLOBALS[gblTimeFmt]").          fputs($log,date("$gblDateFmt\t$gblTimeFmt").
972                  "\t$GLOBALS[gblUserName]\t$msg\n");                  "\t$gblUserName\t$msg\n");
973          fclose($log);          fclose($log);
974    
975          if (! $changelog) return;          if (! $changelog) return;
976    
         global $gblFsRoot;  
977          $log=fopen("$gblFsRoot/.changelog","a+");          $log=fopen("$gblFsRoot/.changelog","a+");
978          if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot)          if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot)
979                  $target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot));                  $target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot));
980          $msg=str_replace("\t"," ",$msg);          $msg=str_replace("\t"," ",$msg);
981          fputs($log,time()."\t$target\t$GLOBALS[gblUserName]\t$msg\n");          fputs($log,time()."\t$target\t$gblUserName\t$msg\n");
982          fclose($log);          fclose($log);
983    
984          // FIX: implement e-mail notification based on $changelog          // FIX: implement e-mail notification based on $changelog
# Line 1020  function MoveTo($source,$folder) { Line 1038  function MoveTo($source,$folder) {
1038    
1039  function Lock($target) {  function Lock($target) {
1040    
1041            global $gblUserName;
1042    
1043          $target=stripSlashes($target);          $target=stripSlashes($target);
1044          $dir=dirname($target);          $dir=dirname($target);
1045          if (! file_exists($dir."/.lock")) {          if (! file_exists($dir."/.lock")) {
# Line 1031  function Lock($target) { Line 1051  function Lock($target) {
1051                  LogIt($target,"attempt to locked allready locked file!");                  LogIt($target,"attempt to locked allready locked file!");
1052          } else {          } else {
1053                  $lock=fopen("$dir/.lock/$file","w");                  $lock=fopen("$dir/.lock/$file","w");
1054                  fputs($lock,"$GLOBALS[gblUserName]\n");                  fputs($lock,"$gblUserName\n");
1055                  fclose($lock);                  fclose($lock);
1056    
1057                  LogIt($target,"file locked");                  LogIt($target,"file locked");
# Line 1080  function urlpath($url) { Line 1100  function urlpath($url) {
1100  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1101    
1102  function safe_rename($fromdir,$fromfile,$tofile) {  function safe_rename($fromdir,$fromfile,$tofile) {
1103    
1104            global $gblNumBackups;
1105    
1106          function try_rename($from,$to) {          function try_rename($from,$to) {
1107  #               print "$from -> $to\n";  #               print "$from -> $to\n";
1108                  if (file_exists($from) && is_writeable(dirname($to))) {                  if (file_exists($from) && is_writeable(dirname($to))) {
# Line 1109  function safe_rename($fromdir,$fromfile, Line 1132  function safe_rename($fromdir,$fromfile,
1132          try_dir("$todir/.lock");          try_dir("$todir/.lock");
1133          try_rename("$fromdir/.lock/$fromfile","$todir/.lock/$tofile");          try_rename("$fromdir/.lock/$fromfile","$todir/.lock/$tofile");
1134          try_dir("$todir/.bak");          try_dir("$todir/.bak");
1135          for($i=0;$i<=$GLOBALS[gblNumBackups];$i++) {          for($i=0;$i<=$gblNumBackups;$i++) {
1136                  try_rename("$fromdir/.bak/$i/$fromfile","$todir/.bak/$i/$tofile");                  try_rename("$fromdir/.bak/$i/$fromfile","$todir/.bak/$i/$tofile");
1137          }          }
1138  }  }
# Line 1137  function rrmdir($dir) { Line 1160  function rrmdir($dir) {
1160    
1161  function DisplayChangeLog($day) {  function DisplayChangeLog($day) {
1162    
1163          global $gblFsRoot,$HTTP_SERVER_VARS;          global $gblFsRoot, $gblDateFmt, $gblTimeFmt;
1164                    $HTTP_SERVER_VARS;
1165    
1166            $self  = $HTTP_SERVER_VARS["PHP_SELF"];
1167    
1168          if (!file_exists("$gblFsRoot/.changelog")) return;          if (!file_exists("$gblFsRoot/.changelog")) return;
1169          $log=fopen("$gblFsRoot/.changelog","r");          $log=fopen("$gblFsRoot/.changelog","r");
# Line 1156  function DisplayChangeLog($day) { Line 1182  function DisplayChangeLog($day) {
1182          print "<table border=0 width=100%>\n";          print "<table border=0 width=100%>\n";
1183          while ($e = array_shift($logarr)) {          while ($e = array_shift($logarr)) {
1184                  $cl=$cl1; $cl1=$cl2; $cl2=$cl;                  $cl=$cl1; $cl1=$cl2; $cl2=$cl;
1185                  $date = date("$GLOBALS[gblDateFmt]", $e[0]);                  $date = date($gblDateFmt, $e[0]);
1186                  $time = date("$GLOBALS[gblTimeFmt]", $e[0]);                  $time = date($gblTimeFmt, $e[0]);
1187                  $dir = dirname($e[1]);                  $dir = dirname($e[1]);
1188                  $file = basename($e[1]);                  $file = basename($e[1]);
1189                  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";                  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";
1190          }          }
1191          print "</table>";          print "</table>";
1192          print "<p>".GifIcon(up)." Back to <a href=$HTTP_SERVER_VARS[PHP_SELF]>front page</a>.</p>";          print "<p>".GifIcon(up)." Back to <a href=\"$self\">front page</a>.</p>";
1193  }  }
1194    
1195  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
# Line 1212  function Download($path,$force=0) { Line 1238  function Download($path,$force=0) {
1238  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1239    
1240  function chopsl($path) {  function chopsl($path) {
         if (substr($path,strlen($path)-1,1) == "/") $path=substr($path,0,strlen($path)-1);  
1241          $path=str_replace("//","/",$path);          $path=str_replace("//","/",$path);
1242            if (substr($path,strlen($path)-1,1) == "/") $path=substr($path,0,strlen($path)-1);
1243          return $path;          return $path;
1244  }  }
1245    
# Line 1227  function chopsl($path) { Line 1253  function chopsl($path) {
1253          by Vyacheslav Zavadsky <zavadsky@braysystems.com>          by Vyacheslav Zavadsky <zavadsky@braysystems.com>
1254  */  */
1255    
1256  define(trmask_not,1 << 0);  define('trmask_not',1 << 0);
1257  define(trmask_clear,1 << 1);  define('trmask_clear',1 << 1);
1258  define(trmask_deny,1 << 2);  define('trmask_deny',1 << 2);
1259  define(trmask_one_level,1 << 3);  define('trmask_one_level',1 << 3);
1260  define(trmask_group,1 << 4);  define('trmask_group',1 << 4);
1261    
1262  define(trperm_r,1 << 5);  define('trperm_r',1 << 5);
1263  define(trperm_w,1 << 6);  define('trperm_w',1 << 6);
1264  define(trperm_b,1 << 7);  define('trperm_b',1 << 7);
1265  define(trperm_n,1 << 8);  define('trperm_n',1 << 8);
1266    
1267  $trustee_a2n = array(  $trustee_a2n = array(
1268          '!' => trmask_not,          '!' => trmask_not,
# Line 1284  if (! file_exists($trustee_conf)) { Line 1310  if (! file_exists($trustee_conf)) {
1310          $error="<tt>".dirname($trustee_php)."</tt> must be writable by web server user";          $error="<tt>".dirname($trustee_php)."</tt> must be writable by web server user";
1311  } elseif (file_exists($trustee_php) && !is_writable($trustee_php)) {  } elseif (file_exists($trustee_php) && !is_writable($trustee_php)) {
1312          $error="trustees cache file <tt>$trustee_php</tt> exists, but is not writable by web server";          $error="trustees cache file <tt>$trustee_php</tt> exists, but is not writable by web server";
1313  } elseif (1 || filemtime($trustee_conf) >= filemtime($trustee_php)) {  } elseif (@filemtime($trustee_conf) >= @filemtime($trustee_php)) {
1314          $fp_php=@fopen($trustee_php,"w");          $fp_php=@fopen($trustee_php,"w");
1315          fputs($fp_php,"<?php // don't edit by hand!\n");          fputs($fp_php,"<?php // don't edit by hand!\n");
1316    
# Line 1320  if (! file_exists($trustee_conf)) { Line 1346  if (! file_exists($trustee_conf)) {
1346                                                  $error.="trustee error in line '$l' [Unknown modifier '$ch']<br>\n";                                                  $error.="trustee error in line '$l' [Unknown modifier '$ch']<br>\n";
1347                                          }                                          }
1348                                  }                                  }
1349                                  $tr_arr[$path][$user] |= $perm;                                  if (isset($tr_arr[$path][$user])) {
1350                                            $tr_arr[$path][$user] |= $perm;
1351                                    } else {
1352                                            $tr_arr[$path][$user] = $perm;
1353                                    }
1354                          }                          }
1355                  }                  }
1356          }          }
# Line 1359  if (! file_exists($trustee_conf)) { Line 1389  if (! file_exists($trustee_conf)) {
1389          fclose($fp_php);          fclose($fp_php);
1390  }  }
1391    
1392  if ($error) {  if (isset($error)) {
1393          Error("Trustee error",$error,1);          Error("Trustee error",$error,1);
1394  } else {  } else {
1395          include("$trustee_php");          include_once("$trustee_php");
1396  }  }
1397    
1398  return 1;  return 1;
# Line 1370  return 1; Line 1400  return 1;
1400  }//init_trustee  }//init_trustee
1401    
1402  function in_group($user,$group) {  function in_group($user,$group) {
1403          return in_array($groups[$group],$user);          global $groups;
1404            return in_array($user,$groups[$group]);
1405  }  }
1406    
1407  // helper function  // helper function
1408  function unroll_perm($u,$t,$user,$perm) {  function unroll_perm($u,$t,$user,$perm,$one_level) {
1409          // check user  
1410          if ($t & trmask_not && ($u==$user)) continue;          if ($t & trmask_one_level && !$one_level) return $perm;
1411          if (!($t & trmask_not) && ($u!=$user)) continue;  
1412            // user is user whose trustee is this
1413            if ($t & trmask_not && ($u==$user)) return $perm;
1414            if (!($t & trmask_not) && ($u!=$user)) return $perm;
1415    
1416          if ($t & trmask_deny) {          if ($t & trmask_deny) {
1417                  if ($t & trmask_clear) {                  if ($t & trmask_clear) {
1418                          $perm[deny] &= ~$t;                          $perm['deny'] &= ~$t;
1419                  } else {                  } else {
1420                          $perm[deny] |= $t;                          $perm['deny'] |= $t;
1421                  }                  }
1422          } elseif ($t & trmask_clear) {          } elseif ($t & trmask_clear) {
1423                  $perm[allow] &= ~$t;                  $perm['allow'] &= ~$t;
1424          } else {          } else {
1425                  $perm[allow] |= $t;                  $perm['allow'] |= $t;
1426          }          }
1427          return $perm;          return $perm;
1428  }// end of helper function  }// end of helper function
1429    
1430  function check_trustee($user,$path) {  function check_trustee($user,$path) {
1431          global $trustees;          global $trustees;
1432          $perm[allow] = 0;          $perm['allow'] = 0;
1433          $perm[deny] = 0;          $perm['deny'] = 0;
1434    
1435            if (! isset($trustees)) Error("Trustees not found","Can't find in-memory trustee structure \$trustees. Probably bug in code. Contact <tt>dpavlin@rot13.org</tt>",1);
1436    
1437    global $debug;
1438    $debug .= "<br>check_trustee $path ... ";
1439    
1440          $path_arr=explode("/",$path);          $path_arr=explode("/",$path);
1441          $path = "/";          $tmppath = "/";
1442          while (count($path_arr)) {          while (count($path_arr)) {
1443                  if (substr($path,strlen($path)-1,1) != "/") $path.="/";                  $tmppath.=array_shift($path_arr);
1444                  $path.=array_shift($path_arr);  $debug.= ">> $tmppath ";
1445                  $tr = $trustees[$path];  
1446                    if (! isset($trustees[$tmppath])) continue;
1447                    $tr = $trustees[$tmppath];
1448    
1449                    $one_level = (!count($path_arr));
1450    $debug.=" O($one_level) ";
1451    
1452                  if (isset($tr)) {                  if (isset($tr)) {
1453                          // first apply trustee for all                          // first apply trustee for all
1454                          if (isset($tr['*'])) {                          if (isset($tr['*'])) {
1455                                  $perm = unroll_perm($user,$tr['*'],$user, $perm);                                  $perm = unroll_perm($user,$tr['*'],'*', $perm, $one_level);
1456                                  unset($tr['*']);                                  unset($tr['*']);
1457                          }                          }
1458                          // then apply group policies                          // then apply group policies
1459                          foreach ($tr as $u=>$t) {                          foreach ($tr as $g=>$t) {
1460                                  if ($t & trmask_group && in_group($user,$u)) {                                  if ($t & trmask_group && in_group($user,$g)) {
1461                                          // resolv user                                          // resolv user
1462                                          $t = $t & ~trmask_group;                                          $t = $t & ~trmask_group;
1463                                          $u = $user;                                          $perm = unroll_perm($user,$t,$g, $perm, $one_level);
1464                                          $perm = unroll_perm($u,$t,$user, $perm);                                          unset($tr[$g]);
                                         unset($tr[$u]);  
1465                                  }                                  }
1466                          }                          }
1467                          // then apply use policy                          // then apply user policy
1468                          if (isset($tr[$user])) {                          if (isset($tr[$user])) {
1469                                  $perm = unroll_perm($user,$tr[$user],$user, $perm);                                  $perm = unroll_perm($user,$tr[$user],$user, $perm,$one_level);
1470                                  unset($tr[$user]);                                  unset($tr[$user]);
1471                          }                          }
   
1472                  }                  }
1473    $debug.="d(".display_trustee($perm['deny']).") a(".display_trustee($perm['allow']).") ";
1474    
1475          }          }
1476  #print "<br>user: $user path: $path perm: ";  $debug.="<br>check_trustee: user: $user path: $path==$tmppath perm: ";
1477  #print "d: $perm[deny] (".display_trustee($perm[deny]).") a: $perm[allow] (".display_trustee($perm[allow]).")<Br>\n";  $debug.="d: ".$perm['deny']." (".display_trustee($perm['deny']).") a: ".$perm['allow']." (".display_trustee($perm['allow']).")<Br>\n";
1478          return $perm;          return $perm;
1479  }  }
1480    
# Line 1438  function check_trustee($user,$path) { Line 1482  function check_trustee($user,$path) {
1482    
1483  function check_perm($path,$trperm) {  function check_perm($path,$trperm) {
1484          global $gblLogin,$HAVE_TRUSTEE;          global $gblLogin,$HAVE_TRUSTEE;
1485  print "<br>check_perm: <tt>$path</tt> test perm ".display_trustee($perm)."<br>\n";  
1486            global $debug;
1487    $debug.="<br>check_perm: on <tt>$path</tt> for perm ".display_trustee($trperm)."<br>\n";
1488    
1489          $return = ! $HAVE_TRUSTEE;          $return = ! $HAVE_TRUSTEE;
1490          if ($HAVE_TRUSTEE) {          if ($HAVE_TRUSTEE) {
1491                  $perm = check_trustee($gblLogin,$path);                  $perm = check_trustee($gblLogin,$path);
1492  print " d: $perm[deny] (".display_trustee($perm[deny]).") a: $perm[allow] (".display_trustee($perm[allow]).") perm: $trperm";  $debug.=" d: ".$perm['deny']." (".display_trustee($perm['deny']).") a: ".$perm['allow']." (".display_trustee($perm['allow']).") perm to have: $trperm (".display_trustee($trperm).")";
1493                  if ($perm[deny] & $trperm) $return=0;                  if ($perm['deny'] & $trperm) $return=0;
1494                  elseif ($perm[allow] & $trperm) $return=1;                  elseif (($perm['allow'] & $trperm) == $trperm) $return=1;
1495          }          }
1496  print " return: $return<br>\n";  $debug.=" return: $return<br>\n";
1497          return($return);          return($return);
1498  }  }
1499    
# Line 1476  function readMime() { Line 1523  function readMime() {
1523  }  }
1524    
1525  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1526    
1527    // check for invalid characters in filename and dirname (.. and /)
1528    
1529    function check_dirname($file) {
1530            if (strstr($file,"..")) Error("Security violation","No parent dir <tt>..</tt> allowed in directory name <tt>$file</tt>",1);
1531    }
1532    
1533    function check_filename($file) {
1534            if (strstr($file,"..")) Error("Security violation","No parent dir <tt>..</tt> allowed in file name <tt>$file</tt>",1);
1535            if (strstr($file,"/")) Error("Security violation","No slashes <tt>/</tt> allowed in file name <tt>$file</tt>",1);
1536    }
1537    
1538    //////////////////////////////////////////////////////////////////
1539    
1540    // functions to move HTTP server variables to global namespace
1541    // [replacement for register_globals in php.ini]
1542    
1543    function HTTP_GET_VAR($var) {
1544            global $HTTP_GET_VARS, $GLOBALS;
1545            if (isset($HTTP_GET_VARS[$var])) {
1546                    $GLOBALS[$var] = stripSlashes($HTTP_GET_VARS[$var]);
1547                    return $GLOBALS[$var];
1548            }
1549    }
1550    
1551    function HTTP_POST_VAR($var) {
1552            global $HTTP_POST_VARS, $GLOBALS;
1553            if (isset($HTTP_POST_VARS[$var])) {
1554                    $GLOBALS[$var] = stripSlashes($HTTP_POST_VARS[$var]);
1555                    return $GLOBALS[$var];
1556            }
1557    }
1558    
1559    //////////////////////////////////////////////////////////////////
1560    
1561    function Warn($text) {
1562    }
1563    
1564    //////////////////////////////////////////////////////////////////
1565  // MAIN PROGRAM  // MAIN PROGRAM
1566    
1567          $gblFilePerms = 0640 ;         // default for new files          $gblFilePerms = 0640 ;         // default for new files
1568          $gblDirPerms  = 0750 ;          // default for new dirs          $gblDirPerms  = 0750 ;          // default for new dirs
1569    
1570          $STYLE = $HTTP_GET_VARS[STYLE];          if (isset($HTTP_GET_VARS["STYLE"]) && $HTTP_GET_VARS["STYLE"] == "get") {
         if (isset($STYLE) && $STYLE == "get") {  
1571                  include("$html/docman.css");                  include("$html/docman.css");
1572                  exit;                  exit;
1573          }          }
# Line 1502  function readMime() { Line 1587  function readMime() {
1587          }          }
1588    
1589          // try to add dir to script name to realm var          // try to add dir to script name to realm var
1590          if (is_dir("$fsRealmDir/$realm/".dirname($HTTP_SERVER_VARS[SCRIPT_NAME]))) {          if (is_dir("$fsRealmDir/$realm/".dirname($HTTP_SERVER_VARS["SCRIPT_NAME"]))) {
1591                  $realm .= "/".dirname($HTTP_SERVER_VARS[SCRIPT_NAME]);                  $realm .= dirname($HTTP_SERVER_VARS["SCRIPT_NAME"]);
1592                  $realm_sep = "/";                  $realm_sep = "/";
1593          } else {          } else {
1594                  $realm_sep = ".";                  $realm_sep = ".";
# Line 1527  function readMime() { Line 1612  function readMime() {
1612                  Error("Configuration error","Can't find user handling module at <tt>$gblIncDir/htusers/$gblUsers.php</tt> ! Please fix <tt>$realm_config</tt>");                  Error("Configuration error","Can't find user handling module at <tt>$gblIncDir/htusers/$gblUsers.php</tt> ! Please fix <tt>$realm_config</tt>");
1613          }          }
1614    
1615            // take additional login vars
1616            HTTP_GET_VAR("relogin");
1617            HTTP_GET_VAR("force_login");
1618    
1619          // if no password, or empty password logout          // if no password, or empty password logout
1620          if (          if (
1621                  isset($gblLogin) && (                  isset($gblLogin) && (
# Line 1551  function readMime() { Line 1640  function readMime() {
1640          // get ACL informations          // get ACL informations
1641          $HAVE_TRUSTEE = init_trustee();          $HAVE_TRUSTEE = init_trustee();
1642    
1643          if (strtolower($gblLogin) == "anonymous" || !isset($gblPasswd)) {          if (strtolower($gblLogin) == "anonymous" || !isset($gblLogin)) {
1644                  $perm = check_trustee($gblLogin,$path);                  $perm = check_trustee("anonymous","/");
1645                  // browsing must be explicitly allowed for root directory                  // browsing must be explicitly allowed for root directory
1646                  // of repository for anonymous user to work!                  // of repository for anonymous user to work!
1647                  if ($perm[allow] & trperm_b) {                  if ($perm['allow'] & trperm_b) {
1648                            $gblLogin = $gblPasswd = "anonymous";
1649                          $secHash = md5($gblLogin.$gblPasswd);                          $secHash = md5($gblLogin.$gblPasswd);
1650                          $gblUserName = "Anonymous user";                          $gblUserName = "Anonymous user";
1651                  }                  }
# Line 1569  function readMime() { Line 1659  function readMime() {
1659                  Error("401 Unauthorized","No trespassing !",0,1);                  Error("401 Unauthorized","No trespassing !",0,1);
1660          }          }
1661    
1662    
1663          // read mime.types          // read mime.types
1664          readMime();          readMime();
1665    
1666          // get current directory relative to $gblFsRoot          if ($HTTP_SERVER_VARS["REQUEST_METHOD"] == "POST") {
1667          $relDir = $DIR ;        // from POST                  // take variables from server
1668          if ($relDir == "") {    // not defined in POST ?                  if (HTTP_POST_VAR("FN")) check_filename($FN);
1669                  $relDir = urldecode($D) ;  // then use GET                  if (HTTP_POST_VAR("DIR")) {
1670          }                                check_dirname($DIR);
1671                            $relDir = $DIR;
1672          $relDir=stripSlashes($relDir);                  } else {
1673                            trigger_error("Can't get DIR",E_USER_WARNING);
1674          if ($relDir == "/") $relDir = "" ;                                $relDir = "/";
1675          // default : website root = ""                  }
1676                    if (HTTP_POST_VAR("RELPATH")) check_dirname($RELPATH);
1677          if (strstr($relDir,"..")) Error("No updirs allowed");                  HTTP_POST_VAR("T");
1678                    HTTP_POST_VAR("CONFIRM");
1679    
1680          // full paths contain "fs" or "Fs". Paths realitve to root of          } else {
1681          // website contain "rel" or "Rel". The script won't let you                  // get
1682          // edit anything above directory equal to http://server.com                  HTTP_GET_VAR("A");
1683          // i.e. below $gblFsRoot.                  if (HTTP_GET_VAR("D")) {
1684                            check_dirname($D);
1685                            $D=urldecode($D);
1686                            $relDir = $D;
1687                    } else {
1688                            //trigger_error("Can't get D",E_USER_WARNING);
1689                            $relDir = "/";
1690                    }
1691                    if (HTTP_GET_VAR("F")) check_filename($F);
1692            }
1693    
1694          $relScriptDir = dirname($SCRIPT_NAME) ;                  $relScriptDir = dirname($HTTP_SERVER_VARS["SCRIPT_NAME"]) ;    
1695          // i.e. /docman          // i.e. /docman
1696    
1697          // start on server root          // start on server root
1698          $gblFsRoot = $gblRepositoryDir;          $gblFsRoot = $gblRepositoryDir;
1699          // i.e. /home/httpd/html          // i.e. /home/httpd/repository
1700    
1701          $fsDir = $gblFsRoot . $relDir ; // current directory          $fsDir = $gblFsRoot . $relDir ; // current directory
1702          if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ;          if ( !is_dir($fsDir) ) Error("Dir not found","Can't find <tt>$relDir</tt> which points to <tt>$fsDir</tt>",1) ;
1703    
1704            if ($relDir == "") $relDir="/";
1705    
1706          if (isset($HTTP_SERVER_VARS["HTTPS"]) && $HTTP_SERVER_VARS["HTTPS"] == "on") {          if (isset($HTTP_SERVER_VARS["HTTPS"]) && $HTTP_SERVER_VARS["HTTPS"] == "on") {
1707                  $webRoot  = "https://";                  $webRoot  = "https://";
# Line 1607  function readMime() { Line 1710  function readMime() {
1710          }          }
1711          $webRoot .= $HTTP_SERVER_VARS["HTTP_HOST"] . $relScriptDir;          $webRoot .= $HTTP_SERVER_VARS["HTTP_HOST"] . $relScriptDir;
1712    
1713          // take variables from server          if (HTTP_POST_VAR("POSTACTION")) switch ($POSTACTION) {
         $FN=stripSlashes($HTTP_POST_VARS["FN"]);  
         $DIR=stripSlashes($HTTP_POST_VARS["DIR"]);  
         $RELPATH=stripSlashes($HTTP_POST_VARS["RELPATH"]);  
         $T=stripSlashes($HTTP_POST_VARS["T"]);  
         $CONFIRM=stripSlashes($HTTP_POST_VARS["CONFIRM"]);  
   
         // get  
         $A=stripSlashes($HTTP_GET_VARS["A"]);  
         $D=stripSlashes($HTTP_GET_VARS["D"]);  
   
 //      if (isset($F)) Error("Document manager system error","variable $F shouldn't be set here (re-check old code)",1);  
 //      $F=stripSlashes($HTTP_SERVER_VARS["PATH_INFO"]);  
         $F=stripSlashes($HTTP_GET_VARS["F"]);  
   
         switch ($HTTP_POST_VARS["POSTACTION"]) {  
1714          case "UPLOAD" :          case "UPLOAD" :
1715                  $FN_name=stripSlashes($HTTP_POST_FILES["FN"]["tmp_name"]);                  $FN_name=stripSlashes($HTTP_POST_FILES["FN"]["tmp_name"]);
1716                  $FN=stripSlashes($HTTP_POST_FILES["FN"]["name"]);                  $FN=stripSlashes($HTTP_POST_FILES["FN"]["name"]);
# Line 1633  function readMime() { Line 1721  function readMime() {
1721                          Error("You must select file with browse to upload it!");                          Error("You must select file with browse to upload it!");
1722                  }                  }
1723    
1724                  $FILENAME = $HTTP_POST_VARS["FILENAME"];                  if (HTTP_POST_VAR("FILENAME")) check_filename($FILENAME);
1725                  if (strstr($FILENAME,"/"))  
                         Error("Upload error","Non-conforming filename. Filename <tt>$FILENAME</tt> has slashes (<tt>/</tt>) in it.") ;  
1726                  if (! isset($FILENAME)) {       // from update file                  if (! isset($FILENAME)) {       // from update file
1727                          $target = "$fsDir/".basename($FN);                          $target = "$fsDir/".basename($FN);
1728                  } else {                  } else {
# Line 1647  function readMime() { Line 1734  function readMime() {
1734                  if (! file_exists($dir."/.bak")) {                  if (! file_exists($dir."/.bak")) {
1735                          mkdir($dir."/.bak",0700);                          mkdir($dir."/.bak",0700);
1736                  }                  }
1737                  if (! file_exists($dir."/.bak/$GLOBALS[gblNumBackups]")) {                  if (! file_exists($dir."/.bak/$gblNumBackups")) {
1738                          mkdir($dir."/.bak/$GLOBALS[gblNumBackups]",0700);                          mkdir($dir."/.bak/$gblNumBackups",0700);
1739                  }                  }
1740                  $file=basename($target);                  $file=basename($target);
1741                  for($i=$GLOBALS[gblNumBackups]-1;$i>0;$i--) {                  for($i=$gblNumBackups-1;$i>0;$i--) {
1742                          MoveTo("$dir/.bak/$i/$file","$dir/.bak/".($i+1)."/");                          MoveTo("$dir/.bak/$i/$file","$dir/.bak/".($i+1)."/");
1743                  }                  }
1744                  MoveTo($target,$dir."/.bak/1/");                  MoveTo($target,$dir."/.bak/1/");
# Line 1790  function readMime() { Line 1877  function readMime() {
1877          }          }
1878    
1879          // common to all POSTs : redirect to directory view ($relDir)          // common to all POSTs : redirect to directory view ($relDir)
1880          if ( $POSTACTION != "" ) {          if (isset($POSTACTION)) {
1881                  $tstr = $PHP_SELF . "?D=" . urlencode($relDir) ;                  $tstr = $HTTP_SERVER_VARS["PHP_SELF"]."?D=".urlencode($relDir);
1882                  header("Location: " . $tstr) ;                    header("Location: ".$tstr) ;  
1883                  exit ;                  exit ;
1884          }          }
1885                    
# Line 1803  function readMime() { Line 1890  function readMime() {
1890          // $A=Co : checkout file $D/$F          // $A=Co : checkout file $D/$F
1891          // $A=Ci : checkin file $D/$F          // $A=Ci : checkin file $D/$F
1892          // $A=V : view file (do nothing except log)          // $A=V : view file (do nothing except log)
1893          // $A=I : include file .$F.php from $gblFsRoot          // $A=I : include file .$F.php from [$gblIncDir|realm]/include_php
1894          // default : display directory $D          // default : display directory $D
1895    
1896          switch ($A) {          if (isset($A)) switch ($A) {
1897          case "U" :          case "U" :
1898                  // upload to $relDir                  // upload to $relDir
1899                    if (! check_perm($relDir, trperm_w))
1900                            Error("Write access denied","You don't have permission to write in <tt>$relDir</tt>");
1901                  if (!is_writeable($gblFsRoot . $relDir))                  if (!is_writeable($gblFsRoot . $relDir))
1902                          Error("Write access denied",$relDir) ;                          Error("Write access denied","User <tt>$gblLogin</tt> has permission on <tt>$relDir</tt>, but directory is not writable",1);
1903                  $text  = "Use this page to upload a single " ;                  $text  = "Use this page to upload a single " ;
1904                  $text .= "file to <B>$realm</B>." ;                  $text .= "file to <B>$realm</B>." ;
1905                  StartHTML("(Upload Page)", $text) ;                  StartHTML("(Upload Page)", $text) ;
# Line 1858  function readMime() { Line 1947  function readMime() {
1947                  EndHTML() ;                  EndHTML() ;
1948                  exit;                  exit;
1949          case "I" :          case "I" :
1950                  $F=stripSlashes($F);                  if (! isset($F) || $F == "")
1951                  $inc_file="${gblFsRoot}/.${F}.php";                          Error("Can't find file to include","Your request didn't specify file to include which should be in variable <tt>F</tt> like <tt>$HTTP_SERVER_VARS[REQUEST_URI]<b>&F=include_php_file</b></tt>",1);
1952                  if (!isset($F) || $F == "" || !file_exists($inc_file)) Error("Fatal error $inc_file"); // can't find file to include                  $inc_file="$fsRealmDir/$realm".$realm_sep.$F.".php";
1953                    if (! file_exists($inc_file)) {
1954                            Error("Can't find file to include","Can't find include file <tt>$F.php</tt> in <tt>$fsRealmDir/$realm/</tt>. Meybe you should copy <tt>$gblIncDir/include_php/$F.php</tt> to <tt>$inc_file<tt> ?",1);
1955                    }
1956                  if (!is_readable($inc_file))                  if (!is_readable($inc_file))
1957                          Error("Read access to include file denied",".${F}.php");                          Error("Read access to include file denied","Can't read PHP include file <tt>$inc_file</tt>. Fix permissions on it.",1);
1958                  $text  = "Your include file should define \$text variable which holds this text and \$title variable which is page title";                  $text  = "Your include file should define \$text variable which holds this text and \$title variable which is page title";
1959                  $title = "You should define \$title variable with page title";                  $title = "You should define \$title variable with page title";
1960                  include($inc_file);                  include($inc_file);

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

  ViewVC Help
Powered by ViewVC 1.1.26