]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/class-pop3.php
WordPress 4.7
[autoinstalls/wordpress.git] / wp-includes / class-pop3.php
index 063b681046bcd9b05c8896420f3fa2791c03f390..7416dd70013d688aa788545bbd7cd23f5d16c803 100644 (file)
@@ -2,19 +2,18 @@
 /**
  * mail_fetch/setup.php
  *
- * @package SquirrelMail
- *
- * @copyright (c) 1999-2006 The SquirrelMail Project Team
- *
- * @copyright (c) 1999 CDI (cdi@thewebmasters.net) All Rights Reserved
- * Modified by Philippe Mingo 2001 mingo@rotedic.com
+ * Copyright (c) 1999-2011 CDI (cdi@thewebmasters.net) All Rights Reserved
+ * Modified by Philippe Mingo 2001-2009 mingo@rotedic.com
  * An RFC 1939 compliant wrapper class for the POP3 protocol.
  *
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
- * pop3 class
+ * POP3 class
  *
- * $Id: class-pop3.php 6440 2007-12-20 22:28:54Z westi $
+ * @copyright 1999-2011 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @package plugins
+ * @subpackage mail_fetch
  */
 
 class POP3 {
@@ -45,7 +44,10 @@ class POP3 {
                                 //  This must be set to true
                                 //  manually
 
-    function POP3 ( $server = '', $timeout = '' ) {
+       /**
+        * PHP5 constructor.
+        */
+    function __construct ( $server = '', $timeout = '' ) {
         settype($this->BUFFER,"integer");
         if( !empty($server) ) {
             // Do not allow programs to alter MAILSERVER
@@ -63,6 +65,13 @@ class POP3 {
         return true;
     }
 
+       /**
+        * PHP4 constructor.
+        */
+       public function POP3( $server = '', $timeout = '' ) {
+               self::__construct( $server, $timeout );
+       }
+
     function update_timer () {
         if (!ini_get('safe_mode'))
             set_time_limit($this->TIMEOUT);
@@ -73,9 +82,9 @@ class POP3 {
         //  Opens a socket to the specified server. Unless overridden,
         //  port defaults to 110. Returns true on success, false on fail
 
-        // If MAILSERVER is set, override $server with it's value
+        // If MAILSERVER is set, override $server with its value.
 
-       if (!isset($port) || !$port) {$port = 110;}
+    if (!isset($port) || !$port) {$port = 110;}
         if(!empty($this->MAILSERVER))
             $server = $this->MAILSERVER;
 
@@ -252,7 +261,7 @@ class POP3 {
         $MsgArray = array();
 
         $line = fgets($fp,$buffer);
-        while ( !ereg("^\.\r\n",$line))
+        while ( !preg_match('/^\.\r\n/',$line))
         {
             $MsgArray[$count] = $line;
             $count++;
@@ -319,7 +328,7 @@ class POP3 {
             if($msgC > $Total) { break; }
             $line = fgets($fp,$this->BUFFER);
             $line = $this->strip_clf($line);
-            if(ereg("^\.",$line))
+            if(strpos($line, '.') === 0)
             {
                 $this->ERROR = "POP3 pop_list: " . _("Premature end of list");
                 return false;
@@ -365,7 +374,7 @@ class POP3 {
         $MsgArray = array();
 
         $line = fgets($fp,$buffer);
-        while ( !ereg("^\.\r\n",$line))
+        while ( !preg_match('/^\.\r\n/',$line))
         {
             if ( $line{0} == '.' ) { $line = substr($line,1); }
             $MsgArray[$count] = $line;
@@ -421,7 +430,7 @@ class POP3 {
         if(!$this->is_ok($reply))
         {
             //  The POP3 RSET command -never- gives a -ERR
-            //  response - if it ever does, something truely
+            //  response - if it ever does, something truly
             //  wild is going on.
 
             $this->ERROR = "POP3 reset: " . _("Error ") . "[$reply]";
@@ -553,10 +562,7 @@ class POP3 {
             $line = "";
             $count = 1;
             $line = fgets($fp,$buffer);
-            while ( !ereg("^\.\r\n",$line)) {
-                if(ereg("^\.\r\n",$line)) {
-                    break;
-                }
+            while ( !preg_match('/^\.\r\n/',$line)) {
                 list ($msg,$msgUidl) = preg_split('/\s+/',$line);
                 $msgUidl = $this->strip_clf($msgUidl);
                 if($count == $msg) {
@@ -606,7 +612,7 @@ class POP3 {
         if( empty($cmd) )
             return false;
         else
-            return( ereg ("^\+OK", $cmd ) );
+            return( stripos($cmd, '+OK') !== false );
     }
 
     function strip_clf ($text = "") {
@@ -615,8 +621,7 @@ class POP3 {
         if(empty($text))
             return $text;
         else {
-            $stripped = str_replace("\r",'',$text);
-            $stripped = str_replace("\n",'',$stripped);
+            $stripped = str_replace(array("\r","\n"),'',$text);
             return $stripped;
         }
     }
@@ -648,4 +653,10 @@ class POP3 {
     }
 
 }   // End class
-?>
+
+// For php4 compatibility
+if (!function_exists("stripos")) {
+    function stripos($haystack, $needle){
+        return strpos($haystack, stristr( $haystack, $needle ));
+    }
+}