コード例 #1
0
ファイル: article.php プロジェクト: adduc/web-news
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>&nbsp;";
            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>&nbsp;";
        }
        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";
}
コード例 #2
0
ファイル: index.php プロジェクト: adduc/web-news
<?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";
コード例 #3
0
ファイル: forums.php プロジェクト: jokepinocchio/MiniXML
function reply_message($group, $group_filter, $start, $msg, $search, $threaded, $sender)
{
    // Figure out which messages to show...
    $stream = nntp_connect();
    $matches = nntp_search($stream, $group, $search, $threaded);
    $count = count($matches);
    if ($msg < 1 || $msg > $count) {
        nntp_close($stream);
        return;
    }
    $fields = explode("\t", $matches[$msg - 1]);
    $msgnum = (int) $fields[0];
    $subject = eregi_replace("\\[[a-z]+\\.[a-z]+\\] ", "", $fields[1]);
    $author = sanitize_email($fields[2]);
    $date = htmlspecialchars($fields[3], ENT_QUOTES);
    if (strncasecmp($subject, "re:", 3)) {
        $subject = "Re: " . $subject;
    }
    $status = nntp_command($stream, "BODY {$msgnum}", 222);
    if ((int) $status != 222) {
        nntp_close($stream);
        nntp_error("We were unable to reply to the requested message for the following " . "reason:", $status, $group);
        return;
    }
    $body = "";
    while ($line = fgets($stream, 1024)) {
        $line = rtrim($line);
        if ($line == ".") {
            break;
        }
        $body = $body . "> " . $line . "\n";
    }
    nntp_close($stream);
    new_message($group, $group_filter, $start, $subject, $sender, $body);
}
コード例 #4
0
// pair subjects w/ dates from multiple sources
$time_start = getmicrotime();
if (isset($argv[1]) && file_exists($argv[1])) {
    // from file
    $lines = file($argv[1]);
    $count = count($lines);
    for ($i = 0; $i < $count; ++$i) {
        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;