| | |
| | | |
| | | do { |
| | | if ($this->eof()) { |
| | | return $line ? $line : null; |
| | | return $line ?: null; |
| | | } |
| | | |
| | | $buffer = fgets($this->fp, $size); |
| | |
| | | } |
| | | } |
| | | |
| | | return !empty($result) ? $result : false; |
| | | return $result ?: false; |
| | | } |
| | | |
| | | /** |
| | |
| | | return false; |
| | | } |
| | | |
| | | if (!stream_socket_enable_crypto($this->fp, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { |
| | | if (isset($this->prefs['socket_options']['ssl']['crypto_method'])) { |
| | | $crypto_method = $this->prefs['socket_options']['ssl']['crypto_method']; |
| | | } |
| | | else { |
| | | // There is no flag to enable all TLS methods. Net_SMTP |
| | | // handles enabling TLS similarly. |
| | | $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT |
| | | | @STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT |
| | | | @STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; |
| | | } |
| | | |
| | | if (!stream_socket_enable_crypto($this->fp, true, $crypto_method)) { |
| | | $this->setError(self::ERROR_BAD, "Unable to negotiate TLS"); |
| | | $this->closeConnection(); |
| | | return false; |
| | |
| | | list($code, $response) = $this->execute('STATUS', array($this->escape($mailbox), |
| | | '(' . implode(' ', (array) $items) . ')')); |
| | | |
| | | if ($code == self::ERROR_OK && preg_match('/\* STATUS /i', $response)) { |
| | | if ($code == self::ERROR_OK && preg_match('/^\* STATUS /i', $response)) { |
| | | $result = array(); |
| | | $response = substr($response, 9); // remove prefix "* STATUS " |
| | | |
| | |
| | | !empty($args) ? '(' . implode(' ', (array) $args) . ')' : $this->escape(null) |
| | | )); |
| | | |
| | | if ($code == self::ERROR_OK && preg_match('/\* ID /i', $response)) { |
| | | if ($code == self::ERROR_OK && preg_match('/^\* ID /i', $response)) { |
| | | $response = substr($response, 5); // remove prefix "* ID " |
| | | $items = $this->tokenizeResponse($response, 1); |
| | | $result = null; |
| | |
| | | |
| | | list($code, $response) = $this->execute('ENABLE', $extension); |
| | | |
| | | if ($code == self::ERROR_OK && preg_match('/\* ENABLED /i', $response)) { |
| | | if ($code == self::ERROR_OK && preg_match('/^\* ENABLED /i', $response)) { |
| | | $response = substr($response, 10); // remove prefix "* ENABLED " |
| | | $result = (array) $this->tokenizeResponse($response); |
| | | |
| | |
| | | if (!is_numeric(($bytes = substr($str, 1, $epos - 1)))) { |
| | | // error |
| | | } |
| | | |
| | | $result[] = $bytes ? substr($str, $epos + 3, $bytes) : ''; |
| | | // Advance the string |
| | | $str = substr($str, $epos + 3 + $bytes); |
| | | $str = substr($str, $epos + 3 + $bytes); |
| | | break; |
| | | |
| | | // Quoted string |
| | |
| | | } |
| | | } |
| | | } |
| | | if ($str[$pos] != '"') { |
| | | // error |
| | | } |
| | | |
| | | // we need to strip slashes for a quoted string |
| | | $result[] = stripslashes(substr($str, 1, $pos - 1)); |
| | | $str = substr($str, $pos + 1); |
| | |
| | | |
| | | // Parenthesized list |
| | | case '(': |
| | | $str = substr($str, 1); |
| | | $str = substr($str, 1); |
| | | $result[] = self::tokenizeResponse($str); |
| | | break; |
| | | |
| | | case ')': |
| | | $str = substr($str, 1); |
| | | return $result; |
| | | break; |
| | | |
| | | // String atom, number, astring, NIL, *, % |
| | | default: |
| | |
| | | // we do not exclude [ and ] (#1489223) |
| | | if (preg_match('/^([^\x00-\x20\x29\x7F]+)/', $str, $m)) { |
| | | $result[] = $m[1] == 'NIL' ? null : $m[1]; |
| | | $str = substr($str, strlen($m[1])); |
| | | $str = substr($str, strlen($m[1])); |
| | | } |
| | | break; |
| | | } |