I have followed the guide on this site, here and have managed to get my script working fine to collect the articles.

But the problem comes when i change ARTICLE to HEAD so i can just try and recieve headers. My aim is to index newsgroups via downloading all the headers and then filtering them.

I am no php genius but im not a total idiot either! i just cant seem to get either HEAD or BODY to work and dont want to waste time downloading the full article when all i want is the subject line! Especially if im indexing binary groups!

Well thanks for ne help put my way 🙂

Also here is my final code if it helps at all...

<?php

include ("../../include/admin.php");

//$cfgServer = "news.astraweb.com";
//$cfgPort = "119";
//$cfgTimeOut = 10;

/
Getting connected to the news server
/

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

if(!$usenet_handle) {
echo "Connexion failed\n";
exit();
}

else {
echo "Connected\n";
$tmp = fgets($usenet_handle, 1024);
}

/
Getting the article info
/

//$cfgUser = "xxxxxx";
//$cfgPasswd = "yyyyyy";
//$cfgNewsGroup = "alt.php";

// identification required on private server
if($cfgUser) {
fputs($usenet_handle, "AUTHINFO USER ".$cfgUser."\n");
$tmp = fgets($usenet_handle, 1024);

fputs($usenet_handle, "AUTHINFO PASS ".$cfgPasswd."\n");
$tmp = fgets($usenet_handle, 1024);

// check error

if($tmp != "281 Ok\r\n") {
    echo "502 Authentication error\n";
    exit();
}    

}

// select newsgroup

fputs($usenet_handle, "GROUP ".$cfgNewsGroup."\n");
$tmp = fgets($usenet_handle, 1024);

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

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

print "<BR>First : $first";
print "<BR>Last : $last";
print "<BR>Total : $total";
$atotal = $last - $first;
print "<BR>Actual Total : $atotal";

/
Now were connected adn selceted a group
were goin to get the latest 10 articles in that group!
/

//$cfgLimit = 10;

$boucle=$last-$cfgLimit;

while ($boucle <= $last) {

set_time_limit(0);

fputs($usenet_handle, "ARTICLE $boucle/n");

$article="";
$tmp = fgets($usenet_handle, 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_handle, 4096);
        $article = $article.$tmp;
    }

    echo "<BR><BR>+----------------------+";
    echo "Article $boucle";
    echo "+----------------------+<BR><BR><BR>";
    echo "$article";
}    

$boucle++;

}

/
fputs($usenet_handle, "HEAD 1520846");
$tmp = fgets($usenet_handle, 4096);
print $tmp;
/

?>

    19 days later

    Did you ever get this done? I'm doing the same thing and I'd like to know how you did it, if you've completed it. Thanks, Jeremy

      not yet ive bin on holiday 4 2 weeks and hav just got back.

      im going to work on it asap. contact me if u get it done plz 🙂

        Write a Reply...