Changeset 6044

Show
Ignore:
Timestamp:
09/05/07 22:55:38 (1 year ago)
Author:
ryan
Message:

Update pop3 class to latest from squirrelmail. Props westi. see #4337

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/class-pop3.php

    r6026 r6044  
    5858            $this->TIMEOUT = $timeout; 
    5959            if (!ini_get('safe_mode')) 
    60             set_time_limit($timeout); 
     60                set_time_limit($timeout); 
    6161        } 
    6262        return true; 
     
    6565    function update_timer () { 
    6666        if (!ini_get('safe_mode')) 
    67         set_time_limit($this->TIMEOUT); 
     67            set_time_limit($this->TIMEOUT); 
    6868        return true; 
    6969    } 
     
    7575        // If MAILSERVER is set, override $server with it's value 
    7676 
    77         if (!isset($port) || !$port) {$port = 110;} 
     77   if (!isset($port) || !$port) {$port = 110;} 
    7878        if(!empty($this->MAILSERVER)) 
    7979            $server = $this->MAILSERVER; 
    8080 
    8181        if(empty($server)){ 
    82             $this->ERROR = _("POP3 connect:") . ' ' . _("No server specified"); 
     82            $this->ERROR = "POP3 connect: " . _("No server specified"); 
    8383            unset($this->FP); 
    8484            return false; 
     
    8888 
    8989        if(!$fp) { 
    90             $this->ERROR = _("POP3 connect:") . ' ' . _("Error ") . "[$errno] [$errstr]"; 
     90            $this->ERROR = "POP3 connect: " . _("Error ") . "[$errno] [$errstr]"; 
    9191            unset($this->FP); 
    9292            return false; 
     
    100100            error_log("POP3 SEND [connect: $server] GOT [$reply]",0); 
    101101        if(!$this->is_ok($reply)) { 
    102             $this->ERROR = _("POP3 connect:") . ' ' . _("Error ") . "[$reply]"; 
     102            $this->ERROR = "POP3 connect: " . _("Error ") . "[$reply]"; 
    103103            unset($this->FP); 
    104104            return false; 
     
    113113 
    114114        if( empty($user) ) { 
    115             $this->ERROR = _("POP3 user:") . ' ' . _("no login ID submitted"); 
     115            $this->ERROR = "POP3 user: " . _("no login ID submitted"); 
    116116            return false; 
    117117        } elseif(!isset($this->FP)) { 
    118             $this->ERROR = _("POP3 user:") . ' ' . _("connection not established"); 
     118            $this->ERROR = "POP3 user: " . _("connection not established"); 
    119119            return false; 
    120120        } else { 
    121121            $reply = $this->send_cmd("USER $user"); 
    122122            if(!$this->is_ok($reply)) { 
    123                 $this->ERROR = _("POP3 user:") . ' ' . _("Error ") . "[$reply]"; 
     123                $this->ERROR = "POP3 user: " . _("Error ") . "[$reply]"; 
    124124                return false; 
    125125            } else 
     
    133133 
    134134        if(empty($pass)) { 
    135             $this->ERROR = _("POP3 pass:") . ' ' . _("No password submitted"); 
     135            $this->ERROR = "POP3 pass: " . _("No password submitted"); 
    136136            return false; 
    137137        } elseif(!isset($this->FP)) { 
    138             $this->ERROR = _("POP3 pass:") . ' ' . _("connection not established"); 
     138            $this->ERROR = "POP3 pass: " . _("connection not established"); 
    139139            return false; 
    140140        } else { 
    141141            $reply = $this->send_cmd("PASS $pass"); 
    142142            if(!$this->is_ok($reply)) { 
    143                 $this->ERROR = _("POP3 pass:") . ' ' . _("Authentication failed ") . "[$reply]"; 
     143                $this->ERROR = "POP3 pass: " . _("Authentication failed") . " [$reply]"; 
    144144                $this->quit(); 
    145145                return false; 
     
    160160 
    161161        if(!isset($this->FP)) { 
    162             $this->ERROR = _("POP3 apop:") . ' ' . _("No connection to server"); 
     162            $this->ERROR = "POP3 apop: " . _("No connection to server"); 
    163163            return false; 
    164164        } elseif(!$this->ALLOWAPOP) { 
     
    166166            return $retVal; 
    167167        } elseif(empty($login)) { 
    168             $this->ERROR = _("POP3 apop:") . ' ' . _("No login ID submitted"); 
     168            $this->ERROR = "POP3 apop: " . _("No login ID submitted"); 
    169169            return false; 
    170170        } elseif(empty($pass)) { 
    171             $this->ERROR = _("POP3 apop:") . ' ' . _("No password submitted"); 
     171            $this->ERROR = "POP3 apop: " . _("No password submitted"); 
    172172            return false; 
    173173        } else { 
    174174            $banner = $this->BANNER; 
    175175            if( (!$banner) or (empty($banner)) ) { 
    176                 $this->ERROR = _("POP3 apop:") . ' ' . _("No server banner") . ' - ' . _("abort"); 
     176                $this->ERROR = "POP3 apop: " . _("No server banner") . ' - ' . _("abort"); 
    177177                $retVal = $this->login($login,$pass); 
    178178                return $retVal; 
     
    184184                $reply = $this->send_cmd($cmd); 
    185185                if(!$this->is_ok($reply)) { 
    186                     $this->ERROR = _("POP3 apop:") . ' ' . _("apop authentication failed") . ' - ' . _("abort"); 
     186                    $this->ERROR = "POP3 apop: " . _("apop authentication failed") . ' - ' . _("abort"); 
    187187                    $retVal = $this->login($login,$pass); 
    188188                    return $retVal; 
     
    203203 
    204204        if( !isset($this->FP) ) { 
    205             $this->ERROR = _("POP3 login:") . ' ' . _("No connection to server"); 
     205            $this->ERROR = "POP3 login: " . _("No connection to server"); 
    206206            return false; 
    207207        } else { 
     
    228228 
    229229        if(!isset($this->FP)) { 
    230             $this->ERROR = _("POP3 top:") . ' ' . _("No connection to server"); 
     230            $this->ERROR = "POP3 top: " . _("No connection to server"); 
    231231            return false; 
    232232        } 
     
    244244        if(!$this->is_ok($reply)) 
    245245        { 
    246             $this->ERROR = _("POP3 top:") . ' ' . _("Error ") . "[$reply]"; 
     246            $this->ERROR = "POP3 top: " . _("Error ") . "[$reply]"; 
    247247            return false; 
    248248        } 
     
    270270        if(!isset($this->FP)) 
    271271        { 
    272             $this->ERROR = _("POP3 pop_list:") . ' ' . _("No connection to server"); 
     272            $this->ERROR = "POP3 pop_list: " . _("No connection to server"); 
    273273            return false; 
    274274        } 
     
    298298            if(!$this->is_ok($reply)) 
    299299            { 
    300                 $this->ERROR = _("POP3 pop_list:") . ' ' . _("Error ") . "[$reply]"; 
     300                $this->ERROR = "POP3 pop_list: " . _("Error ") . "[$reply]"; 
    301301                return false; 
    302302            } 
     
    309309        { 
    310310            $reply = $this->strip_clf($reply); 
    311             $this->ERROR = _("POP3 pop_list:") . ' ' . _("Error ") .  "[$reply]"; 
     311            $this->ERROR = "POP3 pop_list: " . _("Error ") .  "[$reply]"; 
    312312            return false; 
    313313        } 
     
    321321            if(ereg("^\.",$line)) 
    322322            { 
    323                 $this->ERROR = _("POP3 pop_list:") . ' ' . _("Premature end of list"); 
     323                $this->ERROR = "POP3 pop_list: " . _("Premature end of list"); 
    324324                return false; 
    325325            } 
     
    344344        if(!isset($this->FP)) 
    345345        { 
    346             $this->ERROR = _("POP3 get:") . ' ' . _("No connection to server"); 
     346            $this->ERROR = "POP3 get: " . _("No connection to server"); 
    347347            return false; 
    348348        } 
     
    357357        if(!$this->is_ok($reply)) 
    358358        { 
    359             $this->ERROR = _("POP3 get:") . ' ' . _("Error ") . "[$reply]"; 
     359            $this->ERROR = "POP3 get: " . _("Error ") . "[$reply]"; 
    360360            return false; 
    361361        } 
     
    364364        $MsgArray = array(); 
    365365 
    366         $line = ""
     366        $line = fgets($fp,$buffer)
    367367        while ( !ereg("^\.\r\n",$line)) 
    368368        { 
    369             $line = fgets($fp,$buffer); 
    370             if (preg_match("/^\s+/", $line) && $count > 0) { 
    371                 $MsgArray[$count-1] .= $line; 
    372                 continue; 
    373             } 
    374             if(empty($line))    { break; } 
    375  
     369            if ( $line{0} == '.' ) { $line = substr($line,1); } 
    376370            $MsgArray[$count] = $line; 
    377371            $count++; 
     372            $line = fgets($fp,$buffer); 
     373            if(empty($line))    { break; } 
    378374        } 
    379375        return $MsgArray; 
     
    388384        if(!isset($this->FP)) 
    389385        { 
    390             $this->ERROR = _("POP3 last:") . ' ' . _("No connection to server"); 
     386            $this->ERROR = "POP3 last: " . _("No connection to server"); 
    391387            return $last; 
    392388        } 
     
    395391        if(!$this->is_ok($reply)) 
    396392        { 
    397             $this->ERROR = _("POP3 last:") . ' ' . _("Error ") . "[$reply]"; 
     393            $this->ERROR = "POP3 last: " . _("Error ") . "[$reply]"; 
    398394            return $last; 
    399395        } 
     
    418414        if(!isset($this->FP)) 
    419415        { 
    420             $this->ERROR = _("POP3 reset:") . ' ' . _("No connection to server"); 
     416            $this->ERROR = "POP3 reset: " . _("No connection to server"); 
    421417            return false; 
    422418        } 
     
    428424            //  wild is going on. 
    429425 
    430             $this->ERROR = _("POP3 reset:") . ' ' . _("Error ") . "[$reply]"; 
     426            $this->ERROR = "POP3 reset: " . _("Error ") . "[$reply]"; 
    431427            @error_log("POP3 reset: ERROR [$reply]",0); 
    432428        } 
     
    452448        if(!isset($this->FP)) 
    453449        { 
    454             $this->ERROR = _("POP3 send_cmd:") . ' ' . _("No connection to server"); 
     450            $this->ERROR = "POP3 send_cmd: " . _("No connection to server"); 
    455451            return false; 
    456452        } 
     
    458454        if(empty($cmd)) 
    459455        { 
    460             $this->ERROR = _("POP3 send_cmd:") . ' ' . _("Empty command string"); 
     456            $this->ERROR = "POP3 send_cmd: " . _("Empty command string"); 
    461457            return ""; 
    462458        } 
     
    478474        if(!isset($this->FP)) 
    479475        { 
    480             $this->ERROR = _("POP3 quit:") . ' ' . _("connection does not exist"); 
     476            $this->ERROR = "POP3 quit: " . _("connection does not exist"); 
    481477            return false; 
    482478        } 
     
    515511 
    516512        if(!isset($this->FP)) { 
    517             $this->ERROR = _("POP3 uidl:") . ' ' . _("No connection to server"); 
     513            $this->ERROR = "POP3 uidl: " . _("No connection to server"); 
    518514            return false; 
    519515        } 
     
    527523            if(!$this->is_ok($reply)) 
    528524            { 
    529                 $this->ERROR = _("POP3 uidl:") . ' ' . _("Error ") . "[$reply]"; 
     525                $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]"; 
    530526                return false; 
    531527            } 
     
    550546            if(!$this->is_ok($reply)) 
    551547            { 
    552                 $this->ERROR = _("POP3 uidl:") . ' ' . _("Error ") . "[$reply]"; 
     548                $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]"; 
    553549                return false; 
    554550            } 
     
    583579        if(!isset($this->FP)) 
    584580        { 
    585             $this->ERROR = _("POP3 delete:") . ' ' . _("No connection to server"); 
     581            $this->ERROR = "POP3 delete: " . _("No connection to server"); 
    586582            return false; 
    587583        } 
    588584        if(empty($msgNum)) 
    589585        { 
    590             $this->ERROR = _("POP3 delete:") . ' ' . _("No msg number submitted"); 
     586            $this->ERROR = "POP3 delete: " . _("No msg number submitted"); 
    591587            return false; 
    592588        } 
     
    594590        if(!$this->is_ok($reply)) 
    595591        { 
    596             $this->ERROR = _("POP3 delete:") . ' ' . _("Command failed ") . "[$reply]"; 
     592            $this->ERROR = "POP3 delete: " . _("Command failed ") . "[$reply]"; 
    597593            return false; 
    598594        } 
     
    631627        for($count =0; $count < $length; $count++) 
    632628        { 
    633             $digit = substr($server_text, $count, 1); 
    634             if (!empty($digit))
     629            $digit = substr($server_text,$count,1); 
     630            if(!empty($digit))           
    635631                if( (!$outside) && ($digit != '<') && ($digit != '>') ) 
    636632                { 
     
    652648 
    653649}   // End class 
    654  
    655650?>