当前位置: 首页>>代码示例>>PHP>>正文


PHP rcube_utils::mem_check方法代码示例

本文整理汇总了PHP中rcube_utils::mem_check方法的典型用法代码示例。如果您正苦于以下问题:PHP rcube_utils::mem_check方法的具体用法?PHP rcube_utils::mem_check怎么用?PHP rcube_utils::mem_check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rcube_utils的用法示例。


在下文中一共展示了rcube_utils::mem_check方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_message

 /**
  * Fetch message headers and body structure from the IMAP server and build
  * an object structure.
  *
  * @param int    $uid    Message UID to fetch
  * @param string $folder Folder to read from
  *
  * @return object rcube_message_header Message data
  */
 public function get_message($uid, $folder = null)
 {
     if (!strlen($folder)) {
         $folder = $this->folder;
     }
     // decode combined UID-folder identifier
     if (preg_match('/^\\d+-.+/', $uid)) {
         list($uid, $folder) = explode('-', $uid, 2);
     }
     // Check internal cache
     if (!empty($this->icache['message'])) {
         if (($headers = $this->icache['message']) && $headers->uid == $uid) {
             return $headers;
         }
     }
     $headers = $this->get_message_headers($uid, $folder);
     // message doesn't exist?
     if (empty($headers)) {
         return null;
     }
     // structure might be cached
     if (!empty($headers->structure)) {
         return $headers;
     }
     $this->msg_uid = $uid;
     if (!$this->check_connection()) {
         return $headers;
     }
     if (empty($headers->bodystructure)) {
         $headers->bodystructure = $this->conn->getStructure($folder, $uid, true);
     }
     $structure = $headers->bodystructure;
     if (empty($structure)) {
         return $headers;
     }
     // set message charset from message headers
     if ($headers->charset) {
         $this->struct_charset = $headers->charset;
     } else {
         $this->struct_charset = $this->structure_charset($structure);
     }
     $headers->ctype = @strtolower($headers->ctype);
     // Here we can recognize malformed BODYSTRUCTURE and
     // 1. [@TODO] parse the message in other way to create our own message structure
     // 2. or just show the raw message body.
     // Example of structure for malformed MIME message:
     // ("text" "plain" NIL NIL NIL "7bit" 2154 70 NIL NIL NIL)
     if ($headers->ctype && !is_array($structure[0]) && $headers->ctype != 'text/plain' && strtolower($structure[0] . '/' . $structure[1]) == 'text/plain') {
         // A special known case "Content-type: text" (#1488968)
         if ($headers->ctype == 'text') {
             $structure[1] = 'plain';
             $headers->ctype = 'text/plain';
         } else {
             if (preg_match('/^(text|application)\\/(.*)/', $headers->ctype, $m)) {
                 $structure[0] = $m[1];
                 $structure[1] = $m[2];
             } else {
                 // Try to parse the message using rcube_mime_decode.
                 // We need a better solution, it parses message
                 // in memory, which wouldn't work for very big messages,
                 // (it uses up to 10x more memory than the message size)
                 // it's also buggy and not actively developed
                 if ($headers->size && rcube_utils::mem_check($headers->size * 10)) {
                     $raw_msg = $this->get_raw_body($uid);
                     $struct = rcube_mime::parse_message($raw_msg);
                 } else {
                     return $headers;
                 }
             }
         }
     }
     if (empty($struct)) {
         $struct = $this->structure_part($structure, 0, '', $headers);
     }
     // some workarounds on simple messages...
     if (empty($struct->parts)) {
         // ...don't trust given content-type
         if (!empty($headers->ctype)) {
             $struct->mime_id = '1';
             $struct->mimetype = strtolower($headers->ctype);
             list($struct->ctype_primary, $struct->ctype_secondary) = explode('/', $struct->mimetype);
         }
         // ...and charset (there's a case described in #1488968 where invalid content-type
         // results in invalid charset in BODYSTRUCTURE)
         if (!empty($headers->charset) && $headers->charset != $struct->ctype_parameters['charset']) {
             $struct->charset = $headers->charset;
             $struct->ctype_parameters['charset'] = $headers->charset;
         }
     }
     $headers->structure = $struct;
     return $this->icache['message'] = $headers;
//.........这里部分代码省略.........
开发者ID:ehabqino,项目名称:roundcubemail,代码行数:101,代码来源:rcube_imap.php

示例2: mem_check

 /**
  * Check if we have enough memory to load specified image
  */
 private function mem_check($props)
 {
     // image size is unknown, we can't calculate required memory
     if (!$props['width']) {
         return true;
     }
     // channels: CMYK - 4, RGB - 3
     $multip = ($props['channels'] ?: 3) + 1;
     // calculate image size in memory (in bytes)
     $size = $props['width'] * $props['height'] * $multip;
     return rcube_utils::mem_check($size);
 }
开发者ID:jimjag,项目名称:roundcubemail,代码行数:15,代码来源:rcube_image.php

示例3: import

 /**
  * Import events from iCalendar format
  *
  * @param  string vCalendar input
  * @param  string Input charset (from envelope)
  * @param  boolean True if parsing exceptions should be forwarded to the caller
  * @return array List of events extracted from the input
  */
 public function import($vcal, $charset = 'UTF-8', $forward_exceptions = false, $memcheck = true)
 {
     // TODO: convert charset to UTF-8 if other
     try {
         // estimate the memory usage and try to avoid fatal errors when allowed memory gets exhausted
         if ($memcheck) {
             $count = substr_count($vcal, 'BEGIN:VEVENT') + substr_count($vcal, 'BEGIN:VTODO');
             $expected_memory = $count * 70 * 1024;
             // assume ~ 70K per event (empirically determined)
             if (!rcube_utils::mem_check($expected_memory)) {
                 throw new Exception("iCal file too big");
             }
         }
         $vobject = VObject\Reader::read($vcal, VObject\Reader::OPTION_FORGIVING | VObject\Reader::OPTION_IGNORE_INVALID_LINES);
         if ($vobject) {
             return $this->import_from_vobject($vobject);
         }
     } catch (Exception $e) {
         if ($forward_exceptions) {
             throw $e;
         } else {
             rcube::raise_error(array('code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "iCal data parse error: " . $e->getMessage()), true, false);
         }
     }
     return array();
 }
开发者ID:Fneufneu,项目名称:libcalendaring,代码行数:34,代码来源:libvcalendar.php

示例4: rcmail_mem_check

function rcmail_mem_check($need)
{
    return rcube_utils::mem_check($need);
}
开发者ID:noikiy,项目名称:roundcubemail,代码行数:4,代码来源:bc.php

示例5: get_message

 /**
  * Fetch message headers and body structure from the IMAP server and build
  * an object structure similar to the one generated by PEAR::Mail_mimeDecode
  *
  * @param int     $uid      Message UID to fetch
  * @param string  $folder   Folder to read from
  *
  * @return object rcube_message_header Message data
  */
 public function get_message($uid, $folder = null)
 {
     if (!strlen($folder)) {
         $folder = $this->folder;
     }
     // Check internal cache
     if (!empty($this->icache['message'])) {
         if (($headers = $this->icache['message']) && $headers->uid == $uid) {
             return $headers;
         }
     }
     $headers = $this->get_message_headers($uid, $folder);
     // message doesn't exist?
     if (empty($headers)) {
         return null;
     }
     // structure might be cached
     if (!empty($headers->structure)) {
         return $headers;
     }
     $this->msg_uid = $uid;
     if (!$this->check_connection()) {
         return $headers;
     }
     if (empty($headers->bodystructure)) {
         $headers->bodystructure = $this->conn->getStructure($folder, $uid, true);
     }
     $structure = $headers->bodystructure;
     if (empty($structure)) {
         return $headers;
     }
     // set message charset from message headers
     if ($headers->charset) {
         $this->struct_charset = $headers->charset;
     } else {
         $this->struct_charset = $this->structure_charset($structure);
     }
     $headers->ctype = strtolower($headers->ctype);
     // Here we can recognize malformed BODYSTRUCTURE and
     // 1. [@TODO] parse the message in other way to create our own message structure
     // 2. or just show the raw message body.
     // Example of structure for malformed MIME message:
     // ("text" "plain" NIL NIL NIL "7bit" 2154 70 NIL NIL NIL)
     if ($headers->ctype && !is_array($structure[0]) && $headers->ctype != 'text/plain' && strtolower($structure[0] . '/' . $structure[1]) == 'text/plain') {
         // we can handle single-part messages, by simple fix in structure (#1486898)
         if (preg_match('/^(text|application)\\/(.*)/', $headers->ctype, $m)) {
             $structure[0] = $m[1];
             $structure[1] = $m[2];
         } else {
             // Try to parse the message using Mail_mimeDecode package
             // We need a better solution, Mail_mimeDecode parses message
             // in memory, which wouldn't work for very big messages,
             // (it uses up to 10x more memory than the message size)
             // it's also buggy and not actively developed
             if ($headers->size && rcube_utils::mem_check($headers->size * 10)) {
                 $raw_msg = $this->get_raw_body($uid);
                 $struct = rcube_mime::parse_message($raw_msg);
             } else {
                 return $headers;
             }
         }
     }
     if (empty($struct)) {
         $struct = $this->structure_part($structure, 0, '', $headers);
     }
     // don't trust given content-type
     if (empty($struct->parts) && !empty($headers->ctype)) {
         $struct->mime_id = '1';
         $struct->mimetype = strtolower($headers->ctype);
         list($struct->ctype_primary, $struct->ctype_secondary) = explode('/', $struct->mimetype);
     }
     $headers->structure = $struct;
     return $this->icache['message'] = $headers;
 }
开发者ID:rockchow2002,项目名称:roundcubemail,代码行数:83,代码来源:rcube_imap.php

示例6: rcmail_mem_check

function rcmail_mem_check($need)
{
    _deprecation_warning(__FUNCTION__);
    return rcube_utils::mem_check($need);
}
开发者ID:JotapePinheiro,项目名称:roundcubemail,代码行数:5,代码来源:bc.php


注:本文中的rcube_utils::mem_check方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。