removed ispell output. confuses phpdoc
[squirrelmail.git] / plugins / mail_fetch / class.POP3.php
index 7d266a478194bf0ab81a1e69c32712dac4a362d9..d4f55b16179d2cb028ec620644238261aed21747 100644 (file)
@@ -1,21 +1,26 @@
-<?php 
-
-   /**
-    * mail_fetch/setup.php
-    *
-    * Copyright (c) 1999-2002 The SquirrelMail Project Team
-    *
-    * Copyright (c) 1999 CDI (cdi@thewebmasters.net) All Rights Reserved
-    * Modified by Philippe Mingo 2001 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
-    *
-    * $Id$
-    */
-
+<?php
+
+/**
+ * mail_fetch/class.POP3.php
+ *
+ * Copyright (c) 1999 CDI (cdi@thewebmasters.net) All Rights Reserved
+ * Modified by Philippe Mingo 2001 mingo@rotedic.com
+ * An RFC 1939 compliant wrapper class for the POP3 protocol.
+ *
+ * POP3 class
+ *
+ * @copyright &copy; 1999-2006 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package plugins
+ * @subpackage mail_fetch
+ */
+
+/**
+ * This is the POP3 class - DOCUMENT ME
+ * @package plugins
+ * @subpackage mail_fetch
+ */
 class POP3 {
     var $ERROR      = '';       //  Error string.
 
@@ -56,13 +61,15 @@ class POP3 {
         if(!empty($timeout)) {
             settype($timeout,"integer");
             $this->TIMEOUT = $timeout;
-            set_time_limit($timeout);
+            if (!ini_get('safe_mode'))
+                set_time_limit($timeout);
         }
         return true;
     }
 
     function update_timer () {
-        set_time_limit($this->TIMEOUT);
+        if (!ini_get('safe_mode'))
+            set_time_limit($this->TIMEOUT);
         return true;
     }
 
@@ -71,8 +78,8 @@ class POP3 {
         //  port defaults to 110. Returns true on success, false on fail
 
         // If MAILSERVER is set, override $server with it's value
-       
-       if (!isset($port) || !$port) {$port = 110;}
+
+        if (!isset($port) || !$port) {$port = 110;}
         if(!empty($this->MAILSERVER))
             $server = $this->MAILSERVER;
 
@@ -82,10 +89,10 @@ class POP3 {
             return false;
         }
 
-        $fp = fsockopen("$server", $port, $errno, $errstr);
+        $fp = @fsockopen("$server", $port, $errno, $errstr);
 
         if(!$fp) {
-            $this->ERROR = _("POP3 connect:") . ' ' . _("Error ") . "[$errno] [$errstr]";
+            $this->ERROR = _("POP3 connect:") . ' ' . _("Error") . ' ' . "[$errno] [$errstr]";
             unset($this->FP);
             return false;
         }
@@ -97,7 +104,7 @@ class POP3 {
         if($this->DEBUG)
             error_log("POP3 SEND [connect: $server] GOT [$reply]",0);
         if(!$this->is_ok($reply)) {
-            $this->ERROR = _("POP3 connect:") . ' ' . _("Error ") . "[$reply]";
+            $this->ERROR = _("POP3 connect:") . ' ' . _("Error") . ' ' . "[$reply]";
             unset($this->FP);
             return false;
         }
@@ -106,18 +113,6 @@ class POP3 {
         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 = "") {
         // Sends the USER command, returns true or false
 
@@ -130,7 +125,7 @@ class POP3 {
         } else {
             $reply = $this->send_cmd("USER $user");
             if(!$this->is_ok($reply)) {
-                $this->ERROR = _("POP3 user:") . ' ' . _("Error ") . "[$reply]";
+                $this->ERROR = _("POP3 user:") . ' ' . _("Error") . ' ' . "[$reply]";
                 return false;
             } else
                 return true;
@@ -150,7 +145,7 @@ class POP3 {
         } else {
             $reply = $this->send_cmd("PASS $pass");
             if(!$this->is_ok($reply)) {
-                $this->ERROR = _("POP3 pass:") . ' ' . _("authentication failed ") . "[$reply]";
+                $this->ERROR = _("POP3 pass:") . ' ' . _("Authentication failed") . " [$reply]";
                 $this->quit();
                 return false;
             } else {
@@ -253,7 +248,7 @@ class POP3 {
         }
         if(!$this->is_ok($reply))
         {
-            $this->ERROR = _("POP3 top:") . ' ' . _("Error ") . "[$reply]";
+            $this->ERROR = _("POP3 top:") . ' ' . _("Error") . ' ' . "[$reply]";
             return false;
         }
 
@@ -307,10 +302,10 @@ class POP3 {
             }
             if(!$this->is_ok($reply))
             {
-                $this->ERROR = _("POP3 pop_list:") . ' ' . _("Error ") . "[$reply]";
+                $this->ERROR = _("POP3 pop_list:") . ' ' . _("Error") . ' ' . "[$reply]";
                 return false;
             }
-            list($junk,$num,$size) = explode(" ",$reply);
+            list($junk,$num,$size) = preg_split('/\s+/',$reply);
             return $size;
         }
         $cmd = "LIST";
@@ -318,7 +313,7 @@ class POP3 {
         if(!$this->is_ok($reply))
         {
             $reply = $this->strip_clf($reply);
-            $this->ERROR = _("POP3 pop_list:") . ' ' . _("Error ") .  "[$reply]";
+            $this->ERROR = _("POP3 pop_list:") . ' ' . _("Error") . ' ' .  "[$reply]";
             return false;
         }
         $MsgArray = array();
@@ -333,7 +328,7 @@ class POP3 {
                 $this->ERROR = _("POP3 pop_list:") . ' ' . _("Premature end of list");
                 return false;
             }
-            list($thisMsg,$msgSize) = explode(" ",$line);
+            list($thisMsg,$msgSize) = preg_split('/\s+/',$line);
             settype($thisMsg,"integer");
             if($thisMsg != $msgC)
             {
@@ -366,7 +361,7 @@ class POP3 {
 
         if(!$this->is_ok($reply))
         {
-            $this->ERROR = _("POP3 get:") . ' ' . _("Error ") . "[$reply]";
+            $this->ERROR = _("POP3 get:") . ' ' . _("Error") . ' ' . "[$reply]";
             return false;
         }
 
@@ -399,11 +394,11 @@ class POP3 {
         $reply = $this->send_cmd("STAT");
         if(!$this->is_ok($reply))
         {
-            $this->ERROR = _("POP3 last:") . ' ' . _("Error ") . "[$reply]";
+            $this->ERROR = _("POP3 last:") . ' ' . _("Error") . ' ' . "[$reply]";
             return $last;
         }
 
-        $Vars = explode(" ",$reply);
+        $Vars = preg_split('/\s+/',$reply);
         $count = $Vars[1];
         $size = $Vars[2];
         settype($count,"integer");
@@ -432,7 +427,7 @@ class POP3 {
             //  response - if it ever does, something truely
             //  wild is going on.
 
-            $this->ERROR = _("POP3 reset:") . ' ' . _("Error ") . "[$reply]";
+            $this->ERROR = _("POP3 reset:") . ' ' . _("Error") . ' ' . "[$reply]";
             @error_log("POP3 reset: ERROR [$reply]",0);
         }
         $this->quit();
@@ -531,10 +526,10 @@ class POP3 {
             $reply = $this->send_cmd($cmd);
             if(!$this->is_ok($reply))
             {
-                $this->ERROR = _("POP3 uidl:") . ' ' . _("Error ") . "[$reply]";
+                $this->ERROR = _("POP3 uidl:") . ' ' . _("Error") . ' ' . "[$reply]";
                 return false;
             }
-            list ($ok,$num,$myUidl) = explode(" ",$reply);
+            list ($ok,$num,$myUidl) = preg_split('/\s+/',$reply);
             return $myUidl;
         } else {
             $this->update_timer();
@@ -554,7 +549,7 @@ class POP3 {
             if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
             if(!$this->is_ok($reply))
             {
-                $this->ERROR = _("POP3 uidl:") . ' ' . _("Error ") . "[$reply]";
+                $this->ERROR = _("POP3 uidl:") . ' ' . _("Error") . ' ' . "[$reply]";
                 return false;
             }
 
@@ -565,7 +560,7 @@ class POP3 {
                 if(ereg("^\.\r\n",$line)) {
                     break;
                 }
-                list ($msg,$msgUidl) = explode(" ",$line);
+                list ($msg,$msgUidl) = preg_split('/\s+/',$line);
                 $msgUidl = $this->strip_clf($msgUidl);
                 if($count == $msg) {
                     $UIDLArray[$msg] = $msgUidl;
@@ -598,7 +593,7 @@ class POP3 {
         $reply = $this->send_cmd("DELE $msgNum");
         if(!$this->is_ok($reply))
         {
-            $this->ERROR = _("POP3 delete:") . ' ' . _("Command failed ") . "[$reply]";
+            $this->ERROR = _("POP3 delete:") . ' ' . _("Command failed") . ' ' . "[$reply]";
             return false;
         }
         return true;
@@ -657,4 +652,3 @@ class POP3 {
 
 }   // End class
 
-?>