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


PHP rcube_mime::file_content_type方法代码示例

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


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

示例1: save_data

 function save_data()
 {
     $COMPOSE_ID = rcube_utils::get_input_value('_id', rcube_utils::INPUT_GPC);
     $COMPOSE = null;
     if ($COMPOSE_ID && $_SESSION['compose_data_' . $COMPOSE_ID]) {
         $SESSION_KEY = 'compose_data_' . $COMPOSE_ID;
         $COMPOSE =& $_SESSION[$SESSION_KEY];
     }
     if (!$COMPOSE) {
         die("Invalid session var!");
     }
     $uploadid = rcube_utils::get_input_value('_uploadid', rcube_utils::INPUT_POST);
     $files = rcube_utils::get_input_value('files', rcube_utils::INPUT_POST);
     $RCMAIL = rcmail::get_instance();
     $RCMAIL->output->reset();
     //rcube::write_log('dropbox_attachments', $files);
     if (is_array($files)) {
         $multiple = count($files) > 1;
         foreach ($files as $i => $file) {
             /*File checks*/
             $err = false;
             if ($file['is_dir'] == 'true') {
                 $err = "UPLOAD_ERR_DIRECTORY";
             }
             // Fetch file
             $filepath = $this->download_fopen($file['link']);
             //rcube::write_log('dropbox_attachments', link);
             //rcube::write_log('dropbox_attachments', $filepath);
             rcube::write_log('dropbox_attachments', $file['link']);
             if (!$filepath) {
                 $err = "UPLOAD_ERR_FETCH";
             }
             if (!$err) {
                 $attachment = $this->move_file(array('path' => $filepath, 'size' => $file['bytes'], 'name' => $file['name'], 'mimetype' => rcube_mime::file_content_type($filepath, $file['name']), 'group' => $COMPOSE_ID));
             }
             //rcube::write_log('dropbox_attachments', $attachment);
             if (!$err && $attachment['status'] && !$attachment['abort']) {
                 $id = $attachment['id'];
                 // store new attachment in session
                 unset($attachment['status'], $attachment['abort']);
                 $RCMAIL->session->append($SESSION_KEY . '.attachments', $id, $attachment);
                 if (($icon = $COMPOSE['deleteicon']) && is_file($icon)) {
                     $button = html::img(array('src' => $icon, 'alt' => $RCMAIL->gettext('delete')));
                 } else {
                     if ($COMPOSE['textbuttons']) {
                         $button = rcube::Q($RCMAIL->gettext('delete'));
                     } else {
                         $button = '';
                     }
                 }
                 $content = html::a(array('href' => "#delete", 'onclick' => sprintf("return %s.command('remove-attachment','rcmfile%s', this)", rcmail_output::JS_OBJECT_NAME, $id), 'title' => $RCMAIL->gettext('delete'), 'class' => 'delete'), $button);
                 $content .= rcube::Q($attachment['name']);
                 $RCMAIL->output->command('add2attachment_list', "rcmfile{$id}", array('html' => $content, 'name' => $attachment['name'], 'mimetype' => $attachment['mimetype'], 'classname' => rcube_utils::file2class($attachment['mimetype'], $attachment['name']), 'complete' => true), $uploadid);
             } else {
                 // upload failed
                 if ($err == "UPLOAD_ERR_DIRECTORY") {
                     $msg = "Directory upload not allowed.";
                 } else {
                     if ($err == "UPLOAD_ERR_FETCH") {
                         $msg = "Failed to download file from Dropbox";
                     } else {
                         if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) {
                             $size = $RCMAIL->show_bytes(parse_bytes(ini_get('upload_max_filesize')));
                             $msg = $RCMAIL->gettext(array('name' => 'filesizeerror', 'vars' => array('size' => $size)));
                         } else {
                             if ($attachment['error']) {
                                 $msg = $attachment['error'];
                             } else {
                                 $msg = $RCMAIL->gettext('fileuploaderror');
                             }
                         }
                     }
                 }
                 if ($attachment['error'] || $err != UPLOAD_ERR_NO_FILE) {
                     $RCMAIL->output->command('display_message', $msg, 'error');
                     $RCMAIL->output->command('remove_from_attachment_list', $uploadid);
                 }
             }
         }
     }
     $RCMAIL->output->command('auto_save_start', 'false');
     $RCMAIL->output->send();
 }
开发者ID:rigent1164,项目名称:dropbox_attachments,代码行数:83,代码来源:dropbox_attachments.php

示例2: uu_decode

 /**
  * Parse message body for UUencoded attachments bodies
  *
  * @param rcube_message_part $part Message part to decode
  * @return array
  */
 function uu_decode(&$part)
 {
     // @TODO: messages may be huge, handle body via file
     $part->body = $this->get_part_body($part->mime_id);
     $parts = array();
     $pid = 0;
     // FIXME: line length is max.65?
     $uu_regexp_begin = '/begin [0-7]{3,4} ([^\\r\\n]+)\\r?\\n/s';
     $uu_regexp_end = '/`\\r?\\nend((\\r?\\n)|($))/s';
     while (preg_match($uu_regexp_begin, $part->body, $matches, PREG_OFFSET_CAPTURE)) {
         $startpos = $matches[0][1];
         if (!preg_match($uu_regexp_end, $part->body, $m, PREG_OFFSET_CAPTURE, $startpos)) {
             break;
         }
         $endpos = $m[0][1];
         $begin_len = strlen($matches[0][0]);
         $end_len = strlen($m[0][0]);
         // extract attachment body
         $filebody = substr($part->body, $startpos + $begin_len, $endpos - $startpos - $begin_len - 1);
         $filebody = str_replace("\r\n", "\n", $filebody);
         // remove attachment body from the message body
         $part->body = substr_replace($part->body, '', $startpos, $endpos + $end_len - $startpos);
         // mark body as modified so it will not be cached by rcube_imap_cache
         $part->body_modified = true;
         // add attachments to the structure
         $uupart = new rcube_message_part();
         $uupart->filename = trim($matches[1][0]);
         $uupart->encoding = 'stream';
         $uupart->body = convert_uudecode($filebody);
         $uupart->size = strlen($uupart->body);
         $uupart->mime_id = 'uu.' . $part->mime_id . '.' . $pid;
         $ctype = rcube_mime::file_content_type($uupart->body, $uupart->filename, 'application/octet-stream', true);
         $uupart->mimetype = $ctype;
         list($uupart->ctype_primary, $uupart->ctype_secondary) = explode('/', $ctype);
         $parts[] = $uupart;
         $pid++;
     }
     return $parts;
 }
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:45,代码来源:rcube_message.php

示例3: check_mime_detection

 /**
  * Try to detect some file's mimetypes to test the correct behavior of fileinfo
  */
 function check_mime_detection()
 {
     $files = array('installer/images/roundcube_logo.png' => 'image/png', 'program/resources/blank.tif' => 'image/tiff', 'skins/larry/images/buttons.gif' => 'image/gif', 'skins/larry/README' => 'text/plain');
     $errors = array();
     foreach ($files as $path => $expected) {
         $mimetype = rcube_mime::file_content_type(INSTALL_PATH . $path, basename($path));
         if ($mimetype != $expected) {
             $errors[] = array($path, $mimetype, $expected);
         }
     }
     return $errors;
 }
开发者ID:zamentur,项目名称:roundcube_ynh,代码行数:15,代码来源:rcube_install.php

示例4: fix_mime_part

 /**
  * Helper method to fix potentially invalid mimetypes of PDF attachments
  */
 private function fix_mime_part($part, $message)
 {
     // Some versions of Outlook create garbage Content-Type:
     // application/pdf.A520491B_3BF7_494D_8855_7FAC2C6C0608
     if (preg_match('/^application\\/pdf.+/', $part->mimetype)) {
         $part->mimetype = 'application/pdf';
     }
     // try to fix invalid application/octet-stream mimetypes for PDF attachments
     if ($part->mimetype == 'application/octet-stream' && preg_match('/\\.pdf$/', strval($part->filename))) {
         $body = $message->get_part_body($part->mime_id, false, 2048);
         $real_mimetype = rcube_mime::file_content_type($body, $part->filename, $part->mimetype, true, true);
         if (in_array($real_mimetype, $this->pdf_mimetypes)) {
             $part->mimetype = $real_mimetype;
         }
     }
     list($part->ctype_primary, $part->ctype_secondary) = explode('/', $part->mimetype);
 }
开发者ID:nciftci,项目名称:plugins,代码行数:20,代码来源:pdfviewer.php

示例5: attachment_upload

 /**
  * Handler for attachment uploads
  */
 public function attachment_upload($session_key, $id_prefix = '')
 {
     // Upload progress update
     if (!empty($_GET['_progress'])) {
         $this->rc->upload_progress();
     }
     $recid = $id_prefix . rcube_utils::get_input_value('_id', rcube_utils::INPUT_GPC);
     $uploadid = rcube_utils::get_input_value('_uploadid', rcube_utils::INPUT_GPC);
     if (!is_array($_SESSION[$session_key]) || $_SESSION[$session_key]['id'] != $recid) {
         $_SESSION[$session_key] = array();
         $_SESSION[$session_key]['id'] = $recid;
         $_SESSION[$session_key]['attachments'] = array();
     }
     // clear all stored output properties (like scripts and env vars)
     $this->rc->output->reset();
     if (is_array($_FILES['_attachments']['tmp_name'])) {
         foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath) {
             // Process uploaded attachment if there is no error
             $err = $_FILES['_attachments']['error'][$i];
             if (!$err) {
                 $attachment = array('path' => $filepath, 'size' => $_FILES['_attachments']['size'][$i], 'name' => $_FILES['_attachments']['name'][$i], 'mimetype' => rcube_mime::file_content_type($filepath, $_FILES['_attachments']['name'][$i], $_FILES['_attachments']['type'][$i]), 'group' => $recid);
                 $attachment = $this->rc->plugins->exec_hook('attachment_upload', $attachment);
             }
             if (!$err && $attachment['status'] && !$attachment['abort']) {
                 $id = $attachment['id'];
                 // store new attachment in session
                 unset($attachment['status'], $attachment['abort']);
                 $_SESSION[$session_key]['attachments'][$id] = $attachment;
                 if (($icon = $_SESSION[$session_key . '_deleteicon']) && is_file($icon)) {
                     $button = html::img(array('src' => $icon, 'alt' => $this->rc->gettext('delete')));
                 } else {
                     $button = rcube::Q($this->rc->gettext('delete'));
                 }
                 $content = html::a(array('href' => "#delete", 'class' => 'delete', 'onclick' => sprintf("return %s.remove_from_attachment_list('rcmfile%s')", rcmail_output::JS_OBJECT_NAME, $id), 'title' => $this->rc->gettext('delete'), 'aria-label' => $this->rc->gettext('delete') . ' ' . $attachment['name']), $button);
                 $content .= rcube::Q($attachment['name']);
                 $this->rc->output->command('add2attachment_list', "rcmfile{$id}", array('html' => $content, 'name' => $attachment['name'], 'mimetype' => $attachment['mimetype'], 'classname' => rcube_utils::file2class($attachment['mimetype'], $attachment['name']), 'complete' => true), $uploadid);
             } else {
                 // upload failed
                 if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) {
                     $msg = $this->rc->gettext(array('name' => 'filesizeerror', 'vars' => array('size' => $this->rc->show_bytes(parse_bytes(ini_get('upload_max_filesize'))))));
                 } else {
                     if ($attachment['error']) {
                         $msg = $attachment['error'];
                     } else {
                         $msg = $this->rc->gettext('fileuploaderror');
                     }
                 }
                 $this->rc->output->command('display_message', $msg, 'error');
                 $this->rc->output->command('remove_from_attachment_list', $uploadid);
             }
         }
     } else {
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             // if filesize exceeds post_max_size then $_FILES array is empty,
             // show filesizeerror instead of fileuploaderror
             if ($maxsize = ini_get('post_max_size')) {
                 $msg = $this->rc->gettext(array('name' => 'filesizeerror', 'vars' => array('size' => $this->rc->show_bytes(parse_bytes($maxsize)))));
             } else {
                 $msg = $this->rc->gettext('fileuploaderror');
             }
             $this->rc->output->command('display_message', $msg, 'error');
             $this->rc->output->command('remove_from_attachment_list', $uploadid);
         }
     }
     $this->rc->output->send('iframe');
 }
开发者ID:Fneufneu,项目名称:libcalendaring,代码行数:69,代码来源:libcalendaring.php

示例6: uu_decode

 /**
  * Parse message body for UUencoded attachments bodies
  *
  * @param rcube_message_part $part Message part to decode
  * @return array
  */
 function uu_decode(&$part)
 {
     // @TODO: messages may be huge, hadle body via file
     if (!isset($part->body)) {
         $this->storage->set_folder($this->folder);
         $part->body = $this->storage->get_message_part($this->uid, $part->mime_id, $part);
     }
     $parts = array();
     // uuencode regexp
     $uu_regexp = '/^(begin [0-7]{3,4} ([^\\n]+)\\n)(([\\x21-\\x60]{0,65}\\n){0,2})([\\x21-\\x60]{0,65}|`\\nend)\\s*\\n/sm';
     if (preg_match_all($uu_regexp, $part->body, $matches, PREG_SET_ORDER)) {
         $uu_endstring = "`\nend\n";
         // add attachments to the structure
         foreach ($matches as $pid => $att) {
             // make sure we're looking at a uuencoded file, and not a false positive
             $uu_lines = explode("\n", $att[3]);
             foreach ($uu_lines as $uu_line) {
                 if (strlen($uu_line) == 0) {
                     continue;
                 }
                 $line_len = ord(substr($uu_line, 0, 1)) - 32 & 0x3f;
                 $max_code_len = floor(($line_len + 2) / 3) * 4;
                 $min_code_len = ceil($line_len / 3 * 4);
                 if (strlen($uu_line) - 1 < $min_code_len or strlen($uu_line) - 1 > $max_code_len) {
                     // illegal uuencode, break out of 'foreach $matches' loop
                     break 2;
                 }
             }
             $startpos = strpos($part->body, $att[0]) + strlen($att[1]);
             $endpos = strpos($part->body, $uu_endstring);
             $filebody = substr($part->body, $startpos, $endpos - $startpos);
             // remove attachments bodies from the message body
             $uu_startpos = $startpos - strlen($att[1]);
             $part->body = substr_replace($part->body, "", $uu_startpos, $endpos + strlen($uu_endstring) - $uu_startpos);
             $uupart = new rcube_message_part();
             $uupart->filename = trim($att[2]);
             $uupart->encoding = 'stream';
             $uupart->body = convert_uudecode($filebody);
             $uupart->size = strlen($uupart->body);
             $uupart->mime_id = 'uu.' . $part->mime_id . '.' . $pid;
             $ctype = rcube_mime::file_content_type($uupart->body, $uupart->filename, 'application/octet-stream', true);
             $uupart->mimetype = $ctype;
             list($uupart->ctype_primary, $uupart->ctype_secondary) = explode('/', $ctype);
             $parts[] = $uupart;
             unset($matches[$pid]);
         }
         // mark body as modified so it will not be cached by rcube_imap_cache
         $part->body_modified = true;
     }
     return $parts;
 }
开发者ID:gOOvER,项目名称:EasySCP,代码行数:57,代码来源:rcube_message.php

示例7: rc_mime_content_type

function rc_mime_content_type($path, $name, $failover = 'application/octet-stream', $is_stream = false)
{
    return rcube_mime::file_content_type($path, $name, $failover, $is_stream);
}
开发者ID:noikiy,项目名称:roundcubemail,代码行数:4,代码来源:bc.php

示例8: uu_decode

 /**
  * Parse message body for UUencoded attachments bodies
  *
  * @param rcube_message_part $part Message part to decode
  * @return array
  */
 function uu_decode(&$part)
 {
     // @TODO: messages may be huge, hadle body via file
     if (!isset($part->body)) {
         $this->storage->set_folder($this->folder);
         $part->body = $this->storage->get_message_part($this->uid, $part->mime_id, $part);
     }
     $parts = array();
     // FIXME: line length is max.65?
     $uu_regexp = '/begin [0-7]{3,4} ([^\\n]+)\\n/s';
     if (preg_match_all($uu_regexp, $part->body, $matches, PREG_SET_ORDER)) {
         $uu_endstring = "`\nend\n";
         // add attachments to the structure
         foreach ($matches as $pid => $att) {
             $startpos = strpos($part->body, $att[1]) + strlen($att[1]) + 1;
             // "\n"
             $endpos = strpos($part->body, $uu_endstring);
             $filebody = substr($part->body, $startpos, $endpos - $startpos);
             // remove attachments bodies from the message body
             $part->body = substr_replace($part->body, "", $startpos, $endpos + strlen($uu_endstring) - $startpos);
             $uupart = new rcube_message_part();
             $uupart->filename = trim($att[1]);
             $uupart->encoding = 'stream';
             $uupart->body = convert_uudecode($filebody);
             $uupart->size = strlen($uupart->body);
             $uupart->mime_id = 'uu.' . $part->mime_id . '.' . $pid;
             $ctype = rcube_mime::file_content_type($uupart->body, $uupart->filename, 'application/octet-stream', true);
             $uupart->mimetype = $ctype;
             list($uupart->ctype_primary, $uupart->ctype_secondary) = explode('/', $ctype);
             $parts[] = $uupart;
             unset($matches[$pid]);
         }
         // remove attachments bodies from the message body
         $part->body = preg_replace($uu_regexp, '', $part->body);
         // mark body as modified so it will not be cached by rcube_imap_cache
         $part->body_modified = true;
     }
     return $parts;
 }
开发者ID:bbspike,项目名称:sentora-core,代码行数:45,代码来源:rcube_message.php

示例9: getAttachment

 public function getAttachment()
 {
     $attachments = [];
     $ids = rcube_utils::get_input_value('ids', rcube_utils::INPUT_GPC);
     if (!isset($ids)) {
         return $attachments;
     }
     $rcmail = rcmail::get_instance();
     $db = $rcmail->get_dbh();
     $ids = implode(',', $ids);
     $userid = $rcmail->user->ID;
     $index = 0;
     $sql_result = $db->query("SELECT vtiger_attachments.* FROM vtiger_attachments INNER JOIN vtiger_seattachmentsrel ON vtiger_seattachmentsrel.attachmentsid=vtiger_attachments.attachmentsid WHERE vtiger_seattachmentsrel.crmid IN ({$ids});");
     while ($row = $db->fetch_assoc($sql_result)) {
         $orgFile = $rcmail->config->get('root_directory') . $row['path'] . $row['attachmentsid'] . '_' . $row['name'];
         list($usec, $sec) = explode(' ', microtime());
         $filepath = $rcmail->config->get('root_directory') . 'modules/OSSMail/roundcube/temp/' . $sec . $userid . $row['attachmentsid'] . $index . '.tmp';
         if (file_exists($orgFile)) {
             copy($orgFile, $filepath);
             $attachment = ['path' => $filepath, 'size' => filesize($filepath), 'name' => $row['name'], 'mimetype' => rcube_mime::file_content_type($filepath, $row['name'], $row['type'])];
             $attachments[] = $attachment;
         }
         $index++;
     }
     return $attachments;
 }
开发者ID:rcrrich,项目名称:UpdatePackages,代码行数:26,代码来源:yetiforce.php

示例10: rc_mime_content_type

function rc_mime_content_type($path, $name, $failover = 'application/octet-stream', $is_stream = false)
{
    _deprecation_warning(__FUNCTION__);
    return rcube_mime::file_content_type($path, $name, $failover, $is_stream);
}
开发者ID:JotapePinheiro,项目名称:roundcubemail,代码行数:5,代码来源:bc.php


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