WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #21559, comment 4


Ignore:
Timestamp:
08/13/12 13:16:45 (3 years ago)
Author:
bilalcoder
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #21559, comment 4

    initial v1  
    1 I intended to make the code more readable and will structured, added some methods like '''send()''' and '''get_reply()''', they contain both a DEBUG condition to log the string that is being handled to avoid checking each time throughout the code (example): 
    2  
    3 {{{ 
    4 if($this->DEBUG)  
    5     error_log("POP3 SEND [connect: $server] GOT [$reply]",0); 
    6 }}} 
    7  
    8 Notice that the get_reply() strips CRLF from the response string automatically [http://core.trac.wordpress.org/browser/trunk/wp-includes/class-pop3.php#L463/ instead of doing it each time outside the function ], moreover , i found a bug in pop_list() [http://core.trac.wordpress.org/browser/trunk/wp-includes/class-pop3.php#L303/ class-pop3#L303] where some email providers return an extra word (messages) in the response, the workaround ([http://core.trac.wordpress.org/attachment/ticket/21559/class-pop3.php#L314/ #L314]) i suggested is to preg_match for number sequences and get last number matched in the list. 
    9  
    10 I found a simple [http://core.trac.wordpress.org/attachment/ticket/21559/class-pop3.php#L535/ workaround] for parse_banner(), it is possible to use preg_match to get strings that are located between <> , seems better to me than: 
    11  
    12  
    13 {{{ 
    14     function parse_banner ( $server_text ) { 
    15         $outside = true; 
    16         $banner = ""; 
    17         $length = strlen($server_text); 
    18         for($count =0; $count < $length; $count++) 
    19         { 
    20             $digit = substr($server_text,$count,1); 
    21             if(!empty($digit))             { 
    22                 if( (!$outside) && ($digit != '<') && ($digit != '>') ) 
    23                 { 
    24                     $banner .= $digit; 
    25                 } 
    26                 if ($digit == '<') 
    27                 { 
    28                     $outside = false; 
    29                 } 
    30                 if($digit == '>') 
    31                 { 
    32                     $outside = true; 
    33                 } 
    34             } 
    35         } 
    36         $banner = $this->strip_clf($banner);    // Just in case 
    37         return "<$banner>"; 
    38     } 
    39 }}} 
    40  
    41 i added two optional arguments to the constructor $timeout ( setting timeout ) and $connect ( if true, then connect to the pop3 server ). 
    42  
    43 i apologize if there is any mistakes in the text.