original_string: public static function filenameToMime($filename, $unknown = true)
      {
          $pos = strlen($filename) + 1;
          $type = '';
  
          $map = self::_getMimeExtensionMap();
          for ($i = 0; $i <= $map['__MAXPERIOD__']; ++$i) {
              $npos = strrpos(substr($filename, 0, $pos - 1), '.');
              if ($npos === false) {
                  break;
              }
              $pos = $npos + 1;
          }
  
          $type = ($pos === false) ? '' : self::extToMime(substr($filename, $pos));
  
          return (empty($type) || (!$unknown && (strpos($type, 'x-extension') !== false)))
              ? 'application/octet-stream'
              : $type;
      }
code: public static function filenameToMime($filename, $unknown = true)
      {
          $pos = strlen($filename) + 1;
          $type = '';
  
          $map = self::_getMimeExtensionMap();
          for ($i = 0; $i <= $map['__MAXPERIOD__']; ++$i) {
              $npos = strrpos(substr($filename, 0, $pos - 1), '.');
              if ($npos === false) {
                  break;
              }
              $pos = $npos + 1;
          }
  
          $type = ($pos === false) ? '' : self::extToMime(substr($filename, $pos));
  
          return (empty($type) || (!$unknown && (strpos($type, 'x-extension') !== false)))
              ? 'application/octet-stream'
              : $type;
      }
code_tokens: public static function filenameToMime ( $ filename , $ unknown = true ) { $ pos = strlen ( $ filename ) + 1 ; $ type = '' ; $ map = self :: _getMimeExtensionMap ( ) ; for ( $ i = 0 ; $ i <= $ map [ '__MAXPERIOD__' ] ; ++ $ i ) { $ npos = strrpos ( substr ( $ filename , 0 , $ pos - 1 ) , '.' ) ; if ( $ npos === false ) { break ; } $ pos = $ npos + 1 ; } $ type = ( $ pos === false ) ? '' : self :: extToMime ( substr ( $ filename , $ pos ) ) ; return ( empty ( $ type ) || ( ! $ unknown && ( strpos ( $ type , 'x-extension' ) !== false ) ) ) ? 'application/octet-stream' : $ type ; }
docstring: Attempt to convert a filename to a MIME type, based on the global Horde
  and application specific config files.
  
  @param string $filename  The filename to be mapped to a MIME type.
  @param boolean $unknown  How should unknown extensions be handled? If
  true, will return 'x-extension/*' types.  If
  false, will return 'application/octet-stream'.
  
  @return string  The MIME type of the filename.
docstring_tokens: Attempt to convert a filename to a MIME type based on the global Horde and application specific config files .