thomascube
2008-09-19 bba657e64ff3334ba2f64e88e977a6dc107d682d
program/include/rcube_shared.inc
@@ -28,62 +28,6 @@
/**
 * Provide details about the client's browser
 *
 * @return array Key-value pairs of browser properties
 */
function rcube_browser()
{
  $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
  $bw['ver'] = 0;
  $bw['win'] = stristr($HTTP_USER_AGENT, 'win');
  $bw['mac'] = stristr($HTTP_USER_AGENT, 'mac');
  $bw['linux'] = stristr($HTTP_USER_AGENT, 'linux');
  $bw['unix']  = stristr($HTTP_USER_AGENT, 'unix');
  $bw['ns4'] = stristr($HTTP_USER_AGENT, 'mozilla/4') && !stristr($HTTP_USER_AGENT, 'msie');
  $bw['ns']  = ($bw['ns4'] || stristr($HTTP_USER_AGENT, 'netscape'));
  $bw['ie']  = stristr($HTTP_USER_AGENT, 'msie');
  $bw['mz']  = stristr($HTTP_USER_AGENT, 'mozilla/5');
  $bw['opera'] = stristr($HTTP_USER_AGENT, 'opera');
  $bw['safari'] = stristr($HTTP_USER_AGENT, 'safari');
  if($bw['ns'])
  {
    $test = eregi("mozilla\/([0-9\.]+)", $HTTP_USER_AGENT, $regs);
    $bw['ver'] = $test ? (float)$regs[1] : 0;
  }
  if($bw['mz'])
  {
    $test = ereg("rv:([0-9\.]+)", $HTTP_USER_AGENT, $regs);
    $bw['ver'] = $test ? (float)$regs[1] : 0;
  }
  if($bw['ie'])
  {
    $test = eregi("msie ([0-9\.]+)", $HTTP_USER_AGENT, $regs);
    $bw['ver'] = $test ? (float)$regs[1] : 0;
  }
  if($bw['opera'])
  {
    $test = eregi("opera ([0-9\.]+)", $HTTP_USER_AGENT, $regs);
    $bw['ver'] = $test ? (float)$regs[1] : 0;
  }
  if(eregi(" ([a-z]{2})-([a-z]{2})", $HTTP_USER_AGENT, $regs))
    $bw['lang'] =  $regs[1];
  else
    $bw['lang'] =  'en';
  $bw['dom'] = ($bw['mz'] || $bw['safari'] || ($bw['ie'] && $bw['ver']>=5) || ($bw['opera'] && $bw['ver']>=7));
  $bw['pngalpha'] = $bw['mz'] || $bw['safari'] || ($bw['ie'] && $bw['ver']>=5.5) ||
                    ($bw['ie'] && $bw['ver']>=5 && $bw['mac']) || ($bw['opera'] && $bw['ver']>=7) ? TRUE : FALSE;
  return $bw;
}
/**
 * Send HTTP headers to prevent caching this page
 */
function send_nocacheing_headers()
@@ -93,8 +37,14 @@
  header("Expires: ".gmdate("D, d M Y H:i:s")." GMT");
  header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
  header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
  header("Cache-Control: private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
  header("Pragma: no-cache");
  // We need to set the following headers to make downloads work using IE in HTTPS mode.
  if (isset($_SERVER['HTTPS'])) {
    header('Pragma: ');
    header('Cache-Control: ');
  }
}
@@ -554,33 +504,28 @@
 * @see    http://de2.php.net/manual/en/ref.fileinfo.php
 * @see    http://de2.php.net/mime_content_type
 */
function rc_mime_content_type($path, $failover = 'unknown/unknown')
function rc_mime_content_type($path, $failover = 'application/octet-stream')
{
    global $CONFIG;
    $mime_type = null;
    $mime_magic = rcmail::get_instance()->config->get('mime_magic');
    $mime_magic = $CONFIG['mime_magic'];
    if (function_exists('mime_content_type')) {
   $finfo = mime_content_type($path);
   if ($finfo)
       return $finfo;
    if (!extension_loaded('fileinfo')) {
        @dl('fileinfo.' . PHP_SHLIB_SUFFIX);
    }
    if (!extension_loaded('fileinfo')) {
        if (!dl('fileinfo.' . PHP_SHLIB_SUFFIX)) {
            return $failover;
    if (function_exists('finfo_open')) {
        if ($finfo = finfo_open(FILEINFO_MIME, $mime_magic)) {
            $mime_type = finfo_file($finfo, $path);
            finfo_close($finfo);
        }
    }
    if (!$mime_type && function_exists('mime_content_type')) {
      $mime_type = mime_content_type($path);
    }
    
    $finfo = finfo_open(FILEINFO_MIME, $mime_magic);
    if (!$finfo) {
        return $failover;
    }
    $mime_type = finfo_file($finfo,$path);
    if (!$mime_type) {
        return $failover;
        $mime_type = $failover;
    }
    finfo_close($finfo);
    return $mime_type;
}