Changeset 8fcc3e1 in github


Ignore:
Timestamp:
Oct 14, 2010 6:22:25 AM (3 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
0f0c17a
Parents:
1c1e1e3
Message:
  • Improved IMAP errors handling
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • index.php

    r249db18 r8fcc3e1  
    119119  } 
    120120  else { 
    121     $OUTPUT->show_message($IMAP->error_code < -1 ? 'imaperror' : 'loginfailed', 'warning'); 
    122     $RCMAIL->plugins->exec_hook('login_failed', array('code' => $IMAP->error_code, 'host' => $auth['host'], 'user' => $auth['user'])); 
     121    $OUTPUT->show_message($IMAP->get_error_code() < -1 ? 'imaperror' : 'loginfailed', 'warning'); 
     122    $RCMAIL->plugins->exec_hook('login_failed', array( 
     123      'code' => $IMAP->get_error_code(), 'host' => $auth['host'], 'user' => $auth['user'])); 
    123124    $RCMAIL->kill_session(); 
    124125  } 
  • program/include/rcube_imap.php

    r29983c1 r8fcc3e1  
    3333{ 
    3434    public $debug_level = 1; 
    35     public $error_code = 0; 
    3635    public $skip_deleted = false; 
    3736    public $root_dir = ''; 
     
    174173        // write error log 
    175174        else if ($this->conn->error) { 
    176             $this->error_code = $this->conn->errornum; 
    177175            if ($pass && $user) 
    178176                raise_error(array('code' => 403, 'type' => 'imap', 
     
    214212    } 
    215213 
     214 
     215    /** 
     216     * Returns code of last error 
     217     * 
     218     * @return int Error code 
     219     */ 
     220    function get_error_code() 
     221    { 
     222        return ($this->conn) ? $this->conn->errornum : 0; 
     223    } 
     224 
     225 
     226    /** 
     227     * Returns message of last error 
     228     * 
     229     * @return string Error message 
     230     */ 
     231    function get_error_str() 
     232    { 
     233        return ($this->conn) ? $this->conn->error : ''; 
     234    } 
    216235     
     236 
    217237    /** 
    218238     * Set options to be used in rcube_imap_generic::connect() 
     
    569589            return count($this->icache['threads']['tree']); 
    570590 
    571         list ($thread_tree, $msg_depth, $has_children) = $this->_fetch_threads($mailbox); 
    572  
    573         $msg_count = count($msg_depth); 
    574  
    575 //    $this->update_thread_cache($mailbox, $thread_tree, $msg_depth, $has_children); 
     591        if (is_array($result = $this->_fetch_threads($mailbox))) 
     592            $thread_tree = array_shift($result); 
     593 
     594//        list ($thread_tree, $msg_depth, $has_children) = $result; 
     595//        $this->update_thread_cache($mailbox, $thread_tree, $msg_depth, $has_children); 
    576596        return count($thread_tree); 
    577597    } 
  • program/include/rcube_imap_generic.php

    r393ba71 r8fcc3e1  
    113113    private $prefs; 
    114114 
     115    const ERROR_OK = 0; 
     116    const ERROR_NO = -1; 
     117    const ERROR_BAD = -2; 
     118    const ERROR_BYE = -3; 
     119    const ERROR_COMMAND = -5; 
     120    const ERROR_UNKNOWN = -4; 
     121 
    115122    /** 
    116123     * Object constructor 
     
    265272    } 
    266273 
    267     function parseResult($string) 
    268     { 
    269             $a = explode(' ', trim($string)); 
    270             if (count($a) >= 2) { 
    271                     $res = strtoupper($a[1]); 
     274    function parseResult($string, $err_prefix='') 
     275    { 
     276            if (preg_match('/^[a-z0-9*]+ (OK|NO|BAD|BYE)(.*)$/i', trim($string), $matches)) { 
     277                    $res = strtoupper($matches[1]); 
     278            $str = trim($matches[2]); 
     279 
    272280                    if ($res == 'OK') { 
    273                             return 0; 
     281                            return self::ERROR_OK; 
    274282                    } else if ($res == 'NO') { 
    275                             return -1; 
     283                $this->errornum = self::ERROR_NO; 
    276284                    } else if ($res == 'BAD') { 
    277                             return -2; 
     285                            $this->errornum = self::ERROR_BAD; 
    278286                    } else if ($res == 'BYE') { 
    279287                @fclose($this->fp); 
    280288                $this->fp = null; 
    281                             return -3; 
    282                     } 
    283             } 
    284             return -4; 
     289                            $this->errornum = self::ERROR_BYE; 
     290                    } 
     291 
     292            if ($str) 
     293                $this->error = $err_prefix ? $err_prefix.$str : $str; 
     294 
     295                return $this->errornum; 
     296            } 
     297            return self::ERROR_UNKNOWN; 
     298    } 
     299 
     300    private function set_error($code, $msg='') 
     301    { 
     302        $this->errornum = $code; 
     303        $this->error    = $msg; 
    285304    } 
    286305 
     
    378397        // process result 
    379398        $result = $this->parseResult($line); 
    380         if ($result == 0) { 
    381             $this->errornum = 0; 
     399        if ($result == self::ERROR_OK) { 
    382400            return $this->fp; 
    383401        } 
    384402 
    385         $this->error    = "Authentication for $user failed (AUTH): $line"; 
    386         $this->errornum = $result; 
     403        $this->error = "Authentication for $user failed (AUTH): $line"; 
    387404 
    388405        return $result; 
     
    403420        $result = $this->parseResult($line); 
    404421 
    405         if ($result == 0) { 
    406             $this->errornum = 0; 
     422        if ($result == self::ERROR_OK) { 
    407423            return $this->fp; 
    408424        } 
    409425 
    410426        @fclose($this->fp); 
    411         $this->fp = false; 
    412  
    413         $this->error    = "Authentication for $user failed (LOGIN): $line"; 
    414         $this->errornum = $result; 
     427        $this->fp    = false; 
     428        $this->error = "Authentication for $user failed (LOGIN): $line"; 
    415429 
    416430        return $result; 
     
    551565            // initialize connection 
    552566            $this->error    = ''; 
    553             $this->errornum = 0; 
     567            $this->errornum = self::ERROR_OK; 
    554568            $this->selected = ''; 
    555569            $this->user     = $user; 
     
    559573            // check input 
    560574            if (empty($host)) { 
    561                     $this->error    = "Empty host"; 
    562                     $this->errornum = -2; 
     575                    $this->set_error(self::ERROR_BAD, "Empty host"); 
    563576                    return false; 
    564577            } 
    565578        if (empty($user)) { 
    566                     $this->error    = "Empty user"; 
    567                 $this->errornum = -1; 
     579                $this->set_error(self::ERROR_NO, "Empty user"); 
    568580                return false; 
    569581            } 
    570582            if (empty($password)) { 
    571                 $this->error    = "Empty password"; 
    572                 $this->errornum = -1; 
     583                $this->set_error(self::ERROR_NO, "Empty password"); 
    573584                    return false; 
    574585            } 
     
    589600 
    590601            if (!$this->fp) { 
    591                 $this->error    = sprintf("Could not connect to %s:%d: %s", $host, $this->prefs['port'], $errstr); 
    592                 $this->errornum = -2; 
     602                $this->set_error(self::ERROR_BAD, sprintf("Could not connect to %s:%d: %s", $host, $this->prefs['port'], $errstr)); 
    593603                    return false; 
    594604            } 
     
    609619                    else 
    610620                            $this->error = sprintf("Empty startup greeting (%s:%d)", $host, $this->prefs['port']); 
    611                 $this->errornum = -2; 
     621                $this->errornum = self::ERROR_BAD; 
    612622                return false; 
    613623            } 
     
    627637                            $line = $this->readLine(4096); 
    628638                if (!preg_match('/^tls0 OK/', $line)) { 
    629                                     $this->error    = "Server responded to STARTTLS with: $line"; 
    630                                     $this->errornum = -2; 
     639                                    $this->set_error(self::ERROR_BAD, "Server responded to STARTTLS with: $line"); 
    631640                    return false; 
    632641                } 
    633642 
    634643                            if (!stream_socket_enable_crypto($this->fp, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { 
    635                                     $this->error    = "Unable to negotiate TLS"; 
    636                                     $this->errornum = -2; 
     644                                    $this->set_error(self::ERROR_BAD, "Unable to negotiate TLS"); 
    637645                                    return false; 
    638646                            } 
     
    666674 
    667675                            // stop if server sent BYE response 
    668                             if ($result == -3) { 
     676                            if ($result == self::ERROR_BYE) { 
    669677                                    return false; 
    670678                            } 
     
    718726            } 
    719727 
    720             if ($this->putLine("sel1 SELECT \"".$this->escape($mailbox).'"')) { 
    721                     do { 
    722                             $line = rtrim($this->readLine(512)); 
    723  
    724                             if (preg_match('/^\* ([0-9]+) (EXISTS|RECENT)$/', $line, $m)) { 
    725                                 $token = strtolower($m[2]); 
    726                                 $this->$token = (int) $m[1]; 
    727                             } 
    728                             else if (preg_match('/\[?PERMANENTFLAGS\s+\(([^\)]+)\)\]/U', $line, $match)) { 
    729                                     $this->permanentflags = explode(' ', $match[1]); 
    730                             } 
    731                     } while (!$this->startsWith($line, 'sel1', true, true)); 
    732  
    733             if ($this->parseResult($line) == 0) { 
    734                             $this->selected = $mailbox; 
    735                             return true; 
    736                     } 
    737             } 
    738  
    739         $this->error = "Couldn't select $mailbox"; 
     728        $command = "sel1 SELECT \"".$this->escape($mailbox).'"'; 
     729 
     730            if (!$this->putLine($command)) { 
     731            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $command"); 
     732            return false; 
     733        } 
     734 
     735                do { 
     736                        $line = rtrim($this->readLine(512)); 
     737 
     738                        if (preg_match('/^\* ([0-9]+) (EXISTS|RECENT)$/', $line, $m)) { 
     739                            $token = strtolower($m[2]); 
     740                            $this->$token = (int) $m[1]; 
     741                        } 
     742                        else if (preg_match('/\[?PERMANENTFLAGS\s+\(([^\)]+)\)\]/U', $line, $match)) { 
     743                            $this->permanentflags = explode(' ', $match[1]); 
     744                        } 
     745                } while (!$this->startsWith($line, 'sel1', true, true)); 
     746 
     747        if ($this->parseResult($line, 'SELECT: ') == self::ERROR_OK) { 
     748                    $this->selected = $mailbox; 
     749                        return true; 
     750                } 
     751 
    740752        return false; 
    741753    } 
     
    802814 
    803815            if (!$this->putLineC($command)) { 
     816            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $command"); 
    804817                return false; 
    805818            } 
     
    813826            } while (!$this->startsWith($line, 's ', true, true)); 
    814827 
    815             $result_code = $this->parseResult($line); 
    816             if ($result_code != 0) { 
    817             $this->error = "Sort: $line"; 
     828            $result_code = $this->parseResult($line, 'SORT: '); 
     829            if ($result_code != self::ERROR_OK) { 
    818830            return false; 
    819831            } 
     
    883895 
    884896            if (!$this->putLine($request)) { 
     897            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $request"); 
    885898                    return false; 
    886899        } 
     
    10161029 
    10171030            $result = -1; 
    1018                 if ($this->putLine("fuid FETCH $id (UID)")) { 
    1019                     do { 
    1020                             $line = rtrim($this->readLine(1024)); 
    1021                                 if (preg_match("/^\* $id FETCH \(UID (.*)\)/i", $line, $r)) { 
    1022                                         $result = $r[1]; 
    1023                                 } 
    1024                         } while (!$this->startsWith($line, 'fuid', true, true)); 
    1025                 } 
     1031        $command = "fuid FETCH $id (UID)"; 
     1032 
     1033                if (!$this->putLine($command)) { 
     1034            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $command"); 
     1035            return -1; 
     1036        } 
     1037 
     1038            do { 
     1039                    $line = rtrim($this->readLine(1024)); 
     1040                        if (preg_match("/^\* $id FETCH \(UID (.*)\)/i", $line, $r)) { 
     1041                                $result = $r[1]; 
     1042                        } 
     1043                } while (!$this->startsWith($line, 'fuid', true, true)); 
    10261044 
    10271045        return $result; 
     
    10641082 
    10651083            if (!$this->putLine($request)) { 
     1084            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $request"); 
    10661085                    return false; 
    10671086            } 
     
    13691388 
    13701389        $c = 0; 
    1371                 $command = $messages ? "UID EXPUNGE $messages" : "EXPUNGE"; 
    1372  
    1373                 if (!$this->putLine("exp1 $command")) { 
     1390                $command = $messages ? "exp1 UID EXPUNGE $messages" : "exp1 EXPUNGE"; 
     1391 
     1392                if (!$this->putLine($command)) { 
     1393            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $command"); 
    13741394            return -1; 
    13751395        } 
     
    13821402                } while (!$this->startsWith($line, 'exp1', true, true)); 
    13831403 
    1384                 if ($this->parseResult($line) == 0) { 
     1404                if ($this->parseResult($line, 'EXPUNGE: ') == self::ERROR_OK) { 
    13851405                        $this->selected = ''; // state has changed, need to reselect 
    13861406                        return $c; 
    13871407                } 
    1388                 $this->error = $line; 
     1408 
    13891409            return -1; 
    13901410    } 
     
    14031423 
    14041424        $c = 0; 
    1405             if (!$this->putLine("flg UID STORE $messages {$mod}FLAGS ($flag)")) { 
     1425        $command = "flg UID STORE $messages {$mod}FLAGS ($flag)"; 
     1426            if (!$this->putLine($command)) { 
     1427            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $command"); 
    14061428            return false; 
    14071429        } 
     
    14141436            } while (!$this->startsWith($line, 'flg', true, true)); 
    14151437 
    1416             if ($this->parseResult($line) == 0) { 
     1438            if ($this->parseResult($line, 'STORE: ') == self::ERROR_OK) { 
    14171439                    return $c; 
    14181440            } 
    14191441 
    1420             $this->error = $line; 
    14211442            return -1; 
    14221443    } 
     
    14441465            } 
    14451466 
    1446         $this->putLine("cpy1 UID COPY $messages \"".$this->escape($to)."\""); 
    1447             $line = $this->readReply(); 
    1448             return $this->parseResult($line); 
     1467        $command = "cpy1 UID COPY $messages \"".$this->escape($to)."\""; 
     1468 
     1469        if (!$this->putLine($command)) { 
     1470            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $command"); 
     1471        } 
     1472 
     1473        $line = $this->readReply(); 
     1474            return $this->parseResult($line, 'COPY: '); 
    14491475    } 
    14501476 
     
    15261552        $data      = ''; 
    15271553 
    1528             if (!$this->putLineC("thrd1 THREAD $algorithm $encoding $criteria")) { 
     1554        $command = "thrd1 THREAD $algorithm $encoding $criteria"; 
     1555 
     1556            if (!$this->putLineC($command)) { 
     1557            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $command"); 
    15291558                    return false; 
    15301559            } 
     
    15381567            } while (!$this->startsWith($line, 'thrd1', true, true)); 
    15391568 
    1540         $result_code = $this->parseResult($line); 
    1541             if ($result_code == 0) { 
     1569        $result_code = $this->parseResult($line, 'THREAD: '); 
     1570            if ($result_code == self::ERROR_OK) { 
    15421571            $depthmap    = array(); 
    15431572            $haschildren = array(); 
     
    15461575            } 
    15471576 
    1548         $this->error = "Thread: $line"; 
    15491577            return false; 
    15501578    } 
     
    15671595 
    15681596            if (!$this->putLineC($query)) { 
     1597            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $query"); 
    15691598                    return false; 
    15701599            } 
     
    15791608        } while (!$this->startsWith($line, 'srch1', true, true)); 
    15801609 
    1581             $result_code = $this->parseResult($line); 
    1582             if ($result_code == 0) { 
     1610            $result_code = $this->parseResult($line, 'SEARCH: '); 
     1611            if ($result_code == self::ERROR_OK) { 
    15831612                    return preg_split('/\s+/', $data, -1, PREG_SPLIT_NO_EMPTY); 
    15841613            } 
    15851614 
    1586         $this->error = "Search: $line"; 
    15871615            return false; 
    15881616    } 
     
    16331661        $ref = $this->escape($ref); 
    16341662        $mailbox = $this->escape($mailbox); 
     1663        $query = $key." ".$command." \"". $ref ."\" \"". $mailbox ."\""; 
    16351664 
    16361665        // send command 
    1637             if (!$this->putLine($key." ".$command." \"". $ref ."\" \"". $mailbox ."\"")) { 
    1638                     $this->error = "Couldn't send $command command"; 
     1666            if (!$this->putLine($query)) { 
     1667            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $query"); 
    16391668                return false; 
    16401669            } 
     
    16581687            if (is_array($folders)) { 
    16591688            return $folders; 
    1660             } else if ($this->parseResult($line) == 0) { 
     1689            } else if ($this->parseResult($line, $command.': ') == self::ERROR_OK) { 
    16611690            return array(); 
    16621691        } 
    16631692 
    1664             $this->error = $line; 
    16651693        return false; 
    16661694    } 
     
    16871715            // send request 
    16881716            if (!$this->putLine($request)) { 
     1717            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $request"); 
    16891718                return false; 
    16901719            } 
     
    17421771        // send request 
    17431772                if (!$this->putLine($request)) { 
     1773            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $request"); 
    17441774                    return false; 
    17451775                } 
     
    18671897    function createFolder($folder) 
    18681898    { 
    1869             if ($this->putLine('c CREATE "' . $this->escape($folder) . '"')) { 
    1870                     do { 
    1871                             $line = $this->readLine(300); 
    1872                     } while (!$this->startsWith($line, 'c ', true, true)); 
    1873                     return ($this->parseResult($line) == 0); 
    1874             } 
    1875             return false; 
     1899        $command = 'c CREATE "' . $this->escape($folder) . '"'; 
     1900     
     1901            if (!$this->putLine($command)) { 
     1902            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $command"); 
     1903            return false; 
     1904        } 
     1905 
     1906            do { 
     1907                    $line = $this->readLine(300); 
     1908            } while (!$this->startsWith($line, 'c ', true, true)); 
     1909 
     1910            return ($this->parseResult($line, 'CREATE: ') == self::ERROR_OK); 
    18761911    } 
    18771912 
    18781913    function renameFolder($from, $to) 
    18791914    { 
    1880             if ($this->putLine('r RENAME "' . $this->escape($from) . '" "' . $this->escape($to) . '"')) { 
    1881                     do { 
    1882                             $line = $this->readLine(300); 
    1883                     } while (!$this->startsWith($line, 'r ', true, true)); 
    1884                     return ($this->parseResult($line) == 0); 
    1885             } 
    1886             return false; 
     1915        $command = 'r RENAME "' . $this->escape($from) . '" "' . $this->escape($to) . '"'; 
     1916     
     1917            if (!$this->putLine($command)) { 
     1918            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $command"); 
     1919            return false; 
     1920        } 
     1921                do { 
     1922                    $line = $this->readLine(300); 
     1923                } while (!$this->startsWith($line, 'r ', true, true)); 
     1924 
     1925                return ($this->parseResult($line, 'RENAME: ') == self::ERROR_OK); 
    18871926    } 
    18881927 
    18891928    function deleteFolder($folder) 
    18901929    { 
    1891             if ($this->putLine('d DELETE "' . $this->escape($folder). '"')) { 
    1892                     do { 
    1893                             $line = $this->readLine(300); 
    1894                     } while (!$this->startsWith($line, 'd ', true, true)); 
    1895                     return ($this->parseResult($line) == 0); 
    1896             } 
    1897             return false; 
     1930        $command = 'd DELETE "' . $this->escape($folder). '"'; 
     1931     
     1932            if (!$this->putLine($command)) { 
     1933            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $command"); 
     1934            return false; 
     1935        } 
     1936            do { 
     1937                    $line = $this->readLine(300); 
     1938            } while (!$this->startsWith($line, 'd ', true, true)); 
     1939 
     1940            return ($this->parseResult($line, 'DELETE: ') == self::ERROR_OK); 
    18981941    } 
    18991942 
     
    19091952    function subscribe($folder) 
    19101953    { 
    1911             $query = 'sub1 SUBSCRIBE "' . $this->escape($folder). '"'; 
    1912             $this->putLine($query); 
     1954            $command = 'sub1 SUBSCRIBE "' . $this->escape($folder). '"'; 
     1955 
     1956            if (!$this->putLine($command)) { 
     1957            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $command"); 
     1958            return false; 
     1959        } 
    19131960 
    19141961        $line = trim($this->readLine(512)); 
    1915             return ($this->parseResult($line) == 0); 
     1962            return ($this->parseResult($line, 'SUBSCRIBE: ') == self::ERROR_OK); 
    19161963    } 
    19171964 
    19181965    function unsubscribe($folder) 
    19191966    { 
    1920         $query = 'usub1 UNSUBSCRIBE "' . $this->escape($folder) . '"'; 
    1921             $this->putLine($query); 
     1967        $command = 'usub1 UNSUBSCRIBE "' . $this->escape($folder) . '"'; 
     1968 
     1969            if (!$this->putLine($command)) { 
     1970            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $command"); 
     1971            return false; 
     1972        } 
    19221973 
    19231974            $line = trim($this->readLine(512)); 
    1924             return ($this->parseResult($line) == 0); 
     1975            return ($this->parseResult($line, 'UNSUBSCRIBE: ') == self::ERROR_OK); 
    19251976    } 
    19261977 
     
    19451996 
    19461997                if ($line[0] != '+') { 
    1947                         // $errornum = $this->parseResult($line); 
    1948                         $this->error = "Cannot write to folder: $line"; 
     1998                        $this->parseResult($line, 'APPEND: '); 
    19491999                            return false; 
    19502000                } 
     
    19582008                } while (!$this->startsWith($line, 'a ', true, true)); 
    19592009 
    1960                 $result = ($this->parseResult($line) == 0); 
    1961                     if (!$result) { 
    1962                         $this->error = $line; 
    1963                     } 
    1964                 return $result; 
    1965             } 
    1966  
    1967             $this->error = "Couldn't send command \"$request\""; 
     2010                return ($this->parseResult($line, 'APPEND: ') == self::ERROR_OK); 
     2011            } 
     2012        else { 
     2013            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $request"); 
     2014        } 
     2015 
    19682016            return false; 
    19692017    } 
     
    19812029            } 
    19822030            if (!$in_fp) { 
    1983                     $this->error = "Couldn't open $path for reading"; 
     2031                    $this->set_error(self::ERROR_UNKNOWN, "Couldn't open $path for reading"); 
    19842032                    return false; 
    19852033            } 
     
    20032051 
    20042052                    if ($line[0] != '+') { 
    2005                             //$errornum = $this->parseResult($line); 
    2006                             $this->error = "Cannot write to folder: $line"; 
     2053                            $this->parseResult($line, 'APPEND: '); 
    20072054                            return false; 
    20082055                    } 
     
    20292076                    } while (!$this->startsWith($line, 'a ', true, true)); 
    20302077 
    2031                     $result = ($this->parseResult($line) == 0); 
    2032                     if (!$result) { 
    2033                         $this->error = $line; 
    2034                     } 
    2035  
    2036                     return $result; 
    2037             } 
    2038  
    2039         $this->error = "Couldn't send command \"$request\""; 
     2078                     
     2079                    return ($this->parseResult($line, 'APPEND: ') == self::ERROR_OK); 
     2080            } 
     2081        else { 
     2082            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $request"); 
     2083        } 
     2084 
    20402085            return false; 
    20412086    } 
     
    20492094                $key = 'F1247'; 
    20502095        $result = false; 
    2051  
    2052                 if ($this->putLine($key . ($is_uid ? ' UID' : '') ." FETCH $id (BODYSTRUCTURE)")) { 
     2096        $command = $key . ($is_uid ? ' UID' : '') ." FETCH $id (BODYSTRUCTURE)"; 
     2097 
     2098                if ($this->putLine($command)) { 
    20532099                        do { 
    20542100                                $line = $this->readLine(5000); 
     
    20602106                        $result = trim(substr($result, strpos($result, 'BODYSTRUCTURE')+13, -1)); 
    20612107                } 
     2108        else { 
     2109            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $command"); 
     2110        } 
    20622111 
    20632112        return $result; 
     
    20742123            $result      = false; 
    20752124            $quota_lines = array(); 
     2125        $command     = 'QUOT1 GETQUOTAROOT "INBOX"'; 
    20762126 
    20772127            // get line(s) containing quota info 
    2078             if ($this->putLine('QUOT1 GETQUOTAROOT "INBOX"')) { 
     2128            if ($this->putLine($command)) { 
    20792129                    do { 
    20802130                            $line = rtrim($this->readLine(5000)); 
     
    20842134                    } while (!$this->startsWith($line, 'QUOT1', true, true)); 
    20852135            } 
     2136        else { 
     2137            $this->set_error(self::ERROR_COMMAND, "Unable to send command: $command"); 
     2138        } 
    20862139 
    20872140            // return false if not found, parse if found 
Note: See TracChangeset for help on using the changeset viewer.