Home | Help | Site Map | Mail    
TOP SITE:   Hostdebut.com Elite quality co-located virtual servers

Dbase
» Dbase SourceCode
» Dbase Inc.
» DbaseProgrammers
» Dbase News Groups
PHP
» PHP SourceCode
» Apache Software
» PHP
MySQL
» MySQL Help
» MySQL AB
*HTML
» Validate links
JavaScript
» JavaScript Help
Networking
» Windows commands
» Subnet Math
» Port Assignments
» Telnet connect
» Wireless
Other
» Find a Monster Job
» Find a Dbase Job
» Compare your Salary
» InfoSec Pros
» $9.99 domains
» NT0 Web-Hosting
» 
Cheap Flowers Web-Hosting

SourceCode for DbaseProgrammers.com


Download and display nntp newsgroup postings

//**************************************
// Author: Jeremy Martin
// nntp newsgroup downloader
//**************************************

<?php
$varServer = "news.server.com";
$varPort = 119;
$varTimeOut = 10;

// open a socket
$usenet_handle = fsockopen($varServer, $varPort, &$errno, &$errstr, $varTimeOut);

if(!$usenet_handle) {
echo "<b><center>Connection failed</center></b>\n";
exit();
}
else {
echo "<b><center>Connected</center></b>\n";
$tmp = fgets($usenet_handle, 1024);
}

//$varUser = "username";
//$varPasswd = "password";
$varNewsGroup = "group.name";

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

fputs($usenet_handle, "AUTHINFO PASS ".$varPasswd."\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 ".$varNewsGroup."\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];
// limit of posts to retrieve
$varLimit = 50;
$boucle=$last-$varLimit;
print "<b><center>Last $varLimit Posts: $boucle to $last</b></center>\n";

while ($boucle <= $last) {
set_time_limit(0);
fputs($usenet_handle, "ARTICLE $last\n");
$article="";
$tmp = fgets($usenet_handle, 4096);
if(substr($tmp,0,3) != "220") {
echo "<br>+----------------------+<br>";
echo "Article $last not able to be read";
echo "<br>+----------------------+<br>";
}
else {
while($tmp!=".\r\n") {
$tmp = fgets($usenet_handle, 4096);
$article = $article.$tmp;
}
$trans = get_html_translation_table (HTML_ENTITIES);
$str = $article;
$encoded = strtr ($str, $trans);
$encoded = nl2br ($encoded);

echo "<br>+----------------------+<br>";
echo "Article $last";
echo "<br>+----------------------+<br><br>";
echo "$encoded\n";
}
$last--;
}

// close connexion
fclose($usenet_handle);

?>



PHP OpenSource | Dbase OpenSource | MySQL Help | Home | Contact

The code of the week
Members Area
Society News
DbaseProgrammers.com is currently working on a new PHP admin and Dbase admin for account administration
More Links
 
Whitepapers
ServerWatch
SQL Class
ICANN
IANA
RFC
W3C
Internet.com
NSA-SNAC
Foxnews
  Copyright DbaseProgrammers.com Aug. 2003