Changeset 2739 in subversion for trunk/roundcubemail/program/lib/imap.inc


Ignore:
Timestamp:
Jul 11, 2009 5:53:11 PM (4 years ago)
Author:
alec
Message:
  • small code improvements
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/lib/imap.inc

    r2738 r2739  
    200200        global $my_prefs; 
    201201         
    202         if(!empty($my_prefs['debug_mode'])) 
     202        if (!empty($my_prefs['debug_mode'])) 
    203203                write_log('imap', 'C: '. rtrim($string)); 
    204204         
     
    247247                        break; 
    248248                } 
    249                 if(!empty($my_prefs['debug_mode'])) 
     249                if (!empty($my_prefs['debug_mode'])) 
    250250                        write_log('imap', 'S: '. chop($buffer)); 
    251251                $line .= $buffer; 
     
    278278        do { 
    279279                $d = fread($fp, $bytes-$len); 
     280                if (!empty($my_prefs['debug_mode'])) 
     281                        write_log('imap', 'S: '. $d); 
    280282                $data .= $d; 
    281                 if ($len == strlen($data)) { 
     283                $data_len = strlen($data); 
     284                if ($len == $data_len) { 
    282285                        break; //nothing was read -> exit to avoid apache lockups 
    283286                } 
    284                 if(!empty($my_prefs['debug_mode'])) 
    285                         write_log('imap', 'S: '. $d); 
    286                 $len = strlen($data); 
     287                $len = $data_len; 
    287288        } while ($len < $bytes); 
    288289         
     
    329330} 
    330331 
    331 function iil_StartsWithI($string, $match, $bye=false) { 
     332function iil_StartsWithI($string, $match, $error=false) { 
    332333        $len = strlen($match); 
    333334        if ($len == 0) { 
     
    337338                return true; 
    338339        } 
    339         if ($bye && strncmp($string, '* BYE ', 6) == 0) { 
     340        if ($error && preg_match('/^\* (BYE|BAD) /i', $string)) { 
    340341                return true; 
    341342 
     
    792793                                        $conn->exists = (int) $a[1]; 
    793794                                } 
    794                                 if (strcasecmp($a[2], 'RECENT') == 0) { 
     795                                else if (strcasecmp($a[2], 'RECENT') == 0) { 
    795796                                        $conn->recent = (int) $a[1]; 
    796797                                } 
     
    893894        $command .= $encoding . ' ALL' . $add; 
    894895        $line     = $data = ''; 
    895          
     896 
    896897        if (!iil_PutLineC($conn->fp, $command)) { 
    897898            return false; 
     
    22662267                        $bytes    = (int)$sizeStr; 
    22672268                        $prev     = ''; 
    2268  
     2269                         
    22692270                        while ($bytes > 0) { 
    22702271                                $line      = iil_ReadLine($fp, 1024); 
     
    22732274                                if ($len > $bytes) { 
    22742275                                        $line = substr($line, 0, $bytes); 
     2276                                        $len = strlen($line); 
    22752277                                } 
    2276                                 $bytes -= strlen($line); 
     2278                                $bytes -= $len; 
    22772279 
    22782280                                if ($mode == 1) { 
     
    23532355                        $line=iil_ReadLine($fp, 300); 
    23542356                } while ($line[0] != 'c'); 
    2355         $conn->error = $line; 
    23562357                return (iil_ParseResult($line) == 0); 
    23572358        } 
     
    23782379                return (iil_ParseResult($line) == 0); 
    23792380        } 
    2380         $conn->error = "Couldn't send command\n"; 
    23812381        return false; 
    23822382} 
Note: See TracChangeset for help on using the changeset viewer.