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($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);
}
// --------------------------------------------select_newsgroup------------------------------------
$cfgNewsGroup = "alt.php";
fputs($usenet_handle, "GROUP ".$cfgNewsGroup."\n");
$tmp = fgets($usenet_handle, 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_articles-----------------------------------
//$cfgLimit = 10;
//
//// upload last articles
//
//$boucle=$last-$cfgLimit;
//
//while ($boucle <= $last) {
//
// set_time_limit(30);
//
// 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 "+----------------------+\n";
// echo "Article $boucle\n";
// echo "+----------------------+\n";
// echo "$article\n";
// }
//
// $boucle++;
//}
// ------------------------------------------close_connexion----------------------------------
fclose($usenet_handle);
?>