本文整理汇总了PHP中rcube_mime::get_mime_extensions方法的典型用法代码示例。如果您正苦于以下问题:PHP rcube_mime::get_mime_extensions方法的具体用法?PHP rcube_mime::get_mime_extensions怎么用?PHP rcube_mime::get_mime_extensions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rcube_mime
的用法示例。
在下文中一共展示了rcube_mime::get_mime_extensions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_mime_extensions
/**
* Check the correct configuration of the 'mime_types' mapping option
*/
function check_mime_extensions()
{
$types = array('application/zip' => 'zip', 'application/x-tar' => 'tar', 'application/java-archive' => 'jar', 'image/gif' => 'gif', 'image/svg+xml' => 'svg');
$errors = array();
foreach ($types as $mimetype => $expected) {
$ext = rcube_mime::get_mime_extensions($mimetype);
if ($ext[0] != $expected) {
$errors[] = array($mimetype, $ext, $expected);
}
}
return $errors;
}
示例2: download_attachments
/**
* Handler for attachment download action
*/
public function download_attachments()
{
$rcmail = rcmail::get_instance();
$imap = $rcmail->get_storage();
$temp_dir = $rcmail->config->get('temp_dir');
$tmpfname = tempnam($temp_dir, 'zipdownload');
$tempfiles = array($tmpfname);
$message = new rcube_message(rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GET));
// open zip file
$zip = new ZipArchive();
$zip->open($tmpfname, ZIPARCHIVE::OVERWRITE);
foreach ($message->attachments as $part) {
$pid = $part->mime_id;
$part = $message->mime_parts[$pid];
$filename = $part->filename;
if ($filename === null || $filename === '') {
$ext = (array) rcube_mime::get_mime_extensions($part->mimetype);
$ext = array_shift($ext);
$filename = $rcmail->gettext('messagepart') . ' ' . $pid;
if ($ext) {
$filename .= '.' . $ext;
}
}
$disp_name = $this->_convert_filename($filename);
if ($part->body) {
$orig_message_raw = $part->body;
$zip->addFromString($disp_name, $orig_message_raw);
} else {
$tmpfn = tempnam($temp_dir, 'zipattach');
$tmpfp = fopen($tmpfn, 'w');
$imap->get_message_part($message->uid, $part->mime_id, $part, null, $tmpfp, true);
$tempfiles[] = $tmpfn;
fclose($tmpfp);
$zip->addFile($tmpfn, $disp_name);
}
}
$zip->close();
$filename = ($message->subject ? $message->subject : 'roundcube') . '.zip';
$this->_deliver_zipfile($tmpfname, $filename);
// delete temporary files from disk
foreach ($tempfiles as $tmpfn) {
unlink($tmpfn);
}
exit;
}
示例3: check_mime_extensions
/**
* Check the correct configuration of the 'mime_types' mapping option
*/
public function check_mime_extensions()
{
$errors = array();
$types = array('application/zip' => 'zip', 'text/css' => 'css', 'application/pdf' => 'pdf', 'image/gif' => 'gif', 'image/svg+xml' => 'svg');
foreach ($types as $mimetype => $expected) {
$ext = rcube_mime::get_mime_extensions($mimetype);
if (!in_array($expected, (array) $ext)) {
$errors[] = array($mimetype, $ext, $expected);
}
}
return $errors;
}
示例4: download_attachments
/**
* Handler for attachment download action
*/
public function download_attachments()
{
$rcmail = rcmail::get_instance();
// require CSRF protected request
$rcmail->request_security_check(rcube_utils::INPUT_GET);
$imap = $rcmail->get_storage();
$temp_dir = $rcmail->config->get('temp_dir');
$tmpfname = tempnam($temp_dir, 'zipdownload');
$tempfiles = array($tmpfname);
$message = new rcube_message(rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GET));
// open zip file
$zip = new ZipArchive();
$zip->open($tmpfname, ZIPARCHIVE::OVERWRITE);
foreach ($message->attachments as $part) {
$pid = $part->mime_id;
$part = $message->mime_parts[$pid];
$filename = $part->filename;
if ($filename === null || $filename === '') {
$ext = (array) rcube_mime::get_mime_extensions($part->mimetype);
$ext = array_shift($ext);
$filename = $rcmail->gettext('messagepart') . ' ' . $pid;
if ($ext) {
$filename .= '.' . $ext;
}
}
$disp_name = $this->_convert_filename($filename);
$tmpfn = tempnam($temp_dir, 'zipattach');
$tmpfp = fopen($tmpfn, 'w');
$tempfiles[] = $tmpfn;
$message->get_part_body($part->mime_id, false, 0, $tmpfp);
$zip->addFile($tmpfn, $disp_name);
fclose($tmpfp);
}
$zip->close();
$filename = ($this->_filename_from_subject($message->subject) ?: 'attachments') . '.zip';
$this->_deliver_zipfile($tmpfname, $filename);
// delete temporary files from disk
foreach ($tempfiles as $tmpfn) {
unlink($tmpfn);
}
exit;
}