| | |
| | | const ERROR_UNKNOWN = -4; |
| | | |
| | | const COMMAND_NORESPONSE = 1; |
| | | const COMMAND_CAPABILITY = 2; |
| | | |
| | | /** |
| | | * Object constructor |
| | |
| | | |
| | | // RFC 4959 (SASL-IR): save one round trip |
| | | if ($this->getCapability('SASL-IR')) { |
| | | $result = $this->execute("AUTHENTICATE PLAIN", array($reply), self::COMMAND_NORESPONSE); |
| | | $result = $this->execute("AUTHENTICATE PLAIN", array($reply), |
| | | self::COMMAND_NORESPONSE | self::COMMAND_CAPABILITY); |
| | | } |
| | | else { |
| | | $this->putLine($this->next_tag() . " AUTHENTICATE PLAIN"); |
| | |
| | | } |
| | | |
| | | if ($result == self::ERROR_OK) { |
| | | // optional CAPABILITY response |
| | | if ($line && preg_match('/\[CAPABILITY ([^]]+)\]/i', $line, $matches)) { |
| | | $this->parseCapability($matches[1]); |
| | | } |
| | | return $this->fp; |
| | | } |
| | | else { |
| | |
| | | function login($user, $password) |
| | | { |
| | | list($code, $response) = $this->execute('LOGIN', array( |
| | | $this->escape($user), $this->escape($password))); |
| | | $this->escape($user), $this->escape($password)), self::COMMAND_CAPABILITY); |
| | | |
| | | // re-set capabilities list if untagged CAPABILITY response provided |
| | | if (preg_match('/\* CAPABILITY (.+)/i', $response, $matches)) { |
| | |
| | | $response = substr($response, 0, -$line_len); |
| | | } |
| | | |
| | | // optional CAPABILITY response |
| | | if (($options & self::COMMAND_CAPABILITY) && $code == self::ERROR_OK |
| | | && preg_match('/\[CAPABILITY ([^]]+)\]/i', $line, $matches) |
| | | ) { |
| | | $this->parseCapability($matches[1]); |
| | | } |
| | | |
| | | return $noresp ? $code : array($code, $response); |
| | | } |
| | | |