60f29868e689158c4465e6cbfee057d8cbcfee57
2 /********************************************************************************
3 * include/posts.inc.php : class for posts
4 * -----------------------
6 * This file is part of the banana distribution
7 * Copyright: See COPYING files that comes with this distribution
8 ********************************************************************************/
24 * @param $_id STRING MSGNUM or MSGID (a group should be selected in this case)
26 function BananaPost($_id)
32 if ($body = $banana->nntp
->body($_id)) {
33 $this->body
= join("\n", $body);
35 return ($this = null
);
38 if (isset($this->headers
['content-transfer-encoding'])) {
39 if (preg_match("/base64/", $this->headers
['content-transfer-encoding'])) {
40 $this->body
= base64_decode($this->body
);
41 } elseif (preg_match("/quoted-printable/", $this->headers
['content-transfer-encoding'])) {
42 $this->body
= quoted_printable_decode($this->body
);
46 if (preg_match('!charset=([^;]*)\s*(;|$)!', $this->headers
['content-type'], $matches)) {
47 require_once 'banana/misc.inc.php';
48 $this->body
= to_html($this->body
, $matches[1]);
55 $hdrs = $banana->nntp
->head($this->id
);
62 foreach ($hdrs as $line) {
63 if (preg_match("/^[\t\r ]+/", $line)) {
64 $line = ($hdr=="X-Face"?
"":" ").ltrim($line);
65 if (in_array($hdr, $banana->parse_hdr
)) {
66 $this->headers
[$hdr] .= $line;
69 list($hdr, $val) = split(":[ \t\r]*", $line, 2);
70 $hdr = strtolower($hdr);
71 if (in_array($hdr, $banana->parse_hdr
)) {
72 $this->headers
[$hdr] = $val;
77 foreach ($banana->hdecode
as $hdr) {
78 if (isset($this->headers
[$hdr])) {
79 $this->headers
[$hdr] = headerDecode($this->headers
[$hdr]);
83 $this->name
= $this->headers
['from'];
84 $this->name
= preg_replace('/<[^ ]*>/', '', $this->name
);
85 $this->name
= trim($this->name
);
88 function checkcancel()
90 if (function_exists('hook_checkcancel')) {
91 return hook_checkcancel($this->headers
);
93 return ($this->headers
['from'] == $_SESSION['name']." <".$_SESSION['mail'].">");
100 $res = '<table class="bicol banana_msg" cellpadding="0" cellspacing="0">';
101 $res .= '<tr><th colspan="2">'._b_('En-tĂȘtes').'</th></tr>';
103 foreach ($banana->show_hdr
as $hdr) {
104 if (isset($this->headers
[$hdr])) {
105 $res2 = formatdisplayheader($hdr, $this->headers
[$hdr]);
107 $res .= '<tr><td class="hdr">'.header_translate($hdr)."</td><td class='val'>$res2</td></tr>\n";
112 $res .= '<tr><th colspan="2">'._b_('Corps').'</th></tr>';
113 $res .= '<tr><td colspan="2"><pre>'.formatbody($this->body
).'</pre></td></tr>';
115 $res .= '<tr><th colspan="2">'._b_('apercu').'</th></tr>';
116 $ndx = $banana->spool
->getndx($this->id
);
117 $res .= '<tr><td class="thrd" colspan="2">'.$banana->spool
->to_html($ndx-$banana->tbefore
, $ndx+
$banana->tafter
, $ndx).'</td></tr>';
119 return $res.'</table>';