alecpl
2010-04-23 63bff1dd31363b8e4d974fc0fcba849f3685a08f
program/include/rcube_imap_generic.php
@@ -26,6 +26,12 @@
*/
/**
 * Struct representing an e-mail message header
 *
 * @package    Mail
 * @author     Aleksander Machniak <alec@alec.pl>
 */
class rcube_mail_header
{
   public $id;
@@ -65,7 +71,17 @@
   public $others = array();
}
// For backward compatibility with cached messages (#1486602)
class iilBasicHeader extends rcube_mail_header
{
}
/**
 * PHP based wrapper class to connect to an IMAP server
 *
 * @package    Mail
 * @author     Aleksander Machniak <alec@alec.pl>
 */
class rcube_imap_generic
{
    public $error;
@@ -366,7 +382,7 @@
        }
    
        // generate hash
        $hash  = md5($this->xor($pass,$opad) . pack("H*", md5($this->xor($pass, $ipad) . base64_decode($encChallenge))));
        $hash  = md5($this->_xor($pass,$opad) . pack("H*", md5($this->_xor($pass, $ipad) . base64_decode($encChallenge))));
    
        // generate reply
        $reply = base64_encode($user . ' ' . $hash);
@@ -378,14 +394,12 @@
        // process result
        $result = $this->parseResult($line);
        if ($result == 0) {
            $this->error    .= '';
            $this->errornum  = 0;
            $this->errornum = 0;
            return $this->fp;
        }
        $this->error    .= 'Authentication for ' . $user . ' failed (AUTH): "';
        $this->error    .= htmlspecialchars($line) . '"';
        $this->errornum  = $result;
        $this->error    = "Authentication for $user failed (AUTH): $line";
        $this->errornum = $result;
        return $result;
    }
@@ -400,17 +414,15 @@
        $result = $this->parseResult($line);
        if ($result == 0) {
            $this->error    .= '';
            $this->errornum  = 0;
            $this->errornum = 0;
            return $this->fp;
        }
        fclose($this->fp);
        $this->fp = false;
    
        $this->error    .= 'Authentication for ' . $user . ' failed (LOGIN): "';
        $this->error    .= htmlspecialchars($line)."\"";
        $this->errornum  = $result;
        $this->error    = "Authentication for $user failed (LOGIN): $line";
        $this->errornum = $result;
        return $result;
    }
@@ -1553,18 +1565,19 @@
       return false;   
    }
    function search($folder, $criteria)
    function search($folder, $criteria, $return_uid=false)
    {
       if (!$this->select($folder)) {
          return false;
       }
       $data = '';
       $query = "srch1 SEARCH " . chop($criteria);
       $query = 'srch1 ' . ($return_uid ? 'UID ' : '') . 'SEARCH ' . chop($criteria);
       if (!$this->putLineC($query)) {
          return false;
       }
       do {
          $line = trim($this->readLine());
          if ($this->startsWith($line, '* SEARCH')) {
@@ -2150,7 +2163,7 @@
       return $result;
    }
    private function xor($string, $string2)
    private function _xor($string, $string2)
    {
       $result = '';
       $size = strlen($string);