⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 func.inc

📁 开源邮件管理系统
💻 INC
📖 第 1 页 / 共 3 页
字号:
      if (strpos($attach_prop->mimetype, 'image/') === 0) {        $out .= html::tag('hr') . html::p(array('align' => "center"),          html::img(array(            'src' => $MESSAGE->get_part_url($attach_prop->mime_id),            'title' => $attach_prop->filename,            'alt' => $attach_prop->filename,          )));        }    }  }    // tell client that there are blocked remote objects  if ($REMOTE_OBJECTS && !$safe_mode)    $OUTPUT->set_env('blockedobjects', true);  return html::div($attrib, $out);  }/** * modify a HTML message that it can be displayed inside a HTML page */function rcmail_html4inline($body, $container_id)  {  $base_url = "";  $last_style_pos = 0;  $body_lc = strtolower($body);    // check for <base href>  if (preg_match(($base_reg = '/(<base.*href=["\']?)([hftps]{3,5}:\/{2}[^"\'\s]+)([^<]*>)/i'), $body, $base_regs))    $base_url = $base_regs[2];    // find STYLE tags  while (($pos = strpos($body_lc, '<style', $last_style_pos)) && ($pos2 = strpos($body_lc, '</style>', $pos)))    {    $pos = strpos($body_lc, '>', $pos)+1;    // replace all css definitions with #container [def]    $styles = rcmail_mod_css_styles(substr($body, $pos, $pos2-$pos), $container_id, $base_url);    $body = substr($body, 0, $pos) . $styles . substr($body, $pos2);    $body_lc = strtolower($body);    $last_style_pos = $pos2;    }  // resolve <base href>  if ($base_url)    {    $body = preg_replace('/(src|background|href)=(["\']?)([\.\/]+[^"\'\s]+)(\2|\s|>)/Uie', "'\\1=\"'.make_absolute_url('\\3', '$base_url').'\"'", $body);    $body = preg_replace('/(url\s*\()(["\']?)([\.\/]+[^"\'\)\s]+)(\2)\)/Uie', "'\\1\''.make_absolute_url('\\3', '$base_url').'\')'", $body);    $body = preg_replace($base_reg, '', $body);    }      // modify HTML links to open a new window if clicked  $body = preg_replace('/<(a|link)\s+([^>]+)>/Uie', "rcmail_alter_html_link('\\1','\\2', '$container_id');", $body);  // add comments arround html and other tags  $out = preg_replace(array(      '/(<!DOCTYPE[^>]*>)/i',      '/(<\?xml[^>]*>)/i',      '/(<\/?html[^>]*>)/i',      '/(<\/?head[^>]*>)/i',      '/(<title[^>]*>.*<\/title>)/Ui',      '/(<\/?meta[^>]*>)/i'),    '<!--\\1-->',    $body);  $out = preg_replace(    array('/<body([^>]*)>/i', '/<\/body>/i'),    array('<div class="rcmBody"\\1>', '</div>'),    $out);  // quote <? of php and xml files that are specified as text/html  $out = preg_replace(array('/<\?/', '/\?>/'), array('&lt;?', '?&gt;'), $out);  return $out;  }/** * parse link attributes and set correct target */function rcmail_alter_html_link($tag, $attrs, $container_id)  {  $attrib = parse_attrib_string($attrs);  if ($tag == 'link' && preg_match('/^https?:\/\//i', $attrib['href']))    $attrib['href'] = "./bin/modcss.php?u=" . urlencode($attrib['href']) . "&amp;c=" . urlencode($container_id);  else if (stristr((string)$attrib['href'], 'mailto:'))    $attrib['onclick'] = sprintf(      "return %s.command('compose','%s',this)",      JS_OBJECT_NAME,      JQ(substr($attrib['href'], 7)));  else if (!empty($attrib['href']) && $attrib['href']{0}!='#')    $attrib['target'] = '_blank';  return "<$tag" . create_attrib_string($attrib, array('href','name','target','onclick','id','class','style','title','rel','type','media')) . ' />';  }/** * decode address string and re-format it as HTML links */function rcmail_address_string($input, $max=NULL, $addicon=NULL)  {  global $IMAP, $PRINT_MODE, $CONFIG, $OUTPUT, $EMAIL_ADDRESS_PATTERN;  $a_parts = $IMAP->decode_address_list($input);  if (!sizeof($a_parts))    return $input;  $c = count($a_parts);  $j = 0;  $out = '';  foreach ($a_parts as $part)    {    $j++;    if ($PRINT_MODE)      $out .= sprintf('%s &lt;%s&gt;', Q($part['name']), $part['mailto']);    else if (preg_match($EMAIL_ADDRESS_PATTERN, $part['mailto']))      {      $out .= sprintf('<a href="mailto:%s" onclick="return %s.command(\'compose\',\'%s\',this)" class="rcmContactAddress" title="%s">%s</a>',                      Q($part['mailto']),                      JS_OBJECT_NAME,                      JQ($part['mailto']),                      Q($part['mailto']),                      Q($part['name']));                            if ($addicon)        $out .= sprintf('&nbsp;<a href="#add" onclick="return %s.command(\'add-contact\',\'%s\',this)" title="%s"><img src="%s%s" alt="add" border="0" /></a>',                        JS_OBJECT_NAME,                        urlencode($part['string']),                        rcube_label('addtoaddressbook'),                        $CONFIG['skin_path'],                        $addicon);      }    else      {      if ($part['name'])        $out .= Q($part['name']);      if ($part['mailto'])        $out .= (strlen($out) ? ' ' : '') . sprintf('&lt;%s&gt;', Q($part['mailto']));      }          if ($c>$j)      $out .= ','.($max ? '&nbsp;' : ' ');            if ($max && $j==$max && $c>$j)      {      $out .= '...';      break;      }            }      return $out;  }function rcmail_message_part_controls()  {  global $MESSAGE;    $part = asciiwords(get_input_value('_part', RCUBE_INPUT_GPC));  if (!is_object($MESSAGE) || !is_array($MESSAGE->parts) || !($_GET['_uid'] && $_GET['_part']) || !$MESSAGE->mime_parts[$part])    return '';      $part = $MESSAGE->mime_parts[$part];  $table = new html_table(array('cols' => 3));    if (!empty($part->filename)) {    $table->add('title', Q(rcube_label('filename')));    $table->add(null, Q($part->filename));    $table->add(null, '[' . html::a('?'.str_replace('_frame=', '_download=', $_SERVER['QUERY_STRING']), Q(rcube_label('download'))) . ']');  }    if (!empty($part->size)) {    $table->add('title', Q(rcube_label('filesize')));    $table->add(null, Q(show_bytes($part->size)));  }    return $table->show($attrib);  }function rcmail_message_part_frame($attrib)  {  global $MESSAGE;    $part = $MESSAGE->mime_parts[asciiwords(get_input_value('_part', RCUBE_INPUT_GPC))];  $ctype_primary = strtolower($part->ctype_primary);  $attrib['src'] = Q('./?'.str_replace('_frame=', ($ctype_primary=='text' ? '_show=' : '_preload='), $_SERVER['QUERY_STRING']));  $attrib_str = create_attrib_string($attrib, array('id', 'class', 'style', 'src', 'width', 'height'));  $out = '<iframe '. $attrib_str . "></iframe>";      return $out;  }/** * clear message composing settings */function rcmail_compose_cleanup()  {  if (!isset($_SESSION['compose']))    return;  // remove attachment files from temp dir  if (is_array($_SESSION['compose']['attachments']))    foreach ($_SESSION['compose']['attachments'] as $attachment)      @unlink($attachment['path']);    unset($_SESSION['compose']);  }  /** * Send the given message compose object using the configured method */function rcmail_deliver_message(&$message, $from, $mailto){  global $CONFIG;  $msg_body = $message->get();  $headers = $message->headers();    // send thru SMTP server using custom SMTP library  if ($CONFIG['smtp_server'])    {    // generate list of recipients    $a_recipients = array($mailto);      if (strlen($headers['Cc']))      $a_recipients[] = $headers['Cc'];    if (strlen($headers['Bcc']))      $a_recipients[] = $headers['Bcc'];      // clean Bcc from header for recipients    $send_headers = $headers;    unset($send_headers['Bcc']);    // here too, it because txtHeaders() below use $message->_headers not only $send_headers    unset($message->_headers['Bcc']);    // send message    $smtp_response = array();    $sent = smtp_mail($from, $a_recipients, ($foo = $message->txtHeaders($send_headers, true)), $msg_body, $smtp_response);    // log error    if (!$sent)      raise_error(array('code' => 800, 'type' => 'smtp', 'line' => __LINE__, 'file' => __FILE__,                        'message' => "SMTP error: ".join("\n", $smtp_response)), TRUE, FALSE);    }    // send mail using PHP's mail() function  else    {    // unset some headers because they will be added by the mail() function    $headers_enc = $message->headers($headers);    $headers_php = $message->_headers;    unset($headers_php['To'], $headers_php['Subject']);        // reset stored headers and overwrite    $message->_headers = array();    $header_str = $message->txtHeaders($headers_php);      if (ini_get('safe_mode'))      $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str);    else      $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str, "-f$from");    }    if ($sent)  // remove MDN headers after sending    unset($headers['Return-Receipt-To'], $headers['Disposition-Notification-To']);    $message->_headers = array();  $message->headers($headers);    return $sent;}function rcmail_send_mdn($uid){  global $CONFIG, $USER, $IMAP;  $message = new rcube_message($uid);    if ($message->headers->mdn_to && !$message->headers->mdn_sent)  {    $identity = $USER->get_identity();    $sender = format_email_recipient($identity['email'], $identity['name']);    $recipient = array_shift($IMAP->decode_address_list($message->headers->mdn_to));    $mailto = $recipient['mailto'];    $compose = new rcube_mail_mime(rcmail_header_delm());    $compose->setParam(array(      'text_encoding' => 'quoted-printable',      'html_encoding' => 'quoted-printable',      'head_encoding' => 'quoted-printable',      'head_charset'  => RCMAIL_CHARSET,      'html_charset'  => RCMAIL_CHARSET,      'text_charset'  => RCMAIL_CHARSET,    ));        // compose headers array    $headers = array(      'Date' => date('r'),      'From' => $sender,      'To'   => $message->headers->mdn_to,      'Subject' => rcube_label('receiptread') . ': ' . $message->subject,      'Message-ID' => sprintf('<%s@%s>', md5(uniqid('rcmail'.rand(),true)), rcmail_mail_domain($_SESSION['imap_host'])),      'X-Sender' => $identity['email'],      'Content-Type' => 'multipart/report; report-type=disposition-notification',    );        if (!empty($CONFIG['useragent']))      $headers['User-Agent'] = $CONFIG['useragent'];    $body = rcube_label("yourmessage") . "\r\n\r\n" .      "\t" . rcube_label("to") . ': ' . rcube_imap::decode_mime_string($message->headers->to, $message->headers->charset) . "\r\n" .      "\t" . rcube_label("subject") . ': ' . $message->subject . "\r\n" .      "\t" . rcube_label("sent") . ': ' . format_date($message->headers->date, $CONFIG['date_long']) . "\r\n" .      "\r\n" . rcube_label("receiptnote") . "\r\n";        $ua = !empty($CONFIG['useragent']) ? $CONFIG['useragent'] : "RoundCube Webmail (Version ".RCMAIL_VERSION.")";    $report = "Reporting-UA: $ua\r\n";        if ($message->headers->to)        $report .= "Original-Recipient: {$message->headers->to}\r\n";        $report .= "Final-Recipient: rfc822; {$identity['email']}\r\n" .               "Original-Message-ID: {$message->headers->messageID}\r\n" .               "Disposition: manual-action/MDN-sent-manually; displayed\r\n";        $compose->headers($headers);    $compose->setTXTBody(wordwrap($body, 75, "\r\n"));    $compose->addAttachment($report, 'message/disposition-notification', 'MDNPart2.txt', false, '7bit', 'inline');    $sent = rcmail_deliver_message($compose, $identity['email'], $mailto);    if ($sent)    {      $IMAP->set_flag($message->uid, 'MDNSENT');      return true;    }  }    return false;}// register UI objects$OUTPUT->add_handlers(array(  'mailboxlist' => 'rcmail_mailbox_list',  'messages' => 'rcmail_message_list',  'messagecountdisplay' => 'rcmail_messagecount_display',  'quotadisplay' => 'rcmail_quota_display',  'messageheaders' => 'rcmail_message_headers',  'messagebody' => 'rcmail_message_body',  'messagecontentframe' => 'rcmail_messagecontent_frame',  'messagepartframe' => 'rcmail_message_part_frame',  'messagepartcontrols' => 'rcmail_message_part_controls',  'searchform' => array($OUTPUT, 'search_form'),));?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -