本文整理汇总了PHP中Horde_Mime::quotedPrintableEncode方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Mime::quotedPrintableEncode方法的具体用法?PHP Horde_Mime::quotedPrintableEncode怎么用?PHP Horde_Mime::quotedPrintableEncode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Mime
的用法示例。
在下文中一共展示了Horde_Mime::quotedPrintableEncode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructs a new procmail recipe.
*
* @param array $params Array of parameters.
* REQUIRED FIELDS:
* 'action'
* OPTIONAL FIELDS:
* 'action-value' (only used if the
* 'action' requires it)
* @param array $scriptparams Array of parameters passed to
* Ingo_Script_Procmail::.
*/
public function __construct($params = array(), $scriptparams = array())
{
$this->_disable = !empty($params['disable']);
$this->_params = array_merge($this->_params, $scriptparams);
switch ($params['action']) {
case Ingo_Storage::ACTION_KEEP:
// Note: you may have to set the DEFAULT variable in your
// backend configuration.
if (isset($this->_params['delivery_agent']) && isset($this->_params['delivery_mailbox_prefix'])) {
$this->_action[] = '| ' . $this->_params['delivery_agent'] . ' ' . $this->_params['delivery_mailbox_prefix'] . '$DEFAULT';
} elseif (isset($this->_params['delivery_agent'])) {
$this->_action[] = '| ' . $this->_params['delivery_agent'] . ' $DEFAULT';
} else {
$this->_action[] = '$DEFAULT';
}
break;
case Ingo_Storage::ACTION_MOVE:
if (isset($this->_params['delivery_agent']) && isset($this->_params['delivery_mailbox_prefix'])) {
$this->_action[] = '| ' . $this->_params['delivery_agent'] . ' ' . $this->_params['delivery_mailbox_prefix'] . $this->procmailPath($params['action-value']);
} elseif (isset($this->_params['delivery_agent'])) {
$this->_action[] = '| ' . $this->_params['delivery_agent'] . ' ' . $this->procmailPath($params['action-value']);
} else {
$this->_action[] = $this->procmailPath($params['action-value']);
}
break;
case Ingo_Storage::ACTION_DISCARD:
$this->_action[] = '/dev/null';
break;
case Ingo_Storage::ACTION_REDIRECT:
$this->_action[] = '! ' . $params['action-value'];
break;
case Ingo_Storage::ACTION_REDIRECTKEEP:
$this->_action[] = '{';
$this->_action[] = ' :0 c';
$this->_action[] = ' ! ' . $params['action-value'];
$this->_action[] = '';
$this->_action[] = ' :0' . (isset($this->_params['delivery_agent']) ? ' w' : '');
if (isset($this->_params['delivery_agent']) && isset($this->_params['delivery_mailbox_prefix'])) {
$this->_action[] = ' | ' . $this->_params['delivery_agent'] . ' ' . $this->_params['delivery_mailbox_prefix'] . '$DEFAULT';
} elseif (isset($this->_params['delivery_agent'])) {
$this->_action[] = ' | ' . $this->_params['delivery_agent'] . ' $DEFAULT';
} else {
$this->_action[] = ' $DEFAULT';
}
$this->_action[] = '}';
break;
case Ingo_Storage::ACTION_REJECT:
$this->_action[] = '{';
$this->_action[] = ' :0 h';
$this->_action[] = ' SUBJECT=| formail -xSubject:';
$this->_action[] = '';
$this->_action[] = ' :0 h';
$this->_action[] = ' SENDER=| formail -zxFrom:';
$this->_action[] = '';
$this->_action[] = ' :0 Wh';
$this->_action[] = ' * !^FROM_DAEMON';
$this->_action[] = ' * !^X-Loop: $SENDER';
$this->_action[] = ' | (formail -rA"X-Loop: $SENDER" \\';
$reason = $params['action-value'];
if (Horde_Mime::is8bit($reason)) {
$this->_action[] = ' -i"Subject: Re: $SUBJECT" \\';
$this->_action[] = ' -i"Content-Transfer-Encoding: quoted-printable" \\';
$this->_action[] = ' -i"Content-Type: text/plain; charset=UTF-8" ; \\';
$reason = Horde_Mime::quotedPrintableEncode($reason, "\n");
} else {
$this->_action[] = ' -i"Subject: Re: $SUBJECT" ; \\';
}
$reason = addcslashes($reason, "\\\n\r\t\"`");
$this->_action[] = ' ' . $this->_params['echo'] . ' -e "' . $reason . '" \\';
$this->_action[] = ' ) | $SENDMAIL -oi -t';
$this->_action[] = '}';
break;
case Ingo_Storage::ACTION_VACATION:
$days = $params['action-value']['days'];
$timed = !empty($params['action-value']['start']) && !empty($params['action-value']['end']);
$this->_action[] = '{';
foreach ($params['action-value']['addresses'] as $address) {
if (!empty($address)) {
$this->_action[] = ' :0';
$this->_action[] = ' * ^TO_' . $address;
$this->_action[] = ' {';
$this->_action[] = ' FILEDATE=`test -f ${VACATION_DIR:-.}/\'.vacation.' . $address . '\' && ' . $this->_params['ls'] . ' -lcn --time-style=+%s ${VACATION_DIR:-.}/\'.vacation.' . $address . '\' | ' . 'awk \'{ print $6 + (' . $days * 86400 . ') }\'`';
$this->_action[] = ' DATE=`' . $this->_params['date'] . ' +%s`';
$this->_action[] = ' DUMMY=`test -f ${VACATION_DIR:-.}/\'.vacation.' . $address . '\' && ' . 'test $FILEDATE -le $DATE && ' . 'rm ${VACATION_DIR:-.}/\'.vacation.' . $address . '\'`';
if ($timed) {
$this->_action[] = ' START=' . $params['action-value']['start'];
$this->_action[] = ' END=' . $params['action-value']['end'];
}
//.........这里部分代码省略.........
示例2: _serialize
/**
* Serialize data.
*
* @param mixed $data The data to be serialized.
* @param mixed $mode The mode of serialization. Can be
* either a single mode or array of modes.
* If array, will be serialized in the
* order provided.
* @param mixed $params Any additional parameters the serialization method
* requires.
*
* @return string A serialized string.
* @throws Horde_Serialize_Exception
*/
protected static function _serialize($data, $mode, $params = null)
{
switch ($mode) {
case self::NONE:
break;
// $params['level'] = Level of compression (default: 3)
// $params['workfactor'] = How does compression phase behave when given
// worst case, highly repetitive, input data
// (default: 30)
// $params['level'] = Level of compression (default: 3)
// $params['workfactor'] = How does compression phase behave when given
// worst case, highly repetitive, input data
// (default: 30)
case self::BZIP:
$data = bzcompress($data, isset($params['level']) ? $params['level'] : 3, isset($params['workfactor']) ? $params['workfactor'] : 30);
if (is_integer($data)) {
$data = false;
}
break;
case self::WDDX:
$data = wddx_serialize_value($data);
break;
case self::IMAP8:
$data = Horde_Mime::quotedPrintableEncode($data);
break;
case self::IMAPUTF7:
$data = Horde_Imap_Client_Utf7imap::Utf8ToUtf7Imap(Horde_String::convertCharset($data, 'ISO-8859-1', 'UTF-8'));
break;
case self::IMAPUTF8:
$data = Horde_Mime::decode($data);
break;
// $params['level'] = Level of compression (default: 3)
// $params['level'] = Level of compression (default: 3)
case self::GZ_DEFLATE:
$data = gzdeflate($data, isset($params['level']) ? $params['level'] : 3);
break;
case self::BASIC:
$data = serialize($data);
break;
// $params['level'] = Level of compression (default: 3)
// $params['level'] = Level of compression (default: 3)
case self::GZ_COMPRESS:
$data = gzcompress($data, isset($params['level']) ? $params['level'] : 3);
break;
case self::BASE64:
$data = base64_encode($data);
break;
// $params['level'] = Level of compression (default: 3)
// $params['level'] = Level of compression (default: 3)
case self::GZ_ENCODE:
$data = gzencode($data, isset($params['level']) ? $params['level'] : 3);
break;
case self::RAW:
$data = rawurlencode($data);
break;
case self::URL:
$data = urlencode($data);
break;
// $params = Source character set
// $params = Source character set
case self::UTF7:
$data = Horde_String::convertCharset($data, $params, 'UTF-7');
break;
// $params = Source character set
// $params = Source character set
case self::UTF7_BASIC:
$data = self::serialize($data, array(self::UTF7, self::BASIC), $params);
break;
case self::JSON:
$tmp = json_encode($data);
/* Basic error handling attempts.
* TODO: JSON_ERROR_UTF8 = 5; available as of PHP 5.3.3 */
if (json_last_error() === 5) {
$data = json_encode(Horde_String::convertCharset($data, $params, 'UTF-8', true));
} else {
$data = $tmp;
}
break;
case self::LZF:
$data = lzf_compress($data);
break;
}
if ($data === false) {
throw new Horde_Serialize_Exception('Serialization failed.');
}
return $data;
//.........这里部分代码省略.........
示例3: _exportvData
//.........这里部分代码省略.........
$value = $this->_exportUtcOffset($value);
break;
// Integer fields.
// Integer fields.
case 'PERCENT-COMPLETE':
case 'PRIORITY':
case 'REPEAT':
case 'SEQUENCE':
$value = "{$value}";
break;
// Geo fields.
// Geo fields.
case 'GEO':
if ($this->_oldFormat) {
$value = $value['longitude'] . ',' . $value['latitude'];
} else {
$value = $value['latitude'] . ';' . $value['longitude'];
}
break;
// Recurrence fields.
// Recurrence fields.
case 'EXRULE':
case 'RRULE':
break;
default:
if ($this->_oldFormat) {
if (is_array($attribute['values']) && count($attribute['values']) > 1) {
$values = $attribute['values'];
if ($name == 'N' || $name == 'ADR' || $name == 'ORG') {
$glue = ';';
} else {
$glue = ',';
}
$values = str_replace(';', '\\;', $values);
$value = implode($glue, $values);
} else {
/* vcard 2.1 and vcalendar 1.0 escape only
* semicolons */
$value = str_replace(';', '\\;', $value);
}
// Text containing newlines or ASCII >= 127 must be BASE64
// or QUOTED-PRINTABLE encoded. Currently we use
// QUOTED-PRINTABLE as default.
if (preg_match("/[^ -]/", $value) && empty($params['ENCODING'])) {
$params['ENCODING'] = 'QUOTED-PRINTABLE';
$params_str .= ';ENCODING=QUOTED-PRINTABLE';
// Add CHARSET as well. At least the synthesis client
// gets confused otherwise
if (empty($params['CHARSET'])) {
$params['CHARSET'] = 'UTF-8';
$params_str .= ';CHARSET=' . $params['CHARSET'];
}
}
} else {
if (is_array($attribute['values']) && count($attribute['values'])) {
$values = $attribute['values'];
if ($name == 'N' || $name == 'ADR' || $name == 'ORG') {
$glue = ';';
} else {
$glue = ',';
}
// As of rfc 2426 2.5 semicolon and comma must be
// escaped.
$values = str_replace(array('\\', ';', ','), array('\\\\', '\\;', '\\,'), $values);
$value = implode($glue, $values);
} else {
// As of rfc 2426 2.5 semicolon and comma must be
// escaped.
$value = str_replace(array('\\', ';', ','), array('\\\\', '\\;', '\\,'), $value);
}
$value = preg_replace('/\\r?\\n/', '\\n', $value);
}
break;
}
$value = str_replace("\r", '', $value);
if (!empty($params['ENCODING']) && $params['ENCODING'] == 'QUOTED-PRINTABLE' && strlen(trim($value))) {
$result .= $name . $params_str . ':' . preg_replace(array('/(?<!\\r)\\n/', '/(?<!=)\\r\\n/'), array("\r\n", "=0D=0A=\r\n "), Horde_Mime::quotedPrintableEncode($value)) . $this->_newline;
} else {
$attr_string = $name . $params_str . ':' . $value;
if (!$this->_oldFormat) {
if (isset($params['ENCODING']) && $params['ENCODING'] == 'b') {
$attr_string = trim(chunk_split($attr_string, 75, $this->_newline . ' '));
} else {
$attr_string = Horde_String::wordwrap($attr_string, 75, $this->_newline . ' ', true, true);
}
}
$result .= $attr_string . $this->_newline;
}
}
$tzs = array();
foreach ($this->_components as $component) {
if (!$component instanceof Horde_Icalendar_Vtimezone || !isset($tzs[$component->getAttribute('TZID')])) {
$result .= $component->exportvCalendar();
if ($component instanceof Horde_Icalendar_Vtimezone) {
$tzs[$component->getAttribute('TZID')] = true;
}
}
}
return $result . 'END:' . $base . $this->_newline;
}