POP3::top()publicWP 1.0

Method of the class: POP3{}

No Hooks.

Return

null. Nothing (null).

Usage

$POP3 = new POP3();
$POP3->top ( $msgNum, $numLines );
$msgNum (required)
-
$numLines **
-
Default: "0"

POP3::top() code WP 6.4.3

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;
}