本文整理汇总了PHP中Horde_Mime::is8bit方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Mime::is8bit方法的具体用法?PHP Horde_Mime::is8bit怎么用?PHP Horde_Mime::is8bit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Mime
的用法示例。
在下文中一共展示了Horde_Mime::is8bit方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _tryLogin
/**
* Authenticate to the POP3 server.
*
* @param string $method POP3 login method.
*
* @throws Horde_Imap_Client_Exception
*/
protected function _tryLogin($method)
{
$username = $this->getParam('username');
$password = $this->getParam('password');
switch ($method) {
case 'CRAM-MD5':
case 'CRAM-SHA1':
case 'CRAM-SHA256':
// RFC 5034: CRAM-MD5
// CRAM-SHA1 & CRAM-SHA256 supported by Courier SASL library
$challenge = $this->_sendLine('AUTH ' . $method);
$response = base64_encode($username . ' ' . hash_hmac(Horde_String::lower(substr($method, 5)), base64_decode(substr($challenge['resp'], 2)), $password, true));
$this->_sendLine($response, array('debug' => sprintf('[AUTH Response (username: %s)]', $username)));
break;
case 'DIGEST-MD5':
// RFC 2831; Obsoleted by RFC 6331
$challenge = $this->_sendLine('AUTH DIGEST-MD5');
$response = base64_encode(new Horde_Imap_Client_Auth_DigestMD5($username, $password, base64_decode(substr($challenge['resp'], 2)), $this->getParam('hostspec'), 'pop3'));
$sresponse = $this->_sendLine($response, array('debug' => sprintf('[AUTH Response (username: %s)]', $username)));
if (stripos(base64_decode(substr($sresponse['resp'], 2)), 'rspauth=') === false) {
throw new Horde_Imap_Client_Exception(Horde_Imap_Client_Translation::r("Unexpected response from server when authenticating."), Horde_Imap_Client_Exception::SERVER_CONNECT);
}
/* POP3 doesn't use protocol's third step. */
$this->_sendLine('');
break;
case 'LOGIN':
// RFC 4616 (AUTH=PLAIN) & 5034 (POP3 SASL)
$this->_sendLine('AUTH LOGIN');
$this->_sendLine(base64_encode($username));
$this->_sendLine(base64_encode($password), array('debug' => sprintf('[AUTH Password (username: %s)]', $username)));
break;
case 'PLAIN':
// RFC 5034
$this->_sendLine('AUTH PLAIN ' . base64_encode(implode("", array($username, $username, $password))), array('debug' => sprintf('AUTH PLAIN [Auth Response (username: %s)]', $username)));
break;
case 'APOP':
/* If UTF8 (+ USER) is active, and non-ASCII exists, need to apply
* SASLprep to username/password. RFC 6856[2.2]. Reject if
* UTF8 (+ USER) is not supported and 8-bit characters exist. */
if (Horde_Mime::is8bit($username) || Horde_Mime::is8bit($password)) {
if (empty($this->_temp['utf8']) || !$this->_capability('UTF8', 'USER') || !class_exists('Horde_Stringprep')) {
$error = true;
} else {
Horde_Stringprep::autoload();
$saslprep = new Znerol\Component\Stringprep\Profile\SASLprep();
try {
$username = $saslprep->apply($username, 'UTF-8', Znerol\Compnonent\Stringprep\Profile::MODE_QUERY);
$password = $saslprep->apply($password, 'UTF-8', Znerol\Compnonent\Stringprep\Profile::MODE_STORE);
$error = false;
} catch (Znerol\Component\Stringprep\ProfileException $e) {
$error = true;
}
}
if ($error) {
throw new Horde_Imap_Client_Exception(Horde_Imap_Client_Translation::r("Authentication failed."), Horde_Imap_Client_Exception::LOGIN_AUTHENTICATIONFAILED);
}
}
// RFC 1939 [7]
$this->_sendLine('APOP ' . $username . ' ' . hash('md5', $this->_temp['pop3timestamp'] . $password));
break;
case 'USER':
/* POP3 servers without UTF8 (+ USER) does not accept non-ASCII
* in USER/PASS. RFC 6856[2.2] */
if ((empty($this->_temp['utf8']) || !$this->_capability('UTF8', 'USER')) && (Horde_Mime::is8bit($username) || Horde_Mime::is8bit($password))) {
throw new Horde_Imap_Client_Exception(Horde_Imap_Client_Translation::r("Authentication failed."), Horde_Imap_Client_Exception::LOGIN_AUTHENTICATIONFAILED);
}
// RFC 1939 [7]
$this->_sendLine('USER ' . $username);
$this->_sendLine('PASS ' . $password, array('debug' => 'PASS [Password]'));
break;
case 'SCRAM-SHA-1':
$scram = new Horde_Imap_Client_Auth_Scram($username, $password, 'SHA1');
$c1 = $this->_sendLine('AUTH ' . $method . ' ' . base64_encode($scram->getClientFirstMessage()));
$sr1 = base64_decode(substr($c1['resp'], 2));
if (!$scram->parseServerFirstMessage($sr1)) {
throw new Horde_Imap_Client_Exception(Horde_Imap_Client_Translation::r("Authentication failed."), Horde_Imap_Client_Exception::LOGIN_AUTHENTICATIONFAILED);
}
$c2 = $this->_sendLine(base64_encode($scram->getClientFinalMessage()));
$sr2 = base64_decode(substr($c2['resp'], 2));
if (!$scram->parseServerFirstMessage($sr)) {
throw new Horde_Imap_Client_Exception(Horde_Imap_Client_Translation::r("Authentication failed."), Horde_Imap_Client_Exception::LOGIN_AUTHENTICATIONFAILED);
/* This means authentication passed, according to the server,
* but the server signature is incorrect. This indicates that
* server verification has failed. Immediately disconnect from
* the server, since this is a possible security issue. */
$this->logout();
throw new Horde_Imap_Client_Exception(Horde_Imap_Client_Translation::r("Server failed verification check."), Horde_Imap_Client_Exception::LOGIN_SERVER_VERIFICATION_FAILED);
}
$this->_sendLine('');
break;
default:
$e = new Horde_Imap_Client_Exception(Horde_Imap_Client_Translation::r("Unknown authentication method: %s"), Horde_Imap_Client_Exception::SERVER_CONNECT);
$e->messagePrintf(array($method));
//.........这里部分代码省略.........
示例2: __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)
* 'disable'
* @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);
$delivery = '| ';
if (isset($this->_params['delivery_agent'])) {
$delivery .= $this->_params['delivery_agent'] . ' ';
}
if (isset($this->_params['delivery_mailbox_prefix'])) {
$delivery .= ' ' . $this->_params['delivery_mailbox_prefix'];
}
switch ($params['action']) {
case 'Ingo_Rule_User_Keep':
// Note: you may have to set the DEFAULT variable in your
// backend configuration.
$this->_action[] = $delivery .= '$DEFAULT';
break;
case 'Ingo_Rule_User_Move':
$this->_action[] = $delivery .= $this->procmailPath($params['action-value']);
break;
case 'Ingo_Rule_User_Discard':
$this->_action[] = '/dev/null';
break;
case 'Ingo_Rule_User_Redirect':
$this->_action[] = '! ' . $params['action-value'];
break;
case 'Ingo_Rule_User_RedirectKeep':
$this->_action[] = '{';
$this->_action[] = ' :0 c';
$this->_action[] = ' ! ' . $params['action-value'];
if (strpos($this->_flags, 'c') === false) {
$this->_action[] = '';
$this->_action[] = ' :0' . (isset($this->_params['delivery_agent']) ? ' w' : '');
$this->_action[] = ' ' . $delivery . '$DEFAULT';
}
$this->_action[] = '}';
break;
case 'Ingo_Rule_User_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_QuotedPrintable::encode($reason);
} 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_Rule_System_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)) {
continue;
}
$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'];
}
$this->_action[] = '';
$this->_action[] = ' :0 h';
$this->_action[] = ' SUBJECT=| formail -xSubject:';
$this->_action[] = '';
$this->_action[] = ' :0 Whc: ${VACATION_DIR:-.}/vacation.lock';
if ($timed) {
//.........这里部分代码省略.........
示例3: readForm
public function readForm()
{
global $prefs, $session;
// Event owner.
$targetcalendar = Horde_Util::getFormData('targetcalendar');
if (strpos($targetcalendar, '\\')) {
list(, $this->creator) = explode('\\', $targetcalendar, 2);
} elseif (!isset($this->_id)) {
$this->creator = $GLOBALS['registry']->getAuth();
}
// Basic fields.
$this->title = Horde_Util::getFormData('title', $this->title);
$this->description = Horde_Util::getFormData('description', $this->description);
$this->location = Horde_Util::getFormData('location', $this->location);
$this->timezone = Horde_Util::getFormData('timezone', $this->timezone);
$this->private = (bool) Horde_Util::getFormData('private');
// URL.
$url = Horde_Util::getFormData('eventurl', $this->url);
if (strlen($url)) {
// Analyze and re-construct.
$url = @parse_url($url);
if ($url) {
if (function_exists('http_build_url')) {
if (empty($url['path'])) {
$url['path'] = '/';
}
$url = http_build_url($url);
} else {
$new_url = '';
if (isset($url['scheme'])) {
$new_url .= $url['scheme'] . '://';
}
if (isset($url['user'])) {
$new_url .= $url['user'];
if (isset($url['pass'])) {
$new_url .= ':' . $url['pass'];
}
$new_url .= '@';
}
if (isset($url['host'])) {
// Convert IDN hosts to ASCII.
if (function_exists('idn_to_ascii')) {
$url['host'] = @idn_to_ascii($url['host']);
} elseif (Horde_Mime::is8bit($url['host'])) {
//throw new Kronolith_Exception(_("Invalid character in URL."));
$url['host'] = '';
}
$new_url .= $url['host'];
}
if (isset($url['path'])) {
$new_url .= $url['path'];
}
if (isset($url['query'])) {
$new_url .= '?' . $url['query'];
}
if (isset($url['fragment'])) {
$new_url .= '#' . $url['fragment'];
}
$url = $new_url;
}
}
}
$this->url = $url;
// Status.
$this->status = Horde_Util::getFormData('status', $this->status);
// Attendees.
$attendees = $session->get('kronolith', 'attendees', Horde_Session::TYPE_ARRAY);
if (!is_null($newattendees = Horde_Util::getFormData('attendees'))) {
$newattendees = Kronolith::parseAttendees(trim($newattendees));
foreach ($newattendees as $email => $attendee) {
if (!isset($attendees[$email])) {
$attendees[$email] = $attendee;
}
}
foreach (array_keys($attendees) as $email) {
if (!isset($newattendees[$email])) {
unset($attendees[$email]);
}
}
}
$this->attendees = $attendees;
// Event start.
$allDay = Horde_Util::getFormData('whole_day');
if ($start_date = Horde_Util::getFormData('start_date')) {
// From ajax interface.
$this->start = Kronolith::parseDate($start_date . ' ' . Horde_Util::getFormData('start_time'), true, $this->timezone);
if ($allDay) {
$this->start->hour = $this->start->min = $this->start->sec = 0;
}
} else {
// From traditional interface.
$start = Horde_Util::getFormData('start');
$start_year = $start['year'];
$start_month = $start['month'];
$start_day = $start['day'];
$start_hour = Horde_Util::getFormData('start_hour');
$start_min = Horde_Util::getFormData('start_min');
$am_pm = Horde_Util::getFormData('am_pm');
if (!$prefs->getValue('twentyFour')) {
if ($am_pm == 'PM') {
//.........这里部分代码省略.........
示例4: _encode
/**
* @see encode()
*/
protected function _encode($name, $val, $opts)
{
$curr = 0;
$encode = $wrap = false;
$out = array();
// 2 = '=', ';'
$pre_len = strlen($name) + 2;
/* Several possibilities:
* - String is ASCII. Output as ASCII (duh).
* - Language information has been provided. We MUST encode output
* to include this information.
* - String is non-ASCII, but can losslessly translate to ASCII.
* Output as ASCII (most efficient).
* - String is in non-ASCII, but doesn't losslessly translate to
* ASCII. MUST encode output (duh). */
if (empty($opts['lang']) && !Horde_Mime::is8bit($val, 'UTF-8')) {
$string = $val;
} else {
$cval = Horde_String::convertCharset($val, 'UTF-8', $opts['charset']);
$string = Horde_String::lower($opts['charset']) . '\'' . (empty($opts['lang']) ? '' : Horde_String::lower($opts['lang'])) . '\'' . rawurlencode($cval);
$encode = true;
/* Account for trailing '*'. */
++$pre_len;
}
if ($pre_len + strlen($string) > 75) {
/* Account for continuation '*'. */
++$pre_len;
$wrap = true;
while ($string) {
$chunk = 75 - $pre_len - strlen($curr);
$pos = min($chunk, strlen($string) - 1);
/* Don't split in the middle of an encoded char. */
if ($chunk == $pos && $pos > 2) {
for ($i = 0; $i <= 2; ++$i) {
if ($string[$pos - $i] == '%') {
$pos -= $i + 1;
break;
}
}
}
$lines[] = substr($string, 0, $pos + 1);
$string = substr($string, $pos + 1);
++$curr;
}
} else {
$lines = array($string);
}
foreach ($lines as $i => $line) {
$out[$name . ($wrap ? '*' . $i : '') . ($encode ? '*' : '')] = $line;
}
if (!empty($opts['broken_rfc2231']) && !isset($out[$name])) {
$out = array_merge(array($name => Horde_Mime::encode($val, $opts['charset'])), $out);
}
/* Escape characters in params (See RFC 2045 [Appendix A]).
* Must be quoted-string if one of these exists. */
return $this->_escapeParams($out);
}
示例5: __get
/**
* @throws Horde_Idna_Exception
*/
public function __get($name)
{
switch ($name) {
case 'bare_address':
return is_null($this->host) ? $this->mailbox : $this->mailbox . '@' . $this->host;
case 'bare_address_idn':
$personal = $this->_personal;
$this->_personal = null;
$res = $this->encoded;
$this->_personal = $personal;
return $res;
case 'eai':
return is_null($this->mailbox) ? false : Horde_Mime::is8bit($this->mailbox);
case 'encoded':
return $this->writeAddress(true);
case 'host':
return $this->_host;
case 'host_idn':
return Horde_Idna::encode($this->_host);
case 'label':
return is_null($this->personal) ? $this->bare_address : $this->_personal;
case 'personal':
return strcasecmp($this->_personal, $this->bare_address) === 0 ? null : $this->_personal;
case 'personal_encoded':
return Horde_Mime::encode($this->personal);
case 'valid':
return (bool) strlen($this->mailbox);
}
}
示例6: _upgradeMailboxPrefs
/**
* As of IMP 6, special mailboxes are stored in UTF-8, not UTF7-IMAP.
*/
protected function _upgradeMailboxPrefs()
{
global $injector, $prefs;
$special_mboxes = array('drafts_folder', 'spam_folder', 'trash_folder');
foreach ($special_mboxes as $val) {
if (!$prefs->isDefault($val)) {
$old_pref = strval(IMP_Mailbox::getPref($val));
if (!Horde_Mime::is8bit($old_pref, 'UTF-8')) {
$mbox = IMP_Mailbox::get(Horde_String::convertCharset($old_pref, 'UTF7-IMAP', 'UTF-8'));
$prefs->setValue($val, $old_pref->{$mbox}->pref_to);
}
}
}
$imp_identity = $injector->getInstance('IMP_Identity');
foreach ($imp_identity->getAll('sent_mail_folder') as $key => $val) {
if (!is_null($val) && !Horde_Mime::is8bit($val, 'UTF-8')) {
$mbox = IMP_Mailbox::get(Horde_String::convertCharset(strval($val), 'UTF7-IMAP', 'UTF-8'));
$imp_identity->setValue(IMP_Mailbox::MBOX_SENT, $mbox, $key);
}
}
}
示例7: tovCard
/**
* Exports a given Turba_Object as an iCalendar vCard.
*
* @param Turba_Object $object Turba_Object.
* @param string $version The vcard version to produce.
* @param array $fields Hash of field names and
* Horde_SyncMl_Property properties with the
* requested fields.
* @param boolean $skipEmpty Whether to skip empty fields.
*
* @return Horde_Icalendar_Vcard A vcard object.
*/
public function tovCard(Turba_Object $object, $version = '2.1', array $fields = null, $skipEmpty = false)
{
global $injector;
$hash = $object->getAttributes();
$attributes = array_keys($this->map);
$vcard = new Horde_Icalendar_Vcard($version);
$formattedname = false;
$charset = $version == '2.1' ? array('CHARSET' => 'UTF-8') : array();
$hooks = $injector->getInstance('Horde_Core_Hooks');
$decode_hook = $hooks->hookExists('decode_attribute', 'turba');
// Tags are stored externally to Turba, so they don't appear in the
// source map.
$attributes[] = '__tags';
foreach ($attributes as $key) {
$val = $object->getValue($key);
if ($skipEmpty && !is_array($val) && !strlen($val)) {
continue;
}
if ($decode_hook) {
try {
$val = $hooks->callHook('decode_attribute', 'turba', array($key, $val, $object));
} catch (Turba_Exception $e) {
}
}
switch ($key) {
case '__uid':
$vcard->setAttribute('UID', $val);
break;
case 'name':
if ($fields && !isset($fields['FN'])) {
break;
}
$vcard->setAttribute('FN', $val, Horde_Mime::is8bit($val) ? $charset : array());
$formattedname = true;
break;
case 'nickname':
case 'alias':
$params = Horde_Mime::is8bit($val) ? $charset : array();
if (!$fields || isset($fields['NICKNAME'])) {
$vcard->setAttribute('NICKNAME', $val, $params);
}
if (!$fields || isset($fields['X-EPOCSECONDNAME'])) {
$vcard->setAttribute('X-EPOCSECONDNAME', $val, $params);
}
break;
case 'homeAddress':
if ($fields && (!isset($fields['LABEL']) || isset($fields['LABEL']->Params['TYPE']) && !$this->_hasValEnum($fields['LABEL']->Params['TYPE']->ValEnum, 'HOME'))) {
break;
}
if ($version == '2.1') {
$vcard->setAttribute('LABEL', $val, array('HOME' => null));
} else {
$vcard->setAttribute('LABEL', $val, array('TYPE' => 'HOME'));
}
break;
case 'workAddress':
if ($fields && (!isset($fields['LABEL']) || isset($fields['LABEL']->Params['TYPE']) && !$this->_hasValEnum($fields['LABEL']->Params['TYPE']->ValEnum, 'WORK'))) {
break;
}
if ($version == '2.1') {
$vcard->setAttribute('LABEL', $val, array('WORK' => null));
} else {
$vcard->setAttribute('LABEL', $val, array('TYPE' => 'WORK'));
}
break;
case 'otherAddress':
if ($fields && !isset($fields['LABEL'])) {
break;
}
$vcard->setAttribute('LABEL', $val);
break;
case 'phone':
if ($fields && !isset($fields['TEL'])) {
break;
}
$vcard->setAttribute('TEL', $val);
break;
case 'homePhone':
if ($fields && (!isset($fields['TEL']) || isset($fields['TEL']->Params['TYPE']) && !$this->_hasValEnum($fields['TEL']->Params['TYPE']->ValEnum, 'HOME'))) {
break;
}
if ($version == '2.1') {
$vcard->setAttribute('TEL', $val, array('HOME' => null, 'VOICE' => null));
} else {
$vcard->setAttribute('TEL', $val, array('TYPE' => array('HOME', 'VOICE')));
}
break;
case 'workPhone':
//.........这里部分代码省略.........
示例8: readForm
/**
* Reads form/post data and updates this event's properties.
*
* @param Kronolith_Event|null $existing If this is an exception event
* this is taken as the base event.
* @since 4.2.6
*
*/
public function readForm(Kronolith_Event $existing = null)
{
global $prefs, $session;
// Event owner.
$targetcalendar = Horde_Util::getFormData('targetcalendar');
if (strpos($targetcalendar, '\\')) {
list(, $this->creator) = explode('\\', $targetcalendar, 2);
} elseif (!isset($this->_id)) {
$this->creator = $GLOBALS['registry']->getAuth();
}
// Basic fields.
$this->title = Horde_Util::getFormData('title', $this->title);
$this->description = Horde_Util::getFormData('description', $this->description);
$this->location = Horde_Util::getFormData('location', $this->location);
$this->timezone = Horde_Util::getFormData('timezone', $this->timezone);
$this->private = (bool) Horde_Util::getFormData('private');
// URL.
$url = Horde_Util::getFormData('eventurl', $this->url);
if (strlen($url)) {
// Analyze and re-construct.
$url = @parse_url($url);
if ($url) {
if (function_exists('http_build_url')) {
if (empty($url['path'])) {
$url['path'] = '/';
}
$url = http_build_url($url);
} else {
$new_url = '';
if (isset($url['scheme'])) {
$new_url .= $url['scheme'] . '://';
}
if (isset($url['user'])) {
$new_url .= $url['user'];
if (isset($url['pass'])) {
$new_url .= ':' . $url['pass'];
}
$new_url .= '@';
}
if (isset($url['host'])) {
// Convert IDN hosts to ASCII.
if (function_exists('idn_to_ascii')) {
$url['host'] = @idn_to_ascii($url['host']);
} elseif (Horde_Mime::is8bit($url['host'])) {
//throw new Kronolith_Exception(_("Invalid character in URL."));
$url['host'] = '';
}
$new_url .= $url['host'];
}
if (isset($url['path'])) {
$new_url .= $url['path'];
}
if (isset($url['query'])) {
$new_url .= '?' . $url['query'];
}
if (isset($url['fragment'])) {
$new_url .= '#' . $url['fragment'];
}
$url = $new_url;
}
}
}
$this->url = $url;
// Status.
$this->status = Horde_Util::getFormData('status', $this->status);
// Attendees.
$attendees = $session->get('kronolith', 'attendees', Horde_Session::TYPE_ARRAY);
if (!is_null($newattendees = Horde_Util::getFormData('attendees'))) {
$newattendees = Kronolith::parseAttendees(trim($newattendees));
foreach ($newattendees as $email => $attendee) {
if (!isset($attendees[$email])) {
$attendees[$email] = $attendee;
}
}
foreach (array_keys($attendees) as $email) {
if (!isset($newattendees[$email])) {
unset($attendees[$email]);
}
}
}
$this->attendees = $attendees;
// Event start.
$allDay = Horde_Util::getFormData('whole_day');
if ($start_date = Horde_Util::getFormData('start_date')) {
// From ajax interface.
$this->start = Kronolith::parseDate($start_date . ' ' . Horde_Util::getFormData('start_time'), true, $this->timezone);
if ($allDay) {
$this->start->hour = $this->start->min = $this->start->sec = 0;
}
} else {
// From traditional interface.
$start = Horde_Util::getFormData('start');
//.........这里部分代码省略.........
示例9: _scanStream
/**
* Scans a stream for the requested data.
*
* @param resource $fp A stream resource.
* @param string $type Either '8bit', 'binary', or 'preg'.
* @param mixed $data Any additional data needed to do the scan.
*
* @param boolean The result of the scan.
*/
protected function _scanStream($fp, $type, $data = null)
{
rewind($fp);
while (is_resource($fp) && !feof($fp)) {
$line = fread($fp, 8192);
switch ($type) {
case '8bit':
if (Horde_Mime::is8bit($line)) {
return true;
}
break;
case 'binary':
if (strpos($line, "") !== false) {
return true;
}
break;
case 'preg':
if (preg_match($data, $line)) {
return true;
}
break;
}
}
return false;
}
示例10: testIs8bit
/**
* @dataProvider is8bitProvider
*/
public function testIs8bit($data, $expected)
{
$this->assertEquals($expected, Horde_Mime::is8bit($data));
}
示例11: forwardMessageText
/**
* Returns the forward text for a message.
*
* @param IMP_Contents $contents An IMP_Contents object.
* @param array $opts Additional options:
* - format: (string) Force to this format.
* DEFAULT: Auto-determine.
*
* @return array An array with the following keys:
* - body: (string) The text of the body part.
* - charset: (string) The guessed charset to use for the forward.
* - format: (string) The format of the body message ('html', 'text').
*/
public function forwardMessageText($contents, array $opts = array())
{
$h = $contents->getHeader();
$from = strval($h['from']);
$msg_pre = "\n----- " . ($from ? sprintf(_("Forwarded message from %s"), $from) : _("Forwarded message")) . " -----\n" . $this->_getMsgHeaders($h) . "\n";
$msg_post = "\n\n----- " . _("End forwarded message") . " -----\n";
list($compose_html, $force_html) = $this->_msgTextFormat($opts, 'forward_format');
$msg_text = $this->_getMessageText($contents, array('html' => $compose_html));
if (!empty($msg_text) && ($msg_text['mode'] == 'html' || $force_html)) {
$msg = $this->text2html($msg_pre) . ($msg_text['mode'] == 'text' ? $this->text2html($msg_text['text']) : $msg_text['text']) . $this->text2html($msg_post);
$format = 'html';
} else {
$msg = $msg_pre . $msg_text['text'] . $msg_post;
$format = 'text';
}
// Bug #10148: Message text might be us-ascii, but forward headers may
// contain 8-bit characters.
if ($msg_text['charset'] == 'us-ascii' && (Horde_Mime::is8bit($msg_pre) || Horde_Mime::is8bit($msg_post))) {
$msg_text['charset'] = 'UTF-8';
}
return array('body' => $msg, 'charset' => $msg_text['charset'], 'format' => $format);
}
示例12: _upgradeMailboxPrefs
/**
* As of IMP 6, special mailboxes are stored in UTF-8, not UTF7-IMAP.
*/
protected function _upgradeMailboxPrefs()
{
global $injector, $prefs;
$special_mboxes = array('drafts_folder', 'spam_folder', 'trash_folder');
foreach ($special_mboxes as $val) {
if (!$prefs->isDefault($val)) {
$old_pref = strval(IMP_Mailbox::getPref($val));
if (!Horde_Mime::is8bit($old_pref)) {
$mbox = IMP_Mailbox::get(new Horde_Imap_Client_Mailbox($old_pref, true));
$prefs->setValue($val, $mbox->pref_to);
}
}
}
$imp_identity = $injector->getInstance('IMP_Identity');
foreach ($imp_identity->getAll('sent_mail_folder') as $key => $val) {
if (!is_null($val) && !Horde_Mime::is8bit($val)) {
$mbox = IMP_Mailbox::get(new Horde_Imap_Client_Mailbox($val, true));
$imp_identity->setValue(IMP_Mailbox::MBOX_SENT, $mbox, $key);
}
}
}