alecpl
2008-04-29 257782150db70dbe852d1c71fe6fd8abda0229f0
program/include/rcube_shared.inc
@@ -91,8 +91,9 @@
 */
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))
@@ -106,13 +107,13 @@
  // 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;
@@ -120,10 +121,10 @@
      $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);
@@ -236,18 +237,22 @@
 * @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)
    $iscached = ($_SERVER['HTTP_IF_NONE_MATCH'] == $etag);
  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");
@@ -262,7 +267,10 @@
    header("Etag: $etag");
  
  if ($iscached)
    {
    ob_end_clean();
    exit;
    }
}
@@ -650,29 +658,6 @@
  return $ts;
}
/**
 * Return the last occurence of a string in another string
 *
 * @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
 */
function strrstr($haystack, $needle)
{
  $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;
  }
}
/**
 * A method to guess the mime_type of an attachment.