/** /* * Select a group as active group */ public function selectGroup($group) { SpotDebug::msg(SpotDebug::TRACE, __CLASS__ . "->selectGroup(" . $group . ")"); $this->connect(); $this->_currentgroup = $group; return $this->_nntp->selectGroup($this->_currentgroup); }
/** * @param string $group Name of the group to select. * @param bool $articles (optional) experimental! When true the article numbers is returned in 'articles'. * @param bool $force Force a refresh to get updated data from the usenet server. * * @return mixed On success : (array) Group information. * On failure : (object) PEAR_Error. * * @access public */ public function selectGroup($group, $articles = false, $force = false) { $connected = $this->_checkConnection(false); if ($connected !== true) { return $connected; } // Check if the current selected group is the same, or if we have not selected a group or if a fresh summary is wanted. if ($force || $this->_currentGroup !== $group || is_null($this->_selectedGroupSummary)) { $this->_currentGroup = $group; return parent::selectGroup($group, $articles); } else { return $this->_selectedGroupSummary; } }
<html> <head> <title>NNTP news.php.net</title> </head> <body> <h1>Message</h1> <?php require_once "Net/NNTP/Client.php"; $nntp = new Net_NNTP_Client(); $ret = $nntp->connect("news.php.net"); if (PEAR::isError($ret)) { echo '<font color="red">No connection to newsserver!</font><br>'; echo $ret->getMessage(); } else { if (isset($_GET['msgid']) and isset($_GET['group'])) { $msgdata = $nntp->selectGroup($_GET['group']); if (PEAR::isError($msgdata)) { echo '<font color="red">' . $msgdata->getMessage() . '</font><br>'; } else { $header = $nntp->getHeaderRaw($_GET['msgid']); echo '<hr>'; echo '<h2>Header</h2>'; echo '<pre>'; foreach ($header as $line) { echo $line . '<br>'; } echo '</pre>'; echo '<hr>'; echo '<h2>Body</h2>'; echo '<form><textarea wrap="off" cols="79", rows="25">' . $nntp->getBodyRaw($_GET['msgid'], true) . '</textarea></form>'; }
<?php // hai.. what this does: fetch only a header field from a // usenet group (very fast), and apply some regex to it.. // use it for testing regex stuff $hostname = 'news.usenetserver.com'; $username = '******'; $password = '******'; $group = 'alt.binaries.teevee'; $header_field = 'Subject'; $max_articles = 100000; # /usr/share/pear/Net/NNTP/Client.php include 'Net/NNTP/Client.php'; $nntp = new Net_NNTP_Client(); $nntp->connect($hostname); $nntp->authenticate($username, $password); $group = $nntp->selectGroup('alt.binaries.teevee'); print_r($group); $first = $group['last'] - $max_articles; $last = $group['last']; $articles = $nntp->getHeaderField($header_field, "{$first}-{$last}"); print count($articles) . " articles indexed..\n"; foreach ($articles as $article) { $pattern = '/(\\((\\d+)\\/(\\d+)\\))$/i'; if (!preg_match($pattern, rtrim($article), $matches)) { echo "Not matched: {$article}\n"; } else { # echo "$matches[2]\n"; } } exit;