mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 00:42:54 +02:00
Merge branch 'wip-MDL-60390-master-full' of git://github.com/marinaglancy/moodle
This commit is contained in:
commit
e93112a7ca
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* The Horde_Array:: class provides various methods for array manipulation.
|
||||
*
|
||||
* Copyright 2003-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2003-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
@ -28,7 +28,7 @@ class Horde_Array
|
||||
* 1 = descending
|
||||
* @param boolean $assoc Keep key value association?
|
||||
*/
|
||||
static public function arraySort(array &$array, $key = null, $dir = 0,
|
||||
public static function arraySort(array &$array, $key = null, $dir = 0,
|
||||
$assoc = true)
|
||||
{
|
||||
/* Return if the array is empty. */
|
||||
@ -64,7 +64,7 @@ class Horde_Array
|
||||
*
|
||||
* @return boolean True on sucess, false on error.
|
||||
*/
|
||||
static public function getArrayParts($field, &$base, &$keys)
|
||||
public static function getArrayParts($field, &$base, &$keys)
|
||||
{
|
||||
if (!preg_match('|([^\[]*)((\[[^\[\]]*\])+)|', $field, $matches)) {
|
||||
return false;
|
||||
@ -89,7 +89,7 @@ class Horde_Array
|
||||
*
|
||||
* @return mixed The final value of the key path.
|
||||
*/
|
||||
static public function getElement(&$array, array &$keys, $value = null)
|
||||
public static function getElement(&$array, array &$keys, $value = null)
|
||||
{
|
||||
if (count($keys)) {
|
||||
$key = array_shift($keys);
|
||||
@ -116,7 +116,7 @@ class Horde_Array
|
||||
*
|
||||
* @return array The extracted rectangle.
|
||||
*/
|
||||
static public function getRectangle(array $array, $row, $col, $height,
|
||||
public static function getRectangle(array $array, $row, $col, $height,
|
||||
$width)
|
||||
{
|
||||
$rec = array();
|
||||
@ -138,7 +138,7 @@ class Horde_Array
|
||||
*
|
||||
* @return array An array with keys the same as values.
|
||||
*/
|
||||
static public function valuesToKeys(array $array)
|
||||
public static function valuesToKeys(array $array)
|
||||
{
|
||||
return $array
|
||||
? array_combine($array, $array)
|
||||
|
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Helper class for sorting arrays on arbitrary criteria for usort/uasort.
|
||||
*
|
||||
* Copyright 2003-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2003-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
|
@ -1,16 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2005-2008 Matthew Fonda <mfonda@php.net>
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2005-2008 Matthew Fonda
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
* @author Matthew Fonda <mfonda@php.net>
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -21,7 +21,7 @@
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2005-2008 Matthew Fonda
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
*
|
||||
|
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
*/
|
||||
@ -48,7 +48,7 @@ abstract class Horde_Crypt_Blowfish_Base
|
||||
*
|
||||
* @return boolean True if supported.
|
||||
*/
|
||||
static public function supported()
|
||||
public static function supported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
*/
|
||||
|
@ -2,16 +2,17 @@
|
||||
/**
|
||||
* Copyright 2005-2008 Matthew Fonda <mfonda@php.net>
|
||||
* Copyright 2008 Philippe Jausions <jausions@php.net>
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2005-2008 Matthew Fonda
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
* @author Matthew Fonda <mfonda@php.net>
|
||||
* @author Philippe Jausions <jausions@php.net>
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -22,7 +23,8 @@
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2005-2008 Matthew Fonda
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2008 Philippe Jausions
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
*/
|
||||
@ -37,9 +39,9 @@ class Horde_Crypt_Blowfish_Mcrypt extends Horde_Crypt_Blowfish_Base
|
||||
|
||||
/**
|
||||
*/
|
||||
static public function supported()
|
||||
public static function supported()
|
||||
{
|
||||
return extension_loaded('mcrypt');
|
||||
return PHP_VERSION_ID < 70100 && extension_loaded('mcrypt');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
*/
|
||||
@ -24,7 +24,7 @@ class Horde_Crypt_Blowfish_Openssl extends Horde_Crypt_Blowfish_Base
|
||||
{
|
||||
/**
|
||||
*/
|
||||
static public function supported()
|
||||
public static function supported()
|
||||
{
|
||||
return extension_loaded('openssl');
|
||||
}
|
||||
|
128
lib/horde/framework/Horde/Crypt/Blowfish/Pbkdf2.php
Normal file
128
lib/horde/framework/Horde/Crypt/Blowfish/Pbkdf2.php
Normal file
@ -0,0 +1,128 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2015-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
*/
|
||||
|
||||
/**
|
||||
* PBKDF2 (Password-Based Key Derivation Function 2) implementation (RFC
|
||||
* 2898; PKCS #5 v2.0).
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2015-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
* @link https://defuse.ca/php-pbkdf2.htm pbkdf2 code released to the
|
||||
* public domain.
|
||||
*/
|
||||
class Horde_Crypt_Blowfish_Pbkdf2
|
||||
{
|
||||
/**
|
||||
* Hash algorithm used to create key.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $hashAlgo;
|
||||
|
||||
/**
|
||||
* Number of iterations to use.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $iterations;
|
||||
|
||||
/**
|
||||
* Salt.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $salt;
|
||||
|
||||
/**
|
||||
* The derived key.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_key;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $pass The password.
|
||||
* @param string $key_length Length of the derived key (in bytes).
|
||||
* @param array $opts Additional options:
|
||||
* - algo: (string) Hash algorithm.
|
||||
* - i_count: (integer) Iteration count.
|
||||
* - salt: (string) The salt to use.
|
||||
*/
|
||||
public function __construct($pass, $key_length, array $opts = array())
|
||||
{
|
||||
$this->iterations = isset($opts['i_count'])
|
||||
? $opts['i_count']
|
||||
: 16384;
|
||||
|
||||
if (($key_length <= 0) || ($this->iterations <= 0)) {
|
||||
throw new InvalidArgumentException('Invalid arguments');
|
||||
}
|
||||
|
||||
$this->hashAlgo = isset($opts['algo'])
|
||||
? $opts['algo']
|
||||
: 'SHA256';
|
||||
|
||||
/* Nice to have, but salt does not need to be cryptographically
|
||||
* secure random value. */
|
||||
$this->salt = isset($opts['salt'])
|
||||
? $opts['salt']
|
||||
: (function_exists('openssl_random_pseudo_bytes')
|
||||
? openssl_random_pseudo_bytes($key_length)
|
||||
: substr(hash('sha512', new Horde_Support_Randomid(), true), 0, $key_length));
|
||||
|
||||
if (function_exists('hash_pbkdf2')) {
|
||||
$this->_key = hash_pbkdf2(
|
||||
$this->hashAlgo,
|
||||
$pass,
|
||||
$this->salt,
|
||||
$this->iterations,
|
||||
$key_length,
|
||||
true
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
$hash_length = strlen(hash($this->hashAlgo, '', true));
|
||||
$block_count = ceil($key_length / $hash_length);
|
||||
|
||||
$hash = '';
|
||||
for ($i = 1; $i <= $block_count; ++$i) {
|
||||
// $i encoded as 4 bytes, big endian.
|
||||
$last = $this->salt . pack('N', $i);
|
||||
for ($j = 0; $j < $this->iterations; $j++) {
|
||||
$last = hash_hmac($this->hashAlgo, $last, $pass, true);
|
||||
if ($j) {
|
||||
$xorsum ^= $last;
|
||||
} else {
|
||||
$xorsum = $last;
|
||||
}
|
||||
}
|
||||
$hash .= $xorsum;
|
||||
}
|
||||
|
||||
$this->_key = substr($hash, 0, $key_length);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->_key;
|
||||
}
|
||||
|
||||
}
|
@ -2,17 +2,17 @@
|
||||
/**
|
||||
* Copyright 2005-2008 Matthew Fonda <mfonda@php.net>
|
||||
* Copyright 2008 Philippe Jausions <jausions@php.net>
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2005-2008 Matthew Fonda
|
||||
* @copyright 2008 Philippe Jausions
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
* @author Matthew Fonda <mfonda@php.net>
|
||||
* @author Philippe Jausions <jausions@php.net>
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -24,7 +24,7 @@
|
||||
* @category Horde
|
||||
* @copyright 2005-2008 Matthew Fonda
|
||||
* @copyright 2008 Philippe Jausions
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
*/
|
||||
|
@ -1,16 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2005-2008 Matthew Fonda <mfonda@php.net>
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2005-2008 Matthew Fonda
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
* @author Matthew Fonda <mfonda@php.net>
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -20,7 +20,7 @@
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2005-2008 Matthew Fonda
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
*/
|
||||
|
@ -2,17 +2,17 @@
|
||||
/**
|
||||
* Copyright 2005-2008 Matthew Fonda <mfonda@php.net>
|
||||
* Copyright 2008 Philippe Jausions <jausions@php.net>
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2005-2008 Matthew Fonda
|
||||
* @copyright 2008 Philippe Jausions
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
* @author Matthew Fonda <mfonda@php.net>
|
||||
* @author Philippe Jausions <jausions@php.net>
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -24,7 +24,7 @@
|
||||
* @category Horde
|
||||
* @copyright 2005-2008 Matthew Fonda
|
||||
* @copyright 2008 Philippe Jausions
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
*/
|
||||
|
@ -2,17 +2,17 @@
|
||||
/**
|
||||
* Copyright 2005-2008 Matthew Fonda <mfonda@php.net>
|
||||
* Copyright 2008 Philippe Jausions <jausions@php.net>
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2005-2008 Matthew Fonda
|
||||
* @copyright 2008 Philippe Jausions
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
* @author Matthew Fonda <mfonda@php.net>
|
||||
* @author Philippe Jausions <jausions@php.net>
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -24,7 +24,7 @@
|
||||
* @category Horde
|
||||
* @copyright 2005-2008 Matthew Fonda
|
||||
* @copyright 2008 Philippe Jausions
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Crypt_Blowfish
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2010-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2010-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2010-2014 Horde LLC
|
||||
* @copyright 2010-2017 Horde LLC
|
||||
* @package Util
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2010-2014 Horde LLC
|
||||
* @copyright 2010-2017 Horde LLC
|
||||
* @package Util
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
*/
|
||||
@ -248,7 +248,7 @@ class Horde_Domhtml implements Iterator
|
||||
*/
|
||||
protected function _loadHTML($html)
|
||||
{
|
||||
if (PHP_MINOR_VERSION >= 4) {
|
||||
if (version_compare(PHP_VERSION, '5.4', '>=')) {
|
||||
$mask = defined('LIBXML_PARSEHUGE')
|
||||
? LIBXML_PARSEHUGE
|
||||
: 0;
|
||||
|
@ -1,16 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Horde base exception class.
|
||||
*
|
||||
* Copyright 2008-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2008-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @author
|
||||
* @category Horde
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL-2.1
|
||||
* @package Exception
|
||||
*/
|
||||
|
||||
/**
|
||||
* Horde base exception class.
|
||||
*
|
||||
* @author
|
||||
* @category Horde
|
||||
* @copyright 2008-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL-2.1
|
||||
* @package Exception
|
||||
*/
|
||||
class Horde_Exception extends Exception
|
||||
{
|
||||
/**
|
||||
|
@ -1,16 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Horde exception class that accepts output of error_get_last() as $code and
|
||||
* mask itself as that error.
|
||||
*
|
||||
* Copyright 2008-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2008-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @author
|
||||
* @category Horde
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL
|
||||
* @package Exception
|
||||
*/
|
||||
|
||||
/**
|
||||
* Horde exception class that accepts output of error_get_last() as $code and
|
||||
* mask itself as that error.
|
||||
*
|
||||
* @author
|
||||
* @category Horde
|
||||
* @copyright 2008-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL
|
||||
* @package Exception
|
||||
*/
|
||||
class Horde_Exception_LastError extends Horde_Exception
|
||||
{
|
||||
/**
|
||||
|
@ -1,15 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception thrown if an object wasn't found.
|
||||
*
|
||||
* Copyright 2010-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2010-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @author
|
||||
* @category Horde
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL
|
||||
* @package Exception
|
||||
*/
|
||||
|
||||
/**
|
||||
* Exception thrown if an object wasn't found.
|
||||
*
|
||||
* @author
|
||||
* @category Horde
|
||||
* @copyright 2010-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL
|
||||
* @package Exception
|
||||
*/
|
||||
class Horde_Exception_NotFound extends Horde_Exception
|
||||
{
|
||||
/**
|
||||
|
@ -1,15 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Horde exception class that converts PEAR errors to exceptions.
|
||||
*
|
||||
* Copyright 2008-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2008-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @author
|
||||
* @category Horde
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL
|
||||
* @package Exception
|
||||
*/
|
||||
|
||||
/**
|
||||
* Horde exception class that converts PEAR errors to exceptions.
|
||||
*
|
||||
* @author
|
||||
* @category Horde
|
||||
* @copyright 2008-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL
|
||||
* @package Exception
|
||||
*/
|
||||
class Horde_Exception_Pear extends Horde_Exception
|
||||
{
|
||||
/**
|
||||
@ -17,7 +27,7 @@ class Horde_Exception_Pear extends Horde_Exception
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
static protected $_class = __CLASS__;
|
||||
protected static $_class = __CLASS__;
|
||||
|
||||
/**
|
||||
* Exception constructor.
|
||||
@ -73,9 +83,9 @@ class Horde_Exception_Pear extends Horde_Exception
|
||||
*
|
||||
* @throws Horde_Exception_Pear In case the result was a PEAR_Error.
|
||||
*/
|
||||
static public function catchError($result)
|
||||
public static function catchError($result)
|
||||
{
|
||||
if ($result instanceOf PEAR_Error) {
|
||||
if ($result instanceof PEAR_Error) {
|
||||
throw new self::$_class($result);
|
||||
}
|
||||
return $result;
|
||||
|
@ -1,15 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception thrown if any access without sufficient permissions occured.
|
||||
*
|
||||
* Copyright 2010-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2010-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @author
|
||||
* @category Horde
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL
|
||||
* @package Exception
|
||||
*/
|
||||
|
||||
/**
|
||||
* Exception thrown if any access without sufficient permissions occured.
|
||||
*
|
||||
* @author
|
||||
* @category Horde
|
||||
* @copyright 2010-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL
|
||||
* @package Exception
|
||||
*/
|
||||
class Horde_Exception_PermissionDenied extends Horde_Exception
|
||||
{
|
||||
/**
|
||||
|
@ -1,50 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Exception
|
||||
*
|
||||
* Copyright 2010-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2010-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @author Jan Schneider <jan@horde.org>
|
||||
* @category Horde
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL
|
||||
* @package Exception
|
||||
*/
|
||||
|
||||
/**
|
||||
* Horde_Exception_Translation is the translation wrapper class for Horde_Exception.
|
||||
*
|
||||
* @author Jan Schneider <jan@horde.org>
|
||||
* @package Exception
|
||||
* @author Jan Schneider <jan@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2010-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL
|
||||
* @package Exception
|
||||
*/
|
||||
class Horde_Exception_Translation extends Horde_Translation
|
||||
class Horde_Exception_Translation extends Horde_Translation_Autodetect
|
||||
{
|
||||
/**
|
||||
* Returns the translation of a message.
|
||||
* The translation domain
|
||||
*
|
||||
* @var string $message The string to translate.
|
||||
*
|
||||
* @return string The string translation, or the original string if no
|
||||
* translation exists.
|
||||
* @var string
|
||||
*/
|
||||
static public function t($message)
|
||||
{
|
||||
self::$_domain = 'Horde_Exception';
|
||||
self::$_directory = '@data_dir@' == '@'.'data_dir'.'@' ? __DIR__ . '/../../../locale' : '@data_dir@/Horde_Exception/locale';
|
||||
return parent::t($message);
|
||||
}
|
||||
protected static $_domain = 'Horde_Exception';
|
||||
|
||||
/**
|
||||
* Returns the plural translation of a message.
|
||||
* The absolute PEAR path to the translations for the default gettext handler.
|
||||
*
|
||||
* @param string $singular The singular version to translate.
|
||||
* @param string $plural The plural version to translate.
|
||||
* @param integer $number The number that determines singular vs. plural.
|
||||
*
|
||||
* @return string The string translation, or the original string if no
|
||||
* translation exists.
|
||||
* @var string
|
||||
*/
|
||||
static public function ngettext($singular, $plural, $number)
|
||||
{
|
||||
self::$_domain = 'Horde_Exception';
|
||||
self::$_directory = '@data_dir@' == '@'.'data_dir'.'@' ? __DIR__ . '/../../../locale' : '@data_dir@/Horde_Exception/locale';
|
||||
return parent::ngettext($singular, $plural, $number);
|
||||
}
|
||||
protected static $_pearDirectory = '@data_dir@';
|
||||
}
|
||||
|
@ -1,16 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Horde exception class that can wrap and set its details from PEAR_Error,
|
||||
* Exception, and other objects with similar interfaces.
|
||||
*
|
||||
* Copyright 2008-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2008-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @author
|
||||
* @category Horde
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL
|
||||
* @package Exception
|
||||
*/
|
||||
|
||||
/**
|
||||
* Horde exception class that can wrap and set its details from PEAR_Error,
|
||||
* Exception, and other objects with similar interfaces.
|
||||
*
|
||||
* @author
|
||||
* @category Horde
|
||||
* @copyright 2008-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL
|
||||
* @package Exception
|
||||
*/
|
||||
class Horde_Exception_Wrapped extends Horde_Exception
|
||||
{
|
||||
/**
|
||||
|
169
lib/horde/framework/Horde/Idna.php
Normal file
169
lib/horde/framework/Horde/Idna.php
Normal file
@ -0,0 +1,169 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (BSD). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/bsd.
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @license http://www.horde.org/licenses/bsd BSD
|
||||
* @package Idna
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provide normalized encoding/decoding support for IDNA strings.
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/bsd BSD
|
||||
* @package Idna
|
||||
*/
|
||||
class Horde_Idna
|
||||
{
|
||||
/**
|
||||
* The backend to use.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected static $_backend;
|
||||
|
||||
/**
|
||||
* @throws Horde_Idna_Exception
|
||||
*/
|
||||
public static function encode($data)
|
||||
{
|
||||
switch ($backend = static::_getBackend()) {
|
||||
case 'INTL':
|
||||
return idn_to_ascii($data);
|
||||
|
||||
case 'INTL_UTS46':
|
||||
$result = idn_to_ascii($data, 0, INTL_IDNA_VARIANT_UTS46, $info);
|
||||
self::_checkForError($info);
|
||||
return $result;
|
||||
|
||||
default:
|
||||
return $backend->encode($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Horde_Idna_Exception
|
||||
*/
|
||||
public static function decode($data)
|
||||
{
|
||||
switch ($backend = static::_getBackend()) {
|
||||
case 'INTL':
|
||||
case 'INTL_UTS46':
|
||||
$parts = explode('.', $data);
|
||||
foreach ($parts as &$part) {
|
||||
if (strpos($part, 'xn--') === 0) {
|
||||
switch ($backend) {
|
||||
case 'INTL':
|
||||
$part = idn_to_utf8($part);
|
||||
break;
|
||||
|
||||
case 'INTL_UTS46':
|
||||
$part = idn_to_utf8($part, 0, INTL_IDNA_VARIANT_UTS46, $info);
|
||||
self::_checkForError($info);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return implode('.', $parts);
|
||||
|
||||
default:
|
||||
return $backend->decode($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the $idna_info parameter of idn_to_ascii() or idn_to_utf8()
|
||||
* contains errors.
|
||||
*
|
||||
* @param array $info Fourth parameter to idn_to_ascii() or idn_to_utf8().
|
||||
*
|
||||
* @throws Horde_Idna_Exception
|
||||
*/
|
||||
protected static function _checkForError($info)
|
||||
{
|
||||
switch (true) {
|
||||
case $info['errors'] & IDNA_ERROR_EMPTY_LABEL:
|
||||
throw new Horde_Idna_Exception(Horde_Idna_Translation::t(
|
||||
"Domain name is empty"
|
||||
));
|
||||
case $info['errors'] & IDNA_ERROR_LABEL_TOO_LONG:
|
||||
case $info['errors'] & IDNA_ERROR_DOMAIN_NAME_TOO_LONG:
|
||||
throw new Horde_Idna_Exception(Horde_Idna_Translation::t(
|
||||
"Domain name is too long"
|
||||
));
|
||||
case $info['errors'] & IDNA_ERROR_LEADING_HYPHEN:
|
||||
throw new Horde_Idna_Exception(Horde_Idna_Translation::t(
|
||||
"Starts with a hyphen"
|
||||
));
|
||||
case $info['errors'] & IDNA_ERROR_TRAILING_HYPHEN:
|
||||
throw new Horde_Idna_Exception(Horde_Idna_Translation::t(
|
||||
"Ends with a hyphen"
|
||||
));
|
||||
case $info['errors'] & IDNA_ERROR_HYPHEN_3_4:
|
||||
throw new Horde_Idna_Exception(Horde_Idna_Translation::t(
|
||||
"Contains hyphen in the third and fourth positions"
|
||||
));
|
||||
case $info['errors'] & IDNA_ERROR_LEADING_COMBINING_MARK:
|
||||
throw new Horde_Idna_Exception(Horde_Idna_Translation::t(
|
||||
"Starts with a combining mark"
|
||||
));
|
||||
case $info['errors'] & IDNA_ERROR_DISALLOWED:
|
||||
throw new Horde_Idna_Exception(Horde_Idna_Translation::t(
|
||||
"Contains disallowed characters"
|
||||
));
|
||||
case $info['errors'] & IDNA_ERROR_PUNYCODE:
|
||||
throw new Horde_Idna_Exception(Horde_Idna_Translation::t(
|
||||
"Starts with \"xn--\" but does not contain valid Punycode"
|
||||
));
|
||||
case $info['errors'] & IDNA_ERROR_LABEL_HAS_DOT:
|
||||
throw new Horde_Idna_Exception(Horde_Idna_Translation::t(
|
||||
"Contains a dot"
|
||||
));
|
||||
case $info['errors'] & IDNA_ERROR_INVALID_ACE_LABEL:
|
||||
throw new Horde_Idna_Exception(Horde_Idna_Translation::t(
|
||||
"ACE label does not contain a valid label string"
|
||||
));
|
||||
case $info['errors'] & IDNA_ERROR_BIDI:
|
||||
throw new Horde_Idna_Exception(Horde_Idna_Translation::t(
|
||||
"Does not meet the IDNA BiDi requirements (for right-to-left characters)"
|
||||
));
|
||||
case $info['errors'] & IDNA_ERROR_CONTEXTJ:
|
||||
throw new Horde_Idna_Exception(Horde_Idna_Translation::t(
|
||||
"Does not meet the IDNA CONTEXTJ requirements"
|
||||
));
|
||||
case $info['errors']:
|
||||
throw new Horde_Idna_Exception(Horde_Idna_Translation::t(
|
||||
"Unknown error"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the IDNA backend.
|
||||
*
|
||||
* @return mixed IDNA backend (false if none available).
|
||||
*/
|
||||
protected static function _getBackend()
|
||||
{
|
||||
if (!isset(self::$_backend)) {
|
||||
if (extension_loaded('intl')) {
|
||||
/* Only available in PHP > 5.4.0 */
|
||||
self::$_backend = defined('INTL_IDNA_VARIANT_UTS46')
|
||||
? 'INTL_UTS46'
|
||||
: 'INTL';
|
||||
} else {
|
||||
self::$_backend = new Horde_Idna_Punycode();
|
||||
}
|
||||
}
|
||||
|
||||
return self::$_backend;
|
||||
}
|
||||
|
||||
}
|
24
lib/horde/framework/Horde/Idna/Exception.php
Normal file
24
lib/horde/framework/Horde/Idna/Exception.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (BSD). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/bsd.
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @license http://www.horde.org/licenses/bsd BSD
|
||||
* @package Idna
|
||||
*/
|
||||
|
||||
/**
|
||||
* Exception class for the Horde_Idna package.
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/bsd BSD
|
||||
* @package Idna
|
||||
*/
|
||||
class Horde_Idna_Exception extends Horde_Exception
|
||||
{}
|
354
lib/horde/framework/Horde/Idna/Punycode.php
Normal file
354
lib/horde/framework/Horde/Idna/Punycode.php
Normal file
@ -0,0 +1,354 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 TrueServer B.V.
|
||||
* Copyright 2015-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (BSD). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/bsd.
|
||||
*
|
||||
* @author Renan Gonçalves <renan.saddam@gmail.com>
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @license http://www.horde.org/licenses/bsd BSD
|
||||
* @package Idna
|
||||
*/
|
||||
|
||||
/**
|
||||
* Punycode implementation as described in RFC 3492.
|
||||
*
|
||||
* Original code (v1.0.1; released under the MIT License):
|
||||
* https://github.com/true/php-punycode/
|
||||
*
|
||||
* @author Renan Gonçalves <renan.saddam@gmail.com>
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2014 TrueServer B.V.
|
||||
* @copyright 2015-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/bsd BSD
|
||||
* @package Idna
|
||||
* @link http://tools.ietf.org/html/rfc3492
|
||||
*/
|
||||
class Horde_Idna_Punycode
|
||||
{
|
||||
/**
|
||||
* Bootstring parameter values.
|
||||
*/
|
||||
const BASE = 36;
|
||||
const TMIN = 1;
|
||||
const TMAX = 26;
|
||||
const SKEW = 38;
|
||||
const DAMP = 700;
|
||||
const INITIAL_BIAS = 72;
|
||||
const INITIAL_N = 128;
|
||||
const PREFIX = 'xn--';
|
||||
const DELIMITER = '-';
|
||||
|
||||
/**
|
||||
* Encode table.
|
||||
*
|
||||
* @param array
|
||||
*/
|
||||
protected static $_encodeTable = array(
|
||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
|
||||
'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
|
||||
'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
);
|
||||
|
||||
/**
|
||||
* Decode table.
|
||||
*
|
||||
* @param array
|
||||
*/
|
||||
protected static $_decodeTable = array(
|
||||
'a' => 0, 'b' => 1, 'c' => 2, 'd' => 3, 'e' => 4, 'f' => 5,
|
||||
'g' => 6, 'h' => 7, 'i' => 8, 'j' => 9, 'k' => 10, 'l' => 11,
|
||||
'm' => 12, 'n' => 13, 'o' => 14, 'p' => 15, 'q' => 16, 'r' => 17,
|
||||
's' => 18, 't' => 19, 'u' => 20, 'v' => 21, 'w' => 22, 'x' => 23,
|
||||
'y' => 24, 'z' => 25, '0' => 26, '1' => 27, '2' => 28, '3' => 29,
|
||||
'4' => 30, '5' => 31, '6' => 32, '7' => 33, '8' => 34, '9' => 35
|
||||
);
|
||||
|
||||
/**
|
||||
* Encode a domain to its Punycode version.
|
||||
*
|
||||
* @param string $input Domain name in Unicde to be encoded.
|
||||
*
|
||||
* @return string Punycode representation in ASCII.
|
||||
*/
|
||||
public function encode($input)
|
||||
{
|
||||
$parts = explode('.', $input);
|
||||
|
||||
foreach ($parts as &$part) {
|
||||
$part = $this->_encodePart($part);
|
||||
}
|
||||
|
||||
return implode('.', $parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a part of a domain name, such as tld, to its Punycode version.
|
||||
*
|
||||
* @param string $input Part of a domain name.
|
||||
*
|
||||
* @return string Punycode representation of a domain part.
|
||||
*/
|
||||
protected function _encodePart($input)
|
||||
{
|
||||
$codePoints = $this->_codePoints($input);
|
||||
|
||||
$n = static::INITIAL_N;
|
||||
$bias = static::INITIAL_BIAS;
|
||||
$delta = 0;
|
||||
$h = $b = count($codePoints['basic']);
|
||||
|
||||
$output = '';
|
||||
foreach ($codePoints['basic'] as $code) {
|
||||
$output .= $this->_codePointToChar($code);
|
||||
}
|
||||
if ($input === $output) {
|
||||
return $output;
|
||||
}
|
||||
if ($b > 0) {
|
||||
$output .= static::DELIMITER;
|
||||
}
|
||||
|
||||
$codePoints['nonBasic'] = array_unique($codePoints['nonBasic']);
|
||||
sort($codePoints['nonBasic']);
|
||||
|
||||
$i = 0;
|
||||
$length = Horde_String::length($input, 'UTF-8');
|
||||
|
||||
while ($h < $length) {
|
||||
$m = $codePoints['nonBasic'][$i++];
|
||||
$delta = $delta + ($m - $n) * ($h + 1);
|
||||
$n = $m;
|
||||
|
||||
foreach ($codePoints['all'] as $c) {
|
||||
if (($c < $n) || ($c < static::INITIAL_N)) {
|
||||
++$delta;
|
||||
}
|
||||
|
||||
if ($c === $n) {
|
||||
$q = $delta;
|
||||
for ($k = static::BASE; ; $k += static::BASE) {
|
||||
$t = $this->_calculateThreshold($k, $bias);
|
||||
if ($q < $t) {
|
||||
break;
|
||||
}
|
||||
|
||||
$code = $t + (($q - $t) % (static::BASE - $t));
|
||||
$output .= static::$_encodeTable[$code];
|
||||
|
||||
$q = ($q - $t) / (static::BASE - $t);
|
||||
}
|
||||
|
||||
$output .= static::$_encodeTable[$q];
|
||||
$bias = $this->_adapt($delta, $h + 1, ($h === $b));
|
||||
$delta = 0;
|
||||
++$h;
|
||||
}
|
||||
}
|
||||
|
||||
++$delta;
|
||||
++$n;
|
||||
}
|
||||
|
||||
return static::PREFIX . $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a Punycode domain name to its Unicode counterpart.
|
||||
*
|
||||
* @param string $input Domain name in Punycode
|
||||
*
|
||||
* @return string Unicode domain name.
|
||||
*/
|
||||
public function decode($input)
|
||||
{
|
||||
$parts = explode('.', $input);
|
||||
|
||||
foreach ($parts as &$part) {
|
||||
if (strpos($part, static::PREFIX) === 0) {
|
||||
$part = $this->_decodePart(
|
||||
substr($part, strlen(static::PREFIX))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return implode('.', $parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a part of domain name, such as tld.
|
||||
*
|
||||
* @param string $input Part of a domain name.
|
||||
*
|
||||
* @return string Unicode domain part.
|
||||
*/
|
||||
protected function _decodePart($input)
|
||||
{
|
||||
$n = static::INITIAL_N;
|
||||
$i = 0;
|
||||
$bias = static::INITIAL_BIAS;
|
||||
$output = '';
|
||||
|
||||
$pos = strrpos($input, static::DELIMITER);
|
||||
if ($pos !== false) {
|
||||
$output = substr($input, 0, $pos++);
|
||||
} else {
|
||||
$pos = 0;
|
||||
}
|
||||
|
||||
$outputLength = strlen($output);
|
||||
$inputLength = strlen($input);
|
||||
|
||||
/* Punycode lookup is case-insensitive. */
|
||||
$input = Horde_String::lower($input);
|
||||
|
||||
while ($pos < $inputLength) {
|
||||
$oldi = $i;
|
||||
$w = 1;
|
||||
|
||||
for ($k = static::BASE; ; $k += static::BASE) {
|
||||
$digit = static::$_decodeTable[$input[$pos++]];
|
||||
$i = $i + ($digit * $w);
|
||||
$t = $this->_calculateThreshold($k, $bias);
|
||||
|
||||
if ($digit < $t) {
|
||||
break;
|
||||
}
|
||||
|
||||
$w = $w * (static::BASE - $t);
|
||||
}
|
||||
|
||||
$bias = $this->_adapt($i - $oldi, ++$outputLength, ($oldi === 0));
|
||||
$n = $n + (int) ($i / $outputLength);
|
||||
$i = $i % ($outputLength);
|
||||
|
||||
$output = Horde_String::substr($output, 0, $i, 'UTF-8') .
|
||||
$this->_codePointToChar($n) .
|
||||
Horde_String::substr($output, $i, $outputLength - 1, 'UTF-8');
|
||||
|
||||
++$i;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the bias threshold to fall between TMIN and TMAX.
|
||||
*
|
||||
* @param integer $k
|
||||
* @param integer $bias
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
protected function _calculateThreshold($k, $bias)
|
||||
{
|
||||
if ($k <= ($bias + static::TMIN)) {
|
||||
return static::TMIN;
|
||||
} elseif ($k >= ($bias + static::TMAX)) {
|
||||
return static::TMAX;
|
||||
}
|
||||
return $k - $bias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bias adaptation.
|
||||
*
|
||||
* @param integer $delta
|
||||
* @param integer $numPoints
|
||||
* @param boolean $firstTime
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
protected function _adapt($delta, $numPoints, $firstTime)
|
||||
{
|
||||
$delta = (int) (
|
||||
($firstTime)
|
||||
? $delta / static::DAMP
|
||||
: $delta / 2
|
||||
);
|
||||
$delta += (int) ($delta / $numPoints);
|
||||
|
||||
$k = 0;
|
||||
while ($delta > ((static::BASE - static::TMIN) * static::TMAX) / 2) {
|
||||
$delta = (int) ($delta / (static::BASE - static::TMIN));
|
||||
$k = $k + static::BASE;
|
||||
}
|
||||
$k = $k + (int) (((static::BASE - static::TMIN + 1) * $delta) / ($delta + static::SKEW));
|
||||
|
||||
return $k;
|
||||
}
|
||||
|
||||
/**
|
||||
* List code points for a given input.
|
||||
*
|
||||
* @param string $input
|
||||
*
|
||||
* @return array Multi-dimension array with basic, non-basic and
|
||||
* aggregated code points.
|
||||
*/
|
||||
protected function _codePoints($input)
|
||||
{
|
||||
$codePoints = array(
|
||||
'all' => array(),
|
||||
'basic' => array(),
|
||||
'nonBasic' => array()
|
||||
);
|
||||
|
||||
$len = Horde_String::length($input, 'UTF-8');
|
||||
for ($i = 0; $i < $len; ++$i) {
|
||||
$char = Horde_String::substr($input, $i, 1, 'UTF-8');
|
||||
$code = $this->_charToCodePoint($char);
|
||||
if ($code < 128) {
|
||||
$codePoints['all'][] = $codePoints['basic'][] = $code;
|
||||
} else {
|
||||
$codePoints['all'][] = $codePoints['nonBasic'][] = $code;
|
||||
}
|
||||
}
|
||||
|
||||
return $codePoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a single or multi-byte character to its code point.
|
||||
*
|
||||
* @param string $char
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
protected function _charToCodePoint($char)
|
||||
{
|
||||
$code = ord($char[0]);
|
||||
if ($code < 128) {
|
||||
return $code;
|
||||
} elseif ($code < 224) {
|
||||
return (($code - 192) * 64) + (ord($char[1]) - 128);
|
||||
} elseif ($code < 240) {
|
||||
return (($code - 224) * 4096) + ((ord($char[1]) - 128) * 64) + (ord($char[2]) - 128);
|
||||
}
|
||||
return (($code - 240) * 262144) + ((ord($char[1]) - 128) * 4096) + ((ord($char[2]) - 128) * 64) + (ord($char[3]) - 128);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a code point to its single or multi-byte character
|
||||
*
|
||||
* @param integer $code
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _codePointToChar($code)
|
||||
{
|
||||
if ($code <= 0x7F) {
|
||||
return chr($code);
|
||||
} elseif ($code <= 0x7FF) {
|
||||
return chr(($code >> 6) + 192) . chr(($code & 63) + 128);
|
||||
} elseif ($code <= 0xFFFF) {
|
||||
return chr(($code >> 12) + 224) . chr((($code >> 6) & 63) + 128) . chr(($code & 63) + 128);
|
||||
}
|
||||
return chr(($code >> 18) + 240) . chr((($code >> 12) & 63) + 128) . chr((($code >> 6) & 63) + 128) . chr(($code & 63) + 128);
|
||||
}
|
||||
|
||||
}
|
40
lib/horde/framework/Horde/Idna/Translation.php
Normal file
40
lib/horde/framework/Horde/Idna/Translation.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (BSD). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/bsd.
|
||||
*
|
||||
* @author Jan Schneider <jan@horde.org>
|
||||
* @category Horde
|
||||
* @license http://www.horde.org/licenses/bsd BSD
|
||||
* @package Idna
|
||||
*/
|
||||
|
||||
/**
|
||||
* Horde_Idna_Translation is the translation wrapper class for
|
||||
* Horde_Idna.
|
||||
*
|
||||
* @author Jan Schneider <jan@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/bsd BSD
|
||||
* @package Idna
|
||||
* @since Horde_Idna 1.1.0
|
||||
*/
|
||||
class Horde_Idna_Translation extends Horde_Translation_Autodetect
|
||||
{
|
||||
/**
|
||||
* The translation domain
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $_domain = 'Horde_Idna';
|
||||
|
||||
/**
|
||||
* The absolute PEAR path to the translations for the default gettext handler.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $_pearDirectory = '@data_dir@';
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2008-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2008-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2008-2014 Horde LLC
|
||||
* @copyright 2008-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -17,7 +17,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2008-2014 Horde LLC
|
||||
* @copyright 2008-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -33,6 +33,8 @@ class Horde_Imap_Client
|
||||
const MBOX_SUBSCRIBED_EXISTS = 2;
|
||||
const MBOX_UNSUBSCRIBED = 3;
|
||||
const MBOX_ALL = 4;
|
||||
/* @since 2.23.0 */
|
||||
const MBOX_ALL_SUBSCRIBED = 5;
|
||||
|
||||
/* Constants for status() */
|
||||
const STATUS_MESSAGES = 1;
|
||||
@ -173,9 +175,11 @@ class Horde_Imap_Client
|
||||
/**
|
||||
* Capability dependencies.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static public $capability_deps = array(
|
||||
public static $capability_deps = array(
|
||||
// RFC 7162 [3.2]
|
||||
'QRESYNC' => array(
|
||||
// QRESYNC requires CONDSTORE, but the latter is implied and is
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2002-2003 Richard Heyes
|
||||
* Copyright 2011-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2011-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* This code is based on the original code contained in the PEAR Auth_SASL
|
||||
* package (v0.5.1):
|
||||
@ -40,7 +40,7 @@
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2002-2003 Richard Heyes
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -53,7 +53,7 @@
|
||||
* @author Richard Heyes <richard@php.net>
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @copyright 2002-2003 Richard Heyes
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
270
lib/horde/framework/Horde/Imap/Client/Auth/Scram.php
Normal file
270
lib/horde/framework/Horde/Imap/Client/Auth/Scram.php
Normal file
@ -0,0 +1,270 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2015-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2015-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides authentication via the SCRAM SASL mechanism (RFC 5802 [3]).
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2015-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
* @since 2.29.0
|
||||
*/
|
||||
class Horde_Imap_Client_Auth_Scram
|
||||
{
|
||||
/**
|
||||
* AuthMessage (RFC 5802 [3]).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_authmsg;
|
||||
|
||||
/**
|
||||
* Hash name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_hash;
|
||||
|
||||
/**
|
||||
* Number of Hi iterations (RFC 5802 [2]).
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $_iterations;
|
||||
|
||||
/**
|
||||
* Nonce.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_nonce;
|
||||
|
||||
/**
|
||||
* Password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_pass;
|
||||
|
||||
/**
|
||||
* Server salt.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_salt;
|
||||
|
||||
/**
|
||||
* Calculated server signature value.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_serversig;
|
||||
|
||||
/**
|
||||
* Username.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $user Username.
|
||||
* @param string $pass Password.
|
||||
* @param string $hash Hash name.
|
||||
*
|
||||
* @throws Horde_Imap_Client_Exception
|
||||
*/
|
||||
public function __construct($user, $pass, $hash = 'SHA1')
|
||||
{
|
||||
$error = false;
|
||||
|
||||
$this->_hash = $hash;
|
||||
|
||||
try {
|
||||
if (!class_exists('Horde_Stringprep') ||
|
||||
!class_exists('Horde_Crypt_Blowfish_Pbkdf2')) {
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
Horde_Stringprep::autoload();
|
||||
$saslprep = new Znerol\Component\Stringprep\Profile\SASLprep();
|
||||
|
||||
$this->_user = $saslprep->apply(
|
||||
$user,
|
||||
'UTF-8',
|
||||
Znerol\Component\Stringprep\Profile::MODE_QUERY
|
||||
);
|
||||
$this->_pass = $saslprep->apply(
|
||||
$pass,
|
||||
'UTF-8',
|
||||
Znerol\Component\Stringprep\Profile::MODE_STORE
|
||||
);
|
||||
} catch (Znerol\Component\Stringprep\ProfileException $e) {
|
||||
$error = true;
|
||||
} catch (Exception $e) {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
if ($error) {
|
||||
throw new Horde_Imap_Client_Exception(
|
||||
Horde_Imap_Client_Translation::r("Authentication failure."),
|
||||
Horde_Imap_Client_Exception::LOGIN_AUTHORIZATIONFAILED
|
||||
);
|
||||
}
|
||||
|
||||
/* Generate nonce. (Done here so this can be overwritten for
|
||||
* testing purposes.) */
|
||||
$this->_nonce = strval(new Horde_Support_Randomid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the initial client message.
|
||||
*
|
||||
* @return string Initial client message.
|
||||
*/
|
||||
public function getClientFirstMessage()
|
||||
{
|
||||
/* n: client doesn't support channel binding,
|
||||
* <empty>,
|
||||
* n=<user>: SASLprepped username with "," and "=" escaped,
|
||||
* r=<nonce>: Random nonce */
|
||||
$this->_authmsg = 'n=' . str_replace(
|
||||
array(',', '='),
|
||||
array('=2C', '=3D'),
|
||||
$this->_user
|
||||
) . ',r=' . $this->_nonce;
|
||||
|
||||
return 'n,,' . $this->_authmsg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the initial server message response.
|
||||
*
|
||||
* @param string $msg Initial server response.
|
||||
*
|
||||
* @return boolean False if authentication failed at this stage.
|
||||
*/
|
||||
public function parseServerFirstMessage($msg)
|
||||
{
|
||||
$i = $r = $s = false;
|
||||
|
||||
foreach (explode(',', $msg) as $val) {
|
||||
list($attr, $aval) = array_map('trim', explode('=', $val, 2));
|
||||
|
||||
switch ($attr) {
|
||||
case 'i':
|
||||
$this->_iterations = intval($aval);
|
||||
$i = true;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
/* Beginning of server-provided nonce MUST be the same as the
|
||||
* nonce we provided. */
|
||||
if (strpos($aval, $this->_nonce) !== 0) {
|
||||
return false;
|
||||
}
|
||||
$this->_nonce = $aval;
|
||||
$r = true;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
$this->_salt = base64_decode($aval);
|
||||
$s = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($i && $r && $s) {
|
||||
$this->_authmsg .= ',' . $msg;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the final client message.
|
||||
*
|
||||
* @return string Final client message.
|
||||
*/
|
||||
public function getClientFinalMessage()
|
||||
{
|
||||
$final_msg = 'c=biws,r=' . $this->_nonce;
|
||||
|
||||
/* Salted password. */
|
||||
$s_pass = strval(new Horde_Crypt_Blowfish_Pbkdf2(
|
||||
$this->_pass,
|
||||
strlen(hash($this->_hash, '', true)),
|
||||
array(
|
||||
'algo' => $this->_hash,
|
||||
'i_count' => $this->_iterations,
|
||||
'salt' => $this->_salt
|
||||
)
|
||||
));
|
||||
|
||||
/* Client key. */
|
||||
$c_key = hash_hmac($this->_hash, 'Client Key', $s_pass, true);
|
||||
|
||||
/* Stored key. */
|
||||
$s_key = hash($this->_hash, $c_key, true);
|
||||
|
||||
/* Client signature. */
|
||||
$auth_msg = $this->_authmsg . ',' . $final_msg;
|
||||
$c_sig = hash_hmac($this->_hash, $auth_msg, $s_key, true);
|
||||
|
||||
/* Proof. */
|
||||
$proof = $c_key ^ $c_sig;
|
||||
|
||||
/* Server signature. */
|
||||
$this->_serversig = hash_hmac(
|
||||
$this->_hash,
|
||||
$auth_msg,
|
||||
hash_hmac($this->_hash, 'Server Key', $s_pass, true),
|
||||
true
|
||||
);
|
||||
|
||||
/* c=biws: channel-binding ("biws" = base64('n,,')),
|
||||
* p=<proof>: base64 encoded ClientProof,
|
||||
* r=<nonce>: Nonce as returned from the server. */
|
||||
return $final_msg . ',p=' . base64_encode($proof);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the final server message response.
|
||||
*
|
||||
* @param string $msg Final server response.
|
||||
*
|
||||
* @return boolean False if authentication failed.
|
||||
*/
|
||||
public function parseServerFinalMessage($msg)
|
||||
{
|
||||
foreach (explode(',', $msg) as $val) {
|
||||
list($attr, $aval) = array_map('trim', explode('=', $val, 2));
|
||||
|
||||
switch ($attr) {
|
||||
case 'e':
|
||||
return false;
|
||||
|
||||
case 'v':
|
||||
return (base64_decode($aval) === $this->_serversig);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
102
lib/horde/framework/Horde/Imap/Client/Base/Alerts.php
Normal file
102
lib/horde/framework/Horde/Imap/Client/Base/Alerts.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handle IMAP alerts sent from the server.
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
* @since 2.24.0
|
||||
*/
|
||||
class Horde_Imap_Client_Base_Alerts
|
||||
implements SplSubject
|
||||
{
|
||||
/**
|
||||
* Alert data.
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $_alert;
|
||||
|
||||
/**
|
||||
* Observers.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_observers = array();
|
||||
|
||||
/**
|
||||
* Add an alert.
|
||||
*
|
||||
* @param string $alert The alert string.
|
||||
* @param string $type The alert type.
|
||||
*/
|
||||
public function add($alert, $type = null)
|
||||
{
|
||||
$this->_alert = new stdClass;
|
||||
$this->_alert->alert = $alert;
|
||||
if (!is_null($type)) {
|
||||
$this->_alert->type = $type;
|
||||
}
|
||||
|
||||
$this->notify();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last alert received.
|
||||
*
|
||||
* @return object Alert information. Object with these properties:
|
||||
* <pre>
|
||||
* - alert: (string) Alert string.
|
||||
* - type: (string) [OPTIONAL] Alert type.
|
||||
* </pre>
|
||||
*/
|
||||
public function getLast()
|
||||
{
|
||||
return $this->_alert;
|
||||
}
|
||||
|
||||
/* SplSubject methods. */
|
||||
|
||||
/**
|
||||
*/
|
||||
public function attach(SplObserver $observer)
|
||||
{
|
||||
$this->detach($observer);
|
||||
$this->_observers[] = $observer;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function detach(SplObserver $observer)
|
||||
{
|
||||
if (($key = array_search($observer, $this->_observers, true)) !== false) {
|
||||
unset($this->_observers[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification is triggered internally whenever the object's internal
|
||||
* data storage is altered.
|
||||
*/
|
||||
public function notify()
|
||||
{
|
||||
foreach ($this->_observers as $val) {
|
||||
$val->update($this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -21,7 +21,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @internal
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -21,7 +21,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @internal
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
@ -46,7 +46,7 @@ class Horde_Imap_Client_Base_Deprecated
|
||||
*
|
||||
* @throws Horde_Imap_Client_Exception
|
||||
*/
|
||||
static public function getCacheId($base_ob, $mailbox, $condstore,
|
||||
public static function getCacheId($base_ob, $mailbox, $condstore,
|
||||
array $addl = array())
|
||||
{
|
||||
$query = Horde_Imap_Client::STATUS_UIDVALIDITY | Horde_Imap_Client::STATUS_MESSAGES | Horde_Imap_Client::STATUS_UIDNEXT;
|
||||
@ -87,7 +87,7 @@ class Horde_Imap_Client_Base_Deprecated
|
||||
* - uidnext: (integer)
|
||||
* - uidvalidity: (integer) Always present
|
||||
*/
|
||||
static public function parseCacheId($id)
|
||||
public static function parseCacheId($id)
|
||||
{
|
||||
$data = array(
|
||||
'H' => 'highestmodseq',
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -21,7 +21,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @internal
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
@ -78,6 +78,11 @@ class Horde_Imap_Client_Base_Mailbox
|
||||
}
|
||||
|
||||
switch ($entry) {
|
||||
case Horde_Imap_Client::STATUS_FLAGS:
|
||||
case Horde_Imap_Client::STATUS_SYNCFLAGUIDS:
|
||||
case Horde_Imap_Client::STATUS_SYNCVANISHED:
|
||||
return array();
|
||||
|
||||
case Horde_Imap_Client::STATUS_FIRSTUNSEEN:
|
||||
/* If we know there are no messages in the current mailbox, we
|
||||
* know there are no unseen messages. */
|
||||
@ -89,13 +94,9 @@ class Horde_Imap_Client_Base_Mailbox
|
||||
case Horde_Imap_Client::STATUS_SYNCMODSEQ:
|
||||
return 0;
|
||||
|
||||
case Horde_Imap_Client::STATUS_SYNCFLAGUIDS:
|
||||
case Horde_Imap_Client::STATUS_SYNCVANISHED:
|
||||
return array();
|
||||
|
||||
case Horde_Imap_Client::STATUS_PERMFLAGS:
|
||||
/* If PERMFLAGS is not returned by server, must assume that all
|
||||
* flags can be change permanently (RFC 3501 [6.3.1]). */
|
||||
* flags can be changed permanently (RFC 3501 [6.3.1]). */
|
||||
$flags = isset($this->_status[Horde_Imap_Client::STATUS_FLAGS])
|
||||
? $this->_status[Horde_Imap_Client::STATUS_FLAGS]
|
||||
: array();
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2013-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2013-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2013-2014 Horde LLC
|
||||
* @copyright 2013-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2013-2014 Horde LLC
|
||||
* @copyright 2013-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
* @since 2.14.0
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2005-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2005-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2005-2014 Horde LLC
|
||||
* @copyright 2005-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2005-2014 Horde LLC
|
||||
* @copyright 2005-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2013-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2013-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2013-2014 Horde LLC
|
||||
* @copyright 2013-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2013-2014 Horde LLC
|
||||
* @copyright 2013-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2005-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2005-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2005-2014 Horde LLC
|
||||
* @copyright 2005-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -17,11 +17,12 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2005-2014 Horde LLC
|
||||
* @copyright 2005-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
class Horde_Imap_Client_Cache_Backend_Cache extends Horde_Imap_Client_Cache_Backend
|
||||
class Horde_Imap_Client_Cache_Backend_Cache
|
||||
extends Horde_Imap_Client_Cache_Backend
|
||||
{
|
||||
/** Cache structure version. */
|
||||
const VERSION = 3;
|
||||
@ -118,40 +119,43 @@ class Horde_Imap_Client_Cache_Backend_Cache extends Horde_Imap_Client_Cache_Back
|
||||
foreach ($this->_update as $mbox => $val) {
|
||||
$s = &$this->_slicemap[$mbox];
|
||||
|
||||
if (!empty($val['add'])) {
|
||||
if ($s['c'] <= $this->_params['slicesize']) {
|
||||
$val['slice'][] = $s['i'];
|
||||
$this->_loadSlice($mbox, $s['i']);
|
||||
}
|
||||
$val['slicemap'] = true;
|
||||
|
||||
foreach (array_keys(array_flip($val['add'])) as $uid) {
|
||||
if ($s['c']++ > $this->_params['slicesize']) {
|
||||
$s['c'] = 0;
|
||||
$val['slice'][] = ++$s['i'];
|
||||
try {
|
||||
if (!empty($val['add'])) {
|
||||
if ($s['c'] <= $this->_params['slicesize']) {
|
||||
$val['slice'][] = $s['i'];
|
||||
$this->_loadSlice($mbox, $s['i']);
|
||||
}
|
||||
$s['s'][$uid] = $s['i'];
|
||||
}
|
||||
}
|
||||
$val['slicemap'] = true;
|
||||
|
||||
if (!empty($val['slice'])) {
|
||||
$d = &$this->_data[$mbox];
|
||||
$val['slicemap'] = true;
|
||||
|
||||
foreach (array_keys(array_flip($val['slice'])) as $slice) {
|
||||
$data = array();
|
||||
foreach (array_keys($s['s'], $slice) as $uid) {
|
||||
$data[$uid] = is_array($d[$uid])
|
||||
? serialize($d[$uid])
|
||||
: $d[$uid];
|
||||
foreach (array_keys(array_flip($val['add'])) as $uid) {
|
||||
if ($s['c']++ > $this->_params['slicesize']) {
|
||||
$s['c'] = 0;
|
||||
$val['slice'][] = ++$s['i'];
|
||||
$this->_loadSlice($mbox, $s['i']);
|
||||
}
|
||||
$s['s'][$uid] = $s['i'];
|
||||
}
|
||||
$this->_cache->set($this->_getCid($mbox, $slice), serialize($data), $lifetime);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($val['slicemap'])) {
|
||||
$this->_cache->set($this->_getCid($mbox, 'slicemap'), serialize($s), $lifetime);
|
||||
if (!empty($val['slice'])) {
|
||||
$d = &$this->_data[$mbox];
|
||||
$val['slicemap'] = true;
|
||||
|
||||
foreach (array_keys(array_flip($val['slice'])) as $slice) {
|
||||
$data = array();
|
||||
foreach (array_keys($s['s'], $slice) as $uid) {
|
||||
$data[$uid] = is_array($d[$uid])
|
||||
? serialize($d[$uid])
|
||||
: $d[$uid];
|
||||
}
|
||||
$this->_cache->set($this->_getCid($mbox, $slice), serialize($data), $lifetime);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($val['slicemap'])) {
|
||||
$this->_cache->set($this->_getCid($mbox, 'slicemap'), serialize($s), $lifetime);
|
||||
}
|
||||
} catch (Horde_Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,7 +180,9 @@ class Horde_Imap_Client_Cache_Backend_Cache extends Horde_Imap_Client_Cache_Back
|
||||
|
||||
foreach (array_intersect($uids, array_keys($ptr)) as $val) {
|
||||
if (is_string($ptr[$val])) {
|
||||
$ptr[$val] = @unserialize($ptr[$val]);
|
||||
try {
|
||||
$ptr[$val] = @unserialize($ptr[$val]);
|
||||
} catch (Exception $e) {}
|
||||
}
|
||||
|
||||
$ret[$val] = (empty($fields) || empty($ptr[$val]))
|
||||
@ -217,7 +223,9 @@ class Horde_Imap_Client_Cache_Backend_Cache extends Horde_Imap_Client_Cache_Back
|
||||
foreach ($data as $k => $v) {
|
||||
if (isset($d[$k])) {
|
||||
if (is_string($d[$k])) {
|
||||
$d[$k] = @unserialize($d[$k]);
|
||||
try {
|
||||
$d[$k] = @unserialize($d[$k]);
|
||||
} catch (Exception $e) {}
|
||||
}
|
||||
$d[$k] = is_array($d[$k])
|
||||
? array_merge($d[$k], $v)
|
||||
@ -395,9 +403,13 @@ class Horde_Imap_Client_Cache_Backend_Cache extends Horde_Imap_Client_Cache_Back
|
||||
return;
|
||||
}
|
||||
|
||||
if ((($data = $this->_cache->get($cache_id, 0)) !== false) &&
|
||||
($data = @unserialize($data)) &&
|
||||
is_array($data)) {
|
||||
if (($data = $this->_cache->get($cache_id, 0)) !== false) {
|
||||
try {
|
||||
$data = @unserialize($data);
|
||||
} catch (Exception $e) {}
|
||||
}
|
||||
|
||||
if (($data !== false) && is_array($data)) {
|
||||
$this->_data[$mailbox] += $data;
|
||||
$this->_loaded[$cache_id] = true;
|
||||
} else {
|
||||
@ -425,10 +437,13 @@ class Horde_Imap_Client_Cache_Backend_Cache extends Horde_Imap_Client_Cache_Back
|
||||
protected function _loadSliceMap($mailbox, $uidvalid = null)
|
||||
{
|
||||
if (!isset($this->_slicemap[$mailbox]) &&
|
||||
(($data = $this->_cache->get($this->_getCid($mailbox, 'slicemap'), 0)) !== false) &&
|
||||
($slice = @unserialize($data)) &&
|
||||
is_array($slice)) {
|
||||
$this->_slicemap[$mailbox] = $slice;
|
||||
(($data = $this->_cache->get($this->_getCid($mailbox, 'slicemap'), 0)) !== false)) {
|
||||
try {
|
||||
if (($slice = @unserialize($data)) &&
|
||||
is_array($slice)) {
|
||||
$this->_slicemap[$mailbox] = $slice;
|
||||
}
|
||||
} catch (Exception $e) {}
|
||||
}
|
||||
|
||||
if (isset($this->_slicemap[$mailbox])) {
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2013-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2013-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2013-2014 Horde LLC
|
||||
* @copyright 2013-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -17,11 +17,12 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2013-2014 Horde LLC
|
||||
* @copyright 2013-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
class Horde_Imap_Client_Cache_Backend_Db extends Horde_Imap_Client_Cache_Backend
|
||||
class Horde_Imap_Client_Cache_Backend_Db
|
||||
extends Horde_Imap_Client_Cache_Backend
|
||||
{
|
||||
/** SQL table names. */
|
||||
const BASE_TABLE = 'horde_imap_client_data';
|
||||
@ -84,9 +85,11 @@ class Horde_Imap_Client_Cache_Backend_Db extends Horde_Imap_Client_Cache_Backend
|
||||
$res = $this->_db->select($query[0], $query[1]);
|
||||
|
||||
foreach ($res as $row) {
|
||||
$out[$row['msguid']] = @unserialize($compress->decompress(
|
||||
$columns['data']->binaryToString($row['data'])
|
||||
));
|
||||
try {
|
||||
$out[$row['msguid']] = @unserialize($compress->decompress(
|
||||
$columns['data']->binaryToString($row['data'])
|
||||
));
|
||||
} catch (Exception $e) {}
|
||||
}
|
||||
} catch (Horde_Db_Exception $e) {}
|
||||
|
||||
@ -126,24 +129,24 @@ class Horde_Imap_Client_Cache_Backend_Db extends Horde_Imap_Client_Cache_Backend
|
||||
if (isset($res[$key])) {
|
||||
try {
|
||||
/* Update */
|
||||
$this->_db->update(
|
||||
sprintf('UPDATE %s SET data = ? WHERE messageid = ? AND msguid = ?', self::MSG_TABLE),
|
||||
$this->_db->updateBlob(
|
||||
self::MSG_TABLE,
|
||||
array('data' => new Horde_Db_Value_Binary($compress->compress(serialize(array_merge($res[$key], $val))))),
|
||||
array(
|
||||
new Horde_Db_Value_Binary($compress->compress(serialize(array_merge($res[$key], $val)))),
|
||||
$uid,
|
||||
strval($key)
|
||||
'messageid = ? AND msguid = ?',
|
||||
array($uid, strval($key))
|
||||
)
|
||||
);
|
||||
} catch (Horde_Db_Exception $e) {}
|
||||
} else {
|
||||
/* Insert */
|
||||
try {
|
||||
$this->_db->insert(
|
||||
sprintf('INSERT INTO %s (data, msguid, messageid) VALUES (?, ?, ?)', self::MSG_TABLE),
|
||||
$this->_db->insertBlob(
|
||||
self::MSG_TABLE,
|
||||
array(
|
||||
new Horde_Db_Value_Binary($compress->compress(serialize($val))),
|
||||
strval($key),
|
||||
$uid
|
||||
'data' => new Horde_Db_Value_Binary($compress->compress(serialize($val))),
|
||||
'msguid' => strval($key),
|
||||
'messageid' => $uid
|
||||
)
|
||||
);
|
||||
} catch (Horde_Db_Exception $e) {}
|
||||
@ -193,9 +196,11 @@ class Horde_Imap_Client_Cache_Backend_Db extends Horde_Imap_Client_Cache_Backend
|
||||
break;
|
||||
|
||||
default:
|
||||
$res[$key] = @unserialize(
|
||||
$columns['data']->binaryToString($val)
|
||||
);
|
||||
try {
|
||||
$res[$key] = @unserialize(
|
||||
$columns['data']->binaryToString($val)
|
||||
);
|
||||
} catch (Exception $e) {}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -236,23 +241,18 @@ class Horde_Imap_Client_Cache_Backend_Db extends Horde_Imap_Client_Cache_Backend
|
||||
if (in_array($key, $fields)) {
|
||||
/* Update */
|
||||
try {
|
||||
$this->_db->update(
|
||||
sprintf(
|
||||
'UPDATE %s SET data = ? WHERE field = ? AND messageid = ?',
|
||||
self::MD_TABLE
|
||||
),
|
||||
array($val, $key, $uid)
|
||||
$this->_db->updateBlob(
|
||||
self::MD_TABLE,
|
||||
array('data' => $val),
|
||||
array('field = ? AND messageid = ?', array($key, $uid))
|
||||
);
|
||||
} catch (Horde_Db_Exception $e) {}
|
||||
} else {
|
||||
/* Insert */
|
||||
try {
|
||||
$this->_db->insert(
|
||||
sprintf(
|
||||
'INSERT INTO %s (data, field, messageid) VALUES (?, ?, ?)',
|
||||
self::MD_TABLE
|
||||
),
|
||||
array($val, $key, $uid)
|
||||
$this->_db->insertBlob(
|
||||
self::MD_TABLE,
|
||||
array('data' => $val, 'field' => $key, 'messageid' => $uid)
|
||||
);
|
||||
} catch (Horde_Db_Exception $e) {}
|
||||
}
|
||||
@ -317,7 +317,7 @@ class Horde_Imap_Client_Cache_Backend_Db extends Horde_Imap_Client_Cache_Backend
|
||||
}
|
||||
|
||||
$purge = time() - $lifetime;
|
||||
$sql = 'DELETE FROM %s WHERE messageid IN (SELECT messageid FROM %s WHERE modified < ?';
|
||||
$sql = 'DELETE FROM %s WHERE messageid IN (SELECT messageid FROM %s WHERE modified < ?)';
|
||||
|
||||
foreach (array(self::MD_TABLE, self::MSG_TABLE) as $val) {
|
||||
try {
|
||||
@ -325,7 +325,8 @@ class Horde_Imap_Client_Cache_Backend_Db extends Horde_Imap_Client_Cache_Backend
|
||||
sprintf($sql, $val, self::BASE_TABLE),
|
||||
array($purge)
|
||||
);
|
||||
} catch (Horde_Db_Exception $e) {}
|
||||
} catch (Horde_Db_Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
@ -333,7 +334,8 @@ class Horde_Imap_Client_Cache_Backend_Db extends Horde_Imap_Client_Cache_Backend
|
||||
sprintf('DELETE FROM %s WHERE modified < ?', self::BASE_TABLE),
|
||||
array($purge)
|
||||
);
|
||||
} catch (Horde_Db_Exception $e) {}
|
||||
} catch (Horde_Db_Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2013-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2013-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2013-2014 Horde LLC
|
||||
* @copyright 2013-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -17,7 +17,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2013-2014 Horde LLC
|
||||
* @copyright 2013-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
* @since 2.17.0
|
||||
@ -273,36 +273,39 @@ extends Horde_Imap_Client_Cache_Backend
|
||||
public function save()
|
||||
{
|
||||
foreach ($this->_update as $mbox => $val) {
|
||||
if (!empty($val['u'])) {
|
||||
$ptr = &$this->_data[$mbox];
|
||||
foreach ($this->_getMsgCids($mbox, array_keys($val['u'])) as $k2 => $v2) {
|
||||
try {
|
||||
$this->_hash->set(
|
||||
$v2,
|
||||
$this->_pack->pack($ptr[$k2]),
|
||||
array('expire' => $this->_params['lifetime'])
|
||||
);
|
||||
} catch (Horde_Pack_Exception $e) {
|
||||
$this->deleteMsgs($mbox, array($v2));
|
||||
$val['d'][] = $v2;
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (!empty($val['u'])) {
|
||||
$ptr = &$this->_data[$mbox];
|
||||
foreach ($this->_getMsgCids($mbox, array_keys($val['u'])) as $k2 => $v2) {
|
||||
try {
|
||||
$this->_hash->set(
|
||||
$v2,
|
||||
$this->_pack->pack($ptr[$k2]),
|
||||
array('expire' => $this->_params['lifetime'])
|
||||
);
|
||||
} catch (Horde_Pack_Exception $e) {
|
||||
$this->deleteMsgs($mbox, array($v2));
|
||||
$val['d'][] = $v2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($val['d'])) {
|
||||
$this->_hash->delete(array_values(
|
||||
$this->_getMsgCids($mbox, $val['d'])
|
||||
));
|
||||
}
|
||||
if (!empty($val['d'])) {
|
||||
$this->_hash->delete(array_values(
|
||||
$this->_getMsgCids($mbox, $val['d'])
|
||||
));
|
||||
}
|
||||
|
||||
if (!empty($val['m'])) {
|
||||
try {
|
||||
$this->_hash->set(
|
||||
$this->_getCid($mbox),
|
||||
$this->_pack->pack($this->_mbox[$mbox]),
|
||||
array('expire' => $this->_params['lifetime'])
|
||||
);
|
||||
} catch (Horde_Pack_Exception $e) {}
|
||||
if (!empty($val['m'])) {
|
||||
try {
|
||||
$this->_hash->set(
|
||||
$this->_getCid($mbox),
|
||||
$this->_pack->pack($this->_mbox[$mbox]),
|
||||
array('expire' => $this->_params['lifetime'])
|
||||
);
|
||||
} catch (Horde_Pack_Exception $e) {}
|
||||
}
|
||||
} catch (Horde_Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,27 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2013-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2013-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2013-2014 Horde LLC
|
||||
* @copyright 2013-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
||||
/**
|
||||
* A MongoDB database implementation for caching IMAP/POP data.
|
||||
*
|
||||
* Requires the Horde_Mongo class.
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2013-2014 Horde LLC
|
||||
* @copyright 2013-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
class Horde_Imap_Client_Cache_Backend_Mongo extends Horde_Imap_Client_Cache_Backend implements Horde_Mongo_Collection_Index
|
||||
class Horde_Imap_Client_Cache_Backend_Mongo
|
||||
extends Horde_Imap_Client_Cache_Backend
|
||||
implements Horde_Mongo_Collection_Index
|
||||
{
|
||||
/** Mongo collection names. */
|
||||
const BASE = 'horde_imap_client_cache_data';
|
||||
@ -119,13 +122,12 @@ class Horde_Imap_Client_Cache_Backend_Mongo extends Horde_Imap_Client_Cache_Back
|
||||
try {
|
||||
$cursor = $this->_db->selectCollection(self::MSG)->find(
|
||||
$query,
|
||||
array(
|
||||
self::MSG_DATA => true,
|
||||
self::MSG_MSGUID => true
|
||||
)
|
||||
array(self::MSG_DATA => true, self::MSG_MSGUID => true)
|
||||
);
|
||||
foreach ($cursor as $val) {
|
||||
$out[$val[self::MSG_MSGUID]] = $this->_value($val[self::MSG_DATA]);
|
||||
try {
|
||||
$out[$val[self::MSG_MSGUID]] = $this->_value($val[self::MSG_DATA]);
|
||||
} catch (Exception $e) {}
|
||||
}
|
||||
} catch (MongoException $e) {}
|
||||
|
||||
@ -149,10 +151,7 @@ class Horde_Imap_Client_Cache_Backend_Mongo extends Horde_Imap_Client_Cache_Back
|
||||
|
||||
try {
|
||||
$cursor = $this->_db->selectCollection(self::MSG)->find(
|
||||
$query,
|
||||
array(
|
||||
self::MSG_MSGUID => true
|
||||
)
|
||||
$query, array(self::MSG_MSGUID => true)
|
||||
);
|
||||
foreach ($cursor as $val) {
|
||||
$out[] = $val[self::MSG_MSGUID];
|
||||
@ -187,11 +186,12 @@ class Horde_Imap_Client_Cache_Backend_Mongo extends Horde_Imap_Client_Cache_Back
|
||||
self::MSG_UID => $uid
|
||||
));
|
||||
} else {
|
||||
$coll->insert(array(
|
||||
$doc = array(
|
||||
self::MSG_DATA => $this->_value($val),
|
||||
self::MSG_MSGUID => strval($key),
|
||||
self::MSG_UID => $uid
|
||||
));
|
||||
);
|
||||
$coll->insert($doc);
|
||||
}
|
||||
} catch (MongoException $e) {}
|
||||
}
|
||||
@ -231,13 +231,12 @@ class Horde_Imap_Client_Cache_Backend_Mongo extends Horde_Imap_Client_Cache_Back
|
||||
try {
|
||||
$cursor = $this->_db->selectCollection(self::MD)->find(
|
||||
$query,
|
||||
array(
|
||||
self::MD_DATA => true,
|
||||
self::MD_FIELD => true
|
||||
)
|
||||
array(self::MD_DATA => true, self::MD_FIELD => true)
|
||||
);
|
||||
foreach ($cursor as $val) {
|
||||
$out[$val[self::MD_FIELD]] = $this->_value($val[self::MD_DATA]);
|
||||
try {
|
||||
$out[$val[self::MD_FIELD]] = $this->_value($val[self::MD_DATA]);
|
||||
} catch (Exception $e) {}
|
||||
}
|
||||
|
||||
if (is_null($uidvalid) ||
|
||||
@ -287,7 +286,9 @@ class Horde_Imap_Client_Cache_Backend_Mongo extends Horde_Imap_Client_Cache_Back
|
||||
if (!empty($uids) && ($uid = $this->_getUid($mailbox))) {
|
||||
try {
|
||||
$this->_db->selectCollection(self::MSG)->remove(array(
|
||||
self::MSG_MSGUID => array('$in' => array_map('strval', $uids)),
|
||||
self::MSG_MSGUID => array(
|
||||
'$in' => array_map('strval', $uids)
|
||||
),
|
||||
self::MSG_UID => $uid
|
||||
));
|
||||
} catch (MongoException $e) {}
|
||||
@ -304,9 +305,8 @@ class Horde_Imap_Client_Cache_Backend_Mongo extends Horde_Imap_Client_Cache_Back
|
||||
|
||||
foreach (array(self::BASE, self::MD, self::MSG) as $val) {
|
||||
try {
|
||||
$this->_db->selectCollection($val)->remove(array(
|
||||
'uid' => $uid
|
||||
));
|
||||
$this->_db->selectCollection($val)
|
||||
->remove(array('uid' => $uid));
|
||||
} catch (MongoException $e) {}
|
||||
}
|
||||
}
|
||||
@ -340,9 +340,8 @@ class Horde_Imap_Client_Cache_Backend_Mongo extends Horde_Imap_Client_Cache_Back
|
||||
|
||||
foreach (array(self::BASE, self::MD, self::MSG) as $val) {
|
||||
try {
|
||||
$this->_db->selectCollection($val)->remove(array(
|
||||
'uid' => array('$in' => $uids)
|
||||
));
|
||||
$this->_db->selectCollection($val)
|
||||
->remove(array('uid' => array('$in' => $uids)));
|
||||
} catch (MongoException $e) {}
|
||||
}
|
||||
}
|
||||
@ -381,12 +380,13 @@ class Horde_Imap_Client_Cache_Backend_Mongo extends Horde_Imap_Client_Cache_Back
|
||||
*/
|
||||
protected function _createUid($mailbox)
|
||||
{
|
||||
$this->_db->selectCollection(self::BASE)->insert(array(
|
||||
$doc = array(
|
||||
self::BASE_HOSTSPEC => $this->_params['hostspec'],
|
||||
self::BASE_MAILBOX => $mailbox,
|
||||
self::BASE_PORT => $this->_params['port'],
|
||||
self::BASE_USERNAME => $this->_params['username']
|
||||
));
|
||||
);
|
||||
$this->_db->selectCollection(self::BASE)->insert($doc);
|
||||
|
||||
return $this->_getUid($mailbox);
|
||||
}
|
||||
@ -408,7 +408,9 @@ class Horde_Imap_Client_Cache_Backend_Mongo extends Horde_Imap_Client_Cache_Back
|
||||
|
||||
return ($data instanceof MongoBinData)
|
||||
? @unserialize($compress->decompress($data->bin))
|
||||
: new MongoBinData($compress->compress(serialize($data)), MongoBinData::BYTE_ARRAY);
|
||||
: new MongoBinData(
|
||||
$compress->compress(serialize($data)), MongoBinData::BYTE_ARRAY
|
||||
);
|
||||
}
|
||||
|
||||
/* Horde_Mongo_Collection_Index methods. */
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2013-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2013-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2013-2014 Horde LLC
|
||||
* @copyright 2013-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,11 +16,12 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2013-2014 Horde LLC
|
||||
* @copyright 2013-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
class Horde_Imap_Client_Cache_Backend_Null extends Horde_Imap_Client_Cache_Backend
|
||||
class Horde_Imap_Client_Cache_Backend_Null
|
||||
extends Horde_Imap_Client_Cache_Backend
|
||||
{
|
||||
/**
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2011-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2011-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -78,12 +78,20 @@ class Horde_Imap_Client_Data_Acl extends Horde_Imap_Client_Data_AclCommon implem
|
||||
* to handle these rights when dealing with RFC 2086 servers since
|
||||
* we are abstracting out use of ACL_CREATE/ACL_DELETE to their
|
||||
* component RFC 4314 rights. */
|
||||
foreach ($this->_virtual as $key => $val) {
|
||||
foreach ($val as $right) {
|
||||
if ($this[$right]) {
|
||||
foreach (array_keys($this->_virtual) as $virtual) {
|
||||
unset($this[$virtual]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($this->_virtual as $key => $val) {
|
||||
if ($this[$key]) {
|
||||
unset($this[$key]);
|
||||
if (!$this[reset($val)]) {
|
||||
$this->_rights = array_unique(array_merge($this->_rights, $val));
|
||||
}
|
||||
$this->_rights = array_unique(array_merge($this->_rights, $val));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2011-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2011-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2011-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2011-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2011-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2011-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2008-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2008-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* getBaseSubject() code adapted from imap-base-subject.c (Dovecot 1.2)
|
||||
* Original code released under the LGPL-2.1
|
||||
@ -11,7 +11,7 @@
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2002-2008 Timo Sirainen
|
||||
* @copyright 2008-2014 Horde LLC
|
||||
* @copyright 2008-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -23,7 +23,7 @@
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2002-2008 Timo Sirainen
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -125,10 +125,8 @@ class Horde_Imap_Client_Data_BaseSubject
|
||||
|
||||
if (stripos($str, 're', $i) === 0) {
|
||||
$i += 2;
|
||||
} elseif (stripos($str, 'fwd', $i) === 0) {
|
||||
$i += 3;
|
||||
} elseif (stripos($str, 'fw', $i) === 0) {
|
||||
$i += 2;
|
||||
$i += (stripos($str, 'fwd', $i) === 0) ? 3 : 2;
|
||||
} else {
|
||||
return $ret;
|
||||
}
|
||||
|
214
lib/horde/framework/Horde/Imap/Client/Data/Capability.php
Normal file
214
lib/horde/framework/Horde/Imap/Client/Data/Capability.php
Normal file
@ -0,0 +1,214 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
||||
/**
|
||||
* Query the capabilities of a server.
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
* @since 2.24.0
|
||||
*/
|
||||
class Horde_Imap_Client_Data_Capability
|
||||
implements Serializable, SplSubject
|
||||
{
|
||||
/**
|
||||
* Capability data.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_data = array();
|
||||
|
||||
/**
|
||||
* Observers.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_observers = array();
|
||||
|
||||
/**
|
||||
* Add a capability (and optional parameters).
|
||||
*
|
||||
* @param string $capability The capability to add.
|
||||
* @param mixed $params A parameter (or array of parameters) to add.
|
||||
*/
|
||||
public function add($capability, $params = null)
|
||||
{
|
||||
$capability = Horde_String::upper($capability);
|
||||
|
||||
if (is_null($params)) {
|
||||
if (isset($this->_data[$capability])) {
|
||||
return;
|
||||
}
|
||||
$params = true;
|
||||
} else {
|
||||
if (!is_array($params)) {
|
||||
$params = array($params);
|
||||
}
|
||||
$params = array_map('Horde_String::upper', $params);
|
||||
|
||||
if (isset($this->_data[$capability]) &&
|
||||
is_array($this->_data[$capability])) {
|
||||
$params = array_merge($this->_data[$capability], $params);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_data[$capability] = $params;
|
||||
$this->notify();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a capability.
|
||||
*
|
||||
* @param string $capability The capability to remove.
|
||||
* @param string $params A parameter (or array of parameters) to
|
||||
* remove from the capability.
|
||||
*/
|
||||
public function remove($capability, $params = null)
|
||||
{
|
||||
$capability = Horde_String::upper($capability);
|
||||
|
||||
if (is_null($params)) {
|
||||
unset($this->_data[$capability]);
|
||||
} elseif (isset($this->_data[$capability])) {
|
||||
if (!is_array($params)) {
|
||||
$params = array($params);
|
||||
}
|
||||
$params = array_map('Horde_String::upper', $params);
|
||||
|
||||
$this->_data[$capability] = is_array($this->_data[$capability])
|
||||
? array_diff($this->_data[$capability], $params)
|
||||
: array();
|
||||
|
||||
if (empty($this->_data[$capability])) {
|
||||
unset($this->_data[$capability]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->notify();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the server supports the given capability.
|
||||
*
|
||||
* @param string $capability The capability string to query.
|
||||
* @param string $parameter If set, require the parameter to exist.
|
||||
*
|
||||
* @return boolean True if the capability (and parameter) exist.
|
||||
*/
|
||||
public function query($capability, $parameter = null)
|
||||
{
|
||||
$capability = Horde_String::upper($capability);
|
||||
|
||||
if (!isset($this->_data[$capability])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return is_null($parameter) ?:
|
||||
(is_array($this->_data[$capability]) &&
|
||||
in_array(Horde_String::upper($parameter), $this->_data[$capability]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of parameters for an extension.
|
||||
*
|
||||
* @param string $capability The capability string to query.
|
||||
*
|
||||
* @return array An array of parameters if the extension exists and
|
||||
* supports parameters. Otherwise, an empty array.
|
||||
*/
|
||||
public function getParams($capability)
|
||||
{
|
||||
return ($this->query($capability) && is_array($out = $this->_data[Horde_String::upper($capability)]))
|
||||
? $out
|
||||
: array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the extension enabled?
|
||||
*
|
||||
* @param string $capability The extension (+ parameter) to query. If
|
||||
* null, returns all enabled extensions.
|
||||
*
|
||||
* @return mixed If $capability is null, return all enabled extensions.
|
||||
* Otherwise, true if the extension (+ parameter) is
|
||||
* enabled.
|
||||
*/
|
||||
public function isEnabled($capability = null)
|
||||
{
|
||||
return is_null($capability)
|
||||
? array()
|
||||
: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw data.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @return array Capability data.
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return $this->_data;
|
||||
}
|
||||
|
||||
/* SplSubject methods. */
|
||||
|
||||
/**
|
||||
*/
|
||||
public function attach(SplObserver $observer)
|
||||
{
|
||||
$this->detach($observer);
|
||||
$this->_observers[] = $observer;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function detach(SplObserver $observer)
|
||||
{
|
||||
if (($key = array_search($observer, $this->_observers, true)) !== false) {
|
||||
unset($this->_observers[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification is triggered internally whenever the object's internal
|
||||
* data storage is altered.
|
||||
*/
|
||||
public function notify()
|
||||
{
|
||||
foreach ($this->_observers as $val) {
|
||||
$val->update($this);
|
||||
}
|
||||
}
|
||||
|
||||
/* Serializable methods. */
|
||||
|
||||
/**
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
return json_encode($this->_data);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function unserialize($data)
|
||||
{
|
||||
$this->_data = json_decode($data, true);
|
||||
}
|
||||
|
||||
}
|
117
lib/horde/framework/Horde/Imap/Client/Data/Capability/Imap.php
Normal file
117
lib/horde/framework/Horde/Imap/Client/Data/Capability/Imap.php
Normal file
@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
||||
/**
|
||||
* Query the capabilities of an IMAP server.
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
* @since 2.24.0
|
||||
*
|
||||
* @property-read integer $cmdlength Allowable command length (in octets).
|
||||
*/
|
||||
class Horde_Imap_Client_Data_Capability_Imap
|
||||
extends Horde_Imap_Client_Data_Capability
|
||||
{
|
||||
/**
|
||||
* The list of enabled extensions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_enabled = array();
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
switch ($name) {
|
||||
case 'cmdlength':
|
||||
/* RFC 2683 [3.2.1.5] originally recommended that lines should
|
||||
* be limited to "approximately 1000 octets". However, servers
|
||||
* should allow a command line of at least "8000 octets".
|
||||
* RFC 7162 [4] updates the recommendation to 8192 octets.
|
||||
* As a compromise, assume all modern IMAP servers handle
|
||||
* ~2000 octets and, if CONDSTORE/QRESYNC is supported, assume
|
||||
* they can handle ~8000 octets. (Don't need dependency support
|
||||
* checks here - the simple presence of CONDSTORE/QRESYNC is
|
||||
* enough to trigger.) */
|
||||
return (isset($this->_data['CONDSTORE']) || isset($this->_data['QRESYNC']))
|
||||
? 8000
|
||||
: 2000;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function query($capability, $parameter = null)
|
||||
{
|
||||
if (parent::query($capability, $parameter)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (Horde_String::upper($capability)) {
|
||||
case 'CONDSTORE':
|
||||
case 'ENABLE':
|
||||
/* RFC 7162 [3.2.3] - QRESYNC implies CONDSTORE and ENABLE. */
|
||||
return (is_null($parameter) && $this->query('QRESYNC'));
|
||||
|
||||
case 'UTF8':
|
||||
/* RFC 6855 [3] - UTF8=ONLY implies UTF8=ACCEPT. */
|
||||
return ((Horde_String::upper($parameter) === 'ACCEPT') &&
|
||||
$this->query('UTF8', 'ONLY'));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function isEnabled($capability = null)
|
||||
{
|
||||
return is_null($capability)
|
||||
? $this->_enabled
|
||||
: in_array(Horde_String::upper($capability), $this->_enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a capability as enabled/disabled.
|
||||
*
|
||||
* @param array $capability A capability (+ parameter).
|
||||
* @param boolean $enable If true, enables the capability.
|
||||
*/
|
||||
public function enable($capability, $enable = true)
|
||||
{
|
||||
$capability = Horde_String::upper($capability);
|
||||
$enabled = $this->isEnabled($capability);
|
||||
|
||||
if ($enable && !$enabled) {
|
||||
switch ($capability) {
|
||||
case 'QRESYNC':
|
||||
/* RFC 7162 [3.2.3] - Enabling QRESYNC also implies enabling
|
||||
* of CONDSTORE. */
|
||||
$this->enable('CONDSTORE');
|
||||
break;
|
||||
}
|
||||
|
||||
$this->_enabled[] = $capability;
|
||||
$this->notify();
|
||||
} elseif (!$enable && $enabled) {
|
||||
$this->_enabled = array_diff($this->_enabled, array($capability));
|
||||
$this->notify();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2011-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2011-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,13 +16,15 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*
|
||||
* @todo $date should return null if it doesn't exist.
|
||||
*
|
||||
* @property Horde_Mail_Rfc822_List $bcc Bcc address(es).
|
||||
* @property Horde_Mail_Rfc822_List $cc Cc address(es).
|
||||
* @property Horde_Imap_Client_DateTime $date IMAP internal date.
|
||||
* @property Horde_Imap_Client_DateTime $date Message date.
|
||||
* @property Horde_Mail_Rfc822_List $from From address(es).
|
||||
* @property string $in_reply_to Message-ID of the message replied to.
|
||||
* @property string $message_id Message-ID of the message.
|
||||
@ -33,8 +35,8 @@
|
||||
*/
|
||||
class Horde_Imap_Client_Data_Envelope implements Serializable
|
||||
{
|
||||
/** Serializable version. */
|
||||
const VERSION = 2;
|
||||
/* Serializable version. */
|
||||
const VERSION = 3;
|
||||
|
||||
/**
|
||||
* Data object.
|
||||
@ -62,18 +64,17 @@ class Horde_Imap_Client_Data_Envelope implements Serializable
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
switch ($name) {
|
||||
case 'reply_to':
|
||||
$name = 'reply-to';
|
||||
// Fall-through
|
||||
$name = $this->_normalizeProperty($name);
|
||||
|
||||
switch ($name) {
|
||||
case 'bcc':
|
||||
case 'cc':
|
||||
case 'from':
|
||||
case 'reply-to':
|
||||
case 'sender':
|
||||
case 'to':
|
||||
if (($ob = $this->_data->getOb($name)) !== null) {
|
||||
return $ob;
|
||||
if ($h = $this->_data[$name]) {
|
||||
return $h->getAddressList(true);
|
||||
}
|
||||
|
||||
if (in_array($name, array('sender', 'reply-to'))) {
|
||||
@ -82,16 +83,16 @@ class Horde_Imap_Client_Data_Envelope implements Serializable
|
||||
break;
|
||||
|
||||
case 'date':
|
||||
if (($val = $this->_data->getValue($name)) !== null) {
|
||||
return new Horde_Imap_Client_DateTime($val);
|
||||
if ($val = $this->_data['date']) {
|
||||
return new Horde_Imap_Client_DateTime($val->value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'in_reply_to':
|
||||
case 'message_id':
|
||||
case 'in-reply-to':
|
||||
case 'message-id':
|
||||
case 'subject':
|
||||
if (($val = $this->_data->getValue($name)) !== null) {
|
||||
return $val;
|
||||
if ($val = $this->_data[$name]) {
|
||||
return $val->value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -107,8 +108,8 @@ class Horde_Imap_Client_Data_Envelope implements Serializable
|
||||
case 'date':
|
||||
return new Horde_Imap_Client_DateTime();
|
||||
|
||||
case 'in_reply_to':
|
||||
case 'message_id':
|
||||
case 'in-reply-to':
|
||||
case 'message-id':
|
||||
case 'subject':
|
||||
return '';
|
||||
}
|
||||
@ -124,43 +125,39 @@ class Horde_Imap_Client_Data_Envelope implements Serializable
|
||||
return;
|
||||
}
|
||||
|
||||
$name = $this->_normalizeProperty($name);
|
||||
|
||||
switch ($name) {
|
||||
case 'bcc':
|
||||
case 'cc':
|
||||
case 'date':
|
||||
case 'from':
|
||||
case 'in_reply_to':
|
||||
case 'message_id':
|
||||
case 'reply_to':
|
||||
case 'in-reply-to':
|
||||
case 'message-id':
|
||||
case 'reply-to':
|
||||
case 'sender':
|
||||
case 'subject':
|
||||
case 'to':
|
||||
switch ($name) {
|
||||
case 'from':
|
||||
foreach (array('reply_to', 'sender') as $val) {
|
||||
if ($this->$val->match($value)) {
|
||||
$this->_data->removeHeader($val);
|
||||
}
|
||||
if ($this->reply_to->match($value)) {
|
||||
unset($this->_data['reply-to']);
|
||||
}
|
||||
if ($this->sender->match($value)) {
|
||||
unset($this->_data['sender']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'reply_to':
|
||||
case 'reply-to':
|
||||
case 'sender':
|
||||
if ($this->from->match($value)) {
|
||||
$this->_data->removeHeader($name);
|
||||
unset($this->_data[$name]);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Convert reply-to name. */
|
||||
if ($name == 'reply_to') {
|
||||
$name = 'reply-to';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$this->_data->addHeader($name, $value, array(
|
||||
'sanity_check' => true
|
||||
));
|
||||
$this->_data->addHeader($name, $value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -169,20 +166,37 @@ class Horde_Imap_Client_Data_Envelope implements Serializable
|
||||
*/
|
||||
public function __isset($name)
|
||||
{
|
||||
switch ($name) {
|
||||
case 'reply_to':
|
||||
$name = 'reply-to';
|
||||
// Fall-through
|
||||
$name = $this->_normalizeProperty($name);
|
||||
|
||||
switch ($name) {
|
||||
case 'reply-to':
|
||||
case 'sender':
|
||||
if ($this->_data->getValue($name) !== null) {
|
||||
if (isset($this->_data[$name])) {
|
||||
return true;
|
||||
}
|
||||
$name = 'from';
|
||||
break;
|
||||
}
|
||||
|
||||
return ($this->_data->getValue($name) !== null);
|
||||
return isset($this->_data[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
protected function _normalizeProperty($name)
|
||||
{
|
||||
switch ($name) {
|
||||
case 'in_reply_to':
|
||||
return 'in-reply-to';
|
||||
|
||||
case 'message_id':
|
||||
return 'message-id';
|
||||
|
||||
case 'reply_to':
|
||||
return 'reply-to';
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/* Serializable methods. */
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2011-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2011-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -17,7 +17,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -34,6 +34,13 @@ class Horde_Imap_Client_Data_Fetch
|
||||
*/
|
||||
protected $_data = array();
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$this->_data = unserialize(serialize($this->_data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the full message property.
|
||||
*
|
||||
@ -42,7 +49,7 @@ class Horde_Imap_Client_Data_Fetch
|
||||
*/
|
||||
public function setFullMsg($msg)
|
||||
{
|
||||
$this->_data[Horde_Imap_Client::FETCH_FULLMSG] = $msg;
|
||||
$this->_data[Horde_Imap_Client::FETCH_FULLMSG] = $this->_setMixed($msg);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,7 +61,12 @@ class Horde_Imap_Client_Data_Fetch
|
||||
*/
|
||||
public function getFullMsg($stream = false)
|
||||
{
|
||||
return $this->_msgText($stream, isset($this->_data[Horde_Imap_Client::FETCH_FULLMSG]) ? $this->_data[Horde_Imap_Client::FETCH_FULLMSG] : null);
|
||||
return $this->_msgText(
|
||||
$stream,
|
||||
isset($this->_data[Horde_Imap_Client::FETCH_FULLMSG])
|
||||
? $this->_data[Horde_Imap_Client::FETCH_FULLMSG]
|
||||
: null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,6 +100,9 @@ class Horde_Imap_Client_Data_Fetch
|
||||
*/
|
||||
public function setHeaders($label, $data)
|
||||
{
|
||||
if ($data instanceof Horde_Stream) {
|
||||
$data = $data->stream;
|
||||
}
|
||||
$this->_data[Horde_Imap_Client::FETCH_HEADERS][$label] = $data;
|
||||
}
|
||||
|
||||
@ -104,18 +119,23 @@ class Horde_Imap_Client_Data_Fetch
|
||||
*/
|
||||
public function getHeaders($label, $format = 0)
|
||||
{
|
||||
return $this->_getHeaders($label, $format, Horde_Imap_Client::FETCH_HEADERS);
|
||||
return $this->_getHeaders(
|
||||
$label,
|
||||
$format,
|
||||
Horde_Imap_Client::FETCH_HEADERS
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a header text entry.
|
||||
*
|
||||
* @param string $id The MIME ID.
|
||||
* @param string $text The header text.
|
||||
* @param string $id The MIME ID.
|
||||
* @param mixed $text The header text, as either a string or stream
|
||||
* resource.
|
||||
*/
|
||||
public function setHeaderText($id, $text)
|
||||
{
|
||||
$this->_data[Horde_Imap_Client::FETCH_HEADERTEXT][$id] = $text;
|
||||
$this->_data[Horde_Imap_Client::FETCH_HEADERTEXT][$id] = $this->_setMixed($text);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -131,18 +151,23 @@ class Horde_Imap_Client_Data_Fetch
|
||||
*/
|
||||
public function getHeaderText($id = 0, $format = 0)
|
||||
{
|
||||
return $this->_getHeaders($id, $format, Horde_Imap_Client::FETCH_HEADERTEXT);
|
||||
return $this->_getHeaders(
|
||||
$id,
|
||||
$format,
|
||||
Horde_Imap_Client::FETCH_HEADERTEXT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a MIME header entry.
|
||||
*
|
||||
* @param string $id The MIME ID.
|
||||
* @param string $text The header text.
|
||||
* @param string $id The MIME ID.
|
||||
* @param mixed $text The header text, as either a string or stream
|
||||
* resource.
|
||||
*/
|
||||
public function setMimeHeader($id, $text)
|
||||
{
|
||||
$this->_data[Horde_Imap_Client::FETCH_MIMEHEADER][$id] = $text;
|
||||
$this->_data[Horde_Imap_Client::FETCH_MIMEHEADER][$id] = $this->_setMixed($text);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,7 +183,11 @@ class Horde_Imap_Client_Data_Fetch
|
||||
*/
|
||||
public function getMimeHeader($id, $format = 0)
|
||||
{
|
||||
return $this->_getHeaders($id, $format, Horde_Imap_Client::FETCH_MIMEHEADER);
|
||||
return $this->_getHeaders(
|
||||
$id,
|
||||
$format,
|
||||
Horde_Imap_Client::FETCH_MIMEHEADER
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,21 +202,10 @@ class Horde_Imap_Client_Data_Fetch
|
||||
{
|
||||
$this->_data[Horde_Imap_Client::FETCH_BODYPART][$id] = array(
|
||||
'd' => $decode,
|
||||
't' => $text
|
||||
't' => $this->_setMixed($text)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the body part size for a body part.
|
||||
*
|
||||
* @param string $id The MIME ID.
|
||||
* @param integer $size The size (in bytes).
|
||||
*/
|
||||
public function setBodyPartSize($id, $size)
|
||||
{
|
||||
$this->_data[Horde_Imap_Client::FETCH_BODYPARTSIZE][$id] = intval($size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a body part entry.
|
||||
*
|
||||
@ -198,7 +216,12 @@ class Horde_Imap_Client_Data_Fetch
|
||||
*/
|
||||
public function getBodyPart($id, $stream = false)
|
||||
{
|
||||
return $this->_msgText($stream, isset($this->_data[Horde_Imap_Client::FETCH_BODYPART][$id]) ? $this->_data[Horde_Imap_Client::FETCH_BODYPART][$id]['t'] : null);
|
||||
return $this->_msgText(
|
||||
$stream,
|
||||
isset($this->_data[Horde_Imap_Client::FETCH_BODYPART][$id])
|
||||
? $this->_data[Horde_Imap_Client::FETCH_BODYPART][$id]['t']
|
||||
: null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -215,6 +238,17 @@ class Horde_Imap_Client_Data_Fetch
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the body part size for a body part.
|
||||
*
|
||||
* @param string $id The MIME ID.
|
||||
* @param integer $size The size (in bytes).
|
||||
*/
|
||||
public function setBodyPartSize($id, $size)
|
||||
{
|
||||
$this->_data[Horde_Imap_Client::FETCH_BODYPARTSIZE][$id] = intval($size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the body part size, if returned by the server.
|
||||
*
|
||||
@ -238,7 +272,7 @@ class Horde_Imap_Client_Data_Fetch
|
||||
*/
|
||||
public function setBodyText($id, $text)
|
||||
{
|
||||
$this->_data[Horde_Imap_Client::FETCH_BODYTEXT][$id] = $text;
|
||||
$this->_data[Horde_Imap_Client::FETCH_BODYTEXT][$id] = $this->_setMixed($text);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -251,7 +285,12 @@ class Horde_Imap_Client_Data_Fetch
|
||||
*/
|
||||
public function getBodyText($id = 0, $stream = false)
|
||||
{
|
||||
return $this->_msgText($stream, isset($this->_data[Horde_Imap_Client::FETCH_BODYTEXT][$id]) ? $this->_data[Horde_Imap_Client::FETCH_BODYTEXT][$id] : null);
|
||||
return $this->_msgText(
|
||||
$stream,
|
||||
isset($this->_data[Horde_Imap_Client::FETCH_BODYTEXT][$id])
|
||||
? $this->_data[Horde_Imap_Client::FETCH_BODYTEXT][$id]
|
||||
: null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -286,7 +325,10 @@ class Horde_Imap_Client_Data_Fetch
|
||||
*/
|
||||
public function setFlags(array $flags)
|
||||
{
|
||||
$this->_data[Horde_Imap_Client::FETCH_FLAGS] = array_map('strtolower', $flags);
|
||||
$this->_data[Horde_Imap_Client::FETCH_FLAGS] = array_map(
|
||||
'Horde_String::lower',
|
||||
array_map('trim', $flags)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -462,7 +504,10 @@ class Horde_Imap_Client_Data_Fetch
|
||||
*/
|
||||
public function merge(Horde_Imap_Client_Data_Fetch $data)
|
||||
{
|
||||
$this->_data = array_replace_recursive($this->_data, $data->getRawData());
|
||||
$this->_data = array_replace_recursive(
|
||||
$this->_data,
|
||||
$data->getRawData()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -498,28 +543,33 @@ class Horde_Imap_Client_Data_Fetch
|
||||
*/
|
||||
protected function _msgText($stream, $data)
|
||||
{
|
||||
if ($stream) {
|
||||
if (is_resource($data)) {
|
||||
rewind($data);
|
||||
return $data;
|
||||
if ($data instanceof Horde_Stream) {
|
||||
if ($stream) {
|
||||
$data->rewind();
|
||||
return $data->stream;
|
||||
}
|
||||
|
||||
$tmp = fopen('php://temp', 'w+');
|
||||
|
||||
if (!is_null($data)) {
|
||||
fwrite($tmp, $data);
|
||||
rewind($tmp);
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
return strval($data);
|
||||
}
|
||||
|
||||
if (is_resource($data)) {
|
||||
rewind($data);
|
||||
return stream_get_contents($data);
|
||||
return $stream
|
||||
? $data
|
||||
: stream_get_contents($data);
|
||||
}
|
||||
|
||||
return strval($data);
|
||||
if (!$stream) {
|
||||
return strval($data);
|
||||
}
|
||||
|
||||
$tmp = fopen('php://temp', 'w+');
|
||||
|
||||
if (!is_null($data)) {
|
||||
fwrite($tmp, $data);
|
||||
rewind($tmp);
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -540,28 +590,77 @@ class Horde_Imap_Client_Data_Fetch
|
||||
switch ($format) {
|
||||
case self::HEADER_STREAM:
|
||||
if (!isset($this->_data[$key][$id])) {
|
||||
return $this->_msgText(true, null);
|
||||
$data = null;
|
||||
} elseif (is_object($this->_data[$key][$id])) {
|
||||
return $this->_getHeaders($id, 0, $key);
|
||||
switch ($key) {
|
||||
case Horde_Imap_Client::FETCH_HEADERS:
|
||||
$data = $this->_getHeaders($id, 0, $key);
|
||||
break;
|
||||
|
||||
case Horde_Imap_Client::FETCH_HEADERTEXT:
|
||||
case Horde_Imap_Client::FETCH_MIMEHEADER:
|
||||
$data = $this->_data[$key][$id];
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$data = $this->_data[$key][$id];
|
||||
}
|
||||
return $this->_msgText(true, $this->_data[$key][$id]);
|
||||
|
||||
return $this->_msgText(true, $data);
|
||||
|
||||
case self::HEADER_PARSE:
|
||||
if (!isset($this->_data[$key][$id])) {
|
||||
return new Horde_Mime_Headers();
|
||||
} elseif (is_object($this->_data[$key][$id])) {
|
||||
return clone $this->_data[$key][$id];
|
||||
switch ($key) {
|
||||
case Horde_Imap_Client::FETCH_HEADERS:
|
||||
return clone $this->_data[$key][$id];
|
||||
|
||||
case Horde_Imap_Client::FETCH_HEADERTEXT:
|
||||
case Horde_Imap_Client::FETCH_MIMEHEADER:
|
||||
$hdrs = $this->_data[$key][$id];
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$hdrs = $this->_getHeaders($id, self::HEADER_STREAM, $key);
|
||||
}
|
||||
return Horde_Mime_Headers::parseHeaders($this->_getHeaders($id, self::HEADER_STREAM, $key));
|
||||
|
||||
return Horde_Mime_Headers::parseHeaders($hdrs);
|
||||
}
|
||||
|
||||
if (!isset($this->_data[$key][$id])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return is_object($this->_data[$key][$id])
|
||||
? $this->_data[$key][$id]->toString(array('nowrap' => true))
|
||||
: $this->_msgText(false, $this->_data[$key][$id]);
|
||||
if (is_object($this->_data[$key][$id])) {
|
||||
switch ($key) {
|
||||
case Horde_Imap_Client::FETCH_HEADERS:
|
||||
return $this->_data[$key][$id]->toString(
|
||||
array('nowrap' => true)
|
||||
);
|
||||
|
||||
case Horde_Imap_Client::FETCH_HEADERTEXT:
|
||||
case Horde_Imap_Client::FETCH_MIMEHEADER:
|
||||
return strval($this->_data[$key][$id]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_msgText(false, $this->_data[$key][$id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts mixed input (string or resource) to the correct internal
|
||||
* representation.
|
||||
*
|
||||
* @param mixed $data Mixed data (string, resource, Horde_Stream object).
|
||||
*
|
||||
* @return mixed The internal representation of that data.
|
||||
*/
|
||||
protected function _setMixed($data)
|
||||
{
|
||||
return is_resource($data)
|
||||
? new Horde_Stream_Existing(array('stream' => $data))
|
||||
: $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2011-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2011-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
||||
/**
|
||||
* Extend astring element to allow for non-ASCII characters.
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
* @since 2.25.0
|
||||
*/
|
||||
class Horde_Imap_Client_Data_Format_Astring_Nonascii
|
||||
extends Horde_Imap_Client_Data_Format_Astring
|
||||
implements Horde_Imap_Client_Data_Format_String_Support_Nonascii
|
||||
{
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,18 +16,35 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
class Horde_Imap_Client_Data_Format_Filter_Quote extends php_user_filter
|
||||
{
|
||||
/**
|
||||
* Has the initial quote been prepended?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_prepend;
|
||||
|
||||
/**
|
||||
*/
|
||||
public function onCreate()
|
||||
{
|
||||
$this->_prepend = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see stream_filter_register()
|
||||
*/
|
||||
public function filter($in, $out, &$consumed, $closing)
|
||||
{
|
||||
stream_bucket_append($out, stream_bucket_new($this->stream, '"'));
|
||||
if (!$this->_prepend) {
|
||||
stream_bucket_append($out, stream_bucket_new($this->stream, '"'));
|
||||
$this->_prepend = true;
|
||||
}
|
||||
|
||||
while ($bucket = stream_bucket_make_writeable($in)) {
|
||||
$consumed += $bucket->datalen;
|
||||
@ -35,7 +52,11 @@ class Horde_Imap_Client_Data_Format_Filter_Quote extends php_user_filter
|
||||
stream_bucket_append($out, $bucket);
|
||||
}
|
||||
|
||||
stream_bucket_append($out, stream_bucket_new($this->stream, '"'));
|
||||
/* feof() call needed due to:
|
||||
* http://news.php.net/php.internals/80363 */
|
||||
if ($closing || feof($this->stream)) {
|
||||
stream_bucket_append($out, stream_bucket_new($this->stream, '"'));
|
||||
}
|
||||
|
||||
return PSFS_PASS_ON;
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -17,12 +17,19 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
class Horde_Imap_Client_Data_Format_Filter_String extends php_user_filter
|
||||
{
|
||||
/**
|
||||
* Skip status.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_skip = false;
|
||||
|
||||
/**
|
||||
* @see stream_filter_register()
|
||||
*/
|
||||
@ -30,6 +37,7 @@ class Horde_Imap_Client_Data_Format_Filter_String extends php_user_filter
|
||||
{
|
||||
$this->params->binary = false;
|
||||
$this->params->literal = false;
|
||||
$this->params->nonascii = false;
|
||||
// no_quote_list is used below as a config option
|
||||
$this->params->quoted = false;
|
||||
|
||||
@ -42,10 +50,9 @@ class Horde_Imap_Client_Data_Format_Filter_String extends php_user_filter
|
||||
public function filter($in, $out, &$consumed, $closing)
|
||||
{
|
||||
$p = $this->params;
|
||||
$skip = false;
|
||||
|
||||
while ($bucket = stream_bucket_make_writeable($in)) {
|
||||
if (!$skip) {
|
||||
if (!$this->_skip) {
|
||||
$len = $bucket->datalen;
|
||||
$str = $bucket->data;
|
||||
|
||||
@ -58,7 +65,7 @@ class Horde_Imap_Client_Data_Format_Filter_String extends php_user_filter
|
||||
$p->literal = true;
|
||||
|
||||
// No need to scan input anymore.
|
||||
$skip = true;
|
||||
$this->_skip = true;
|
||||
break 2;
|
||||
|
||||
case 10: // LF
|
||||
@ -90,6 +97,7 @@ class Horde_Imap_Client_Data_Format_Filter_String extends php_user_filter
|
||||
// CTL characters must be, at a minimum, quoted.
|
||||
$p->quoted = true;
|
||||
} elseif ($chr > 127) {
|
||||
$p->nonascii = true;
|
||||
// 8-bit chars must be in a literal.
|
||||
$p->literal = true;
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -74,7 +74,8 @@ class Horde_Imap_Client_Data_Format_List extends Horde_Imap_Client_Data_Format i
|
||||
$out .= '(' . $val->escape() . ') ';
|
||||
} elseif (($val instanceof Horde_Imap_Client_Data_Format_String) &&
|
||||
$val->literal()) {
|
||||
throw new Horde_Imap_Client_Data_Format_Exception('Requires literal output.');
|
||||
/* ERROR: Requires literal output. */
|
||||
return '';
|
||||
} else {
|
||||
$out .= $val->escape() . ' ';
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,11 +16,12 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
class Horde_Imap_Client_Data_Format_ListMailbox extends Horde_Imap_Client_Data_Format_Mailbox
|
||||
class Horde_Imap_Client_Data_Format_ListMailbox
|
||||
extends Horde_Imap_Client_Data_Format_Mailbox
|
||||
{
|
||||
/**
|
||||
*/
|
||||
|
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
||||
/**
|
||||
* Object representation of an IMAP mailbox string used in a LIST command
|
||||
* when UTF8=ACCEPT is supported/enabled on the server (RFC 6855 [3]).
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
class Horde_Imap_Client_Data_Format_ListMailbox_Utf8
|
||||
extends Horde_Imap_Client_Data_Format_Mailbox_Utf8
|
||||
{
|
||||
/**
|
||||
*/
|
||||
protected function _filterParams()
|
||||
{
|
||||
$ob = parent::_filterParams();
|
||||
|
||||
/* Don't quote % or * characters. */
|
||||
$ob->no_quote_list = true;
|
||||
|
||||
return $ob;
|
||||
}
|
||||
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,12 +16,20 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
class Horde_Imap_Client_Data_Format_Mailbox extends Horde_Imap_Client_Data_Format_Astring
|
||||
class Horde_Imap_Client_Data_Format_Mailbox
|
||||
extends Horde_Imap_Client_Data_Format_Astring
|
||||
{
|
||||
/**
|
||||
* Mailbox encoding.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_encoding = 'utf7imap';
|
||||
|
||||
/**
|
||||
* Mailbox object.
|
||||
*
|
||||
@ -36,7 +44,7 @@ class Horde_Imap_Client_Data_Format_Mailbox extends Horde_Imap_Client_Data_Forma
|
||||
{
|
||||
$this->_mailbox = Horde_Imap_Client_Mailbox::get($data);
|
||||
|
||||
parent::__construct($this->_mailbox->utf7imap);
|
||||
parent::__construct($this->_mailbox->{$this->_encoding});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -76,7 +84,7 @@ class Horde_Imap_Client_Data_Format_Mailbox extends Horde_Imap_Client_Data_Forma
|
||||
*/
|
||||
public function length()
|
||||
{
|
||||
return strlen($this->_mailbox->utf7imap);
|
||||
return strlen($this->_mailbox->{$this->_encoding});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,7 +92,7 @@ class Horde_Imap_Client_Data_Format_Mailbox extends Horde_Imap_Client_Data_Forma
|
||||
public function getStream()
|
||||
{
|
||||
$stream = new Horde_Stream_Temp();
|
||||
$stream->add($this->_mailbox->utf7imap);
|
||||
$stream->add($this->_mailbox->{$this->_encoding});
|
||||
return $stream;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
||||
/**
|
||||
* Object representation of an IMAP mailbox string allowed when UTF8=ACCEPT
|
||||
* is supported/enabled on the server (RFC 6855 [3]).
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
class Horde_Imap_Client_Data_Format_Mailbox_Utf8
|
||||
extends Horde_Imap_Client_Data_Format_Mailbox
|
||||
implements Horde_Imap_Client_Data_Format_String_Support_Nonascii
|
||||
{
|
||||
/**
|
||||
*/
|
||||
protected $_encoding = 'utf8';
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
parent::__construct($data);
|
||||
|
||||
/* RFC 3501 allows any US-ASCII character, except null (\0), in
|
||||
* mailbox data.
|
||||
* RFC 6855 [3] institutes additional limitations on valid mailbox
|
||||
* characters, to comply with RFC 5198 [2] (Net-Unicode Definition):
|
||||
* "MUST NOT contain control characters (U+0000-U+001F and
|
||||
* U+0080-U+009F), a delete character (U+007F), a line separator
|
||||
* (U+2028), or a paragraph separator (U+2029)." */
|
||||
if ($this->quoted() &&
|
||||
preg_match('/[\x00-\x1f\x7f\x80-\x9f\x{2028}\x{2029}]/u', strval($this))) {
|
||||
throw new Horde_Imap_Client_Data_Format_Exception(
|
||||
'Invalid character found in mailbox data.'
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->literal()) {
|
||||
$this->forceQuoted();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
||||
/**
|
||||
* Extend nstring element to allow for non-ASCII characters.
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
* @since 2.25.0
|
||||
*/
|
||||
class Horde_Imap_Client_Data_Format_Nstring_Nonascii
|
||||
extends Horde_Imap_Client_Data_Format_Nstring
|
||||
implements Horde_Imap_Client_Data_Format_String_Support_Nonascii
|
||||
{
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,11 +16,12 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
class Horde_Imap_Client_Data_Format_String extends Horde_Imap_Client_Data_Format
|
||||
class Horde_Imap_Client_Data_Format_String
|
||||
extends Horde_Imap_Client_Data_Format
|
||||
{
|
||||
/**
|
||||
* String filter parameters.
|
||||
@ -34,15 +35,16 @@ class Horde_Imap_Client_Data_Format_String extends Horde_Imap_Client_Data_Format
|
||||
* - eol: (boolean) If true, normalize EOLs in input. @since 2.2.0
|
||||
* - skipscan: (boolean) If true, don't scan input for
|
||||
* binary/literal/quoted data. @since 2.2.0
|
||||
*
|
||||
* @throws Horde_Imap_Client_Data_Format_Exception
|
||||
*/
|
||||
public function __construct($data, array $opts = array())
|
||||
{
|
||||
/* String data is stored in a stream. */
|
||||
$this->_data = new Horde_Stream_Temp();
|
||||
|
||||
$this->_filter = $this->_filterParams();
|
||||
|
||||
if (empty($opts['skipscan'])) {
|
||||
$this->_filter = $this->_filterParams();
|
||||
stream_filter_register('horde_imap_client_string', 'Horde_Imap_Client_Data_Format_Filter_String');
|
||||
$res = stream_filter_append($this->_data->stream, 'horde_imap_client_string', STREAM_FILTER_WRITE, $this->_filter);
|
||||
} else {
|
||||
@ -64,6 +66,14 @@ class Horde_Imap_Client_Data_Format_String extends Horde_Imap_Client_Data_Format
|
||||
if (!is_null($res2)) {
|
||||
stream_filter_remove($res2);
|
||||
}
|
||||
|
||||
if (isset($this->_filter) &&
|
||||
$this->_filter->nonascii &&
|
||||
!($this instanceof Horde_Imap_Client_Data_Format_String_Support_Nonascii)) {
|
||||
throw new Horde_Imap_Client_Data_Format_Exception(
|
||||
'String contains non-ASCII characters.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
||||
/**
|
||||
* Extend string element to allow for non-ASCII characters.
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
* @since 2.25.0
|
||||
*/
|
||||
class Horde_Imap_Client_Data_Format_String_Nonascii
|
||||
extends Horde_Imap_Client_Data_Format_String
|
||||
implements Horde_Imap_Client_Data_Format_String_Support_Nonascii
|
||||
{
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface a Horde_Imap_Client_Data_Format_String object should extend if
|
||||
* it supports non-ASCII output (RFC 3501 [4.3.1]).
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
* @since 2.25.0
|
||||
*/
|
||||
interface Horde_Imap_Client_Data_Format_String_Support_Nonascii
|
||||
{
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2013-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2013-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2013-2014 Horde LLC
|
||||
* @copyright 2013-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2013-2014 Horde LLC
|
||||
* @copyright 2013-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
* @since 2.21.0
|
||||
|
178
lib/horde/framework/Horde/Imap/Client/Data/SearchCharset.php
Normal file
178
lib/horde/framework/Horde/Imap/Client/Data/SearchCharset.php
Normal file
@ -0,0 +1,178 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
||||
/**
|
||||
* Query the search charsets available on a server.
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
* @since 2.24.0
|
||||
*
|
||||
* @property-read array $charsets The list of valid charsets that have been
|
||||
* discovered on the server.
|
||||
*/
|
||||
class Horde_Imap_Client_Data_SearchCharset
|
||||
implements Serializable, SplSubject
|
||||
{
|
||||
/**
|
||||
* Base client object.
|
||||
*
|
||||
* @var Horde_Imap_Client_Base
|
||||
*/
|
||||
protected $_baseob;
|
||||
|
||||
/**
|
||||
* Charset data.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_charsets = array(
|
||||
'US-ASCII' => true
|
||||
);
|
||||
|
||||
/**
|
||||
* Observers.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_observers = array();
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
switch ($name) {
|
||||
case 'charsets':
|
||||
return array_keys(array_filter($this->_charsets));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function setBaseOb(Horde_Imap_Client_Base $ob)
|
||||
{
|
||||
$this->_baseob = $ob;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the validity of a charset.
|
||||
*
|
||||
* @param string $charset The charset to query.
|
||||
* @param boolean $cached If true, only query cached values.
|
||||
*
|
||||
* @return boolean True if the charset is valid for searching.
|
||||
*/
|
||||
public function query($charset, $cached = false)
|
||||
{
|
||||
$charset = Horde_String::upper($charset);
|
||||
|
||||
if (isset($this->_charsets[$charset])) {
|
||||
return $this->_charsets[$charset];
|
||||
} elseif ($cached) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!$this->_baseob) {
|
||||
throw new RuntimeException(
|
||||
'Base object needs to be defined to query for charset.'
|
||||
);
|
||||
}
|
||||
|
||||
/* Use a dummy search query and search for BADCHARSET response. */
|
||||
$query = new Horde_Imap_Client_Search_Query();
|
||||
$query->charset($charset, false);
|
||||
$query->ids($this->_baseob->getIdsOb(1, true));
|
||||
$query->text('a');
|
||||
try {
|
||||
$this->_baseob->search('INBOX', $query, array(
|
||||
'nocache' => true,
|
||||
'sequence' => true
|
||||
));
|
||||
$this->_charsets[$charset] = true;
|
||||
} catch (Horde_Imap_Client_Exception $e) {
|
||||
$this->_charsets[$charset] = ($e->getCode() !== Horde_Imap_Client_Exception::BADCHARSET);
|
||||
}
|
||||
|
||||
$this->notify();
|
||||
|
||||
return $this->_charsets[$charset];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the validity of a given charset.
|
||||
*
|
||||
* @param string $charset The charset.
|
||||
* @param boolean $valid Is charset valid?
|
||||
*/
|
||||
public function setValid($charset, $valid = true)
|
||||
{
|
||||
$charset = Horde_String::upper($charset);
|
||||
$valid = (bool)$valid;
|
||||
|
||||
if (!isset($this->_charsets[$charset]) ||
|
||||
($this->_charsets[$charset] !== $valid)) {
|
||||
$this->_charsets[$charset] = $valid;
|
||||
$this->notify();
|
||||
}
|
||||
}
|
||||
|
||||
/* SplSubject methods. */
|
||||
|
||||
/**
|
||||
*/
|
||||
public function attach(SplObserver $observer)
|
||||
{
|
||||
$this->detach($observer);
|
||||
$this->_observers[] = $observer;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function detach(SplObserver $observer)
|
||||
{
|
||||
if (($key = array_search($observer, $this->_observers, true)) !== false) {
|
||||
unset($this->_observers[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification is triggered internally whenever the object's internal
|
||||
* data storage is altered.
|
||||
*/
|
||||
public function notify()
|
||||
{
|
||||
foreach ($this->_observers as $val) {
|
||||
$val->update($this);
|
||||
}
|
||||
}
|
||||
|
||||
/* Serializable methods. */
|
||||
|
||||
/**
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
return json_encode($this->_charsets);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function unserialize($data)
|
||||
{
|
||||
$this->_charsets = json_decode($data, true);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
||||
/**
|
||||
* Query the search charsets available on a server that supports the UTF-8
|
||||
* IMAP extension (RFC 6855).
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
* @since 2.24.0
|
||||
*/
|
||||
class Horde_Imap_Client_Data_SearchCharset_Utf8
|
||||
extends Horde_Imap_Client_Data_SearchCharset
|
||||
{
|
||||
/**
|
||||
* Charset data.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_charsets = array(
|
||||
'US-ASCII' => true,
|
||||
'UTF-8' => true
|
||||
);
|
||||
|
||||
/**
|
||||
*/
|
||||
public function query($charset, $cached = false)
|
||||
{
|
||||
return isset($this->_charsets[Horde_String::upper($charset)]);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function setValid($charset, $valid = true)
|
||||
{
|
||||
}
|
||||
|
||||
/* Serializable methods. */
|
||||
|
||||
/**
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function unserialize($data)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
* @since 2.2.0
|
||||
@ -36,7 +36,7 @@ class Horde_Imap_Client_Data_Sync
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static public $map = array(
|
||||
public static $map = array(
|
||||
'H' => 'highestmodseq',
|
||||
'M' => 'messages',
|
||||
'U' => 'uidnext',
|
||||
@ -46,7 +46,7 @@ class Horde_Imap_Client_Data_Sync
|
||||
/**
|
||||
* Are there messages that have had flag changes?
|
||||
*
|
||||
* @var Horde_Imap_Client_Ids
|
||||
* @var boolean
|
||||
*/
|
||||
public $flags = null;
|
||||
|
||||
@ -182,7 +182,7 @@ class Horde_Imap_Client_Data_Sync
|
||||
: ($this->uidnext . ':' . $curr['U']);
|
||||
|
||||
$squery = new Horde_Imap_Client_Search_Query();
|
||||
$squery->ids($new_ids);
|
||||
$squery->ids(new Horde_Imap_Client_Ids($new_ids));
|
||||
$sres = $base_ob->search($mailbox, $squery);
|
||||
|
||||
$this->_newmsgsuids = $sres['match'];
|
||||
@ -237,8 +237,8 @@ class Horde_Imap_Client_Data_Sync
|
||||
if ($this->highestmodseq &&
|
||||
($this->highestmodseq == $status_sync['syncmodseq'])) {
|
||||
$vanished = is_null($ids)
|
||||
? $status_sync['syncvanisheduids']
|
||||
: $base_ob->getIdsOb(array_intersect($ids->ids, $status_sync['syncvanisheduids']->ids));
|
||||
? $status_sync['syncvanished']
|
||||
: $base_ob->getIdsOb(array_intersect($ids->ids, $status_sync['syncvanished']->ids));
|
||||
} else {
|
||||
$vanished = $base_ob->vanished($mailbox, $this->highestmodseq ? $this->highestmodseq : 1, array(
|
||||
'ids' => $ids
|
||||
@ -258,10 +258,9 @@ class Horde_Imap_Client_Data_Sync
|
||||
case 'flagsuids':
|
||||
case 'newmsgsuids':
|
||||
case 'vanisheduids':
|
||||
$varname = '_' . $name;
|
||||
return empty($this->$varname)
|
||||
return empty($this->{'_' . $name})
|
||||
? new Horde_Imap_Client_Ids()
|
||||
: $this->$varname;
|
||||
: $this->{'_' . $name};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2008-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2008-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2008-2014 Horde LLC
|
||||
* @copyright 2008-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -17,7 +17,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2008-2014 Horde LLC
|
||||
* @copyright 2008-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -84,8 +84,7 @@ class Horde_Imap_Client_Data_Thread implements Countable, Serializable
|
||||
*/
|
||||
public function getThread($index)
|
||||
{
|
||||
reset($this->_thread);
|
||||
while (list(,$v) = each($this->_thread)) {
|
||||
foreach ($this->_thread as $v) {
|
||||
if (isset($v[$index])) {
|
||||
reset($v);
|
||||
|
||||
@ -96,7 +95,8 @@ class Horde_Imap_Client_Data_Thread implements Countable, Serializable
|
||||
$levels = $out = array();
|
||||
$last = 0;
|
||||
|
||||
while (list($k2, $v2) = each($v)) {
|
||||
while (($v2 = current($v)) !== false) {
|
||||
$k2 = key($v);
|
||||
$ob2 = clone $ob;
|
||||
$ob2->level = $v2;
|
||||
$out[$k2] = $ob2;
|
||||
@ -106,6 +106,7 @@ class Horde_Imap_Client_Data_Thread implements Countable, Serializable
|
||||
}
|
||||
$levels[$v2] = $k2;
|
||||
$last = $v2;
|
||||
next($v);
|
||||
}
|
||||
|
||||
foreach ($levels as $v) {
|
||||
@ -158,12 +159,11 @@ class Horde_Imap_Client_Data_Thread implements Countable, Serializable
|
||||
{
|
||||
$out = array();
|
||||
|
||||
reset($this->_thread);
|
||||
while (list(,$v) = each($this->_thread)) {
|
||||
$out = array_merge($out, array_keys($v));
|
||||
foreach ($this->_thread as $val) {
|
||||
$out += $val;
|
||||
}
|
||||
|
||||
return $out;
|
||||
return array_keys($out);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -18,7 +18,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -26,18 +26,55 @@ class Horde_Imap_Client_DateTime extends DateTime
|
||||
{
|
||||
/**
|
||||
*/
|
||||
public function __construct($time = null)
|
||||
public function __construct($time = null, $tz = null)
|
||||
{
|
||||
/* See https://bugs.php.net/bug.php?id=67118 */
|
||||
$bug_67118 = (version_compare(PHP_VERSION, '5.6', '>=')) ||
|
||||
in_array(PHP_VERSION, array('5.4.29', '5.5.13'));
|
||||
$tz = new DateTimeZone('UTC');
|
||||
|
||||
/* Bug #14381 Catch malformed offset - which doesn't cause
|
||||
DateTime to throw exception. */
|
||||
if (substr(rtrim($time), -5) === ' 0000') {
|
||||
$time = substr(trim($time), 0, strlen(trim($time)) - 5) . ' +0000';
|
||||
try {
|
||||
if ($bug_67118) {
|
||||
new DateTime($time, $tz);
|
||||
}
|
||||
parent::__construct($time, $tz);
|
||||
return;
|
||||
} catch (Exception $e) {}
|
||||
}
|
||||
|
||||
try {
|
||||
if ($bug_67118) {
|
||||
new DateTime($time, $tz);
|
||||
}
|
||||
parent::__construct($time, $tz);
|
||||
return;
|
||||
} catch (Exception $e) {}
|
||||
|
||||
/* Check for malformed day-of-week parts, usually incorrectly
|
||||
* localized. E.g. Fr, 15 Apr 2016 15:15:09 +0000 */
|
||||
if (!preg_match("/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun),/", $time)) {
|
||||
$time = preg_replace("/^(\S*,)/", '', $time, 1, $i);
|
||||
if ($i) {
|
||||
try {
|
||||
if ($bug_67118) {
|
||||
new DateTime($time, $tz);
|
||||
}
|
||||
parent::__construct($time, $tz);
|
||||
return;
|
||||
} catch (Exception $e) {}
|
||||
}
|
||||
}
|
||||
|
||||
/* Bug #5717 - Check for UT vs. UTC. */
|
||||
if (substr(rtrim($time), -3) === ' UT') {
|
||||
try {
|
||||
if ($bug_67118) {
|
||||
new DateTime($time . 'C', $tz);
|
||||
}
|
||||
parent::__construct($time . 'C', $tz);
|
||||
return;
|
||||
} catch (Exception $e) {}
|
||||
@ -48,6 +85,9 @@ class Horde_Imap_Client_DateTime extends DateTime
|
||||
$date = preg_replace("/\s*\([^\)]+\)\s*$/", '', $time, -1, $i);
|
||||
if ($i) {
|
||||
try {
|
||||
if ($bug_67118) {
|
||||
new DateTime($date, $tz);
|
||||
}
|
||||
parent::__construct($date, $tz);
|
||||
return;
|
||||
} catch (Exception $e) {}
|
||||
@ -63,7 +103,7 @@ class Horde_Imap_Client_DateTime extends DateTime
|
||||
{
|
||||
return $this->error()
|
||||
? '0'
|
||||
: $this->format('U');
|
||||
: strval($this->getTimestamp());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,7 +113,7 @@ class Horde_Imap_Client_DateTime extends DateTime
|
||||
*/
|
||||
public function error()
|
||||
{
|
||||
return (intval($this->format('U')) === -1);
|
||||
return ($this->getTimestamp() === -1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2008-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2008-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2008-2014 Horde LLC
|
||||
* @copyright 2008-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -19,7 +19,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2008-2014 Horde LLC
|
||||
* @copyright 2008-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -199,6 +199,11 @@ class Horde_Imap_Client_Exception extends Horde_Exception_Wrapped
|
||||
*/
|
||||
const LOGIN_PRIVACYREQUIRED = 106;
|
||||
|
||||
/**
|
||||
* Server verification failed (SCRAM authentication).
|
||||
*/
|
||||
const LOGIN_SERVER_VERIFICATION_FAILED = 107;
|
||||
|
||||
|
||||
// Mailbox access failures
|
||||
|
||||
@ -247,15 +252,17 @@ class Horde_Imap_Client_Exception extends Horde_Exception_Wrapped
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $msg Error message (non-translated).
|
||||
* @param code $code Error code.
|
||||
* @param string $message Error message (non-translated).
|
||||
* @param code $code Error code.
|
||||
*/
|
||||
public function __construct($message = null, $code = null)
|
||||
{
|
||||
parent::__construct($message, $code);
|
||||
|
||||
$this->raw_msg = $this->message;
|
||||
$this->message = Horde_Imap_Client_Translation::t($this->message);
|
||||
try {
|
||||
$this->message = Horde_Imap_Client_Translation::t($this->message);
|
||||
} catch (Horde_Translation_Exception $e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -278,4 +285,19 @@ class Horde_Imap_Client_Exception extends Horde_Exception_Wrapped
|
||||
$this->code = intval($code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform substitution of variables in the error message.
|
||||
*
|
||||
* Needed to allow for correct translation of error message.
|
||||
*
|
||||
* @since 2.22.0
|
||||
*
|
||||
* @param array $args Arguments used for substitution.
|
||||
*/
|
||||
public function messagePrintf(array $args = array())
|
||||
{
|
||||
$this->raw_msg = vsprintf($this->raw_msg, $args);
|
||||
$this->message = vsprintf($this->message, $args);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -31,9 +31,10 @@ extends Horde_Imap_Client_Exception
|
||||
public function __construct($feature)
|
||||
{
|
||||
parent::__construct(
|
||||
sprintf(Horde_Imap_Client_Translation::r("%s not supported on POP3 servers."), $feature),
|
||||
Horde_Imap_Client_Translation::r("%s not supported on POP3 servers."),
|
||||
self::NOT_SUPPORTED
|
||||
);
|
||||
$this->messagePrintf(array($feature));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -17,7 +17,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2011-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2011-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -184,9 +184,12 @@ class Horde_Imap_Client_Fetch_Query implements ArrayAccess, Countable, Iterator
|
||||
*/
|
||||
public function headers($label, $search, array $opts = array())
|
||||
{
|
||||
$this->_data[Horde_Imap_Client::FETCH_HEADERS][$label] = array_merge($opts, array(
|
||||
'headers' => $search
|
||||
));
|
||||
$this->_data[Horde_Imap_Client::FETCH_HEADERS][$label] = array_merge(
|
||||
$opts,
|
||||
array(
|
||||
'headers' => array_map('strval', $search)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -292,10 +295,7 @@ class Horde_Imap_Client_Fetch_Query implements ArrayAccess, Countable, Iterator
|
||||
*/
|
||||
public function hash()
|
||||
{
|
||||
return hash(
|
||||
(PHP_MINOR_VERSION >= 4) ? 'fnv132' : 'sha1',
|
||||
serialize($this)
|
||||
);
|
||||
return hash('md5', serialize($this));
|
||||
}
|
||||
|
||||
/* ArrayAccess methods. */
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,13 +16,14 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*
|
||||
* @property-read integer $key_type The key type (sequence or UID).
|
||||
*/
|
||||
class Horde_Imap_Client_Fetch_Results implements ArrayAccess, Countable, IteratorAggregate
|
||||
class Horde_Imap_Client_Fetch_Results
|
||||
implements ArrayAccess, Countable, IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* Key type constants.
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2011-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2011-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*
|
||||
@ -180,7 +180,7 @@ class Horde_Imap_Client_Ids implements Countable, Iterator, Serializable
|
||||
}
|
||||
}
|
||||
|
||||
$this->_sorted = (count($this->_ids) === 1);
|
||||
$this->_sorted = is_array($this->_ids) && (count($this->_ids) === 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -221,16 +221,26 @@ class Horde_Imap_Client_Ids implements Countable, Iterator, Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the IDs numerically.
|
||||
* Sorts the IDs.
|
||||
*/
|
||||
public function sort()
|
||||
{
|
||||
if (!$this->_sorted && is_array($this->_ids)) {
|
||||
sort($this->_ids, SORT_NUMERIC);
|
||||
$this->_sort($this->_ids);
|
||||
$this->_sorted = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the IDs numerically.
|
||||
*
|
||||
* @param array $ids The array list.
|
||||
*/
|
||||
protected function _sort(&$ids)
|
||||
{
|
||||
sort($ids, SORT_NUMERIC);
|
||||
}
|
||||
|
||||
/**
|
||||
* Split the sequence string at an approximate length.
|
||||
*
|
||||
@ -296,15 +306,14 @@ class Horde_Imap_Client_Ids implements Countable, Iterator, Serializable
|
||||
$in = $this->_ids;
|
||||
|
||||
if ($sort && !$this->_sorted) {
|
||||
sort($in, SORT_NUMERIC);
|
||||
$this->_sort($in);
|
||||
}
|
||||
|
||||
$first = $last = array_shift($in);
|
||||
$i = count($in) - 1;
|
||||
$out = array();
|
||||
|
||||
reset($in);
|
||||
while (list($key, $val) = each($in)) {
|
||||
foreach ($in as $key => $val) {
|
||||
if (($last + 1) == $val) {
|
||||
$last = $val;
|
||||
}
|
||||
@ -350,8 +359,7 @@ class Horde_Imap_Client_Ids implements Countable, Iterator, Serializable
|
||||
|
||||
$idarray = explode(',', $str);
|
||||
|
||||
reset($idarray);
|
||||
while (list(,$val) = each($idarray)) {
|
||||
foreach ($idarray as $val) {
|
||||
$range = explode(':', $val);
|
||||
if (isset($range[1])) {
|
||||
for ($i = min($range), $j = max($range); $i <= $j; ++$i) {
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
* @since 2.1.0
|
||||
@ -141,6 +141,12 @@ class Horde_Imap_Client_Ids_Map implements Countable, IteratorAggregate, Seriali
|
||||
|
||||
$this->sort();
|
||||
|
||||
if (count($remove) == count($this->_ids) &&
|
||||
!array_diff($remove, array_keys($this->_ids))) {
|
||||
$this->_ids = array();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Find the minimum sequence number to remove. We know entries before
|
||||
* this are untouched so no need to process them multiple times. */
|
||||
$first = min($remove);
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2011-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2011-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,12 +16,21 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
class Horde_Imap_Client_Ids_Pop3 extends Horde_Imap_Client_Ids
|
||||
{
|
||||
/**
|
||||
*/
|
||||
protected function _sort(&$ids)
|
||||
{
|
||||
/* There is no guarantee of POP3 UIDL order - IDs need to be unique,
|
||||
* but there is no requirement they need be incrementing. RFC
|
||||
* 1939[7] */
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a POP3 message sequence string.
|
||||
*
|
||||
@ -33,6 +42,8 @@ class Horde_Imap_Client_Ids_Pop3 extends Horde_Imap_Client_Ids
|
||||
*/
|
||||
protected function _toSequenceString($sort = true)
|
||||
{
|
||||
/* $sort is ignored - see _sort(). */
|
||||
|
||||
/* Use space as delimiter as it is the only printable ASCII character
|
||||
* that is not allowed as part of the UID (RFC 1939 [7]). */
|
||||
return implode(' ', count($this->_ids) > 25000 ? array_unique($this->_ids) : array_keys(array_flip($this->_ids)));
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -17,7 +17,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2016 Horde LLC
|
||||
* @deprecated
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
* @since 2.10.0
|
||||
@ -28,11 +28,13 @@ class Horde_Imap_Client_Interaction_Command
|
||||
extends Horde_Imap_Client_Data_Format_List
|
||||
{
|
||||
/**
|
||||
* Debug string to use instead of command text.
|
||||
* Debug string(s) to use instead of command text.
|
||||
*
|
||||
* @var string
|
||||
* Multiple entries refer to the various steps in a continuation command.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $debug = null;
|
||||
public $debug = array();
|
||||
|
||||
/**
|
||||
* Use LITERAL+ if available
|
||||
@ -48,6 +50,35 @@ extends Horde_Imap_Client_Data_Format_List
|
||||
*/
|
||||
public $literal8 = false;
|
||||
|
||||
/**
|
||||
* A callback to run on error.
|
||||
*
|
||||
* If callback returns true, the command will be treated as successful.
|
||||
*
|
||||
* @since 2.24.0
|
||||
*
|
||||
* @var callback
|
||||
*/
|
||||
public $on_error = null;
|
||||
|
||||
/**
|
||||
* A callback to run on success.
|
||||
*
|
||||
* @since 2.28.0
|
||||
*
|
||||
* @var callback
|
||||
*/
|
||||
public $on_success = null;
|
||||
|
||||
/**
|
||||
* Pipeline object associated with this command.
|
||||
*
|
||||
* @since 2.28.0
|
||||
*
|
||||
* @var Horde_Imap_Client_Interaction_Pipeline
|
||||
*/
|
||||
public $pipeline;
|
||||
|
||||
/**
|
||||
* Server response.
|
||||
*
|
||||
@ -93,15 +124,7 @@ extends Horde_Imap_Client_Data_Format_List
|
||||
{
|
||||
switch ($name) {
|
||||
case 'continuation':
|
||||
foreach ($this as $val) {
|
||||
if (($val instanceof Horde_Imap_Client_Interaction_Command_Continuation) ||
|
||||
(($val instanceof Horde_Imap_Client_Data_Format_String) &&
|
||||
$val->literal())) {
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return $this->_continuationCheck($this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,4 +160,25 @@ extends Horde_Imap_Client_Data_Format_List
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive check for continuation functions.
|
||||
*/
|
||||
protected function _continuationCheck($list)
|
||||
{
|
||||
foreach ($list as $val) {
|
||||
if (($val instanceof Horde_Imap_Client_Interaction_Command_Continuation) ||
|
||||
(($val instanceof Horde_Imap_Client_Data_Format_String) &&
|
||||
$val->literal())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (($val instanceof Horde_Imap_Client_Data_Format_List) &&
|
||||
$this->_continuationCheck($val)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2013-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2013-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2013-2014 Horde LLC
|
||||
* @copyright 2013-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -17,7 +17,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2013-2014 Horde LLC
|
||||
* @copyright 2013-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
* @since 2.10.0
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2013-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2013-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2013-2014 Horde LLC
|
||||
* @copyright 2013-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -17,7 +17,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2013-2014 Horde LLC
|
||||
* @copyright 2013-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
* @since 2.10.0
|
||||
@ -103,13 +103,22 @@ class Horde_Imap_Client_Interaction_Pipeline implements Countable, IteratorAggre
|
||||
* response.
|
||||
*
|
||||
* @return Horde_Imap_Client_Interaction_Command Command that was
|
||||
* completed.
|
||||
* completed. Returns null
|
||||
* if tagged response
|
||||
* is not contained in this
|
||||
* pipeline object.
|
||||
*/
|
||||
public function complete(Horde_Imap_Client_Interaction_Server_Tagged $resp)
|
||||
{
|
||||
$cmd = $this->_commands[$resp->tag];
|
||||
$cmd->response = $resp;
|
||||
unset($this->_todo[$resp->tag]);
|
||||
if (isset($this->_commands[$resp->tag])) {
|
||||
$cmd = $this->_commands[$resp->tag];
|
||||
$cmd->response = $resp;
|
||||
unset($this->_todo[$resp->tag]);
|
||||
} else {
|
||||
/* This can be reached if a previous pipeline action was aborted,
|
||||
* e.g. via an Exception. */
|
||||
$cmd = null;
|
||||
}
|
||||
|
||||
return $cmd;
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -17,7 +17,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -70,7 +70,7 @@ class Horde_Imap_Client_Interaction_Server
|
||||
*
|
||||
* @return Horde_Imap_Client_Interaction_Server A server response object.
|
||||
*/
|
||||
static public function create(Horde_Imap_Client_Tokenize $t)
|
||||
public static function create(Horde_Imap_Client_Tokenize $t)
|
||||
{
|
||||
$t->rewind();
|
||||
$tag = $t->next();
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2012-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2012-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2012-2014 Horde LLC
|
||||
* @copyright 2012-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2011-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2011-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -17,7 +17,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2011-2014 Horde LLC
|
||||
* @copyright 2011-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*
|
||||
@ -52,7 +52,7 @@ class Horde_Imap_Client_Mailbox implements Serializable
|
||||
*
|
||||
* @return Horde_Imap_Client_Mailbox A mailbox object.
|
||||
*/
|
||||
static public function get($mbox, $utf7imap = false)
|
||||
public static function get($mbox, $utf7imap = false)
|
||||
{
|
||||
return ($mbox instanceof Horde_Imap_Client_Mailbox)
|
||||
? $mbox
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2004-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2004-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2004-2014 Horde LLC
|
||||
* @copyright 2004-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2004-2014 Horde LLC
|
||||
* @copyright 2004-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -94,7 +94,7 @@ class Horde_Imap_Client_Mailbox_List implements Countable, IteratorAggregate
|
||||
*
|
||||
* @return integer See usort().
|
||||
*/
|
||||
protected final function _mboxCompare($a, $b)
|
||||
final protected function _mboxCompare($a, $b)
|
||||
{
|
||||
/* Always return INBOX as "smaller". */
|
||||
if ($this->_sortinbox) {
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2014-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2014 Horde LLC
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2014 Horde LLC
|
||||
* @copyright 2014-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
* @since 2.21.0
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2013-2014 Horde LLC (http://www.horde.org/)
|
||||
* Copyright 2013-2017 Horde LLC (http://www.horde.org/)
|
||||
*
|
||||
* See the enclosed file COPYING for license information (LGPL). If you
|
||||
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
|
||||
*
|
||||
* @category Horde
|
||||
* @copyright 2013-2014 Horde LLC
|
||||
* @copyright 2013-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
*/
|
||||
@ -19,7 +19,7 @@
|
||||
*
|
||||
* @author Michael Slusarz <slusarz@horde.org>
|
||||
* @category Horde
|
||||
* @copyright 2013-2014 Horde LLC
|
||||
* @copyright 2013-2017 Horde LLC
|
||||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
|
||||
* @package Imap_Client
|
||||
* @since 2.16.0
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user