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 ********************************************************************************/
20 * @param $_nntp RESOURCE handle to NNTP socket
21 * @param $_id STRING MSGNUM or MSGID (a group should be selected in this case)
23 function NNTPPost(&$_nntp, $_id) {
24 $this->headers
= new headers($_nntp, $_id);
25 if (!$this->headers
) {
29 $this->body
= join("\n", $_nntp->body($_id));
30 if (isset($this->headers
->contentencoding
) && preg_match("/base64/", $this->headers
->contentencoding
)) {
31 $this->body
= base64_decode($this->body
);
33 if (isset($this->headers
->contentencoding
) && preg_match("/quoted-printable/", $this->headers
->contentencoding
)) {
34 $this->body
= quoted_printable_decode($this->body
);
36 if (preg_match('!charset=([^;]*);!', $this->headers
->contenttype
, $matches)) {
37 $this->body
= iconv($matches[1], 'iso-8859-1', $this->body
);
46 /** MSGNUM : *local* spool id */
47 var $nb; // numéro du post
48 /** MSGID : Message-ID */
49 var $msgid; // Message-ID
52 /** Name (if present in From header) */
54 /** Mail (in From header) */
57 var $subject; // Subject
58 /** Newsgroup¨ header */
59 var $newsgroups; // Newsgroups
60 /** Followup-To header */
62 /** Content-Type header */
64 /** Content-Transfer-Encoding header */
68 /** Organization header */
70 /** References header */
74 * @param $_nntp RESOURCE handle to NNTP socket
75 * @param $_id STRING MSGNUM or MSGID
78 function headers(&$_nntp, $_id) {
80 $hdrs = $_nntp->head($_id);
86 foreach ($hdrs as $line) {
87 if (preg_match("/^[\t\r ]+/", $line)) {
88 $line = ($lasthdr=="X-Face"?
"":" ").ltrim($line);
89 if (in_array($lasthdr, array_keys($news['head']))) {
90 $this->{$news['head'][$lasthdr]} .= $line;
93 list($hdr, $val) = split(":[ \t\r]*", $line, 2);
94 if (in_array($hdr, array_keys($news['head']))) {
95 $this->{$news['head'][$hdr]} = $val;
101 foreach ($news['hdecode'] as $hdr) {
102 if (isset($this->$hdr)) {
103 $this->$hdr = headerDecode($this->$hdr);
106 // sets name and mail
107 $this->name
= $this->from
;
108 $this->mail
= $this->from
;
109 if (preg_match("/(.*)<(.*)@(.*)>/", $val, $match)) {
110 $this->name
= str_replace("\"", "", trim($match[1]));
111 $this->mail
= $match[2]."@".$match[3];
113 if (preg_match("/([\w\.]+)@([\w\.]+) \((.*)\)/", $val, $match)) {
114 $this->name
= trim($match[3]);
115 $this->mail
= $match[1]."@".$match[2];