/[drupal]/contributions/modules/filerequest/downloadhandler.php
ViewVC logotype

Diff of /contributions/modules/filerequest/downloadhandler.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.4, Mon Jul 3 14:03:54 2006 UTC revision 1.4.2.1, Wed Aug 2 10:25:40 2006 UTC
# Line 26  Line 26 
26      along with this program; if not, write to the Free Software      along with this program; if not, write to the Free Software
27      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28  */  */
29  /* $Id: downloadhandler.php,v 1.3.2.7 2006/04/04 10:58:08 elmuerte Exp $ */  /* $Id: downloadhandler.php,v 1.4 2006/07/03 14:03:54 elmuerte Exp $ */
30    
31    
32  define("READBUFFER_SIZE", 4096); // read buffer size  define("READBUFFER_SIZE", 4096); // read buffer size
# Line 40  define("DOWNSAMPLE_TO_ORIGIN", true); // Line 40  define("DOWNSAMPLE_TO_ORIGIN", true); //
40                                       // image to the original format, otherwise it will                                       // image to the original format, otherwise it will
41                                       // be converted to a jpg                                       // be converted to a jpg
42    
43  /*  
44      not OS safe  if (!function_exists("mime_content_type")) {
 */  
 if (!function_exists("mime_content_type"))  {  
45    function mime_content_type($f) {    function mime_content_type($f) {
46      $f = escapeshellarg($f);      $mime = '';
47      return trim( exec("file -bi ".$f) );      if (substr(PHP_OS, 0, 3) != 'WIN') {
48          // TODO: might need to be improved
49        }
50        else {
51          $f = escapeshellarg($f);
52          $mime = trim( exec("file -bi ".$f) );
53        }
54        if ($mime && !empty($mime)) return $mime;
55        return "application/octet-stream";
56    }    }
57  }  }
58    
# Line 111  function __fr_can_download_file(&$config Line 117  function __fr_can_download_file(&$config
117    
118  /**  /**
119   * Send a file to the client. Absolute file path required!   * Send a file to the client. Absolute file path required!
120     * @param   string   the location of the filename
121   * @param   bool     forces the file to be send as an attachment (no inline viewing)   * @param   bool     forces the file to be send as an attachment (no inline viewing)
122   * @param   function is a function in the form: function($filename) and returns the mimetype   * @param   string   filename to the watermark applied to images
123     * @param   string   mime type of this file
124   * @return  bool     true if the download was handled   * @return  bool     true if the download was handled
125   */   */
126  function __fr_process_download($filename, $forcedl=false, $watermark=false, $mimeOverride=null)  function __fr_process_download($filename, $forcedl=false, $watermark=false, $mimeType='')
127  {  {
128    global $__fr_reporting_leech;    global $__fr_reporting_leech;
129    
# Line 198  function __fr_process_download($filename Line 206  function __fr_process_download($filename
206      }      }
207    }    }
208    
209    // figure out mime last    // figure out mime type
210    $fi["mime"] = "";    $fi["mime"] = trim($mimeType);
   if (is_callable($mimeOverride)) $fi["mime"] = $mimeOverride(basename($filename));  
211    if (empty($fi["mime"])) {    if (empty($fi["mime"])) {
212      if (function_exists("mime_content_type")) $fi["mime"] = mime_content_type($filename);      if (function_exists("mime_content_type")) $fi["mime"] = mime_content_type($filename);
213    }    }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.4.2.1

  ViewVC Help
Powered by ViewVC 1.1.2