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
);
49 /** MSGNUM : *local* spool id */
50 var $nb; // numéro du post
51 /** MSGID : Message-ID */
52 var $msgid; // Message-ID
55 /** Name (if present in From header) */
57 /** Mail (in From header) */
60 var $subject; // Subject
61 /** Newsgroup¨ header */
62 var $newsgroups; // Newsgroups
63 /** Followup-To header */
65 /** Content-Type header */
67 /** Content-Transfer-Encoding header */
71 /** Organization header */
73 /** References header */
77 * @param $_nntp RESOURCE handle to NNTP socket
78 * @param $_id STRING MSGNUM or MSGID
81 function headers(&$_nntp,$_id) {
83 $hdrs = $_nntp->head($_id);
89 foreach ($hdrs as $line) {
90 if (preg_match("/^[\t\r ]+/",$line)) {
91 $line = ($lasthdr=="X-Face"?
"":" ").ltrim($line);
92 if (in_array($lasthdr,array_keys($news['head'])))
93 $this->{$news['head'][$lasthdr]} .= $line;
95 list($hdr,$val) = split(":[ \t\r]*",$line,2);
96 if (in_array($hdr,array_keys($news['head'])))
97 $this->{$news['head'][$hdr]} = $val;
102 foreach ($news['hdecode'] as $hdr) {
103 if (isset($this->$hdr)) {
104 $this->$hdr = headerDecode($this->$hdr);
107 // sets name and mail
108 $this->name
= $this->from
;
109 $this->mail
= $this->from
;
110 if (preg_match("/(.*)<(.*)@(.*)>/",$val,$match)) {
111 $this->name
= str_replace("\"","",trim($match[1]));
112 $this->mail
= $match[2]."@".$match[3];
114 if (preg_match("/([\w\.]+)@([\w\.]+) \((.*)\)/",$val,$match)) {
115 $this->name
= trim($match[3]);
116 $this->mail
= $match[1]."@".$match[2];