3 /********************************************************************************
4 * include/posts.inc.php : class for posts
5 * -----------------------
7 * This file is part of the banana distribution
8 * Copyright: See COPYING files that comes with this distribution
9 ********************************************************************************/
21 * @param $_nntp RESOURCE handle to NNTP socket
22 * @param $_id STRING MSGNUM or MSGID (a group should be selected in this case)
24 function post(&$_nntp,$_id) {
25 $this->headers
= new headers($_nntp,$_id);
26 if (!$this->headers
) {
30 $this->body
= join("\n",$nntp->body($_id));
31 if ((isset($this->headers
->contentencoding
)) &&
32 (preg_match("/base64/",$this->headers
->contentencoding
))) {
33 $this->body
= base64_decode($this->body
);
35 if ((isset($this->headers
->contentencoding
)) &&
36 (preg_match("/quoted-printable/",$this->headers
->contentencoding
))) {
37 $this->body
= quoted_printable_decode($this->body
);
50 /** MSGNUM : *local* spool id */
51 var $nb; // numéro du post
52 /** MSGID : Message-ID */
53 var $msgid; // Message-ID
56 /** Name (if present in From header) */
58 /** Mail (in From header) */
61 var $subject; // Subject
62 /** Newsgroup¨ header */
63 var $newsgroups; // Newsgroups
64 /** Followup-To header */
66 /** Content-Type header */
68 /** Content-Transfer-Encoding header */
72 /** Organization header */
74 /** References header */
78 * @param $_nntp RESOURCE handle to NNTP socket
79 * @param $_id STRING MSGNUM or MSGID
82 function headers(&$_nntp,$_id) {
84 $hdrs = $_nntp->head($_id);
90 foreach ($hdrs as $line) {
91 if (preg_match("/^[\t\r ]+/",$line)) {
92 $line = ($lasthdr=="X-Face"?
"":" ").ltrim($line);
93 if (in_array($lasthdr,array_keys($news['head'])))
94 $this->{$news['head'][$lasthdr]} .= $line;
96 list($hdr,$val) = split(":[ \t\r]*",$line,2);
97 if (in_array($hdr,array_keys($news['head'])))
98 $this->{$news['head'][$hdr]} = $val;
103 foreach ($news['hdecode'] as $hdr) {
104 if (isset($this->$hdr)) {
105 $this->$hdr = headerDecode($this->$hdr);
108 // sets name and mail
109 $this->name
= $this->from
;
110 $this->mail
= $this->from
;
111 if (preg_match("/(.*)<(.*)@(.*)>/",$val,$match)) {
112 $this->name
= str_replace("\"","",trim($match[1]));
113 $this->mail
= $match[2]."@".$match[3];
115 if (preg_match("/([\w\.]+)@([\w\.]+) \((.*)\)/",$val,$match)) {
116 $this->name
= trim($match[3]);
117 $this->mail
= $match[1]."@".$match[2];