9397b86b9edaf2ee8418e4af5e91fc50052e0434
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 post(&$_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
)) &&
31 (preg_match("/base64/",$this->headers
->contentencoding
))) {
32 $this->body
= base64_decode($this->body
);
34 if ((isset($this->headers
->contentencoding
)) &&
35 (preg_match("/quoted-printable/",$this->headers
->contentencoding
))) {
36 $this->body
= quoted_printable_decode($this->body
);
38 if(preg_match('!charset=([^;]*);!', $this->headers
->contenttype
, $matches)) {
39 $this->body
= iconv($matches[1], 'iso-8859-1', $this->body
);
48 /** MSGNUM : *local* spool id */
49 var $nb; // numéro du post
50 /** MSGID : Message-ID */
51 var $msgid; // Message-ID
54 /** Name (if present in From header) */
56 /** Mail (in From header) */
59 var $subject; // Subject
60 /** Newsgroup¨ header */
61 var $newsgroups; // Newsgroups
62 /** Followup-To header */
64 /** Content-Type header */
66 /** Content-Transfer-Encoding header */
70 /** Organization header */
72 /** References header */
76 * @param $_nntp RESOURCE handle to NNTP socket
77 * @param $_id STRING MSGNUM or MSGID
80 function headers(&$_nntp,$_id) {
82 $hdrs = $_nntp->head($_id);
88 foreach ($hdrs as $line) {
89 if (preg_match("/^[\t\r ]+/",$line)) {
90 $line = ($lasthdr=="X-Face"?
"":" ").ltrim($line);
91 if (in_array($lasthdr,array_keys($news['head'])))
92 $this->{$news['head'][$lasthdr]} .= $line;
94 list($hdr,$val) = split(":[ \t\r]*",$line,2);
95 if (in_array($hdr,array_keys($news['head'])))
96 $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];