Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'libs/Zend/Mail/Protocol/Abstract.php')
-rw-r--r--libs/Zend/Mail/Protocol/Abstract.php94
1 files changed, 61 insertions, 33 deletions
diff --git a/libs/Zend/Mail/Protocol/Abstract.php b/libs/Zend/Mail/Protocol/Abstract.php
index 4ef5792b11..cbfeaa8946 100644
--- a/libs/Zend/Mail/Protocol/Abstract.php
+++ b/libs/Zend/Mail/Protocol/Abstract.php
@@ -12,39 +12,39 @@
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
- *
+ *
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Abstract.php 16219 2009-06-21 19:45:39Z thomas $
+ * @version $Id: Abstract.php 21635 2010-03-24 15:25:13Z yoshida@zend.co.jp $
*/
/**
* @see Zend_Validate
*/
-require_once 'Zend/Validate.php';
+// require_once 'Zend/Validate.php';
/**
* @see Zend_Validate_Hostname
*/
-require_once 'Zend/Validate/Hostname.php';
+// require_once 'Zend/Validate/Hostname.php';
/**
* Zend_Mail_Protocol_Abstract
*
* Provides low-level methods for concrete adapters to communicate with a remote mail server and track requests and responses.
- *
+ *
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Abstract.php 16219 2009-06-21 19:45:39Z thomas $
+ * @version $Id: Abstract.php 21635 2010-03-24 15:25:13Z yoshida@zend.co.jp $
* @todo Implement proxy settings
*/
abstract class Zend_Mail_Protocol_Abstract
@@ -60,6 +60,11 @@ abstract class Zend_Mail_Protocol_Abstract
*/
const TIMEOUT_CONNECTION = 30;
+ /**
+ * Maximum of the transaction log
+ */
+ const MAXIMUM_LOG = 64;
+
/**
* Hostname or IP address of remote server
@@ -106,15 +111,16 @@ abstract class Zend_Mail_Protocol_Abstract
/**
* String template for parsing server responses using sscanf (default: 3 digit code and response string)
* @var resource
+ * @deprecated Since 1.10.3
*/
protected $_template = '%d%s';
/**
* Log of mail requests and server responses for a session
- * @var string
+ * @var array
*/
- private $_log;
+ private $_log = array();
/**
@@ -134,7 +140,7 @@ abstract class Zend_Mail_Protocol_Abstract
/**
* @see Zend_Mail_Protocol_Exception
*/
- require_once 'Zend/Mail/Protocol/Exception.php';
+ // require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception(join(', ', $this->_validHost->getMessages()));
}
@@ -191,7 +197,7 @@ abstract class Zend_Mail_Protocol_Abstract
*/
public function getLog()
{
- return $this->_log;
+ return implode('', $this->_log);
}
@@ -202,9 +208,23 @@ abstract class Zend_Mail_Protocol_Abstract
*/
public function resetLog()
{
- $this->_log = '';
+ $this->_log = array();
}
+ /**
+ * Add the transaction log
+ *
+ * @param string new transaction
+ * @return void
+ */
+ protected function _addLog($value)
+ {
+ if (count($this->_log) >= self::MAXIMUM_LOG) {
+ array_shift($this->_log);
+ }
+
+ $this->_log[] = $value;
+ }
/**
* Connect to the server using the supplied transport and target
@@ -230,7 +250,7 @@ abstract class Zend_Mail_Protocol_Abstract
/**
* @see Zend_Mail_Protocol_Exception
*/
- require_once 'Zend/Mail/Protocol/Exception.php';
+ // require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception($errorStr);
}
@@ -238,7 +258,7 @@ abstract class Zend_Mail_Protocol_Abstract
/**
* @see Zend_Mail_Protocol_Exception
*/
- require_once 'Zend/Mail/Protocol/Exception.php';
+ // require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('Could not set stream timeout');
}
@@ -272,7 +292,7 @@ abstract class Zend_Mail_Protocol_Abstract
/**
* @see Zend_Mail_Protocol_Exception
*/
- require_once 'Zend/Mail/Protocol/Exception.php';
+ // require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('No connection has been established to ' . $this->_host);
}
@@ -281,13 +301,13 @@ abstract class Zend_Mail_Protocol_Abstract
$result = fwrite($this->_socket, $request . self::EOL);
// Save request to internal log
- $this->_log .= $request . self::EOL;
+ $this->_addLog($request . self::EOL);
if ($result === false) {
/**
* @see Zend_Mail_Protocol_Exception
*/
- require_once 'Zend/Mail/Protocol/Exception.php';
+ // require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('Could not send request to ' . $this->_host);
}
@@ -308,7 +328,7 @@ abstract class Zend_Mail_Protocol_Abstract
/**
* @see Zend_Mail_Protocol_Exception
*/
- require_once 'Zend/Mail/Protocol/Exception.php';
+ // require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('No connection has been established to ' . $this->_host);
}
@@ -321,7 +341,7 @@ abstract class Zend_Mail_Protocol_Abstract
$reponse = fgets($this->_socket, 1024);
// Save request to internal log
- $this->_log .= $reponse;
+ $this->_addLog($reponse);
// Check meta data to ensure connection is still valid
$info = stream_get_meta_data($this->_socket);
@@ -330,7 +350,7 @@ abstract class Zend_Mail_Protocol_Abstract
/**
* @see Zend_Mail_Protocol_Exception
*/
- require_once 'Zend/Mail/Protocol/Exception.php';
+ // require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception($this->_host . ' has timed out');
}
@@ -338,7 +358,7 @@ abstract class Zend_Mail_Protocol_Abstract
/**
* @see Zend_Mail_Protocol_Exception
*/
- require_once 'Zend/Mail/Protocol/Exception.php';
+ // require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('Could not read from ' . $this->_host);
}
@@ -359,8 +379,10 @@ abstract class Zend_Mail_Protocol_Abstract
protected function _expect($code, $timeout = null)
{
$this->_response = array();
- $cmd = '';
- $msg = '';
+ $cmd = '';
+ $more = '';
+ $msg = '';
+ $errMsg = '';
if (!is_array($code)) {
$code = array($code);
@@ -368,17 +390,23 @@ abstract class Zend_Mail_Protocol_Abstract
do {
$this->_response[] = $result = $this->_receive($timeout);
- sscanf($result, $this->_template, $cmd, $msg);
-
- if ($cmd === null || !in_array($cmd, $code)) {
- /**
- * @see Zend_Mail_Protocol_Exception
- */
- require_once 'Zend/Mail/Protocol/Exception.php';
- throw new Zend_Mail_Protocol_Exception($result);
+ list($cmd, $more, $msg) = preg_split('/([\s-]+)/', $result, 2, PREG_SPLIT_DELIM_CAPTURE);
+
+ if ($errMsg !== '') {
+ $errMsg .= ' ' . $msg;
+ } elseif ($cmd === null || !in_array($cmd, $code)) {
+ $errMsg = $msg;
}
- } while (strpos($msg, '-') === 0); // The '-' message prefix indicates an information string instead of a response string.
+ } while (strpos($more, '-') === 0); // The '-' message prefix indicates an information string instead of a response string.
+
+ if ($errMsg !== '') {
+ /**
+ * @see Zend_Mail_Protocol_Exception
+ */
+ // require_once 'Zend/Mail/Protocol/Exception.php';
+ throw new Zend_Mail_Protocol_Exception($errMsg);
+ }
return $msg;
}