|
|
@ -647,7 +647,7 @@ function iil_Connect($host, $user, $password, $options=null) {
|
|
|
|
$conn->capability = explode(' ', strtoupper($matches[1]));
|
|
|
|
$conn->capability = explode(' ', strtoupper($matches[1]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$conn->message .= $line . "\n";
|
|
|
|
$conn->message .= $line;
|
|
|
|
|
|
|
|
|
|
|
|
// TLS connection
|
|
|
|
// TLS connection
|
|
|
|
if ($ICL_SSL == 'tls' && iil_C_GetCapability($conn, 'STARTTLS')) {
|
|
|
|
if ($ICL_SSL == 'tls' && iil_C_GetCapability($conn, 'STARTTLS')) {
|
|
|
@ -672,6 +672,8 @@ function iil_Connect($host, $user, $password, $options=null) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$orig_method = $auth_method;
|
|
|
|
|
|
|
|
|
|
|
|
if ($auth_method == 'CHECK') {
|
|
|
|
if ($auth_method == 'CHECK') {
|
|
|
|
// check for supported auth methods
|
|
|
|
// check for supported auth methods
|
|
|
|
if (iil_C_GetCapability($conn, 'AUTH=CRAM-MD5') || iil_C_GetCapability($conn, 'AUTH=CRAM_MD5')) {
|
|
|
|
if (iil_C_GetCapability($conn, 'AUTH=CRAM-MD5') || iil_C_GetCapability($conn, 'AUTH=CRAM_MD5')) {
|
|
|
@ -689,7 +691,7 @@ function iil_Connect($host, $user, $password, $options=null) {
|
|
|
|
$line = trim(iil_ReadLine($conn->fp, 1024));
|
|
|
|
$line = trim(iil_ReadLine($conn->fp, 1024));
|
|
|
|
|
|
|
|
|
|
|
|
if ($line[0] == '+') {
|
|
|
|
if ($line[0] == '+') {
|
|
|
|
//got a challenge string, try CRAM-5
|
|
|
|
// got a challenge string, try CRAM-MD5
|
|
|
|
$result = iil_C_Authenticate($conn, $user, $password, substr($line,2));
|
|
|
|
$result = iil_C_Authenticate($conn, $user, $password, substr($line,2));
|
|
|
|
|
|
|
|
|
|
|
|
// stop if server sent BYE response
|
|
|
|
// stop if server sent BYE response
|
|
|
@ -698,20 +700,19 @@ function iil_Connect($host, $user, $password, $options=null) {
|
|
|
|
$iil_errornum = $conn->errorNum;
|
|
|
|
$iil_errornum = $conn->errorNum;
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$conn->message .= "AUTH CRAM-MD5: $result\n";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$conn->message .= "AUTH CRAM-MD5: failed\n";
|
|
|
|
if (!is_resource($result) && $orig_method == 'CHECK') {
|
|
|
|
$auth_method = 'PLAIN';
|
|
|
|
$auth_method = 'PLAIN';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!$result || $auth_method == 'PLAIN') {
|
|
|
|
if ($auth_method == 'PLAIN') {
|
|
|
|
// do plain text auth
|
|
|
|
// do plain text auth
|
|
|
|
$result = iil_C_Login($conn, $user, $password);
|
|
|
|
$result = iil_C_Login($conn, $user, $password);
|
|
|
|
$conn->message .= "AUTH PLAIN: $result\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!is_int($result)) {
|
|
|
|
if (is_resource($result)) {
|
|
|
|
iil_C_Namespace($conn);
|
|
|
|
iil_C_Namespace($conn);
|
|
|
|
return $conn;
|
|
|
|
return $conn;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|