[ Index ]
 

Code source de b2evolution 2.1.0-beta

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/blogs/inc/_ext/ -> _pop3.class.php (source)

   1  <?php
   2  /**

   3   * An RFC 1939 compliant wrapper class for the POP3 protocol.

   4   *

   5   * This file is part of the b2evolution project - {@link http://b2evolution.net/}

   6   *

   7   * @copyright (c)2003-2007 by Francois PLANQUE - {@link http://fplanque.net/}

   8   * Parts of this file are copyright (c)1999 by CDI (cdi@thewebmasters.net).

   9   * Parts of this file are copyright (c)1999-2002 by The SquirrelMail Project Team.

  10   * Parts of this file are copyright (c)2004-2005 by Daniel HAHLER - {@link http://thequod.de/contact}.

  11   *

  12   * @license http://b2evolution.net/about/license.html GNU General Public License (GPL)

  13   *

  14   * {@internal Open Source relicensing agreement:

  15   * Daniel HAHLER grants Francois PLANQUE the right to license

  16   * Daniel HAHLER's contributions to this file and the b2evolution project

  17   * under any OSI approved OSS license (http://www.opensource.org/licenses/).

  18   * }}

  19   *

  20   * @package libs

  21   * @subpackage pop3

  22   *

  23   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}

  24   * @author CDI.

  25   * @author blueyed: Daniel HAHLER.

  26   * @author fplanque: Francois PLANQUE.

  27   * @author The SquirrelMail Project Team.

  28   *

  29   * @version $Id: _pop3.class.php,v 1.1 2007/06/25 10:59:08 fplanque Exp $

  30   */
  31  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  32  
  33  /**

  34   * An RFC 1939 compliant wrapper class for the POP3 protocol.

  35   *

  36   * @package evocore

  37   */
  38  class POP3 {
  39      var $ERROR            = '';                //    Error string.

  40  
  41      var $TIMEOUT        = 60;                //    Default timeout before giving up on a

  42                                                              //    network operation.

  43  
  44      var $COUNT            = -1;                //    Mailbox msg count

  45  
  46      var $BUFFER            = 512;            //    Socket buffer for socket fgets() calls.

  47                                                              //    Per RFC 1939 the returned line a POP3

  48                                                              //    server can send is 512 bytes.

  49  
  50      var $FP                    = '';                //    The connection to the server's

  51                                                              //    file descriptor

  52  
  53      var $MAILSERVER = '';                // Set this to hard code the server name

  54  
  55      var $DEBUG            = false;        // set to true to echo pop3

  56                                                              // commands and responses to error_log

  57                                                              // this WILL log passwords!

  58  
  59      var $BANNER            = '';                //    Holds the banner returned by the

  60                                                              //    pop server - used for apop()

  61  
  62      var $RFC1939        = true;            //    Set by noop(). See rfc1939.txt

  63                                                              //

  64  
  65      var $ALLOWAPOP    = false;        //    Allow or disallow apop()

  66                                                              //    This must be set to true

  67                                                              //    manually

  68  
  69  
  70      /**

  71       * Constructor

  72       */
  73  	function POP3 ( $server = '', $timeout = '' ) {
  74              settype($this->BUFFER,'integer');
  75              if( !empty($server) ) {
  76                      // Do not allow programs to alter MAILSERVER

  77                      // if it is already specified. They can get around

  78                      // this if they -really- want to, so don't count on it.

  79                      if(empty($this->MAILSERVER))
  80                              $this->MAILSERVER = $server;
  81              }
  82              if(!empty($timeout)) {
  83                      settype($timeout,'integer');
  84                      $this->TIMEOUT = $timeout;
  85                      if( function_exists('set_time_limit') )
  86                      {
  87                          set_time_limit($timeout);
  88                      }
  89              }
  90              return true;
  91      }
  92  
  93  
  94      /**

  95       * sets/refreshes script timeout

  96       */
  97  	function update_timer () {
  98          if( function_exists('set_time_limit') )
  99          {
 100              set_time_limit($this->TIMEOUT);
 101              return true;
 102          }
 103          return false;
 104      }
 105  
 106  
 107      /**

 108       * Opens a socket to the specified server. Unless overridden,

 109       * port defaults to 110.

 110       *

 111       * @param string server, overriden by MAILSERVER, if not empty

 112       * @param integer port, default 110

 113       * @return boolean true on success, false on fail

 114       */
 115  	function connect ($server, $port = 110)
 116      {
 117          if( !empty($this->MAILSERVER) )
 118              $server = $this->MAILSERVER;
 119  
 120          if( empty($server) ){
 121              $this->ERROR = T_('POP3 connect:') . ' ' . T_('No server specified');
 122              unset($this->FP);
 123              return false;
 124          }
 125  
 126          $fp = @fsockopen($server, $port, $errno, $errstr, 20); // this timeout is just for setting up the socket

 127  
 128          if( !$fp )
 129          {
 130              $this->ERROR = T_('POP3 connect:') . ' ' . T_('Error') . " [$errno] [$errstr]";
 131              unset($this->FP);
 132              return false;
 133          }
 134  
 135          // Set timeout for data:

 136          if( function_exists('stream_set_timeout') )
 137          {
 138              // TODO: "-1" is not defined!: stream_set_blocking($fp,-1);   // PHP 4.3.0

 139              stream_set_timeout( $fp, 20 ); // PHP 4.3.0

 140          }
 141          else
 142          {
 143              // TODO: "-1" is not defined!: socket_set_blocking($fp,-1);   // PHP 4

 144              socket_set_timeout( $fp, 20 ); // PHP 4

 145          }
 146  
 147          $this->update_timer();
 148          $reply = fgets($fp,$this->BUFFER);
 149          $reply = $this->strip_clf($reply);
 150          if($this->DEBUG)
 151              error_log("POP3 SEND [connect: $server] GOT [$reply]",0);
 152          if(!$this->is_ok($reply)) {
 153              $this->ERROR = T_('POP3 connect:') . ' ' . T_('Error') . " [$reply]";
 154              unset($this->FP);
 155              return false;
 156          }
 157          $this->FP = $fp;
 158          $this->BANNER = $this->parse_banner($reply);
 159          $this->RFC1939 = $this->noop();
 160          if($this->RFC1939) {
 161              $this->ERROR = T_('POP3: premature NOOP OK, NOT an RFC 1939 Compliant server');
 162              $this->quit();
 163              return false;
 164          }
 165          else
 166              return true;
 167      }
 168  
 169  
 170  	function noop () {
 171  
 172              if(!isset($this->FP)) {
 173                      $this->ERROR = T_('POP3 noop:') . ' ' . T_('No connection to server');
 174                      return false;
 175              } else {
 176                      $cmd = 'NOOP';
 177                      $reply = $this->send_cmd( $cmd );
 178                      return( $this->is_ok( $reply ) );
 179              }
 180      }
 181  
 182      /**

 183       * Sends the USER command

 184       * @return boolean

 185       */
 186  	function user ($user = '') {
 187              if( empty($user) ) {
 188                      $this->ERROR = T_('POP3 user:') . ' ' . T_('No login ID submitted');
 189                      return false;
 190              } elseif(!isset($this->FP)) {
 191                      $this->ERROR = T_('POP3 user:') . ' ' . T_('connection not established');
 192                      return false;
 193              } else {
 194                      $reply = $this->send_cmd("USER $user");
 195                      if(!$this->is_ok($reply)) {
 196                              $this->ERROR = T_('POP3 user:') . ' ' . T_('Error') . " [$reply]";
 197                              return false;
 198                      } else
 199                              return true;
 200              }
 201      }
 202  
 203  	function pass ($pass = '')         {
 204              // Sends the PASS command, returns # of msgs in mailbox,

 205              // returns false (undef) on Auth failure

 206  
 207              if(empty($pass)) {
 208                      $this->ERROR = T_('POP3 pass:') . ' ' . T_('No password submitted');
 209                      return false;
 210              } elseif(!isset($this->FP)) {
 211                      $this->ERROR = T_('POP3 pass:') . ' ' . T_('connection not established');
 212                      return false;
 213              } else {
 214                      $reply = $this->send_cmd("PASS $pass");
 215                      if(!$this->is_ok($reply)) {
 216                              $this->ERROR = T_('POP3 pass:') . ' ' . T_('authentication failed ') . "[$reply]";
 217                              $this->quit();
 218                              return false;
 219                      } else {
 220                              //    Auth successful.

 221                              $count = $this->last('count');
 222                              $this->COUNT = $count;
 223                              $this->RFC1939 = $this->noop();
 224                              if(!$this->RFC1939) {
 225                                      $this->ERROR = T_('POP3 pass:') . ' ' . T_('NOOP failed. Server not RFC 1939 compliant');
 226                                      $this->quit();
 227                                      return false;
 228                              } else
 229                                      return $count;
 230                      }
 231              }
 232      }
 233  
 234  	function apop ($login,$pass) {
 235              //    Attempts an APOP login. If this fails, it'll

 236              //    try a standard login. YOUR SERVER MUST SUPPORT

 237              //    THE USE OF THE APOP COMMAND!

 238              //    (apop is optional per rfc1939)

 239  
 240              if(!isset($this->FP)) {
 241                      $this->ERROR = T_('POP3 apop:') . ' ' . T_('No connection to server');
 242                      return false;
 243              } elseif(!$this->ALLOWAPOP) {
 244                      $retVal = $this->login($login,$pass);
 245                      return $retVal;
 246              } elseif(empty($login)) {
 247                      $this->ERROR = T_('POP3 apop:') . ' ' . T_('No login ID submitted');
 248                      return false;
 249              } elseif(empty($pass)) {
 250                      $this->ERROR = T_('POP3 apop:') . ' ' . T_('No password submitted');
 251                      return false;
 252              } else {
 253                      $banner = $this->BANNER;
 254                      if( (!$banner) or (empty($banner)) ) {
 255                              $this->ERROR = T_('POP3 apop:') . ' ' . T_('No server banner') . ' - ' . T_('abort');
 256                              $retVal = $this->login($login,$pass);
 257                              return $retVal;
 258                      } else {
 259                              $AuthString = $banner;
 260                              $AuthString .= $pass;
 261                              $APOPString = md5($AuthString);
 262                              $cmd = "APOP $login $APOPString";
 263                              $reply = $this->send_cmd($cmd);
 264                              if(!$this->is_ok($reply)) {
 265                                      $this->ERROR = T_('POP3 apop:') . ' ' . T_('apop authentication failed') . ' - ' . T_('abort');
 266                                      $retVal = $this->login($login,$pass);
 267                                      return $retVal;
 268                              } else {
 269                                      //    Auth successful.

 270                                      $count = $this->last('count');
 271                                      $this->COUNT = $count;
 272                                      $this->RFC1939 = $this->noop();
 273                                      if(!$this->RFC1939) {
 274                                              $this->ERROR = T_('POP3 apop:') . ' ' . T_('NOOP failed. Server not RFC 1939 compliant');
 275                                              $this->quit();
 276                                              return false;
 277                                      } else
 278                                              return $count;
 279                              }
 280                      }
 281              }
 282      }
 283  
 284  	function login ($login = '', $pass = '') {
 285              // Sends both user and pass. Returns # of msgs in mailbox or

 286              // false on failure (or -1, if the error occurs while getting

 287              // the number of messages.)

 288  
 289              if( !isset($this->FP) ) {
 290                      $this->ERROR = T_('POP3 login:') . ' ' . T_('No connection to server');
 291                      return false;
 292              } else {
 293                      $fp = $this->FP;
 294                      if( !$this->user( $login ) ) {
 295                              //    Preserve the error generated by user()

 296                              return false;
 297                      } else {
 298                              $count = $this->pass($pass);
 299                              if( (!$count) || ($count == -1) ) {
 300                                      //    Preserve the error generated by last() and pass()

 301                                      return false;
 302                              } else
 303                                      return $count;
 304                      }
 305              }
 306      }
 307  
 308  	function top ($msgNum, $numLines = '0') {
 309              //    Gets the header and first $numLines of the msg body

 310              //    returns data in an array with each returned line being

 311              //    an array element. If $numLines is empty, returns

 312              //    only the header information, and none of the body.

 313  
 314              if(!isset($this->FP)) {
 315                      $this->ERROR = T_('POP3 top:') . ' ' . T_('No connection to server');
 316                      return false;
 317              }
 318              $this->update_timer();
 319  
 320              $fp = $this->FP;
 321              $buffer = $this->BUFFER;
 322              $cmd = "TOP $msgNum $numLines";
 323              fwrite($fp, "TOP $msgNum $numLines\r\n");
 324              $reply = fgets($fp, $buffer);
 325              $reply = $this->strip_clf($reply);
 326              if($this->DEBUG) {
 327                      @error_log("POP3 SEND [$cmd] GOT [$reply]",0);
 328              }
 329              if(!$this->is_ok($reply))
 330              {
 331                      $this->ERROR = T_('POP3 top:') . ' ' . T_('Error') . " [$reply]";
 332                      return false;
 333              }
 334  
 335              $count = 0;
 336              $MsgArray = array();
 337  
 338              $line = fgets($fp,$buffer);
 339              while ( !ereg("^\.\r\n",$line))
 340              {
 341                      $MsgArray[$count] = $line;
 342                      $count++;
 343                      $line = fgets($fp,$buffer);
 344                      if(empty($line))        { break; }
 345              }
 346  
 347              return $MsgArray;
 348      }
 349  
 350  	function pop_list ($msgNum = '') {
 351              //    If called with an argument, returns that msgs' size in octets

 352              //    No argument returns an associative array of undeleted

 353              //    msg numbers and their sizes in octets

 354  
 355              if(!isset($this->FP))
 356              {
 357                      $this->ERROR = T_('POP3 pop_list:') . ' ' . T_('No connection to server');
 358                      return false;
 359              }
 360              $fp = $this->FP;
 361              $Total = $this->COUNT;
 362              if( (!$Total) or ($Total == -1) )
 363              {
 364                      return false;
 365              }
 366              if($Total == 0)
 367              {
 368                      return array('0','0');
 369                      // return -1;        // mailbox empty

 370              }
 371  
 372              $this->update_timer();
 373  
 374              if(!empty($msgNum))
 375              {
 376                      $cmd = "LIST $msgNum";
 377                      fwrite($fp,"$cmd\r\n");
 378                      $reply = fgets($fp,$this->BUFFER);
 379                      $reply = $this->strip_clf($reply);
 380                      if($this->DEBUG) {
 381                              @error_log("POP3 SEND [$cmd] GOT [$reply]",0);
 382                      }
 383                      if(!$this->is_ok($reply))
 384                      {
 385                              $this->ERROR = T_('POP3 pop_list:') . ' ' . T_('Error') . " [$reply]";
 386                              return false;
 387                      }
 388                      list($junk,$num,$size) = explode(' ',$reply);
 389                      return $size;
 390              }
 391              $cmd = 'LIST';
 392              $reply = $this->send_cmd($cmd);
 393              if(!$this->is_ok($reply))
 394              {
 395                      $reply = $this->strip_clf($reply);
 396                      $this->ERROR = T_('POP3 pop_list:') . ' ' . T_('Error') .    " [$reply]";
 397                      return false;
 398              }
 399              $MsgArray = array();
 400              $MsgArray[0] = $Total;
 401              for($msgC=1;$msgC <= $Total; $msgC++)
 402              {
 403                      if($msgC > $Total) { break; }
 404                      $line = fgets($fp,$this->BUFFER);
 405                      $line = $this->strip_clf($line);
 406                      if(ereg("^\.",$line))
 407                      {
 408                              $this->ERROR = T_('POP3 pop_list:') . ' ' . T_('Premature end of list');
 409                              return false;
 410                      }
 411                      list($thisMsg,$msgSize) = explode(' ',$line);
 412                      settype($thisMsg,'integer');
 413                      if($thisMsg != $msgC)
 414                      {
 415                              $MsgArray[$msgC] = 'deleted';
 416                      }
 417                      else
 418                      {
 419                              $MsgArray[$msgC] = $msgSize;
 420                      }
 421              }
 422              return $MsgArray;
 423      }
 424  
 425  	function get ($msgNum) {
 426              //    Retrieve the specified msg number. Returns an array

 427              //    where each line of the msg is an array element.

 428  
 429              if(!isset($this->FP))
 430              {
 431                      $this->ERROR = T_('POP3 get:') . ' ' . T_('No connection to server');
 432                      return false;
 433              }
 434  
 435              $this->update_timer();
 436  
 437              $fp = $this->FP;
 438              $buffer = $this->BUFFER;
 439              $cmd = "RETR $msgNum";
 440              $reply = $this->send_cmd($cmd);
 441  
 442              if(!$this->is_ok($reply))
 443              {
 444                      $this->ERROR = T_('POP3 get:') . ' ' . T_('Error') . " [$reply]";
 445                      return false;
 446              }
 447  
 448              $count = 0;
 449              $MsgArray = array();
 450  
 451              $line = fgets($fp,$buffer);
 452              while ( !ereg("^\.\r\n",$line))
 453              {
 454                      $MsgArray[$count] = $line;
 455                      $count++;
 456                      $line = fgets($fp,$buffer);
 457                      if(empty($line))        { break; }
 458              }
 459              return $MsgArray;
 460      }
 461  
 462  	function last ( $type = 'count' ) {
 463              //    Returns the highest msg number in the mailbox.

 464              //    returns -1 on error, 0+ on success, if type != count

 465              //    results in a popstat() call (2 element array returned)

 466  
 467              $last = -1;
 468              if(!isset($this->FP))
 469              {
 470                      $this->ERROR = T_('POP3 last:') . ' ' . T_('No connection to server');
 471                      return $last;
 472              }
 473  
 474              $reply = $this->send_cmd('STAT');
 475              if(!$this->is_ok($reply))
 476              {
 477                      $this->ERROR = T_('POP3 last:') . ' ' . T_('Error') . " [$reply]";
 478                      return $last;
 479              }
 480  
 481              $Vars = explode(' ',$reply);
 482              $count = $Vars[1];
 483              $size = $Vars[2];
 484              settype($count,'integer');
 485              settype($size,'integer');
 486              if($type != 'count')
 487              {
 488                      return array($count,$size);
 489              }
 490              return $count;
 491      }
 492  
 493  	function reset () {
 494              //    Resets the status of the remote server. This includes

 495              //    resetting the status of ALL msgs to not be deleted.

 496              //    This method automatically closes the connection to the server.

 497  
 498              if(!isset($this->FP))
 499              {
 500                      $this->ERROR = T_('POP3 reset:') . ' ' . T_('No connection to server');
 501                      return false;
 502              }
 503              $reply = $this->send_cmd('RSET');
 504              if(!$this->is_ok($reply))
 505              {
 506                      //    The POP3 RSET command -never- gives a -ERR

 507                      //    response - if it ever does, something truely

 508                      //    wild is going on.

 509  
 510                      $this->ERROR = T_('POP3 reset:') . ' ' . T_('Error') . " [$reply]";
 511                      @error_log("POP3 reset: ERROR [$reply]",0);
 512              }
 513              $this->quit();
 514              return true;
 515      }
 516  
 517  	function send_cmd ( $cmd = '' )
 518      {
 519              //    Sends a user defined command string to the

 520              //    POP server and returns the results. Useful for

 521              //    non-compliant or custom POP servers.

 522              //    Do NOT includ the \r\n as part of your command

 523              //    string - it will be appended automatically.

 524  
 525              //    The return value is a standard fgets() call, which

 526              //    will read up to $this->BUFFER bytes of data, until it

 527              //    encounters a new line, or EOF, whichever happens first.

 528  
 529              //    This method works best if $cmd responds with only

 530              //    one line of data.

 531  
 532              if(!isset($this->FP))
 533              {
 534                      $this->ERROR = T_('POP3 send_cmd:') . ' ' . T_('No connection to server');
 535                      return false;
 536              }
 537  
 538              if(empty($cmd))
 539              {
 540                      $this->ERROR = T_('POP3 send_cmd:') . ' ' . T_('Empty command string');
 541                      return '';
 542              }
 543  
 544              $fp = $this->FP;
 545              $buffer = $this->BUFFER;
 546              $this->update_timer();
 547              fwrite($fp,"$cmd\r\n");
 548              $reply = fgets($fp,$buffer);
 549              $reply = $this->strip_clf($reply);
 550              if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
 551              return $reply;
 552      }
 553  
 554  	function quit() {
 555              //    Closes the connection to the POP3 server, deleting

 556              //    any msgs marked as deleted.

 557  
 558              if(!isset($this->FP))
 559              {
 560                      $this->ERROR = T_('POP3 quit:') . ' ' . T_('connection does not exist');
 561                      return false;
 562              }
 563              $fp = $this->FP;
 564              $cmd = 'QUIT';
 565              fwrite($fp,"$cmd\r\n");
 566              $reply = fgets($fp,$this->BUFFER);
 567              $reply = $this->strip_clf($reply);
 568              if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
 569              fclose($fp);
 570              unset($this->FP);
 571              return true;
 572      }
 573  
 574  	function popstat () {
 575              //    Returns an array of 2 elements. The number of undeleted

 576              //    msgs in the mailbox, and the size of the mbox in octets.

 577  
 578              $PopArray = $this->last('array');
 579  
 580              if($PopArray == -1) { return false; }
 581  
 582              if( (!$PopArray) or (empty($PopArray)) )
 583              {
 584                      return false;
 585              }
 586              return $PopArray;
 587      }
 588  
 589  	function uidl ($msgNum = '')
 590      {
 591              //    Returns the UIDL of the msg specified. If called with

 592              //    no arguments, returns an associative array where each

 593              //    undeleted msg num is a key, and the msg's uidl is the element

 594              //    Array element 0 will contain the total number of msgs

 595  
 596              if(!isset($this->FP)) {
 597                      $this->ERROR = T_('POP3 uidl:') . ' ' . T_('No connection to server');
 598                      return false;
 599              }
 600  
 601              $fp = $this->FP;
 602              $buffer = $this->BUFFER;
 603  
 604              if(!empty($msgNum)) {
 605                      $cmd = "UIDL $msgNum";
 606                      $reply = $this->send_cmd($cmd);
 607                      if(!$this->is_ok($reply))
 608                      {
 609                              $this->ERROR = T_('POP3 uidl:') . ' ' . T_('Error') . " [$reply]";
 610                              return false;
 611                      }
 612                      list ($ok,$num,$myUidl) = explode(' ',$reply);
 613                      return $myUidl;
 614              } else {
 615                      $this->update_timer();
 616  
 617                      $UIDLArray = array();
 618                      $Total = $this->COUNT;
 619                      $UIDLArray[0] = $Total;
 620  
 621                      if ($Total < 1)
 622                      {
 623                              return $UIDLArray;
 624                      }
 625                      $cmd = 'UIDL';
 626                      fwrite($fp, "UIDL\r\n");
 627                      $reply = fgets($fp, $buffer);
 628                      $reply = $this->strip_clf($reply);
 629                      if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
 630                      if(!$this->is_ok($reply))
 631                      {
 632                              $this->ERROR = T_('POP3 uidl:') . ' ' . T_('Error') . " [$reply]";
 633                              return false;
 634                      }
 635  
 636                      $line = '';
 637                      $count = 1;
 638                      $line = fgets($fp,$buffer);
 639                      while ( !ereg("^\.\r\n",$line)) {
 640                              if(ereg("^\.\r\n",$line)) {
 641                                      break;
 642                              }
 643                              list ($msg,$msgUidl) = explode(' ',$line);
 644                              $msgUidl = $this->strip_clf($msgUidl);
 645                              if($count == $msg) {
 646                                      $UIDLArray[$msg] = $msgUidl;
 647                              }
 648                              else
 649                              {
 650                                      $UIDLArray[$count] = 'deleted';
 651                              }
 652                              $count++;
 653                              $line = fgets($fp,$buffer);
 654                      }
 655              }
 656              return $UIDLArray;
 657      }
 658  
 659  	function delete ($msgNum = '') {
 660              //    Flags a specified msg as deleted. The msg will not

 661              //    be deleted until a quit() method is called.

 662  
 663              if(!isset($this->FP))
 664              {
 665                      $this->ERROR = T_('POP3 delete:') . ' ' . T_('No connection to server');
 666                      return false;
 667              }
 668              if(empty($msgNum))
 669              {
 670                      $this->ERROR = T_('POP3 delete:') . ' ' . T_('No msg number submitted');
 671                      return false;
 672              }
 673              $reply = $this->send_cmd("DELE $msgNum");
 674              if(!$this->is_ok($reply))
 675              {
 676                      $this->ERROR = T_('POP3 delete:') . ' ' . T_('Command failed') . " [$reply]";
 677                      return false;
 678              }
 679              return true;
 680      }
 681  
 682      //    *********************************************************

 683  
 684      //    The following methods are internal to the class.

 685  
 686  	function is_ok ($cmd = '') {
 687              //    Return true or false on +OK or -ERR

 688  
 689              if( empty($cmd) )
 690                      return false;
 691              else
 692                      return( ereg ("^\+OK", $cmd ) );
 693      }
 694  
 695  	function strip_clf ($text = '') {
 696              // Strips \r\n from server responses

 697  
 698              if(empty($text))
 699                      return $text;
 700              else {
 701                      $stripped = str_replace("\r",'',$text);
 702                      $stripped = str_replace("\n",'',$stripped);
 703                      return $stripped;
 704              }
 705      }
 706  
 707  	function parse_banner ( $server_text ) {
 708              $outside = true;
 709              $banner = '';
 710              $length = strlen($server_text);
 711              for($count =0; $count < $length; $count++)
 712              {
 713                      $digit = substr($server_text,$count,1);
 714                      if(!empty($digit))                         {
 715                              if( (!$outside) && ($digit != '<') && ($digit != '>') )
 716                              {
 717                                      $banner .= $digit;
 718                              }
 719                              if ($digit == '<')
 720                              {
 721                                      $outside = false;
 722                              }
 723                              if($digit == '>')
 724                              {
 725                                      $outside = true;
 726                              }
 727                      }
 728              }
 729              $banner = $this->strip_clf($banner);        // Just in case

 730              return "<$banner>";
 731      }
 732  
 733  }        // End class

 734  
 735  /*

 736   * $Log: _pop3.class.php,v $

 737   * Revision 1.1  2007/06/25 10:59:08  fplanque

 738   * MODULES (refactored MVC)

 739   *

 740   * Revision 1.7  2007/06/20 23:00:13  blueyed

 741   * doc fixes

 742   *

 743   * Revision 1.6  2007/04/26 00:11:12  fplanque

 744   * (c) 2007

 745   *

 746   * Revision 1.5  2006/07/04 17:32:30  fplanque

 747   * no message

 748   *

 749   * Revision 1.4  2006/05/16 21:45:52  blueyed

 750   * Use stream/socket timeout for data!

 751   *

 752   * Revision 1.3  2006/03/12 23:09:26  fplanque

 753   * doc cleanup

 754   *

 755   * Revision 1.2  2006/03/03 20:10:21  blueyed

 756   * doc

 757   *

 758   * Revision 1.1  2006/02/23 21:12:33  fplanque

 759   * File reorganization to MVC (Model View Controller) architecture.

 760   * See index.hml files in folders.

 761   * (Sorry for all the remaining bugs induced by the reorg... :/)

 762   *

 763   * Revision 1.5  2005/12/12 19:22:03  fplanque

 764   * big merge; lots of small mods; hope I didn't make to many mistakes :]

 765   *

 766   * Revision 1.4  2005/09/06 17:14:12  fplanque

 767   * stop processing early if referer spam has been detected

 768   *

 769   * Revision 1.3  2005/02/28 09:06:44  blueyed

 770   * removed constants for DB config (allows to override it from _config_TEST.php), introduced EVO_CONFIG_LOADED

 771   *

 772   * Revision 1.2  2004/10/14 18:31:27  blueyed

 773   * granting copyright

 774   *

 775   * Revision 1.1  2004/10/13 22:46:34  fplanque

 776   * renamed [b2]evocore/*

 777   *

 778   * Revision 1.14  2004/10/12 16:12:18  fplanque

 779   * Edited code documentation.

 780   *

 781   */
 782  ?>


Généré le : Thu Nov 29 23:58:50 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics