Lists of NNTP servers:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #!/usr/bin/env php <?php if ($argc < 3) { err('No newsgroup and server given'); } $group = $argv[1]; $server = $argv[2]; echo "Checking $group on $server\n"; function err($msg) { fwrite(STDERR, $msg . "\n"); exit(1); } $contimeout = 5; $con = fsockopen($server, 119, $errno, $errstr, $contimeout); if ($con === false) { err($errno . ': ' . $errstr); } //greeting fgets($con, 1024); fwrite($con, 'GROUP ' . $group . "\r\n"); $line = fgets($con, 1024); $code = substr($line, 0, 3); if ($code == 411) { echo "Group not found\n"; } else if ($code == 211) { echo "Group found: " . trim($line) . "\n"; list($code, $count, $first, $last, $name) = explode(' ', trim($line)); echo ' ~' . $count . " articles\n"; } else { echo "error: " . trim($line) . "\n"; } fwrite($con, "QUIT\r\n"); $line = fgets($con, 1024); ?> |