2 /********************************************************************************
3 * install.d/config.inc.php : configuration file
4 * --------------------------
6 * This file is part of the banana distribution
7 * Copyright: See COPYING files that comes with this distribution
8 ********************************************************************************/
10 require_once("include/misc.inc.php");
11 require_once("include/error.inc.php");
17 var $hdecode = array('from','name','organization','subject');
18 var $parse_hdr = array('content-transfer-encoding', 'content-type', 'date', 'followup-to', 'from',
19 'message-id', 'newsgroups', 'organization', 'references', 'subject', 'x-face');
20 var $show_hdr = array('from', 'subject', 'newsgroups', 'followup', 'date', 'organization', 'references', 'x-face');
29 var $custom = "Content-Type: text/plain; charset=iso-8859-15\nMime-Version: 1.0\nContent-Transfer-Encoding: 8bit\nUser-Agent: Banana @VERSION@\n";
31 var $host = 'news://localhost:119/';
33 var $profile = Array( 'name' => 'Anonymous <anonymouse@example.com>', 'sig' => '', 'org' => '',
34 'customhdr' =>'', 'display' => 0, 'lastnews' => 0, 'locale' => 'fr_FR', 'subscribe' => array());
44 if (function_exists('hook_banana')) {
47 $this->_setupProfile();
48 require_once('include/NetNNTP.inc.php');
49 $this->nntp
= new nntp($this->host
);
52 /**************************************************************************/
54 /**************************************************************************/
56 function action_listGroups()
60 $cuts = displayshortcuts();
61 $res = '<h1>'._b_('Les forums de Banana').'</h1>'.$cuts.$this->groups
->to_html();
62 if (count($this->newgroups
->overview
)) {
63 $res .= '<p>'._b_('Les forums suivants ont été créés depuis ton dernier passage :').'</p>';
64 $res .= $this->newgroups
->to_html();
71 function action_listSubs()
73 require_once("include/groups.inc.php");
74 $this->groups
= new BananaGroups(BANANA_GROUP_ALL
);
76 $cuts = displayshortcuts();
77 $res = '<h1>'._b_('Abonnements').'</h1>'.$cuts.$this->groups
->to_html(true
).$cuts;
83 function action_showThread($group, $first)
85 $this->newSpool($group, $this->profile
['display'], $this->profile
['lastnews']);
87 if ($first > count($this->spool
->overview
)) {
88 $first = count($this->spool
->overview
);
91 $first = $first - ($first %
$this->tmax
) +
1;
93 $cuts = displayshortcuts($first);
95 $res = '<h1>'.$group.'</h1>'.$cuts;
96 $res .= $this->spool
->to_html($first, $first+
$this->tmax
);
103 function action_showArticle($group, $id)
105 $this->newSpool($group, $this->profile
['display'], $this->profile
['lastnews']);
108 if ($this->nntp
->lasterrorcode
== "423") {
109 $this->spool
->delid($id);
112 return displayshortcuts().'<p class="error">'._b_('Impossible d\'accéder au message. Le message a peut-être été annulé').'</p>';
115 $cuts = displayshortcuts();
116 $res = '<h1>'._b_('Message').'</h1>'.$cuts;
117 $res .= $this->post
->to_html();
124 function action_newFup($group, $id = -1)
126 $subject = $body = '';
130 $this->nntp
->group($group);
133 $subject = preg_replace("/^re\s*:\s*/i", 'Re: ', $this->post
->headers
['subject']);
134 $body = $this->post
->name
." "._b_("a écrit")." :\n".wrap($this->post
->body
, "> ");
135 $target = isset($this->post
->headers
['followup-to']) ?
$this->post
->headers
['followup-to'] : $this->post
->headers
['newsgroups'];
141 $cuts = displayshortcuts();
142 $html = '<h1>'._b_('Nouveau message').'</h1>'.$cuts;
143 $html .= '<form action="?" method="post">';
144 $html .= '<table class="bicol" cellpadding="0" cellspacing="0">';
145 $html .= '<tr><th colspan="2">'._b_('En-têtes').'</th></tr>';
146 $html .= '<tr><td>'._b_('Nom').'</td><td>'.htmlentities($this->profile
['name']).'</td></tr>';
147 $html .= '<tr><td>'._b_('Sujet').'</td><td><input type="text" name="subject" value="'.htmlentities($subject).'" size="60" /></td></tr>';
148 $html .= '<tr><td>'._b_('Forums').'</td><td><input type="text" name="newsgroups" value="'.htmlentities($target).'" size="60" /></td></tr>';
149 $html .= '<tr><td>'._b_('Suivi à').'</td><td><input type="text" name="newsgroups" value="" size="60" /></td></tr>';
150 $html .= '<tr><td>'._b_('Organisation').'</td><td>'.$this->profile
['org'].'</td></tr>';
151 $html .= '<tr><th colspan="2">'._b_('Corps').'</th></tr>';
152 $html .= '<tr><td colspan="2"><textarea name="body" cols="74" rows="16">'
153 .htmlentities($body).($this->profile
['sig'] ?
"\n\n-- \n".htmlentities($this->profile
['sig']) : '').'</textarea></td></th>';
154 $html .= '<tr><td colspan="2"><input type="hidden" name="group" value="'.$group.'" />';
156 $html .= '<input type="hidden" name="id" value="'.$id.'" />';
158 $html .= '<input type="submit" /></td></tr>';
159 $html .= '</table></form>';
164 /**************************************************************************/
166 /**************************************************************************/
168 function newSpool($group, $disp=0, $since='') {
169 require_once('include/spool.inc.php');
170 $this->spool
= new BananaSpool($group, $disp, $since);
173 function newPost($id)
175 require_once("include/post.inc.php");
176 $this->post
= new BananaPost($id);
181 require_once("include/groups.inc.php");
182 $this->groups
= new BananaGroups(BANANA_GROUP_SUB
);
183 if ($this->groups
->type
== BANANA_GROUP_SUB
) {
184 $this->newgroups
= new BananaGroups(BANANA_GROUP_NEW
);
188 /**************************************************************************/
190 /**************************************************************************/
192 function _setupProfile()
194 if (function_exists('hook_getprofile')) {
195 $this->profile
= hook_getprofile();
198 setlocale(LC_ALL
, $this->profile
['locale']);
202 $banana = new Banana
;