alecpl
2008-10-26 95d90f86d9c5482b531092776181943c9bf57642
program/include/main.inc
@@ -74,17 +74,7 @@
  $opt = rcmail::get_instance()->config->get($config_key);
  if (!empty($opt))
    {
    $db = &rcmail::get_instance()->db;
    if ($db->db_provider=='pgsql')
      {
      $db->db_handle->setOption('disable_smart_seqname', true);
      $db->db_handle->setOption('seqname_format', '%s');
      }
    return $opt;
    }
    
  return $sequence;
  }
@@ -130,20 +120,6 @@
  $app = rcmail::get_instance();
  return $app->url((array)$p + array('_action' => $action, 'task' => $task));
}
/**
 * Add a localized label to the client environment
 * @deprecated
 */
function rcube_add_label()
  {
  global $OUTPUT;
  $arg_list = func_get_args();
  foreach ($arg_list as $i => $name)
    $OUTPUT->add_label($name);
  }
/**
@@ -212,11 +188,14 @@
    return $str;
    
  $aliases = array(
    'UNKNOWN-8BIT'   => 'ISO-8859-15',
    'X-UNKNOWN'      => 'ISO-8859-15',
    'X-USER-DEFINED' => 'ISO-8859-15',
    'ISO-8859-8-I'   => 'ISO-8859-8',
    'KS_C_5601-1987' => 'EUC-KR',
    'US-ASCII'         => 'ISO-8859-1',
    'ANSI_X3.110-1983' => 'ISO-8859-1',
    'ANSI_X3.4-1968'   => 'ISO-8859-1',
    'UNKNOWN-8BIT'     => 'ISO-8859-15',
    'X-UNKNOWN'        => 'ISO-8859-15',
    'X-USER-DEFINED'   => 'ISO-8859-15',
    'ISO-8859-8-I'     => 'ISO-8859-8',
    'KS_C_5601-1987'   => 'EUC-KR',
  );
  // convert charset using iconv module  
@@ -230,12 +209,10 @@
      }
    }
  // settings for mbstring module (by Tadashi Jokagi)
  if (is_null($mbstring_loaded)) {
    if ($mbstring_loaded = extension_loaded("mbstring"))
      mb_internal_encoding(RCMAIL_CHARSET);
  }
  if (is_null($mbstring_loaded))
    $mbstring_loaded = extension_loaded('mbstring');
  // convert charset using mbstring module
  if ($mbstring_loaded)
    {
@@ -347,7 +324,7 @@
      $str = strip_tags($str);
    
    // avoid douple quotation of &
    $out = preg_replace('/&([a-z]{2,5}|#[0-9]{2,4});/', '&\\1;', strtr($str, $encode_arr));
    $out = preg_replace('/&([A-Za-z]{2,6}|#[0-9]{2,4});/', '&\\1;', strtr($str, $encode_arr));
      
    return $newlines ? nl2br($out) : $out;
    }
@@ -575,7 +552,8 @@
  // use value from post
  if (!empty($_POST[$fname]))
    $value = get_input_value($fname, RCUBE_INPUT_POST);
    $value = get_input_value($fname, RCUBE_INPUT_POST,
       $type == 'textarea' && strpos($attrib['class'], 'mce_editor')!==false ? true : false);
  $out = $input->show($value);
         
@@ -597,7 +575,8 @@
  $last_pos = 0;
  
  // ignore the whole block if evil styles are detected
  if (stristr($source, 'expression') || stristr($source, 'behavior'))
  $stripped = preg_replace('/[^a-z\(:]/', '', rcmail_xss_entitiy_decode($source));
  if (preg_match('/expression|behavior|url\(|import/', $stripped))
    return '';
  // cut out all contents between { and }
@@ -630,6 +609,22 @@
  return $styles;
  }
/**
 * Decode escaped entities used by known XSS exploits.
 * See http://downloads.securityfocus.com/vulnerabilities/exploits/26800.eml for examples
 *
 * @param string CSS content to decode
 * @return string Decoded string
 */
function rcmail_xss_entitiy_decode($content)
{
  $out = html_entity_decode(html_entity_decode($content));
  $out = preg_replace('/\\\([0-9a-f]{4})/ie', "chr(hexdec('\\1'))", $out);
  $out = preg_replace('#/\*.*\*/#Um', '', $out);
  return $out;
}
/**
@@ -691,10 +686,10 @@
    $ts = $date;
  else if (!empty($date))
    {
    while (($ts = @strtotime($date))===false)
    // if date parsing fails, we have a date in non-rfc format.
    // remove token from the end and try again
    while ((($ts = @strtotime($date))===false) || ($ts < 0))
      {
        // if we have a date in non-rfc format
        // remove token from the end and try again
        $d = explode(' ', $date);
        array_pop($d);
        if (!$d) break;
@@ -832,7 +827,7 @@
  $log_entry = sprintf("[%s]: %s\n",
                 date("d-M-Y H:i:s O", mktime()),
                 $line);
  if ($CONFIG['log_driver'] == 'syslog') {
    if ($name == 'errors')
      $prio = LOG_ERR;
@@ -843,10 +838,11 @@
    // log_driver == 'file' is assumed here
    if (empty($CONFIG['log_dir']))
      $CONFIG['log_dir'] = INSTALL_PATH.'logs';
    // try to open specific log file for writing
    if ($fp = @fopen($CONFIG['log_dir'].'/'.$name, 'a')) {
      fwrite($fp, $log_entry);
      fflush($fp);
      fclose($fp);
    }
  }
@@ -895,8 +891,7 @@
  $attrib += array('maxlength' => 100, 'relanames' => false);
  // add some labels to client
  rcube_add_label('purgefolderconfirm');
  rcube_add_label('deletemessagesconfirm');
  $RCMAIL->output->add_label('purgefolderconfirm', 'deletemessagesconfirm');
  
  $type = $attrib['type'] ? $attrib['type'] : 'ul';
  unset($attrib['type']);
@@ -1049,8 +1044,10 @@
      $classes[] = 'trash';
    else if ($folder['id']==$CONFIG['junk_mbox'])
      $classes[] = 'junk';
    else if ($folder['id']=='INBOX')
      $classes[] = 'inbox';
    else
      $classes[] = asciiwords($folder_class ? $folder_class : strtolower($folder['id']), true);
      $classes[] = '_'.asciiwords($folder_class ? $folder_class : strtolower($folder['id']), true);
      
    $classes[] = $zebra_class;