| | |
| | | */ |
| | | function rcube_label($attrib) |
| | | { |
| | | global $sess_user_lang, $INSTALL_PATH, $OUTPUT; |
| | | static $sa_text_data, $s_language, $utf8_decode; |
| | | global $sess_user_lang, $OUTPUT; |
| | | static $sa_text_data = false; |
| | | static $s_language, $utf8_decode; |
| | | |
| | | // extract attributes |
| | | if (is_string($attrib)) |
| | |
| | | |
| | | |
| | | // load localized texts |
| | | if (!$sa_text_data || $s_language != $sess_user_lang) |
| | | if ($sa_text_data===false || $s_language != $sess_user_lang) |
| | | { |
| | | $sa_text_data = array(); |
| | | |
| | | // get english labels (these should be complete) |
| | | @include($INSTALL_PATH.'program/localization/en_US/labels.inc'); |
| | | @include($INSTALL_PATH.'program/localization/en_US/messages.inc'); |
| | | @include(INSTALL_PATH.'program/localization/en_US/labels.inc'); |
| | | @include(INSTALL_PATH.'program/localization/en_US/messages.inc'); |
| | | |
| | | if (is_array($labels)) |
| | | $sa_text_data = $labels; |
| | |
| | | $sa_text_data = array_merge($sa_text_data, $messages); |
| | | |
| | | // include user language files |
| | | if ($sess_user_lang!='en' && is_dir($INSTALL_PATH.'program/localization/'.$sess_user_lang)) |
| | | if ($sess_user_lang!='en' && is_dir(INSTALL_PATH.'program/localization/'.$sess_user_lang)) |
| | | { |
| | | include_once($INSTALL_PATH.'program/localization/'.$sess_user_lang.'/labels.inc'); |
| | | include_once($INSTALL_PATH.'program/localization/'.$sess_user_lang.'/messages.inc'); |
| | | include_once(INSTALL_PATH.'program/localization/'.$sess_user_lang.'/labels.inc'); |
| | | include_once(INSTALL_PATH.'program/localization/'.$sess_user_lang.'/messages.inc'); |
| | | |
| | | if (is_array($labels)) |
| | | $sa_text_data = array_merge($sa_text_data, $labels); |
| | |
| | | * @param int Modified date as unix timestamp |
| | | * @param string Etag value for caching |
| | | */ |
| | | function send_modified_header($mdate, $etag=null) |
| | | function send_modified_header($mdate, $etag=null, $skip_check=false) |
| | | { |
| | | if (headers_sent()) |
| | | return; |
| | | |
| | | $iscached = false; |
| | | if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $mdate) |
| | | $iscached = true; |
| | | |
| | | $etag = $etag ? "\"$etag\"" : null; |
| | | if ($etag && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) |
| | | $iscached = true; |
| | | |
| | | if (!$skip_check) |
| | | { |
| | | if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $mdate) |
| | | $iscached = true; |
| | | |
| | | if ($etag) |
| | | $iscached = ($_SERVER['HTTP_IF_NONE_MATCH'] == $etag); |
| | | } |
| | | |
| | | if ($iscached) |
| | | header("HTTP/1.x 304 Not Modified"); |
| | |
| | | header("Etag: $etag"); |
| | | |
| | | if ($iscached) |
| | | { |
| | | ob_end_clean(); |
| | | exit; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | * @param string Input string |
| | | * @param int Max. length |
| | | * @param string Replace removed chars with this |
| | | * @return string Abbrevated string |
| | | * @return string Abbreviated string |
| | | */ |
| | | function abbrevate_string($str, $maxlength, $place_holder='...') |
| | | function abbreviate_string($str, $maxlength, $place_holder='...') |
| | | { |
| | | $length = rc_strlen($str); |
| | | $first_part_length = floor($maxlength/2) - rc_strlen($place_holder); |
| | |
| | | |
| | | |
| | | /** |
| | | * Return the last occurence of a string in another string |
| | | * A method to guess the mime_type of an attachment. |
| | | * |
| | | * @param haystack string string in which to search |
| | | * @param needle string string for which to search |
| | | * @return index of needle within haystack, or false if not found |
| | | * @param string $path Path to the file. |
| | | * @param string $failover Mime type supplied for failover. |
| | | * |
| | | * @return string |
| | | * @author Till Klampaeckel <till@php.net> |
| | | * @see http://de2.php.net/manual/en/ref.fileinfo.php |
| | | * @see http://de2.php.net/mime_content_type |
| | | */ |
| | | function strrstr($haystack, $needle) |
| | | function rc_mime_content_type($path, $failover = 'unknown/unknown') |
| | | { |
| | | $pver = phpversion(); |
| | | if ($pver[0] >= 5) |
| | | return strrpos($haystack, $needle); |
| | | else |
| | | { |
| | | $index = strpos(strrev($haystack), strrev($needle)); |
| | | if($index === false) |
| | | return false; |
| | | |
| | | $index = strlen($haystack) - strlen($needle) - $index; |
| | | return $index; |
| | | } |
| | | global $CONFIG; |
| | | |
| | | $mime_magic = $CONFIG['mime_magic']; |
| | | |
| | | if (function_exists('mime_content_type')) { |
| | | return mime_content_type($path); |
| | | } |
| | | if (!extension_loaded('fileinfo')) { |
| | | if (!dl('fileinfo.' . PHP_SHLIB_SUFFIX)) { |
| | | return $failover; |
| | | } |
| | | } |
| | | $finfo = finfo_open(FILEINFO_MIME, $mime_magic); |
| | | if (!$finfo) { |
| | | return $failover; |
| | | } |
| | | $mime_type = finfo_file($finfo,$path); |
| | | if (!$mime_type) { |
| | | return $failover; |
| | | } |
| | | finfo_close($finfo); |
| | | |
| | | return $mime_type; |
| | | } |
| | | |
| | | |
| | | ?> |
| | | ?> |