function start_article($group, $headers, $charset) { echo " <blockquote>\n"; echo ' <table border="0" cellpadding="2" cellspacing="2" width="100%">' . "\n"; # from echo ' <tr class="vcard">' . "\n"; echo ' <td class="headerlabel">From:</td>' . "\n"; echo ' <td class="headervalue">' . format_author($headers['from'], $charset) . "</td>\n"; # date echo ' <td class="headerlabel">Date:</td>' . "\n"; echo ' <td class="headervalue">' . format_date($headers["date"]) . "</td>\n"; echo " </tr>\n"; # subject echo ' <tr>' . "\n"; echo ' <td class="headerlabel">Subject:</td>' . "\n"; echo ' <td class="headervalue" colspan="3">' . format_subject($headers["subject"], $charset) . "</td>\n"; echo " </tr>\n"; echo " <tr>\n"; # references if (!empty($headers['references']) || !empty($headers['in-reply-to'])) { $ref = $headers["references"] ? $headers["references"] : $headers["in-reply-to"]; echo ' <td class="headerlabel">References:</td>' . "\n"; echo ' <td class="headervalue">'; $r = explode(" ", $ref); $c = 1; $s = nntp_connect(NNTP_HOST) or die("failed to connect to news server"); while (list($k, $v) = each($r)) { if (!$v) { continue; } $v = trim($v); if (!preg_match("/^<.+>\$/", $v)) { continue; } if (strlen($v) > 504) { // 512 chars including CRLF continue; } $res2 = nntp_cmd($s, "XPATH {$v}", 223) or print "<!-- failed to get reference article id " . htmlspecialchars($v, ENT_QUOTES, "UTF-8") . " -->"; list(, $v) = split("/", trim($res2)); if (empty($v)) { continue; } echo "<a href=\"/{$group}/" . urlencode($v) . "\">" . $c++ . "</a> "; if ($c > REFERENCES_LIMIT) { printf('More than %d references', REFERENCES_LIMIT); break; } } echo "</td>\n"; } # groups if ($headers["newsgroups"]) { echo ' <td class="headerlabel">Groups:</td>' . "\n"; echo ' <td class="headervalue">'; $r = explode(",", chop($headers["newsgroups"])); while (list($k, $v) = each($r)) { echo "<a href=\"/" . urlencode($v) . "\">" . htmlspecialchars($v) . "</a> "; } echo "</td>\n"; } echo " </tr>\n"; //while (list($k,$v) = each($headers)) { // echo "<!-- ", htmlspecialchars($k),": ",preg_replace("/-+/", "-", htmlspecialchars($v))," -->\n"; //} echo " </table>\n"; echo " </blockquote>\n"; echo " <blockquote>\n"; echo " <pre>\n"; }
<?php 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"); } head(); ?> <table border="0" cellpadding="6" cellspacing="0"> <tr> <td> <table class="stripped"> <tr> <th>name</th> <th>messages</th> <th>rss</th> <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); echo " <tr>\n"; echo " <td><a class=\"active{$active}\" href=\"/{$group}\">{$group}</a></td>\n";
if (isset($_GET['part'])) { $part = $_GET['part']; } else { error("No part specified"); } $s = nntp_connect(NNTP_HOST); if (!$s) { error("Failed to connect to news server"); } if ($group) { $res = nntp_cmd($s, "GROUP {$group}", 211); if (!$res) { error("Failed to select group"); } } $res = nntp_cmd($s, "ARTICLE {$article}", 220); if (!$res) { error("Failed to get article " . $article); } $emit = false; $inheaders = 1; $headers = array(); $boundary = $charset = $encoding = ""; $mimecount = 0; // number of mime parts $boundaries = array(); $lk = ''; while (!feof($s)) { $line = fgets($s, 4096); if ($line == ".\r\n") { break;
list($time, $subj) = explode(' ', $lines[$i], 2); $inputs[] = array($time, substr($subj, 12)); } } elseif (isset($argv[1])) { echo "File doesn't exist!"; exit(1); } else { // from nntp $s = nntp_connect("news.php.net") or die("failed to connect to news server"); $res = nntp_cmd($s, "GROUP php.notes", 211) or die("failed to get infos on news group"); $new = explode(" ", $res); $first = 1; $last = $new[0]; //$first = 69900; //$last = 70000; $res = nntp_cmd($s, "XOVER {$first}-{$last}", 224) or die("failed to XOVER the new items"); for ($i = $first; $i < $last; $i++) { $line = fgets($s, 4096); list($n, $subj, $author, $odate, $messageid, $references, $bytes, $lines, $extra) = explode("\t", $line, 9); $inputs[] = array($odate, $subj); } } $files = $team = $tmp = array(); $in_old = false; /* * What should be matched: * note ID deleted from SECTION by EDITOR * note ID rejected from SECTION by EDITOR * note ID modified in SECTION by EDITOR * note ID moved from SECTION to SECTION by EDITOR (not matched yet) */
$i = 0; } $s = nntp_connect(NNTP_HOST); if (!$s) { error("Failed to connect to news server"); } $res = nntp_cmd($s, "GROUP {$group}", 211); if (!$res) { error("Failed to get info on group"); } list(, $f, $l, $g) = explode(" ", $res); if (!$i || $i > $l - 19 || $i < $f) { $i = $l - $f > 19 ? $l - 19 : $f; } $n = min($l, $i + 19); $res = nntp_cmd($s, "XOVER {$i}-{$n}", 224); if (!$res) { error("Failed to get xover data"); } $host = htmlspecialchars($_SERVER['HTTP_HOST'], ENT_QUOTES, "UTF-8"); switch ($format) { case 'rss': header("Content-type: text/xml"); echo '<?xml version="1.0" encoding="utf-8"?>' . "\n"; ?> <rss version="0.93"> <channel> <title><?php echo $host; ?> : <?php