alecpl
2010-11-04 bf13ba996ca5e33c8d1bfd88ed92d1c06b0a24c8
program/include/rcube_shared.inc
@@ -227,7 +227,7 @@
  // cut base_url to the last directory
  if (strrpos($base_url, '/')>7)
  {
    $host_url = substr($base_url, 0, strpos($base_url, '/'));
    $host_url = substr($base_url, 0, strpos($base_url, '/', 7));
    $base_url = substr($base_url, 0, strrpos($base_url, '/'));
  }
@@ -476,6 +476,11 @@
    if (!$mime_type) {
        $mime_type = $failover;
    }
    else {
        // sometimes content-type contains charset definition,
        // remove useless "charset=binary", should we remove any charset def. here?
        $mime_type = preg_replace('/; charset=binary;*/i', '', $mime_type);
    }
    return $mime_type;
}
@@ -680,3 +685,51 @@
    }
}
/**
 * intl replacement functions
 */
if (!function_exists('idn_to_utf8'))
{
    function idn_to_utf8($domain, $flags=null)
    {
        static $idn, $loaded;
        if (!$loaded) {
            $idn = new Net_IDNA2();
            $loaded = true;
        }
        if ($idn && $domain && preg_match('/(^|@|\.)xn--/i', $domain)) {
            try {
                $domain = $idn->decode($domain);
            }
            catch (Exception $e) {
            }
        }
        return $domain;
    }
}
if (!function_exists('idn_to_ascii'))
{
    function idn_to_ascii($domain, $flags=null)
    {
        static $idn, $loaded;
        if (!$loaded) {
            $idn = new Net_IDNA2();
            $loaded = true;
        }
        if ($idn && $domain && preg_match('/[^\x20-\x7E]/', $domain)) {
            try {
                $domain = $idn->encode($domain);
            }
            catch (Exception $e) {
            }
        }
        return $domain;
    }
}