| | |
| | | |
| | | |
| | | /** |
| | | * 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() |
| | |
| | | |
| | | 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: '); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | function rc_mime_content_type($path, $failover = 'unknown/unknown') |
| | | { |
| | | 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')) { |
| | | return mime_content_type($path); |
| | | 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); |
| | | } |
| | | } |
| | | $finfo = finfo_open(FILEINFO_MIME, $mime_magic); |
| | | if (!$finfo) { |
| | | return $failover; |
| | | if (!$mime_type && function_exists('mime_content_type')) { |
| | | $mime_type = mime_content_type($path); |
| | | } |
| | | $mime_type = finfo_file($finfo,$path); |
| | | |
| | | if (!$mime_type) { |
| | | return $failover; |
| | | $mime_type = $failover; |
| | | } |
| | | finfo_close($finfo); |
| | | |
| | | return $mime_type; |
| | | } |