]> git.donarmstrong.com Git - roundcube.git/blobdiff - program/include/rcube_shared.inc
Fix symlink mess
[roundcube.git] / program / include / rcube_shared.inc
index 6e58ad86982c5293ae05d48ac77e1dd351a16403..089aab4003fc2703c5b5c429d74641be2fe5de30 100644 (file)
@@ -15,7 +15,7 @@
  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
  +-----------------------------------------------------------------------+
 
- $Id: rcube_shared.inc 5274 2011-09-23 10:11:27Z alec $
+ $Id: rcube_shared.inc 5770 2012-01-13 11:23:17Z alec $
 
 */
 
@@ -163,52 +163,6 @@ function show_bytes($bytes)
   return $str;
 }
 
-/**
- * Convert paths like ../xxx to an absolute path using a base url
- *
- * @param string Relative path
- * @param string Base URL
- * @return string Absolute URL
- */
-function make_absolute_url($path, $base_url)
-{
-  $host_url = $base_url;
-  $abs_path = $path;
-
-  // check if path is an absolute URL
-  if (preg_match('/^[fhtps]+:\/\//', $path))
-    return $path;
-
-  // cut base_url to the last directory
-  if (strrpos($base_url, '/')>7)
-  {
-    $host_url = substr($base_url, 0, strpos($base_url, '/', 7));
-    $base_url = substr($base_url, 0, strrpos($base_url, '/'));
-  }
-
-  // $path is absolute
-  if ($path[0] == '/')
-    $abs_path = $host_url.$path;
-  else
-  {
-    // strip './' because its the same as ''
-    $path = preg_replace('/^\.\//', '', $path);
-
-    if (preg_match_all('/\.\.\//', $path, $matches, PREG_SET_ORDER))
-      foreach ($matches as $a_match)
-      {
-        if (strrpos($base_url, '/'))
-          $base_url = substr($base_url, 0, strrpos($base_url, '/'));
-
-        $path = substr($path, 3);
-      }
-
-    $abs_path = $base_url.'/'.$path;
-  }
-
-  return $abs_path;
-}
-
 /**
  * Wrapper function for wordwrap
  */
@@ -408,12 +362,14 @@ function rc_mime_content_type($path, $name, $failover = 'application/octet-strea
     $mime_type = null;
     $mime_magic = rcmail::get_instance()->config->get('mime_magic');
     $mime_ext = @include(RCMAIL_CONFIG_DIR . '/mimetypes.php');
-    $suffix = $name ? substr($name, strrpos($name, '.')+1) : '*';
 
     // use file name suffix with hard-coded mime-type map
-    if (is_array($mime_ext)) {
-        $mime_type = $mime_ext[$suffix];
+    if (is_array($mime_ext) && $name) {
+        if ($suffix = substr($name, strrpos($name, '.')+1)) {
+            $mime_type = $mime_ext[strtolower($suffix)];
+        }
     }
+
     // try fileinfo extension if available
     if (!$mime_type && function_exists('finfo_open')) {
         if ($finfo = finfo_open(FILEINFO_MIME, $mime_magic)) {
@@ -424,10 +380,12 @@ function rc_mime_content_type($path, $name, $failover = 'application/octet-strea
             finfo_close($finfo);
         }
     }
+
     // try PHP's mime_content_type
     if (!$mime_type && !$is_stream && function_exists('mime_content_type')) {
       $mime_type = @mime_content_type($path);
     }
+
     // fall back to user-submitted string
     if (!$mime_type) {
         $mime_type = $failover;