Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Thursday, October 15, 2026

Diff for phpWebFileManager/plugins/file.php between version 1.2 and 1.3

version 1.2, 2002/08/03 23:20:38 version 1.3, 2002/08/04 18:16:58
Line 50  $fm_init_file = dirname(__FILE__)
Line 50  $fm_init_file = dirname(__FILE__)
 require_once $fm_init_file;  require_once $fm_init_file;
 require_once $PN_PathPrefix . 'lib/fnc.append_slash.php';  require_once $PN_PathPrefix . 'lib/fnc.append_slash.php';
   
 // note that this constant will not remain in future  /*
 // it will be moved into config file, where array of possible   * Main job
 // Apache mime.types locations will be present   */
 $APACHE_MIME_TYPES = '/etc/httpd/conf/apache-mime.types';  
   fm_main();
   
 /*  /*
  * Permission check   * Moving back, just for certainty and security
  */   */
   
 if (! $fm_cfg['perm']['file']['view']) {  chdir($fm_file_plugin_orig_dir);
         echo 'Insufficient privileges for file viewing.';  
 } else {  
   
         /*  
          * Parsing of apache-mime.types file  
          */  
   
         if (is_readable($GLOBALS['APACHE_MIME_TYPES'])) {  /*******************
                 $mime_types = file($GLOBALS['APACHE_MIME_TYPES']);    F U N C T I O N S
                 if (is_array($mime_types)) {   *******************/
   
                         while (list(,$line) = each($mime_types)) {  function fm_parse_apache_mime_types($file)
                                 if ($line[0] == '#')  {
                                         continue;          $mimes_by_ext = array();
           $mime_types   = file($file);
                                 $parts = preg_split('/(\s+)/', $line);  
                                 if (is_array($parts) && sizeof($parts) > 2) {          if (is_array($mime_types)) {
                                         list(,$mime) = each($parts);                  while (list(,$line) = each($mime_types)) {
                                         while (list(,$ext) = each($parts)) {                          if ($line[0] == '#')
                                                 if (trim($ext) != '')                                  continue;
                                                         $mimes_by_ext[$ext] = $mime;  
                                         }                          $parts = preg_split('/(\s+)/', $line);
                           if (is_array($parts) && sizeof($parts) > 2) {
                                   list(,$mime) = each($parts);
                                   while (list(,$ext) = each($parts)) {
                                           if (trim($ext) != '')
                                                   $mimes_by_ext[$ext] = $mime;
                                 }                                  }
                         }                          }
   
                 }                  }
         }          }
   
           return $mimes_by_ext;
   }
   
   function fm_main()
   {
           global $fm_cfg;
           global $HTTP_GET_VARS;
   
         /*          /*
          * Creating $fm_file variable           * Permission check
          */           */
   
         $fm_file = append_slash($fm_cfg['dir']['root']) . substr($HTTP_GET_VARS['fm_path'], 1);          if (! $fm_cfg['perm']['file']['view']) {
                   echo 'Insufficient privileges for file viewing.';
                   return false;
           }
   
         /*          /*
          * Writting file on output           * Creating $file variable from CGI $fm_path variable
            */
   
           if (! isset($HTTP_GET_VARS[$fm_cfg['cgi'].'path'])) {
                   echo 'CGI variable '.$fm_cfg['cgi'].'path is not present.';
                   return false;
           }
   
           $file = append_slash($fm_cfg['dir']['root']) . substr($HTTP_GET_VARS[$fm_cfg['cgi'].'path'], 1);
   
           /*
            * Testing file
          */           */
   
         if (file_exists($fm_file) && is_readable($fm_file)) {          if (! @file_exists($file) || ! @is_readable($file)) {
                 header('Content-length: '.filesize($fm_file));                  echo 'File "'.$file.'" not found or is not readable.';
                 if (preg_match('/.*\.([a-z]{2,5})$/i', $fm_file, $matches)                  return false;
                                 && trim($mimes_by_ext[$matches[1]]) != '') {          }
                         header('Content-type: '.trim($mimes_by_ext[$matches[1]]));  
                 } else {          /*
                         header('Content-type: text/plain');           * Parsing of apache-mime.types file
            */
   
           $mimes_by_ext = array();
           foreach ($fm_cfg['res']['apache_mime_types'] as $mimes_fname) {
                   if (@file_exists($mimes_fname) && @is_readable($mimes_fname)) {
                           $mimes_by_ext = fm_parse_apache_mime_types($mimes_fname);
                           break;
                 }                  }
           }
   
           /*
            * Writting file on output
            */
   
                 readfile($fm_file);          header('Content-length: '.filesize($file));
           if (preg_match('/.*\.([a-z]{2,5})$/i', $file, $matches)
                           && trim($mimes_by_ext[$matches[1]]) != '') {
                   header('Content-type: '.trim($mimes_by_ext[$matches[1]]));
         } else {          } else {
                 echo "File '$fm_file' not found or is not readable.";                  header('Content-type: text/plain');
         }          }
   
           @readfile($file);
           return true;
 }  }
   
 /*  
  * Moving back, just for certainty and security  
  */  
   
 chdir($fm_file_plugin_orig_dir);  
   
 ?>  ?>

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

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top