Commit:    1a72cf3803f548fd59b5c302b0fa5b1d45341e9c
Author:    Ben Ramsey <[email protected]>         Sat, 23 Jan 2016 00:34:32 
-0500
Parents:   ba6d4abfeb8407bf9677062f600a8fc61ca70b5d
Branches:  master

Link:       
http://git.php.net/?p=web/news.git;a=commitdiff;h=1a72cf3803f548fd59b5c302b0fa5b1d45341e9c

Log:
Use new Nntp class to list groups on the index page

Changed paths:
  M  index.php


Diff:
diff --git a/index.php b/index.php
index 624a4b7..0453f3c 100644
--- a/index.php
+++ b/index.php
@@ -2,13 +2,11 @@
 
 require 'common.php';
 
-$s = nntp_connect(NNTP_HOST);
-if (!$s) {
-       error("Failed to connect to news server");
-}
-
-if (!nntp_cmd($s,"LIST",215)) {
-       error("failed to get list of news groups");
+try {
+       $nntpClient = new \Web\News\Nntp(NNTP_HOST);
+       $groups = $nntpClient->listGroups();
+} catch (Exception $e) {
+       error($e->getMessage());
 }
 
 head();
@@ -25,22 +23,17 @@ head();
         <th>rdf</th>
        </tr>
 <?php
-while ($line = fgets($s, 1024)) {
-       if ($line == ".\r\n") {
-               break;
-       }
-       $line = chop($line);
-       list($group, $high, $low, $active) = explode(" ", $line);
+foreach ($groups as $group => $details) {
        echo "       <tr>\n";
-       echo "        <td><a class=\"active$active\" 
href=\"/$group\">$group</a></td>\n";
-       echo "        <td align=\"right\">", $high-$low+1, "</td>\n";
+       echo "        <td><a class=\"active{$details['status']}\" 
href=\"/$group\">$group</a></td>\n";
+       echo "        <td align=\"right\">", 
$details['high']-$details['low']+1, "</td>\n";
        echo "        <td>";
-       if ($active != 'n') {
+       if ($details['status'] != 'n') {
                echo "<a 
href=\"group.php?group=$group&amp;format=rss\">rss</a>";
        }
        echo "</td>\n";
        echo "        <td>";
-       if ($active != 'n') {
+       if ($details['status'] != 'n') {
                echo "<a 
href=\"group.php?group=$group&amp;format=rdf\">rdf</a>";
        }
        echo "</td>\n";


--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to