Upgrade class-pop3. Props Nazgul. fixes #3864
git-svn-id: http://svn.automattic.com/wordpress/trunk@4945 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d2ccc08c17
commit
2826681a18
|
@ -3,7 +3,7 @@
|
||||||
/**
|
/**
|
||||||
* mail_fetch/setup.php
|
* mail_fetch/setup.php
|
||||||
*
|
*
|
||||||
* Copyright (c) 1999-2002 The SquirrelMail Project Team
|
* Copyright (c) 1999-2006 The SquirrelMail Project Team
|
||||||
*
|
*
|
||||||
* Copyright (c) 1999 CDI (cdi@thewebmasters.net) All Rights Reserved
|
* Copyright (c) 1999 CDI (cdi@thewebmasters.net) All Rights Reserved
|
||||||
* Modified by Philippe Mingo 2001 mingo@rotedic.com
|
* Modified by Philippe Mingo 2001 mingo@rotedic.com
|
||||||
|
@ -40,9 +40,6 @@ class POP3 {
|
||||||
var $BANNER = ''; // Holds the banner returned by the
|
var $BANNER = ''; // Holds the banner returned by the
|
||||||
// pop server - used for apop()
|
// pop server - used for apop()
|
||||||
|
|
||||||
var $RFC1939 = TRUE; // Set by noop(). See rfc1939.txt
|
|
||||||
//
|
|
||||||
|
|
||||||
var $ALLOWAPOP = FALSE; // Allow or disallow apop()
|
var $ALLOWAPOP = FALSE; // Allow or disallow apop()
|
||||||
// This must be set to true
|
// This must be set to true
|
||||||
// manually
|
// manually
|
||||||
|
@ -59,12 +56,14 @@ class POP3 {
|
||||||
if(!empty($timeout)) {
|
if(!empty($timeout)) {
|
||||||
settype($timeout,"integer");
|
settype($timeout,"integer");
|
||||||
$this->TIMEOUT = $timeout;
|
$this->TIMEOUT = $timeout;
|
||||||
|
if (!ini_get('safe_mode'))
|
||||||
set_time_limit($timeout);
|
set_time_limit($timeout);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_timer () {
|
function update_timer () {
|
||||||
|
if (!ini_get('safe_mode'))
|
||||||
set_time_limit($this->TIMEOUT);
|
set_time_limit($this->TIMEOUT);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -75,6 +74,7 @@ class POP3 {
|
||||||
|
|
||||||
// If MAILSERVER is set, override $server with it's value
|
// If MAILSERVER is set, override $server with it's value
|
||||||
|
|
||||||
|
if (!isset($port) || !$port) {$port = 110;}
|
||||||
if(!empty($this->MAILSERVER))
|
if(!empty($this->MAILSERVER))
|
||||||
$server = $this->MAILSERVER;
|
$server = $this->MAILSERVER;
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class POP3 {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fp = fsockopen("$server", $port, $errno, $errstr);
|
$fp = @fsockopen("$server", $port, $errno, $errstr);
|
||||||
|
|
||||||
if(!$fp) {
|
if(!$fp) {
|
||||||
$this->ERROR = _("POP3 connect:") . ' ' . _("Error ") . "[$errno] [$errstr]";
|
$this->ERROR = _("POP3 connect:") . ' ' . _("Error ") . "[$errno] [$errstr]";
|
||||||
|
@ -105,27 +105,9 @@ class POP3 {
|
||||||
}
|
}
|
||||||
$this->FP = $fp;
|
$this->FP = $fp;
|
||||||
$this->BANNER = $this->parse_banner($reply);
|
$this->BANNER = $this->parse_banner($reply);
|
||||||
$this->RFC1939 = $this->noop();
|
|
||||||
if($this->RFC1939) {
|
|
||||||
$this->ERROR = _("POP3: premature NOOP OK, NOT an RFC 1939 Compliant server");
|
|
||||||
$this->quit();
|
|
||||||
return false;
|
|
||||||
} else
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function noop () {
|
|
||||||
|
|
||||||
if(!isset($this->FP)) {
|
|
||||||
$this->ERROR = _("POP3 noop:") . ' ' . _("No connection to server");
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
$cmd = "NOOP";
|
|
||||||
$reply = $this->send_cmd( $cmd );
|
|
||||||
return( $this->is_ok( $reply ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function user ($user = "") {
|
function user ($user = "") {
|
||||||
// Sends the USER command, returns true or false
|
// Sends the USER command, returns true or false
|
||||||
|
|
||||||
|
@ -158,19 +140,13 @@ class POP3 {
|
||||||
} else {
|
} else {
|
||||||
$reply = $this->send_cmd("PASS $pass");
|
$reply = $this->send_cmd("PASS $pass");
|
||||||
if(!$this->is_ok($reply)) {
|
if(!$this->is_ok($reply)) {
|
||||||
$this->ERROR = _("POP3 pass:") . ' ' . _("authentication failed ") . "[$reply]";
|
$this->ERROR = _("POP3 pass:") . ' ' . _("Authentication failed ") . "[$reply]";
|
||||||
$this->quit();
|
$this->quit();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
// Auth successful.
|
// Auth successful.
|
||||||
$count = $this->last("count");
|
$count = $this->last("count");
|
||||||
$this->COUNT = $count;
|
$this->COUNT = $count;
|
||||||
$this->RFC1939 = $this->noop();
|
|
||||||
if(!$this->RFC1939) {
|
|
||||||
$this->ERROR = _("POP3 pass:") . ' ' . _("NOOP failed. Server not RFC 1939 compliant");
|
|
||||||
$this->quit();
|
|
||||||
return false;
|
|
||||||
} else
|
|
||||||
return $count;
|
return $count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,12 +190,6 @@ class POP3 {
|
||||||
// Auth successful.
|
// Auth successful.
|
||||||
$count = $this->last("count");
|
$count = $this->last("count");
|
||||||
$this->COUNT = $count;
|
$this->COUNT = $count;
|
||||||
$this->RFC1939 = $this->noop();
|
|
||||||
if(!$this->RFC1939) {
|
|
||||||
$this->ERROR = _("POP3 apop:") . ' ' . _("NOOP failed. Server not RFC 1939 compliant");
|
|
||||||
$this->quit();
|
|
||||||
return false;
|
|
||||||
} else
|
|
||||||
return $count;
|
return $count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -330,7 +300,7 @@ class POP3 {
|
||||||
$this->ERROR = _("POP3 pop_list:") . ' ' . _("Error ") . "[$reply]";
|
$this->ERROR = _("POP3 pop_list:") . ' ' . _("Error ") . "[$reply]";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
list($junk,$num,$size) = explode(" ",$reply);
|
list($junk,$num,$size) = preg_split('/\s+/',$reply);
|
||||||
return $size;
|
return $size;
|
||||||
}
|
}
|
||||||
$cmd = "LIST";
|
$cmd = "LIST";
|
||||||
|
@ -353,7 +323,7 @@ class POP3 {
|
||||||
$this->ERROR = _("POP3 pop_list:") . ' ' . _("Premature end of list");
|
$this->ERROR = _("POP3 pop_list:") . ' ' . _("Premature end of list");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
list($thisMsg,$msgSize) = explode(" ",$line);
|
list($thisMsg,$msgSize) = preg_split('/\s+/',$line);
|
||||||
settype($thisMsg,"integer");
|
settype($thisMsg,"integer");
|
||||||
if($thisMsg != $msgC)
|
if($thisMsg != $msgC)
|
||||||
{
|
{
|
||||||
|
@ -428,7 +398,7 @@ class POP3 {
|
||||||
return $last;
|
return $last;
|
||||||
}
|
}
|
||||||
|
|
||||||
$Vars = explode(" ",$reply);
|
$Vars = preg_split('/\s+/',$reply);
|
||||||
$count = $Vars[1];
|
$count = $Vars[1];
|
||||||
$size = $Vars[2];
|
$size = $Vars[2];
|
||||||
settype($count,"integer");
|
settype($count,"integer");
|
||||||
|
@ -559,7 +529,7 @@ class POP3 {
|
||||||
$this->ERROR = _("POP3 uidl:") . ' ' . _("Error ") . "[$reply]";
|
$this->ERROR = _("POP3 uidl:") . ' ' . _("Error ") . "[$reply]";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
list ($ok,$num,$myUidl) = explode(" ",$reply);
|
list ($ok,$num,$myUidl) = preg_split('/\s+/',$reply);
|
||||||
return $myUidl;
|
return $myUidl;
|
||||||
} else {
|
} else {
|
||||||
$this->update_timer();
|
$this->update_timer();
|
||||||
|
@ -590,7 +560,7 @@ class POP3 {
|
||||||
if(ereg("^\.\r\n",$line)) {
|
if(ereg("^\.\r\n",$line)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
list ($msg,$msgUidl) = explode(" ",$line);
|
list ($msg,$msgUidl) = preg_split('/\s+/',$line);
|
||||||
$msgUidl = $this->strip_clf($msgUidl);
|
$msgUidl = $this->strip_clf($msgUidl);
|
||||||
if($count == $msg) {
|
if($count == $msg) {
|
||||||
$UIDLArray[$msg] = $msgUidl;
|
$UIDLArray[$msg] = $msgUidl;
|
||||||
|
@ -661,7 +631,7 @@ class POP3 {
|
||||||
for($count =0; $count < $length; $count++)
|
for($count =0; $count < $length; $count++)
|
||||||
{
|
{
|
||||||
$digit = substr($server_text, $count, 1);
|
$digit = substr($server_text, $count, 1);
|
||||||
if ( false !== $digit ) {
|
if (!empty($digit)) {
|
||||||
if( (!$outside) && ($digit != '<') && ($digit != '>') )
|
if( (!$outside) && ($digit != '<') && ($digit != '>') )
|
||||||
{
|
{
|
||||||
$banner .= $digit;
|
$banner .= $digit;
|
||||||
|
|
Loading…
Reference in New Issue