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
);
45 /** MSGNUM : *local* spool id */
46 var $nb; // numéro du post
47 /** MSGID : Message-ID */
48 var $msgid; // Message-ID
51 /** Name (if present in From header) */
53 /** Mail (in From header) */
56 var $subject; // Subject
57 /** Newsgroup¨ header */
58 var $newsgroups; // Newsgroups
59 /** Followup-To header */
61 /** Content-Type header */
63 /** Content-Transfer-Encoding header */
67 /** Organization header */
69 /** References header */
73 * @param $_nntp RESOURCE handle to NNTP socket
74 * @param $_id STRING MSGNUM or MSGID
77 function headers(&$_nntp,$_id) {
79 $hdrs = $_nntp->head($_id);
85 foreach ($hdrs as $line) {
86 if (preg_match("/^[\t\r ]+/",$line)) {
87 $line = ($lasthdr=="X-Face"?
"":" ").ltrim($line);
88 if (in_array($lasthdr,array_keys($news['head'])))
89 $this->{$news['head'][$lasthdr]} .= $line;
91 list($hdr,$val) = split(":[ \t\r]*",$line,2);
92 if (in_array($hdr,array_keys($news['head'])))
93 $this->{$news['head'][$hdr]} = $val;
98 foreach ($news['hdecode'] as $hdr) {
99 if (isset($this->$hdr)) {
100 $this->$hdr = headerDecode($this->$hdr);
103 // sets name and mail
104 $this->name
= $this->from
;
105 $this->mail
= $this->from
;
106 if (preg_match("/(.*)<(.*)@(.*)>/",$val,$match)) {
107 $this->name
= str_replace("\"","",trim($match[1]));
108 $this->mail
= $match[2]."@".$match[3];
110 if (preg_match("/([\w\.]+)@([\w\.]+) \((.*)\)/",$val,$match)) {
111 $this->name
= trim($match[3]);
112 $this->mail
= $match[1]."@".$match[2];