| | |
| | | header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
| | | header("Cache-Control: private, must-revalidate, post-check=0, pre-check=0"); |
| | | header("Pragma: no-cache"); |
| | | // Request browser to disable DNS prefetching (CVE-2010-0464) |
| | | header("X-DNS-Prefetch-Control: off"); |
| | | |
| | | // We need to set the following headers to make downloads work using IE in HTTPS mode. |
| | | if (rcube_https_check()) { |
| | |
| | | { |
| | | if (is_numeric($str)) |
| | | return floatval($str); |
| | | |
| | | if (preg_match('/([0-9]+)([a-z])/i', $str, $regs)) |
| | | |
| | | if (preg_match('/([0-9\.]+)\s*([a-z]*)/i', $str, $regs)) |
| | | { |
| | | $bytes = floatval($regs[1]); |
| | | switch (strtolower($regs[2])) |
| | | { |
| | | case 'g': |
| | | case 'gb': |
| | | $bytes *= 1073741824; |
| | | break; |
| | | case 'm': |
| | | case 'mb': |
| | | $bytes *= 1048576; |
| | | break; |
| | | case 'k': |
| | | case 'kb': |
| | | $bytes *= 1024; |
| | | break; |
| | | } |
| | |
| | | function abbreviate_string($str, $maxlength, $place_holder='...') |
| | | { |
| | | $length = mb_strlen($str); |
| | | $first_part_length = floor($maxlength/2) - mb_strlen($place_holder); |
| | | |
| | | if ($length > $maxlength) |
| | | { |
| | | $second_starting_location = $length - $maxlength + $first_part_length + 1; |
| | | $str = mb_substr($str, 0, $first_part_length) . $place_holder . mb_substr($str, $second_starting_location, $length); |
| | | $place_holder_length = mb_strlen($place_holder); |
| | | $first_part_length = floor(($maxlength - $place_holder_length)/2); |
| | | $second_starting_location = $length - $maxlength + $first_part_length + $place_holder_length; |
| | | $str = mb_substr($str, 0, $first_part_length) . $place_holder . mb_substr($str, $second_starting_location); |
| | | } |
| | | |
| | | return $str; |
| | |
| | | $mime_type = $mime_ext[$suffix]; |
| | | } |
| | | // try fileinfo extension if available |
| | | if (!$mime_type) { |
| | | if (!extension_loaded('fileinfo')) { |
| | | @dl('fileinfo.' . PHP_SHLIB_SUFFIX); |
| | | } |
| | | 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('finfo_open')) { |
| | | if ($finfo = finfo_open(FILEINFO_MIME, $mime_magic)) { |
| | | $mime_type = finfo_file($finfo, $path); |
| | | finfo_close($finfo); |
| | | } |
| | | } |
| | | // try PHP's mime_content_type |
| | | if (!$mime_type && function_exists('mime_content_type')) { |
| | | $mime_type = mime_content_type($path); |
| | | $mime_type = mime_content_type($path); |
| | | } |
| | | // fall back to user-submitted string |
| | | if (!$mime_type) { |
| | |
| | | return $input; |
| | | |
| | | // iconv/mbstring are much faster (especially with long strings) |
| | | if (function_exists('mb_convert_encoding') && ($res = mb_convert_encoding($input, 'UTF8', 'UTF8')) !== false) |
| | | if (function_exists('mb_convert_encoding') && ($res = mb_convert_encoding($input, 'UTF-8', 'UTF-8')) !== false) |
| | | return $res; |
| | | |
| | | if (function_exists('iconv') && ($res = iconv('UTF8', 'UTF8//IGNORE', $input)) !== false) |
| | | if (function_exists('iconv') && ($res = @iconv('UTF-8', 'UTF-8//IGNORE', $input)) !== false) |
| | | return $res; |
| | | |
| | | $regexp = '/^('. |
| | |
| | | $seq = ''; |
| | | $out = ''; |
| | | |
| | | for ($i = 0, $len = strlen($input)-1; $i < $len; $i++) { |
| | | for ($i = 0, $len = strlen($input); $i < $len; $i++) { |
| | | $chr = $input[$i]; |
| | | $ord = ord($chr); |
| | | // 1-byte character |
| | |
| | | { |
| | | $input = rc_utf8_clean($input); |
| | | |
| | | return json_encode($input); |
| | | // sometimes even using rc_utf8_clean() the input contains invalid UTF-8 sequences |
| | | // that's why we have @ here |
| | | return @json_encode($input); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * Get all keys from array (recursive) |
| | | * |
| | | * @param array Input array |
| | | * @return array |
| | | */ |
| | | function array_keys_recursive($array) |
| | | { |
| | | $keys = array(); |
| | | |
| | | if (!empty($array)) |
| | | foreach ($array as $key => $child) { |
| | | $keys[] = $key; |
| | | if ($children = array_keys_recursive($child)) |
| | | $keys = array_merge($keys, $children); |
| | | } |
| | | return $keys; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * mbstring replacement functions |
| | | */ |
| | | |