cvs: pear /Net_Sieve Sieve.php
| From: | Anish Mistry | Date: | Wed, 16 Aug 2006 08:08:36 +0000 |
| Subject: | cvs: pear /Net_Sieve Sieve.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-41627@lists.php.net to get a copy of this message | ||
amistry Wed Aug 16 08:08:36 2006 UTC
Modified files:
/pear/Net_Sieve Sieve.php
Log:
Add Request #8071
Enable the ability to toggle TLS support if available.
http://cvs.php.net/viewvc.cgi/pear/Net_Sieve/Sieve.php?r1=1.11&r2=1.12&diff_format=u
Index: pear/Net_Sieve/Sieve.php
diff -u pear/Net_Sieve/Sieve.php:1.11 pear/Net_Sieve/Sieve.php:1.12
--- pear/Net_Sieve/Sieve.php:1.11 Wed Aug 16 07:52:41 2006
+++ pear/Net_Sieve/Sieve.php Wed Aug 16 08:08:36 2006
@@ -112,6 +112,12 @@
* @var boolean
*/
var $_bypassAuth = false;
+ /**
+ * Whether to use TLS if available
+ * @var boolean
+ */
+ var $_useTLS = true;
+
/**
@@ -155,8 +161,9 @@
* @param string $euser Effective User (if $user=admin, login as $euser)
* @param string $bypassAuth Skip the authentication phase. Useful if the socket
is already open.
+ * @param boolean $useTLS Use TLS if available
*/
- function Net_Sieve($user = null , $pass = null , $host = 'localhost', $port = 2000,
$logintype = '', $euser = '', $debug = false, $bypassAuth = false)
+ function Net_Sieve($user = null , $pass = null , $host = 'localhost', $port = 2000,
$logintype = '', $euser = '', $debug = false, $bypassAuth = false, $useTLS =
true)
{
$this->_state = NET_SIEVE_STATE_DISCONNECTED;
$this->_data['user'] = $user;
@@ -168,6 +175,7 @@
$this->_sock = &new Net_Socket();
$this->_debug = $debug;
$this->_bypassAuth = $bypassAuth;
+ $this->_useTLS = $useTLS;
/*
* Include the Auth_SASL package. If the package is not available,
* we disable the authentication methods that depend upon it.
@@ -218,7 +226,7 @@
*/
function _handleConnectAndLogin()
{
- if (PEAR::isError($res = $this->connect($this->_data['host'] ,
$this->_data['port'] ))) {
+ if (PEAR::isError($res = $this->connect($this->_data['host'] ,
$this->_data['port'], $this->_useTLS ))) {
return $res;
}
if($this->_bypassAuth === false) {
@@ -345,9 +353,10 @@
* @param string $host Hostname of server
* @param string $port Port of server
* @param array $options List of options to pass to connect
+ * @param boolean $useTLS Use TLS if available
* @return mixed True on success, PEAR_Error otherwise
*/
- function connect($host, $port, $options = null)
+ function connect($host, $port, $options = null, $useTLS = true)
{
if (NET_SIEVE_STATE_DISCONNECTED != $this->_state) {
$msg='Not currently in DISCONNECTED state';
@@ -380,10 +389,12 @@
// Get logon greeting/capability and parse
$this->_parseCapability($res);
- // check if we can enable TLS via STARTTLS
- if(isset($this->_capability['starttls']) &&
function_exists('stream_socket_enable_crypto') === true) {
- if (PEAR::isError($res = $this->_startTLS())) {
- return $res;
+ if($useTLS === true) {
+ // check if we can enable TLS via STARTTLS
+ if(isset($this->_capability['starttls']) &&
function_exists('stream_socket_enable_crypto') === true) {
+ if (PEAR::isError($res = $this->_startTLS())) {
+ return $res;
+ }
}
}