sucking news out of the usenet
| From: | andy | Date: | Thu, 08 Aug 2002 20:10:17 +0000 |
| Subject: | sucking news out of the usenet | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-111723@lists.php.net to get a copy of this message | ||
Hi guys,
I am trying to build a usenet gateway which is collecting usenet posts and
puts them into a phpbb forum. Same other way around. So I did read an
excelent article on that published by Armel Fauveau at:
http://www.phpbuilder.com/columns/armel20010427.php3?page=1
(this is where
the code underneath is from. So getting the articles works.
My problem is how to glue all the articles together which are relies. I am
sure there is a way to find out which reply belongs to a post. I would like
to feed the phpbb database with it.
This is an example of an article including the header:
Newsgroups: php.general Path: news.php.net Xref: news.php.net
php.general:111709 Return-Path: Mailing-List: contact
php-general-help@lists.php.net; run by ezmlm Delivered-To: mailing list
php-general@lists.php.net Received: (qmail 81897 invoked by uid 1007); 8 Aug
2002 18:28:33 -0000 Message-ID: <20020808182833.81896.qmail@pb1.pair.com>
To: php-general@lists.php.net Reply-To: "sebastian" Date: Thu, 8 Aug 2002
20:27:21 +0200 Lines: 11 X-Priority: 3 X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced
By Microsoft MimeOLE V6.00.2600.0000 X-Posted-By: 141.44.162.176 Subject:
streaming mp3-audio??? From: sebastian@apesinspace.de (Sebastian) hi @ all!
i´m looking for an algorithm or class to stream mp3-audiofiles, such as easy
as it can be. i found nothing on php.net and downloaded some phpscripts from
hotscripts and sourceforge but they were all very cryptical and bad
documentated. please help me, many thanks sebastian .
Lots of text.. puhh! I hope this is somehow possible. Maybe one of you guys
has a good idea on that. You can just cut and past the code underneath and
try it out by yourself.
Thanx for any help on that.
Andy
-----------------------------
http://www.OZforum.info
Australia Information Forum
<?php
# http://www.phpbuilder.com/columns/armel20010427.php3?page=3
$cfgServer = "news.php.net";
$cfgPort = 119;
$cfgTimeOut = 10;
// 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);
}
###################
# page 2
//$cfgUser = "xxxxxx";
//$cfgPasswd = "yyyyyy";
$cfgNewsGroup = "php.general";
// 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);
$first = $info[2];
$last = $info[3];
print "First : $first\n<br>";
print "Last : $last\n<br>";
###################
# page 3
$cfgLimit = 10;
// upload last articles
$boucle=$last-$cfgLimit;
while ($boucle <= $last) {
set_time_limit(0);
fputs($usenet_handle, "ARTICLE $boucle\n");
# fputs($usenet_handle, "BODY $boucle\n");
$article="";
$tmp = fgets($usenet_handle, 4096);
if(substr($tmp,0,3) != "220" AND substr($tmp,0,3) != "222") {
echo "+----------------------+\n<br>";
echo "Error on article $boucle\n<br>";
echo "+----------------------+\n<br>";
}
else {
while($tmp!=".\r\n") {
$tmp = fgets($usenet_handle, 4096);
$article = $article.$tmp;
}
echo "+----------------------+\n<br>";
echo "Article $boucle\n<br>";
echo "+----------------------+\n<br>";
echo "$article\n<br>";
}
$boucle++;
}
// close connexion
fclose($usenet_handle);
?>