</tr>
<?php
foreach ($news['headdisp'] as $nick) {
- if (isset($post->headers->$nick))
+ if (isset($post->headers[$nick]))
echo "<tr><td class=\"{$css['bicoltitre']}\">".header_translate($nick)."</td>"
- ."<td>".formatdisplayheader($nick,$post->headers->$nick,$spool)
+ ."<td>".formatdisplayheader($nick,$post->headers[$nick],$spool)
."</td></tr>\n";
}
?>
*/
class NNTPPost {
+ var $nb;
/** headers */
var $headers;
/** body */
var $body;
+ /** poster name */
+ var $name;
/** constructor
* @param $_nntp RESOURCE handle to NNTP socket
* @param $_id STRING MSGNUM or MSGID (a group should be selected in this case)
*/
function NNTPPost(&$_nntp, $_id) {
- $this->headers = new headers($_nntp, $_id);
- if (!$this->headers) {
- $this = null;
- return false;
- }
+ $this->nb = $_id;
+ $this->_header($_nntp);
+
$this->body = join("\n", $_nntp->body($_id));
- if (isset($this->headers->contentencoding) && preg_match("/base64/", $this->headers->contentencoding)) {
- $this->body = base64_decode($this->body);
- }
- if (isset($this->headers->contentencoding) && preg_match("/quoted-printable/", $this->headers->contentencoding)) {
- $this->body = quoted_printable_decode($this->body);
+
+ if (isset($this->headers['content-transfer-encoding'])) {
+ if (preg_match("/base64/", $this->headers['content-transfer-encoding'])) {
+ $this->body = base64_decode($this->body);
+ } elseif (preg_match("/quoted-printable/", $this->headers['content-transfer-encoding'])) {
+ $this->body = quoted_printable_decode($this->body);
+ }
}
- if (preg_match('!charset=([^;]*);!', $this->headers->contenttype, $matches)) {
+
+ if (preg_match('!charset=([^;]*);!', $this->headers['content-type'], $matches)) {
$this->body = iconv($matches[1], 'iso-8859-1', $this->body);
}
}
-}
-
-/** class for headers
- */
-class Headers {
- /** MSGNUM : *local* spool id */
- var $nb; // numéro du post
- /** MSGID : Message-ID */
- var $msgid; // Message-ID
- /** From header */
- var $from; // From
- /** Name (if present in From header) */
- var $name;
- /** Mail (in From header) */
- var $mail;
- /** Subject header */
- var $subject; // Subject
- /** Newsgroup¨ header */
- var $newsgroups; // Newsgroups
- /** Followup-To header */
- var $followup;
- /** Content-Type header */
- var $contenttype;
- /** Content-Transfer-Encoding header */
- var $contentencoding;
- /** Date header */
- var $date;
- /** Organization header */
- var $organization;
- /** References header */
- var $references;
-
- /** constructor
- * @param $_nntp RESOURCE handle to NNTP socket
- * @param $_id STRING MSGNUM or MSGID
- */
-
- function headers(&$_nntp, $_id) {
+ function _header(&$_nntp)
+ {
global $news;
- $hdrs = $_nntp->head($_id);
+ $hdrs = $_nntp->head($this->nb);
if (!$hdrs) {
$this = null;
return false;
}
+
+ $this->nb = $_id;
// parse headers
foreach ($hdrs as $line) {
if (preg_match("/^[\t\r ]+/", $line)) {
- $line = ($lasthdr=="X-Face"?"":" ").ltrim($line);
- if (in_array($lasthdr, array_keys($news['head']))) {
- $this->{$news['head'][$lasthdr]} .= $line;
+ $line = ($hdr=="X-Face"?"":" ").ltrim($line);
+ if (in_array($hdr, $news['head'])) {
+ $this->headers[$hdr] .= $line;
}
} else {
list($hdr, $val) = split(":[ \t\r]*", $line, 2);
- if (in_array($hdr, array_keys($news['head']))) {
- $this->{$news['head'][$hdr]} = $val;
+ $hdr = strtolower($hdr);
+ if (in_array($hdr, $news['head'])) {
+ $this->headers[$hdr] = $val;
}
- $lasthdr = $hdr;
}
}
// decode headers
foreach ($news['hdecode'] as $hdr) {
- if (isset($this->$hdr)) {
- $this->$hdr = headerDecode($this->$hdr);
+ if (isset($this->headers[$hdr])) {
+ $this->headers[$hdr] = headerDecode($this->headers[$hdr]);
}
}
- // sets name and mail
- $this->name = $this->from;
- $this->mail = $this->from;
- if (preg_match("/(.*)<(.*)@(.*)>/", $val, $match)) {
- $this->name = str_replace("\"", "", trim($match[1]));
- $this->mail = $match[2]."@".$match[3];
- }
- if (preg_match("/([\w\.]+)@([\w\.]+) \((.*)\)/", $val, $match)) {
- $this->name = trim($match[3]);
- $this->mail = $match[1]."@".$match[2];
- }
- $this->nb = $_id;
- $retour->numerr = 0;
+
+ $this->name = $this->headers['from'];
+ $this->name = preg_replace('/<[^ ]*>/', '', $this->name);
+ $this->name = trim($this->name);
}
}
}
}
+function spoolcompare($a,$b) { return ($b->date>=$a->date); }
+
/** Class spoolhead
* class used in thread overviews
*/
* Copyright: See COPYING files that comes with this distribution
********************************************************************************/
-/** comparison function for the overview
- * @param $a OBJECT spoolhead
- * @param $b OBJECT spoolhead
- * @return
- */
-
-function spoolcompare($a,$b) {
- global $news;
- return ($b->date>=$a->date);
-}
-
// spool config in spool.inc.php
$news['maxspool'] = 3000;
// headers in article.php
$news['head'] = array(
- 'From' => 'from',
- 'Subject' => 'subject',
- 'Newsgroups' => 'newsgroups',
- 'Followup-To' => 'followup',
- 'Date' => 'date',
- 'Message-ID' => 'msgid',
- 'Organization' => 'organization',
- 'References' => 'references',
- 'X-Face' => 'xface',
- );
+ 'From' => 'from',
+ 'Subject' => 'subject',
+ 'Newsgroups' => 'newsgroups',
+ 'Followup-To' => 'followup',
+ 'Date' => 'date',
+ 'Message-ID' => 'msgid',
+ 'Organization' => 'organization',
+ 'References' => 'references',
+ 'X-Face' => 'xface',
+);
// headers in article.php
$news['headdisp']=array(
- 'from',
- 'subject',
- 'newsgroups',
- 'followup',
- 'date',
- 'organization',
- 'references',
- 'xface'
-);
+ 'from',
+ 'subject',
+ 'newsgroups',
+ 'followup',
+ 'date',
+ 'organization',
+ 'references',
+ 'xface'
+ );
// overview configuration in article.php
$news['threadtop'] = 5;
// custom headers in post.php
$news['customhdr'] = "Content-Type: text/plain; charset=iso-8859-15\n"
- ."Mime-Version: 1.0\n"
- ."Content-Transfer-Encoding: 8bit\n"
- ."HTTP-Posting-Host: ".gethostbyname($_SERVER['REMOTE_ADDR'])."\n"
- ."User-Agent: Banana 0.7.1\n";
+."Mime-Version: 1.0\n"
+."Content-Transfer-Encoding: 8bit\n"
+."HTTP-Posting-Host: ".gethostbyname($_SERVER['REMOTE_ADDR'])."\n"
+."User-Agent: Banana 0.7.1\n";
$css = array(
- 'bananashortcuts' => 'bananashortcuts',
- 'bicol' => 'bicol',
- 'bicoltitre' => 'bicoltitre',
- 'bicolvpadd' => 'bicolvpadd',
- 'pair' => 'pair',
- 'impair' => 'impair',
- 'bouton' => 'bouton',
- 'error' => 'error',
- 'normal' => 'normal',
- 'total' => 'total',
- 'unread' => 'unread',
- 'group' => 'group',
- 'description' => 'description',
- 'date' => 'date',
- 'subject' => 'subject',
- 'from' => 'from',
- 'author' => 'author',
- 'nopadd' => 'nopadd',
- 'overview' => 'overview',
- 'tree' => 'tree'
-);
+ 'bananashortcuts' => 'bananashortcuts',
+ 'bicol' => 'bicol',
+ 'bicoltitre' => 'bicoltitre',
+ 'bicolvpadd' => 'bicolvpadd',
+ 'pair' => 'pair',
+ 'impair' => 'impair',
+ 'bouton' => 'bouton',
+ 'error' => 'error',
+ 'normal' => 'normal',
+ 'total' => 'total',
+ 'unread' => 'unread',
+ 'group' => 'group',
+ 'description' => 'description',
+ 'date' => 'date',
+ 'subject' => 'subject',
+ 'from' => 'from',
+ 'author' => 'author',
+ 'nopadd' => 'nopadd',
+ 'overview' => 'overview',
+ 'tree' => 'tree'
+ );
?>
case "date":
return formatDate($_text);
- case "followup":
+ case "followup-to":
case "newsgroups":
$res = "";
$groups = preg_split("/(\t| )*,(\t| )*/",$_text);
}
return $rsl;
- case "xface":
+ case "x-face":
return '<img src="xface.php?face='.base64_encode($_text)
.'" alt="x-face" />';
* @return BOOLEAN true if user has right to cancel message
*/
function checkcancel($_headers) {
- return ($_headers->from == $_SESSION['name']." <".$_SESSION['mail'].">");
+ return ($_headers['from'] == $_SESSION['name']." <".$_SESSION['mail'].">");
}
/** getprofile : sets profile variables
$profile = getprofile();
require_once("include/header.inc.php");
if (isset($_REQUEST['group'])) {
- $group=htmlentities(strtolower($_REQUEST['group']));
+ $group=htmlentities(strtolower($_REQUEST['group']));
}
if (isset($_REQUEST['id'])) {
- $id=htmlentities(strtolower($_REQUEST['id']));
+ $id=htmlentities(strtolower($_REQUEST['id']));
}
if (isset($group)) {
- $target = $group;
+ $target = $group;
}
$nntp = new nntp($news['server']);
if (!$nntp) error("nntpsock");
if ($news['user']!="anonymous") {
- $result = $nntp->authinfo($news["user"],$news["pass"]);
- if (!$result) error("nntpauth");
+ $result = $nntp->authinfo($news["user"],$news["pass"]);
+ if (!$result) error("nntpauth");
}
if (isset($group) && isset($id) && isset($_REQUEST['type']) &&
- ($_REQUEST['type']=='followup')) {
- $rq=$nntp->group($group);
- $post = new NNTPPost($nntp,$id);
- if ($post) {
- $subject = (preg_match("/^re:/i",$post->headers->subject)?"":"Re: ")
- .$post->headers->subject;
- if ($profile['dropsig']) {
- $cutoff=strpos($post->body,"\n-- \n");
- if ($cutoff) {
- $quotetext = substr($post->body,0,strpos($post->body,"\n-- \n"));
- } else {
- $quotetext = $post->body;
- }
- } else {
- $quotetext = $post->body;
- }
- $body = $post->headers->name." wrote :\n".wrap($quotetext, "> ");
- if (isset($post->headers->followup))
- $target=$post->headers->followup;
- else
- $target=$post->headers->newsgroups;
- }
+ ($_REQUEST['type']=='followup')) {
+ $rq=$nntp->group($group);
+ $post = new NNTPPost($nntp,$id);
+ if ($post) {
+ $subject = (preg_match("/^re:/i",$post->headers['subject'])?"":"Re: ").$post->headers['subject'];
+ if ($profile['dropsig']) {
+ $cutoff=strpos($post->body,"\n-- \n");
+ if ($cutoff) {
+ $quotetext = substr($post->body,0,strpos($post->body,"\n-- \n"));
+ } else {
+ $quotetext = $post->body;
+ }
+ } else {
+ $quotetext = $post->body;
+ }
+ $body = $post->name." wrote :\n".wrap($quotetext, "> ");
+ if (isset($post->headers['followup-to']))
+ $target = $post->headers['followup-to'];
+ else
+ $target = $post->headers['newsgroups'];
+ }
}
$nntp->quit();
$rq=$nntp->group($group);
$post = new NNTPPost($nntp,$id);
if ($post) {
- $refs = (isset($post->headers->references)?
- $post->headers->references." ":"").$post->headers->msgid;
+ $refs = (isset($post->headers['references'])?
+ $post->headers['references']." ":"").$post->headers['message-id'];
}
$body = preg_replace("/\n\.[ \t\r]*\n/m","\n..\n",stripslashes($_REQUEST['body']));