本文整理汇总了PHP中quoted_printable_decode函数的典型用法代码示例。如果您正苦于以下问题:PHP quoted_printable_decode函数的具体用法?PHP quoted_printable_decode怎么用?PHP quoted_printable_decode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了quoted_printable_decode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAttachments
function getAttachments($id, $path)
{
$parts = imap_fetchstructure($this->mailbox, $id);
$attachments = array();
//FIXME if we do an is_array() here it breaks howver if we don't
//we get foreach errors
foreach ($parts->parts as $key => $value) {
$encoding = $parts->parts[$key]->encoding;
if ($parts->parts[$key]->ifdparameters) {
$filename = $parts->parts[$key]->dparameters[0]->value;
$message = imap_fetchbody($this->mailbox, $id, $key + 1);
switch ($encoding) {
case 0:
$message = imap_8bit($message);
case 1:
$message = imap_8bit($message);
case 2:
$message = imap_binary($message);
case 3:
$message = imap_base64($message);
case 4:
$message = quoted_printable_decode($message);
case 5:
default:
$message = $message;
}
$fp = fopen($path . $filename, "w");
fwrite($fp, $message);
fclose($fp);
$attachments[] = $filename;
}
}
return $attachments;
}
示例2: fetch
public function fetch($delete = false)
{
$oImap = imap_open('{' . $this->mail_server . ':993/imap/ssl/notls/novalidate-cert}', $this->username, $this->password);
$oMailboxStatus = imap_check($oImap);
$aMessages = imap_fetch_overview($oImap, "1:{$oMailboxStatus->Nmsgs}");
$validMessages = array();
foreach ($aMessages as $oMessage) {
print "Trying message '" . $oMessage->subject . "'";
$fileContent = $fileType = '';
$geocoder = factory::create('geocoder');
$postCode = $geocoder->extract_postcode($oMessage->subject);
$fromName = null;
$fromEmail = null;
if (strpos($oMessage->from, '<')) {
$split = split('<', $oMessage->from);
//name - make sure name not an email address
$fromName = trim($split[0]);
if (valid_email($fromName)) {
$fromName = null;
}
//email
$fromEmail = trim(str_replace('>', '', $split[1]));
} else {
$fromEmail = $oMessage->from;
}
$images = array();
$messageStructure = imap_fetchstructure($oImap, $oMessage->msgno);
if (isset($messageStructure->parts)) {
$partNumber = 0;
foreach ($messageStructure->parts as $oPart) {
$partNumber++;
if ($oPart->subtype == 'PLAIN' && !$postCode) {
$messageContent = imap_fetchbody($oImap, $oMessage->msgno, $partNumber);
if ($oPart->encoding == 4) {
$messageContent = quoted_printable_decode($messageContent);
}
$postCode = geocoder::extract_postcode($messageContent);
} elseif ($oPart->encoding == 3 && in_array($oPart->subtype, array('JPEG', 'PNG'))) {
$oImage = null;
$encodedBody = imap_fetchbody($oImap, $oMessage->msgno, $partNumber);
$fileContent = base64_decode($encodedBody);
$oImage = imagecreatefromstring($fileContent);
if (imagesx($oImage) > $this->min_import_size && imagesy($oImage) > $this->min_import_size) {
array_push($images, $oImage);
}
$fileType = strtolower($oPart->subtype);
}
}
}
//add to the messages array
array_push($validMessages, array('postcode' => $postCode, 'images' => $images, 'file_type' => $fileType, 'from_address' => $fromAddress, 'from_email' => $fromEmail, 'from_name' => $fromName));
if ($delete) {
imap_delete($oImap, $oMessage->msgno);
}
}
imap_close($oImap, CL_EXPUNGE);
$this->messages = $validMessages;
}
示例3: decode
public static function decode($str, $isHeader = true)
{
if ($isHeader) {
$str = str_replace("_", " ", $str);
}
return quoted_printable_decode($str);
}
示例4: finish
/**
* Returns the ezcMailText part corresponding to the parsed message.
*
* @return ezcMailText
*/
public function finish()
{
$charset = "us-ascii";
// RFC 2822 default
if (isset($this->headers['Content-Type'])) {
preg_match('/\\s*charset\\s?=\\s?"?([^;"\\s]*);?/', $this->headers['Content-Type'], $parameters);
if (count($parameters) > 0) {
$charset = strtolower(trim($parameters[1], '"'));
}
}
$encoding = strtolower($this->headers['Content-Transfer-Encoding']);
if ($encoding == ezcMail::QUOTED_PRINTABLE) {
$this->text = quoted_printable_decode($this->text);
} else {
if ($encoding == ezcMail::BASE64) {
$this->text = base64_decode($this->text);
}
}
$this->text = ezcMailCharsetConverter::convertToUTF8($this->text, $charset);
$part = new ezcMailText($this->text, 'utf-8', ezcMail::EIGHT_BIT, $charset);
$part->subType = $this->subType;
$part->setHeaders($this->headers->getCaseSensitiveArray());
ezcMailPartParser::parsePartHeaders($this->headers, $part);
$part->size = strlen($this->text);
return $part;
}
示例5: decode
public static function decode($data, $charset, &$o, &$attachments, $options = array())
{
//$body= iconv(strtoupper($charset),'UTF-8',$data);
//return $body;
$data = quoted_printable_decode($data);
// utf8_decode(imap_utf8($data)));
//print ($data);
//$data = iconv(strtoupper($charset),'CP1250//IGNORE',$data);
$ical = new iCalReader($data, 'string');
$arr = $ical->events();
$body = array('ATTENDEE' => array(), 'ORGANIZER' => array());
if (is_array($arr) && array_key_exists(0, $arr) && is_array($arr[0])) {
foreach ($arr[0] as $k => $v) {
$sk = explode(';', $k);
$p = array();
for ($i = 1; $i < count($sk); $i++) {
$t = explode('=', $sk[$i], 2);
$p[$t[0]] = $t[1];
}
$p['VALUE'] = stripslashes($v);
switch ($sk[0]) {
case 'ORGANIZER':
case 'ATTENDEE':
$body[$sk[0]][] = $p;
break;
default:
$body[$sk[0]] = $p;
break;
}
}
}
//db($arr);
//db($body);
return $body;
}
示例6: buildHtml
/**
* Parce httml attach images
*/
public function buildHtml()
{
// Important, without this line the example don't work!
// The images will be attached to the email but these will be not
// showed inline
$this->setType(Zend_Mime::MULTIPART_RELATED);
$zend_mime_part = $this->getBodyHtml();
$html = quoted_printable_decode($zend_mime_part->getContent());
$matches = array();
preg_match_all("#<img.*?src=['\"]([^'\"]+)#i", $html, $matches);
$matches = array_unique($matches[1]);
if (count($matches) > 0) {
foreach ($matches as $key => $filename) {
if (is_readable($filename)) {
$at = new Zend_Mime_Part(file_get_contents($filename));
$at->type = $this->mimeByExtension($filename);
$at->disposition = Zend_Mime::DISPOSITION_INLINE;
$at->encoding = Zend_Mime::ENCODING_BASE64;
$at->id = 'cid_' . md5_file($filename);
$html = str_replace($filename, 'cid:' . $at->id, $html);
$this->addAttachment($at);
}
}
$this->setBodyHtml($html, 'UTF-8', Zend_Mime::ENCODING_8BIT);
}
}
示例7: testEncodingAndDecodingSamples
public function testEncodingAndDecodingSamples()
{
$sampleFp = opendir($this->_samplesDir);
while (false !== ($encodingDir = readdir($sampleFp))) {
if (substr($encodingDir, 0, 1) == '.') {
continue;
}
$sampleDir = $this->_samplesDir . '/' . $encodingDir;
if (is_dir($sampleDir)) {
$fileFp = opendir($sampleDir);
while (false !== ($sampleFile = readdir($fileFp))) {
if (substr($sampleFile, 0, 1) == '.') {
continue;
}
$text = file_get_contents($sampleDir . '/' . $sampleFile);
$os = new Swift_ByteStream_ArrayByteStream();
$os->write($text);
$is = new Swift_ByteStream_ArrayByteStream();
$this->_encoder->encodeByteStream($os, $is);
$encoded = '';
while (false !== ($bytes = $is->read(8192))) {
$encoded .= $bytes;
}
$this->assertEquals(quoted_printable_decode($encoded), preg_replace('~\\r(?!\\n)|(?<!\\r)\\n~', "\r\n", $text), '%s: Encoded string should decode back to original string for sample ' . $sampleDir . '/' . $sampleFile);
}
closedir($fileFp);
}
}
closedir($sampleFp);
}
示例8: testStreamEncoding
public function testStreamEncoding()
{
$testfile = realpath(__FILE__);
$original = file_get_contents($testfile);
// Test Base64
$fp = fopen($testfile, 'rb');
$this->assertTrue(is_resource($fp));
$part = new Mime\Part($fp);
$part->encoding = Mime\Mime::ENCODING_BASE64;
$fp2 = $part->getEncodedStream();
$this->assertTrue(is_resource($fp2));
$encoded = stream_get_contents($fp2);
fclose($fp);
$this->assertEquals(base64_decode($encoded), $original);
// test QuotedPrintable
$fp = fopen($testfile, 'rb');
$this->assertTrue(is_resource($fp));
$part = new Mime\Part($fp);
$part->encoding = Mime\Mime::ENCODING_QUOTEDPRINTABLE;
$fp2 = $part->getEncodedStream();
$this->assertTrue(is_resource($fp2));
$encoded = stream_get_contents($fp2);
fclose($fp);
$this->assertEquals(quoted_printable_decode($encoded), $original);
}
示例9: Encoding_check
function Encoding_check($structure, $msg)
{
if ($structure->encoding == 3) {
//echo "encoding type is 3 </br>";
/*$msg= "<div>" .base64_decode($msg). "</div>";
echo "$msg </br>";*/
return print_msg_content(base64_decode($msg));
} else {
if ($structure->encoding == 4) {
// echo "encoding type is 4 </br>";
// $msg = "<div>" .quoted_printable_decode($msg). "</div>";
//$text = imap_utf7_decode($text);
//echo "$msg </br></br>";
return print_msg_content(quoted_printable_decode($msg));
} else {
if ($structure->encoding == 0) {
//echo "encoding type is 0 </br>";
//$text = decode7Bit($text);
// echo "<div>" .$msg. "</div></br>";
return print_msg_content($msg);
} else {
if ($structure->encoding == 1) {
// echo "encoding type is 1 </br>";
/*echo "<div>" .$msg. "</div></br>";*/
return print_msg_content($msg);
} else {
echo "Some other encoding format of type " . $structure->encoding . "</br>";
}
}
}
}
}
示例10: testEncodingAndDecodingSamplesFromDiConfiguredInstance
public function testEncodingAndDecodingSamplesFromDiConfiguredInstance()
{
$sampleFp = opendir($this->_samplesDir);
while (false !== ($encodingDir = readdir($sampleFp))) {
if (substr($encodingDir, 0, 1) == '.') {
continue;
}
$encoding = $encodingDir;
$encoder = $this->_createEncoderFromContainer();
$sampleDir = $this->_samplesDir . '/' . $encodingDir;
if (is_dir($sampleDir)) {
$fileFp = opendir($sampleDir);
while (false !== ($sampleFile = readdir($fileFp))) {
if (substr($sampleFile, 0, 1) == '.') {
continue;
}
$text = file_get_contents($sampleDir . '/' . $sampleFile);
$os = new Swift_ByteStream_ArrayByteStream();
$os->write($text);
$is = new Swift_ByteStream_ArrayByteStream();
$encoder->encodeByteStream($os, $is);
$encoded = '';
while (false !== ($bytes = $is->read(8192))) {
$encoded .= $bytes;
}
$this->assertEquals(str_replace("\r\n", "\n", quoted_printable_decode($encoded)), str_replace("\r\n", "\n", $text), '%s: Encoded string should decode back to original string for sample ' . $sampleDir . '/' . $sampleFile);
}
closedir($fileFp);
}
}
closedir($sampleFp);
}
示例11: getPart
function getPart($partNumber, $encoding)
{
$data = imap_fetchbody($this->connection, $this->messageNumber, $partNumber, FT_UID);
switch ($encoding) {
case 0:
return $data;
// 7BIT
// 7BIT
case 1:
return $data;
// 8BIT
// 8BIT
case 2:
return $data;
// BINARY
// BINARY
case 3:
return base64_decode($data);
// BASE64
// BASE64
case 4:
return quoted_printable_decode($data);
// QUOTED_PRINTABLE
// QUOTED_PRINTABLE
case 5:
return $data;
// OTHER
}
}
示例12: displayNotificationEmail
function displayNotificationEmail()
{
$html = '';
$html .= '<h3>' . $GLOBALS['Language']->getText('plugin_docman', 'details_approval_email_title') . '</h3>';
$atsm = new Docman_ApprovalTableNotificationCycle();
$atsm->setItem($this->item);
$atf =& Docman_ApprovalTableFactoriesFactory::getFromItem($this->item);
$table = $atf->getTable(false);
$atsm->setTable($table);
$um =& UserManager::instance();
$owner =& $um->getUserById($table->getOwner());
$atsm->setOwner($owner);
$atsm->sendNotifReviewer($owner);
$html .= $GLOBALS['Language']->getText('plugin_docman', 'details_approval_email_subject') . ' ' . $atsm->getNotificationSubject() . "\n";
$html .= '<p class="docman_approval_email">';
if (ProjectManager::instance()->getProject($this->item->getGroupId())->getTruncatedEmailsUsage()) {
$html .= $GLOBALS['Language']->getText('plugin_docman', 'truncated_email');
} else {
$html .= htmlentities(quoted_printable_decode($atsm->getNotificationBodyText()), ENT_COMPAT, 'UTF-8');
}
$html .= '</p>';
$backurl = $this->url . '&action=approval_create&id=' . $this->item->getId();
$html .= '<a href="' . $backurl . '">' . $GLOBALS['Language']->getText('plugin_docman', 'details_approval_email_back') . '</a>';
return $html;
}
示例13: simple_page_mode2
function simple_page_mode2($numeric_id = true)
{
global $Ajax, $Mode2, $selected_id2;
$default = $numeric_id ? -1 : '';
$selected_id2 = get_post('selected_id2', $default);
foreach (array('ADD_ITEM2', 'UPDATE_ITEM2', 'RESET2') as $m) {
if (isset($_POST[$m])) {
$Ajax->activate('_page_body');
if ($m == 'RESET2') {
$selected_id2 = $default;
}
$Mode2 = $m;
return;
}
}
foreach (array('BEd', 'BDel') as $m) {
foreach ($_POST as $p => $pvar) {
if (strpos($p, $m) === 0) {
// $selected_id2 = strtr(substr($p, strlen($m)), array('%2E'=>'.'));
unset($_POST['_focus']);
// focus on first form entry
$selected_id2 = quoted_printable_decode(substr($p, strlen($m)));
$Ajax->activate('_page_body');
$Mode2 = $m;
return;
}
}
}
$Mode2 = '';
}
示例14: fetchBody
private static function fetchBody($obj, $conn, $folder, $id, $structure, $part)
{
$body = $obj->fetchPartBody($conn, $folder, $id, $part);
$encoding = EmailMimeUtil::getPartEncodingCode($structure, $part);
if ($encoding == 3) {
$body = base64_decode($body);
} elseif ($encoding == 4) {
$body = quoted_printable_decode($body);
}
$charset = EmailMimeUtil::getPartCharset($structure, $part);
if (empty($charset)) {
$part_header = $obj->fetchPartHeader($conn, $folder, $id, $part);
$pattern = "/charset=[\"]?([a-zA-Z0-9_-]+)[\"]?/";
preg_match($pattern, $part_header, $matches);
if (count($matches) == 2) {
$charset = $matches[1];
}
}
if (strcasecmp($charset, "utf-8") == 0) {
$is_unicode = true;
} elseif (preg_match("/#[0-9]{5};/", $body)) {
$is_unicode = false;
} else {
$is_unicode = false;
}
if (!$is_unicode) {
$body = ConvertUtil::iIconv($body, "gb2312");
}
$url = Yii::app()->urlManager->createUrl("email/web/show", array("webid" => self::$_web["webid"], "folder" => $folder, "id" => $id, "cid" => ""));
$body = preg_replace("/src=(\")?cid:/i", "src=\"{$url}", $body);
return $body;
}
示例15: get_part
function get_part($ret, $mid, $p, $partno)
{
// DECODE DATA
$data = $partno ? imap_fetchbody($this->con, $mid, $partno) : imap_body($this->con, $mid);
// simple
// Any part may be encoded, even plain text messages, so check everything.
if ($p->encoding == 4) {
$data = quoted_printable_decode($data);
} elseif ($p->encoding == 3) {
$data = base64_decode($data);
}
// PARAMETERS
// get all parameters, like charset, filenames of attachments, etc.
$params = array();
if (isset($p->parameters)) {
foreach ($p->parameters as $x) {
$params[strtolower($x->attribute)] = $x->value;
}
}
if (isset($p->dparameters)) {
foreach ($p->dparameters as $x) {
$params[strtolower($x->attribute)] = $x->value;
}
}
// ATTACHMENT
// Any part with a filename is an attachment,
// so an attached text file (type 0) is not mistaken as the message.
if (!empty($params['filename']) || !empty($params['name'])) {
// filename may be given as 'Filename' or 'Name' or both
$filename = empty($params['filename']) ? $params['name'] : $params['filename'];
// filename may be encoded, so see imap_mime_header_decode()
$ret->attachments[$filename] = $data;
// this is a problem if two files have same name
}
// TEXT
if ($p->type == 0 && $data) {
// Messages may be split in different parts because of inline attachments,
// so append parts together with blank row.
if (strtolower($p->subtype) == 'plain') {
$ret->plainmsg .= trim($data) . "\n\n";
} else {
$ret->htmlmsg .= $data . "<br><br>";
}
$ret->charset = $params['charset'];
// assume all parts are same charset
} elseif ($p->type == 2 && $data) {
$ret->plainmsg .= $data . "\n\n";
}
// SUBPART RECURSION
if (!empty($p->parts)) {
foreach ($p->parts as $partno0 => $p2) {
$subpart = new \stdClass();
$subpart->htmlmsg = $subpart->plainmsg = $subpart->charset = '';
$subpart->attachments = array();
$ret->subpart = $subpart;
$this->get_part($subpart, $mid, $p2, $partno . '.' . ($partno0 + 1));
// 1.2, 1.2.1, etc.
}
}
}