php and the nntp protocol

    Date: 04/07/05 (PHP Community)    Keywords: php, web

    so i'm studying ways to implement a web interface with an nntp server, aka newsgroups server.

    I've tried the low-level way, opening a socket and fwrite-ing the commands and fget-ing the results.

    the thing is, i don't know why, but when the server sends me the list of all the newsgroups available, or the numbers of the msgs in a newsgroup i never get the entire reply!
    let's say there's 100 newsgroups. I only get 40 or something. It seems like the buffer can't hold that ammount of bytes or something.


    Another way to do it, is using the imap functions. I've tried. imap_open, ok. but then i can't figure out how to list the msgs on a newsgroup. i've tried almost every imap function that makes sense, with no avail.



    So, bottom line, if there's anyone who has worked with anything like this and would like to point me in the right direction, i'd be most thankful.

    i'm putting the code behind a cut.




    list_groups.php


    Connection failed.

    \n"; } else { echo "

    Connected.

    "; $cmd = "mode reader\r\n"; fwrite( $conn, $cmd ); $lista .= fgets( $conn, 128 ); $lista .= "
    "; $cmd = "authinfo user $user\r\n"; fwrite( $conn, $cmd ); $lista .= fgets( $conn, 128 ); $lista .= "
    "; $cmd = "authinfo pass $passwd\r\n"; fwrite( $conn, $cmd ); $lista .= fgets( $conn, 128 ); echo "

    Authenticated.

    "; $lista .= "
    "; $cmd = "list\r\n"; fwrite( $conn, $cmd ); $lista .= fgets( $conn, 128 ); $lista .= "
    "; $lista .= fgets( $conn, 256 ); $lista .= "

    newsgroups list

    "; $alllist = ""; $alllist .= fread( $conn, 20480 ); // couldn't work with: while( !feof ( $conn ) ) because it never // reaches the end of file, because i can't get the whole stream :( $newsgroups = explode("\n", $alllist ); $final_list = Array(); foreach( $newsgroups as $newsgroup ) { $raw = explode( " ", $newsgroup ); $title = $raw[0]; $num_posts = (int) $raw[1]; $dados = Array( "title" => $title, "num_posts" => $num_posts ); array_push( $final_list, $dados ); } echo "
    "; echo ""; echo " "; echo "
    "; fclose( $conn ); } ?>


    if you want more, ask. but if you could help me with this example, i'd be set.

    like i said, i get 48 newsgroups despite the server giving me over 100. (i've tried using telnet and it works, but through php, nothing)


    what am i doing wrong? :-\

    Source: http://www.livejournal.com/community/php/281112.html

« MySQL - Selecting based... || An Introduction of Sorts... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home