Example #1
0
 static function validate_login_imap($username, $password)
 {
     $hostname = explode(":", SETUP_AUTH_HOSTNAME_IMAP);
     if (!isset($hostname[1])) {
         $hostname[1] = 143;
     }
     if (isset($hostname[2]) and !extension_loaded("openssl")) {
         sys_log_message_alert("login", sprintf("{t}%s is not compiled / loaded into PHP.{/t}", "IMAP / OpenSSL"));
         return false;
     }
     $imap = new Net_IMAP();
     if (PEAR::isError($e = $imap->connect((isset($hostname[2]) ? $hostname[2] . "://" : "") . $hostname[0], $hostname[1]))) {
         sys_log_message_alert("login", sprintf("{t}Connection error: %s [%s]{/t} ({t}Username{/t}: %s, %s)", _login_get_remoteaddr(), "IMAP", $username, $e->getMessage()));
         return false;
     } else {
         if (PEAR::isError($e = $imap->login($username, $password))) {
             sys_log_message_alert("login", sprintf("{t}Login failed from %s.{/t} (imap) ({t}Username{/t}: %s, %s)", _login_get_remoteaddr(), $username, $e->getMessage()));
             return false;
         }
     }
     return true;
 }