Help needed with nntp

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brent Palmer

    #1

    Help needed with nntp

    Im having trouble with a script trying to display newsgroups.
    The script just hangs when trying to select a newsgroup (fget command).
    Any help appreciated.


    <?php
    // --------------------------------------------connect-------------------------------------------
    $cfgServer = "news-server.bigpond. net.au";
    $cfgPort = 119;
    $cfgTimeOut = 30;

    // open a socket
    if(!$cfgTimeOut )
    // without timeout
    $usenet_handle = fsockopen($cfgS erver, $cfgPort);
    else
    // with timeout
    $usenet_handle = fsockopen($cfgS erver, $cfgPort, &$errno, &$errstr,
    $cfgTimeOut);

    if(!$usenet_han dle) {
    echo "Connexion failed\n";
    exit();
    }
    else {
    echo "Connected\ n";
    $tmp = fgets($usenet_h andle, 1024);
    }

    // --------------------------------------------select_newsgrou p------------------------------------

    $cfgNewsGroup = "alt.php";

    fputs($usenet_h andle, "GROUP ".$cfgNewsGroup ."\n");


    $tmp = fgets($usenet_h andle, 1024);
    // -------Hangs after command fget.-----------

    if($tmp == "480 Authentication required for command\r\n") {
    echo "$tmp\n";
    exit();
    }

    $info = split(" ", $tmp);
    $first = $info[2];
    $last = $info[3];

    print "First : $first\n";
    print "Last : $last\n";


    // -----------------------------------------upload_last_art icles-----------------------------------

    //$cfgLimit = 10;
    //
    //// upload last articles
    //
    //$boucle=$last-$cfgLimit;
    //
    //while ($boucle <= $last) {
    //
    // set_time_limit( 30);
    //
    // fputs($usenet_h andle, "ARTICLE $boucle\n");
    //
    // $article="";
    // $tmp = fgets($usenet_h andle, 4096);
    // if(substr($tmp, 0,3) != "220") {
    // echo "+----------------------+\n";
    // echo "Error on article $boucle\n";
    // echo "+----------------------+\n";
    // }
    // else {
    // while($tmp!=".\ r\n") {
    // $tmp = fgets($usenet_h andle, 4096);
    // $article = $article.$tmp;
    // }
    //
    // echo "+----------------------+\n";
    // echo "Article $boucle\n";
    // echo "+----------------------+\n";
    // echo "$article\n ";
    // }
    //
    // $boucle++;
    //}

    // ------------------------------------------close_connexion----------------------------------

    fclose($usenet_ handle);

    ?>


  • Ken Robinson

    #2
    Re: Help needed with nntp


    Brent Palmer wrote:[color=blue]
    > Im having trouble with a script trying to display newsgroups.
    > The script just hangs when trying to select a newsgroup (fget[/color]
    command).[color=blue]
    > Any help appreciated.
    >[/color]

    According to the PHP manual, the IMAP functions can be used to access
    newgroups. Have you tried to use them?

    Ken

    Comment

    Working...