78cd27b3 |
1 | <?php |
2 | /******************************************************************************** |
ab02e8a9 |
3 | * banana/banana.inc.php : banana main file |
78cd27b3 |
4 | * -------------------------- |
5 | * |
6 | * This file is part of the banana distribution |
7 | * Copyright: See COPYING files that comes with this distribution |
8 | ********************************************************************************/ |
9 | |
10 | class Banana |
11 | { |
78cd27b3 |
12 | |
7972645b |
13 | ####### |
14 | # Configuration variables |
15 | ####### |
16 | |
17 | ### General ### |
18 | static public $profile = Array( 'signature' => '', |
19 | 'headers' => array('From' => 'Anonymous <anonymouse@example.com>'), |
20 | 'display' => 0, |
21 | 'lastnews' => 0, |
22 | 'locale' => 'fr_FR', |
23 | 'subscribe' => array(), |
24 | 'autoup' => 1); |
25 | static public $boxpattern; |
ed3717e5 |
26 | static public $withtabs = true; |
7972645b |
27 | |
28 | ### Spool ### |
29 | static public $spool_max = 3000; |
30 | static public $spool_tbefore = 5; |
31 | static public $spool_tafter = 5; |
32 | static public $spool_tmax = 50; |
e0f557df |
33 | static public $spool_boxlist = true; |
7972645b |
34 | |
35 | ### Message processing ### |
36 | static public $msgparse_headers = array('content-disposition', 'content-transfer-encoding', |
ab02e8a9 |
37 | 'content-type', 'content-id', 'date', 'followup-to', |
38 | 'from', 'message-id', 'newsgroups', 'organization', |
39 | 'references', 'subject', 'x-face', 'in-reply-to', |
40 | 'to', 'cc', 'reply-to'); |
4f6a209a |
41 | |
7972645b |
42 | ### Message display ### |
43 | static public $msgshow_headers = array('from', 'newsgroups', 'followup-to', 'to', 'cc', 'reply-to', |
44 | 'organization', 'date', 'references', 'in-reply-to'); |
bf791d69 |
45 | static public $msgshow_mimeparts = array('multipart/report', 'multipart/mixed', 'text/html', 'text/plain', 'text/enriched', 'text', 'message'); |
7972645b |
46 | static public $msgshow_xface = true; |
47 | static public $msgshow_wrap = 78; |
3be61f09 |
48 | static public $msgshow_externalimages = false; |
ed3717e5 |
49 | static public $msgshow_withthread = true; |
78cd27b3 |
50 | |
87514711 |
51 | /** Match an url |
bf791d69 |
52 | * Should be included in a regexp delimited using /, !, , or @ (eg: "/$url_regexp/ui") |
87514711 |
53 | * If it matches, return 3 main parts : |
54 | * \\1 and \\3 are delimiters |
55 | * \\2 is the url |
56 | * |
57 | * eg : preg_match("!$url_regexp!i", "[http://www.polytechnique.org]", $matches); |
58 | * $matches[1] = "[" |
59 | * $matches[2] = "http://www.polytechnique.org" |
60 | * $matches[3] = "]" |
61 | */ |
e0f557df |
62 | static public $msgshow_url = '(["\[])?((?:[a-z]+:\/\/|www\.)(?:[\.\,\;\!]*[a-z\@0-9~%$£µ&i#\-+=_\/\?]+)+)(["\]])?'; |
78cd27b3 |
63 | |
7972645b |
64 | ### Message edition ### |
65 | static public $msgedit_canattach = true; |
66 | static public $msgedit_maxfilesize = 100000; |
f12fdb59 |
67 | /** Global headers to use for messages |
a1937df3 |
68 | */ |
7972645b |
69 | static public $msgedit_headers = array('Mime-Version' => '1.0', 'User-Agent' => 'Banana @VERSION@'); |
bf791d69 |
70 | /** Mime type order for quoting |
71 | */ |
72 | static public $msgedit_mimeparts = array('multipart/report', 'multipart/mixed', 'text/plain', 'text/enriched', 'text/html', 'text', 'message'); |
73 | |
7972645b |
74 | ### Protocole ### |
a1937df3 |
75 | /** News serveur to use |
76 | */ |
7972645b |
77 | static public $nntp_host = 'news://localhost:119/'; |
ab02e8a9 |
78 | |
7972645b |
79 | static public $mbox_path = '/var/mail'; |
ab02e8a9 |
80 | |
7972645b |
81 | ### Debug ### |
ab02e8a9 |
82 | static public $debug_nntp = false; |
83 | static public $debug_smarty = false; |
84 | |
85 | |
7972645b |
86 | ####### |
87 | # Constants |
88 | ####### |
89 | |
ab02e8a9 |
90 | // Actions |
91 | const ACTION_BOX_NEEDED = 1; // mask |
92 | const ACTION_BOX_LIST = 2; |
93 | const ACTION_BOX_SUBS = 4; |
94 | const ACTION_MSG_LIST = 3; |
95 | const ACTION_MSG_READ = 5; |
96 | const ACTION_MSG_NEW = 9; |
97 | const ACTION_MSG_CANCEL = 17; |
98 | |
99 | // Box list view |
100 | const BOXES_ALL = 0; |
101 | const BOXES_SUB = 1; |
102 | const BOXES_NEW = 2; |
103 | |
104 | // Spool view mode |
105 | const SPOOL_ALL = 0; |
106 | const SPOOL_UNREAD = 1; |
107 | |
7972645b |
108 | |
109 | ####### |
110 | # Runtime variables |
111 | ####### |
112 | |
113 | static public $protocole = null; |
114 | static public $spool = null; |
115 | static public $message = null; |
116 | static public $page = null; |
117 | |
118 | static public $group = null; |
119 | static public $artid = null; |
120 | static public $action = null; |
121 | static public $part = null; |
122 | static public $first = null; |
123 | |
ab02e8a9 |
124 | /** Class parameters storage |
125 | */ |
126 | public $params; |
78cd27b3 |
127 | |
7972645b |
128 | |
129 | ####### |
130 | # Banana Implementation |
131 | ####### |
132 | |
ab02e8a9 |
133 | /** Build the instance of Banana |
134 | * This constructor only call \ref loadParams, connect to the server, and build the Smarty page |
135 | * @param protocole Protocole to use |
f6df9eb2 |
136 | */ |
ab02e8a9 |
137 | public function __construct($params = null, $protocole = 'NNTP', $pageclass = 'BananaPage') |
78cd27b3 |
138 | { |
ab02e8a9 |
139 | Banana::load('text.func'); |
140 | if (is_null($params)) { |
141 | $this->params = $_GET; |
1786dc36 |
142 | } else { |
ab02e8a9 |
143 | $this->params = $params; |
1786dc36 |
144 | } |
ab02e8a9 |
145 | $this->loadParams(); |
1786dc36 |
146 | |
ab02e8a9 |
147 | // connect to protocole handler |
ab02e8a9 |
148 | $classname = 'Banana' . $protocole; |
7972645b |
149 | if (!class_exists($classname)) { |
150 | Banana::load($protocole); |
151 | } |
ab02e8a9 |
152 | Banana::$protocole = new $classname(Banana::$group); |
78cd27b3 |
153 | |
ab02e8a9 |
154 | // build the page |
155 | if ($pageclass == 'BananaPage') { |
156 | Banana::load('page'); |
3c3d29bb |
157 | } |
ab02e8a9 |
158 | Banana::$page = new $pageclass; |
159 | } |
78cd27b3 |
160 | |
ab02e8a9 |
161 | /** Fill state vars (Banana::$group, Banana::$artid, Banana::$action, Banana;:$part, Banana::$first) |
162 | */ |
163 | protected function loadParams() |
164 | { |
165 | Banana::$group = isset($this->params['group']) ? $this->params['group'] : null; |
166 | Banana::$artid = isset($this->params['artid']) ? $this->params['artid'] : null; |
167 | Banana::$first = isset($this->params['first']) ? $this->params['first'] : null; |
168 | Banana::$part = isset($this->params['part']) ? $this->params['part'] : 'text'; |
169 | |
170 | // Look for the action to execute |
171 | if (is_null(Banana::$group)) { |
ded3974d |
172 | if (isset($this->params['action']) && $this->params['action'] == 'subscribe') { |
ab02e8a9 |
173 | Banana::$action = Banana::ACTION_BOX_SUBS; |
78cd27b3 |
174 | } else { |
ab02e8a9 |
175 | Banana::$action = Banana::ACTION_BOX_LIST; |
78cd27b3 |
176 | } |
ab02e8a9 |
177 | return; |
178 | } |
179 | $action = isset($this->params['action']) ? $this->params['action'] : null; |
180 | if (is_null(Banana::$artid)) { |
181 | if ($action == 'new') { |
182 | Banana::$action = Banana::ACTION_MSG_NEW; |
183 | } else { |
184 | Banana::$action = Banana::ACTION_MSG_LIST; |
7a0e2710 |
185 | } |
ab02e8a9 |
186 | return; |
187 | } |
188 | switch ($action) { |
189 | case 'new': |
190 | Banana::$action = Banana::ACTION_MSG_NEW; |
191 | return; |
192 | case 'cancel': |
193 | Banana::$action = Banana::ACTION_MSG_CANCEL; |
194 | return; |
195 | default: |
196 | Banana::$action = Banana::ACTION_MSG_READ; |
78cd27b3 |
197 | } |
198 | } |
199 | |
ab02e8a9 |
200 | /** Run Banana |
201 | * This function need user profile to be initialised |
202 | */ |
203 | public function run() |
78cd27b3 |
204 | { |
ab02e8a9 |
205 | // Configure locales |
206 | setlocale(LC_ALL, Banana::$profile['locale']); |
78cd27b3 |
207 | |
ab02e8a9 |
208 | // Check if the state is valid |
209 | if (Banana::$protocole->lastErrNo()) { |
d8d416c4 |
210 | return Banana::$page->kill(_b_('Une erreur a été rencontrée lors de la connexion au serveur') . '<br />' |
ab02e8a9 |
211 | . Banana::$protocole->lastError()); |
212 | } |
213 | if (!Banana::$protocole->isValid()) { |
214 | return Banana::$page->kill(_b_('Connexion non-valide')); |
215 | } |
216 | if (Banana::$action & Banana::ACTION_BOX_NEEDED) { |
7972645b |
217 | if(Banana::$boxpattern && !preg_match('/' . Banana::$boxpattern . '/i', $group)) { |
ab02e8a9 |
218 | Banana::$page->setPage('group'); |
d8d416c4 |
219 | return Banana::$page->kill(_b_("Ce newsgroup n'existe pas ou vous n'avez pas l'autorisation d'y accéder")); |
ab02e8a9 |
220 | } |
221 | } |
78cd27b3 |
222 | |
ab02e8a9 |
223 | // Dispatch to the action handlers |
224 | switch (Banana::$action) { |
225 | case Banana::ACTION_BOX_SUBS: |
226 | $error = $this->action_subscribe(); |
227 | break; |
228 | case Banana::ACTION_BOX_LIST: |
229 | $error = $this->action_listBoxes(); |
230 | break; |
231 | case Banana::ACTION_MSG_LIST: |
232 | $error = $this->action_showThread(Banana::$group, Banana::$first); |
233 | break; |
234 | case Banana::ACTION_MSG_READ: |
235 | $error = $this->action_showMessage(Banana::$group, Banana::$artid, Banana::$part); |
236 | break; |
237 | case Banana::ACTION_MSG_NEW: |
238 | $error = $this->action_newMessage(Banana::$group, Banana::$artid); |
239 | break; |
240 | case Banana::ACTION_MSG_CANCEL: |
241 | $error = $this->action_cancelMessage(Banana::$group, Banana::$artid); |
242 | break; |
243 | default: |
d8d416c4 |
244 | $error = _b_("L'action demandée n'est pas supportée par Banana"); |
ab02e8a9 |
245 | } |
246 | |
247 | // Generate the page |
248 | if (is_string($error)) { |
249 | return Banana::$page->kill($error); |
250 | } |
251 | return Banana::$page->run(); |
78cd27b3 |
252 | } |
253 | |
a20df265 |
254 | /** Return the CSS code to include in the headers |
255 | */ |
256 | public function css() |
257 | { |
258 | return Banana::$page->css; |
259 | } |
260 | |
ab02e8a9 |
261 | /**************************************************************************/ |
262 | /* actions */ |
263 | /**************************************************************************/ |
264 | protected function action_saveSubs($groups) |
78cd27b3 |
265 | { |
ab02e8a9 |
266 | Banana::$profile['subscribe'] = $groups; |
267 | return true; |
78cd27b3 |
268 | } |
269 | |
ab02e8a9 |
270 | protected function action_subscribe() |
78cd27b3 |
271 | { |
ab02e8a9 |
272 | Banana::$page->setPage('subscribe'); |
273 | if (isset($_POST['validsubs'])) { |
274 | $this->action_saveSubs(array_keys($_POST['subscribe'])); |
275 | Banana::$page->redirect(); |
856dc84a |
276 | } |
ab02e8a9 |
277 | $groups = Banana::$protocole->getBoxList(Banana::BOXES_ALL); |
278 | Banana::$page->assign('groups', $groups); |
279 | return true; |
78cd27b3 |
280 | } |
281 | |
ab02e8a9 |
282 | protected function action_listBoxes() |
7a0e2710 |
283 | { |
ab02e8a9 |
284 | Banana::$page->setPage('forums'); |
285 | $groups = Banana::$protocole->getBoxList(Banana::BOXES_SUB, Banana::$profile['lastnews'], true); |
286 | $newgroups = Banana::$protocole->getBoxList(Banana::BOXES_NEW, Banana::$profile['lastnews'], true); |
287 | Banana::$page->assign('groups', $groups); |
288 | Banana::$page->assign('newgroups', $newgroups); |
289 | return true; |
7a0e2710 |
290 | } |
291 | |
ab02e8a9 |
292 | protected function action_showThread($group, $first) |
78cd27b3 |
293 | { |
ab02e8a9 |
294 | Banana::$page->setPage('thread'); |
295 | if (!$this->loadSpool($group)) { |
296 | return _b_('Impossible charger la liste des messages de ') . $group; |
78cd27b3 |
297 | } |
e0f557df |
298 | if (Banana::$spool_boxlist) { |
299 | $groups = Banana::$protocole->getBoxList(Banana::BOXES_SUB, Banana::$profile['lastnews'], true); |
300 | Banana::$page->assign('groups', $groups); |
301 | } |
7972645b |
302 | Banana::$page->assign('msgbypage', Banana::$spool_tmax); |
ab02e8a9 |
303 | return true; |
78cd27b3 |
304 | } |
305 | |
ab02e8a9 |
306 | protected function action_showMessage($group, $artid, $partid = 'text') |
78cd27b3 |
307 | { |
ab02e8a9 |
308 | Banana::$page->setPage('message'); |
9bc195d6 |
309 | $istext = $partid == 'text' || $partid == 'source' |
25c20c41 |
310 | || preg_match('!^[-a-z0-9_]+/[-a-z0-9_]+$!', $partid); |
9bc195d6 |
311 | if ($istext) { |
ab02e8a9 |
312 | $this->loadSpool($group); |
313 | } |
314 | $msg =& $this->loadMessage($group, $artid); |
315 | if (is_null($msg)) { |
316 | $this->loadSpool($group); |
317 | $this->removeMessage($group, $artid); |
d8d416c4 |
318 | return _b_('Le message demandé n\'existe pas. Il est possible qu\'il ait été annulé'); |
ab02e8a9 |
319 | } |
320 | if ($partid == 'xface') { |
321 | $msg->getXFace(); |
322 | exit; |
9bc195d6 |
323 | } elseif (!$istext) { |
ab02e8a9 |
324 | $part = $msg->getPartById($partid); |
325 | if (!is_null($part)) { |
326 | $part->send(true); |
52cafcf1 |
327 | } |
ab02e8a9 |
328 | $part = $msg->getFile($partid); |
329 | if (!is_null($part)) { |
330 | $part->send(); |
78cd27b3 |
331 | } |
ab02e8a9 |
332 | exit; |
9bc195d6 |
333 | } elseif ($partid == 'text') { |
334 | Banana::$page->assign('body', $msg->getFormattedBody()); |
335 | } elseif ($partid == 'source') { |
b188e462 |
336 | $text = Banana::$protocole->getMessageSource($artid); |
337 | if (!is_utf8($text)) { |
338 | $text = utf8_encode($text); |
339 | } |
340 | Banana::$page->assign('body', '<pre>' . banana_htmlentities($text) . '</pre>'); |
9bc195d6 |
341 | } else { |
342 | Banana::$page->assign('body', $msg->getFormattedBody($partid)); |
78cd27b3 |
343 | } |
9bc195d6 |
344 | |
7972645b |
345 | if (Banana::$profile['autoup']) { |
346 | Banana::$spool->markAsRead($artid); |
347 | } |
e0f557df |
348 | if (Banana::$spool_boxlist) { |
349 | $groups = Banana::$protocole->getBoxList(Banana::BOXES_SUB, Banana::$profile['lastnews'], true); |
350 | Banana::$page->assign('groups', $groups); |
351 | } |
ab02e8a9 |
352 | Banana::$page->assign_by_ref('message', $msg); |
7972645b |
353 | Banana::$page->assign('headers', Banana::$msgshow_headers); |
ab02e8a9 |
354 | return true; |
78cd27b3 |
355 | } |
356 | |
ab02e8a9 |
357 | protected function action_newMessage($group, $artid) |
78cd27b3 |
358 | { |
ab02e8a9 |
359 | Banana::$page->setPage('new'); |
360 | if (!Banana::$protocole->canSend()) { |
361 | return _b_('Vous n\'avez pas le droit de poster'); |
362 | } |
363 | $hdrs = Banana::$protocole->requestedHeaders(); |
364 | $headers = array(); |
365 | foreach ($hdrs as $header) { |
366 | $headers[$header] = array('name' => BananaMessage::translateHeaderName($header)); |
7972645b |
367 | if (isset(Banana::$profile['headers'][$header])) { |
368 | $headers[$header]['fixed'] = Banana::$profile['headers'][$header]; |
78cd27b3 |
369 | } |
370 | } |
ab02e8a9 |
371 | if (isset($_POST['sendmessage'])) { |
372 | $hdr_values = array(); |
373 | foreach ($hdrs as $header) { |
374 | $hdr_values[$header] = isset($headers[$header]['fixed']) ? $headers[$header]['fixed'] : @$_POST[$header]; |
f6df9eb2 |
375 | } |
ab02e8a9 |
376 | if ($artid) { |
377 | $old =& $this->loadMessage($group, $artid); |
378 | $hdr_values['References'] = $old->getHeaderValue('references') . $old->getHeaderValue('message-id'); |
856dc84a |
379 | } |
ab02e8a9 |
380 | $msg = null; |
381 | if (empty($hdr_values['Subject'])) { |
382 | Banana::$page->trig(_b_('Le message doit avoir un sujet')); |
7972645b |
383 | } elseif (Banana::$msgedit_canattach && isset($_FILES['attachment'])) { |
ab02e8a9 |
384 | $uploaded = $_FILES['attachment']; |
385 | if (!is_uploaded_file($uploaded['tmp_name'])) { |
d8d416c4 |
386 | Banana::$page->trig(_b_('Une erreur est survenue lors du téléchargement du fichier')); |
ab02e8a9 |
387 | } else { |
388 | $msg = BananaMessage::newMessage($hdr_values, $_POST['body'], $uploaded); |
389 | } |
390 | } else { |
391 | $msg = BananaMessage::newMessage($hdr_values, $_POST['body']); |
392 | } |
393 | if (!is_null($msg)) { |
394 | if (Banana::$protocole->send($msg)) { |
395 | Banana::$page->redirect(array('group' => $group, 'artid' => $artid)); |
396 | } |
397 | Banana::$page->trig(_b_('Une erreur est survenue lors de l\'envoi du message :') . '<br />' |
398 | . Banana::$protocole->lastError()); |
f6df9eb2 |
399 | } |
78cd27b3 |
400 | } else { |
ab02e8a9 |
401 | if (!is_null($artid)) { |
402 | $msg =& $this->loadMessage($group, $artid); |
d8d416c4 |
403 | $body = $msg->getSender() . _b_(' a écrit :') . "\n" . $msg->quote(); |
ab02e8a9 |
404 | $subject = $msg->getHeaderValue('subject'); |
405 | $headers['Subject']['user'] = 'Re: ' . preg_replace("/^re\s*:\s*/i", '', $subject); |
406 | $target = $msg->getHeaderValue($hdrs['reply']); |
407 | if (empty($target)) { |
408 | $target = $group; |
409 | } |
410 | $headers[$hdrs['dest']]['user'] =& $target; |
411 | } else { |
412 | $body = ''; |
413 | $headers[$hdrs['dest']]['user'] = $group; |
856dc84a |
414 | } |
7972645b |
415 | if (Banana::$profile['signature']) { |
416 | $body .= "\n\n-- \n" . Banana::$profile['signature']; |
ab02e8a9 |
417 | } |
418 | Banana::$page->assign('body', $body); |
78cd27b3 |
419 | } |
ab02e8a9 |
420 | |
7972645b |
421 | Banana::$page->assign('maxfilesize', Banana::$msgedit_maxfilesize); |
422 | Banana::$page->assign('can_attach', Banana::$msgedit_canattach); |
ab02e8a9 |
423 | Banana::$page->assign('headers', $headers); |
856dc84a |
424 | return true; |
78cd27b3 |
425 | } |
426 | |
ab02e8a9 |
427 | protected function action_cancelMessage($group, $artid) |
78cd27b3 |
428 | { |
ab02e8a9 |
429 | Banana::$page->setPage('cancel'); |
430 | $msg =& $this->loadMessage($group, $artid); |
431 | if (!$msg->canCancel()) { |
432 | return _b_('Vous n\'avez pas les droits suffisants pour supprimer ce message'); |
433 | } |
434 | if (isset($_POST['cancel'])) { |
435 | $this->loadSpool($group); |
436 | $ndx = Banana::$spool->getNdX($id) - 1; |
437 | if (!Banana::$protocole->cancel($msg)) { |
438 | return _b_('Une erreur s\'est produite lors de l\'annulation du message :') . '<br />' |
439 | . Banana::$protocole->lastError(); |
440 | } |
441 | if ($ndx < 50) { |
442 | $ndx = 0; |
443 | } |
444 | $this->removeMessage($group, $artid); |
445 | Banana::$page->redirect(Array('group' => $group, 'first' => $ndx)); |
856dc84a |
446 | } |
d759a2ba |
447 | |
ab02e8a9 |
448 | Banana::$page->assign_by_ref('message', $msg); |
d759a2ba |
449 | Banana::$page->assign('body', $msg->getFormattedBody()); |
450 | Banana::$page->assign('headers', Banana::$msgshow_headers); |
856dc84a |
451 | return true; |
78cd27b3 |
452 | } |
453 | |
ab02e8a9 |
454 | /**************************************************************************/ |
a40f3908 |
455 | /* Spoolgen functions */ |
456 | /**************************************************************************/ |
457 | |
458 | private function checkErrors() |
459 | { |
460 | if (Banana::$protocole->lastErrno()) { |
461 | echo "\nL'erreur suivante s'est produite : " |
462 | . Banana::$protocole->lastErrno() . " " |
463 | . Banana::$protocole->lastError() . "\n"; |
464 | return false; |
465 | } |
466 | return true; |
467 | } |
468 | |
469 | static public function createAllSpool(array $protos) |
470 | { |
471 | foreach ($protos as $proto) { |
472 | $banana = new Banana(array(), $proto); |
473 | |
474 | if (!$banana->checkErrors()) { |
475 | continue; |
476 | } |
477 | $groups = Banana::$protocole->getBoxList(); |
478 | if (!$banana->checkErrors()) { |
479 | continue; |
480 | } |
481 | |
482 | print "** $proto **\n"; |
483 | foreach (array_keys($groups) as $g) { |
484 | print "Generating spool for $g : "; |
485 | Banana::$group = $g; |
486 | $spool = $banana->loadSpool($g); |
487 | if (!$banana->checkErrors()) { |
488 | break; |
489 | } |
490 | print "done.\n"; |
491 | unset($spool); |
492 | } |
493 | print "\n"; |
494 | } |
495 | } |
496 | |
497 | /**************************************************************************/ |
ab02e8a9 |
498 | /* Private functions */ |
499 | /**************************************************************************/ |
500 | |
916e4a56 |
501 | protected function loadSpool($group) |
78cd27b3 |
502 | { |
ab02e8a9 |
503 | Banana::load('spool'); |
504 | if (!Banana::$spool || Banana::$spool->group != $group) { |
e0f557df |
505 | $clean = false; |
ab02e8a9 |
506 | if ($group == @$_SESSION['banana_group'] && isset($_SESSION['banana_spool'])) { |
507 | Banana::$spool = unserialize($_SESSION['banana_spool']); |
7b98ea62 |
508 | $clean = @(Banana::$profile['lastnews'] != $_SESSION['banana_lastnews']); |
a5980eae |
509 | } else { |
510 | unset($_SESSION['banana_message']); |
511 | unset($_SESSION['banana_artid']); |
512 | unset($_SESSION['banana_showhdr']); |
7972645b |
513 | } |
7b98ea62 |
514 | BananaSpool::getSpool($group, Banana::$profile['lastnews'], Banana::$profile['autoup'] || $clean); |
ab02e8a9 |
515 | $_SESSION['banana_group'] = $group; |
7972645b |
516 | if (!Banana::$profile['display']) { |
517 | $_SESSION['banana_spool'] = serialize(Banana::$spool); |
7b98ea62 |
518 | $_SESSION['banana_lastnews'] = Banana::$profile['lastnews']; |
7972645b |
519 | } |
ab02e8a9 |
520 | Banana::$spool->setMode(Banana::$profile['display'] ? Banana::SPOOL_UNREAD : Banana::SPOOL_ALL); |
78cd27b3 |
521 | } |
ab02e8a9 |
522 | return true; |
78cd27b3 |
523 | } |
524 | |
916e4a56 |
525 | protected function &loadMessage($group, $artid) |
78cd27b3 |
526 | { |
ab02e8a9 |
527 | Banana::load('message'); |
528 | if ($group == @$_SESSION['banana_group'] && $artid == @$_SESSION['banana_artid'] |
529 | && isset($_SESSION['banana_message'])) { |
530 | $message = unserialize($_SESSION['banana_message']); |
7972645b |
531 | Banana::$msgshow_headers = $_SESSION['banana_showhdr']; |
ab02e8a9 |
532 | } else { |
533 | $message = Banana::$protocole->getMessage($artid); |
534 | $_SESSION['banana_group'] = $group; |
535 | $_SESSION['banana_artid'] = $artid; |
536 | $_SESSION['banana_message'] = serialize($message); |
7972645b |
537 | $_SESSION['banana_showhdr'] = Banana::$msgshow_headers; |
ab02e8a9 |
538 | } |
539 | Banana::$message =& $message; |
540 | return $message; |
78cd27b3 |
541 | } |
d28aa62d |
542 | |
916e4a56 |
543 | protected function removeMessage($group, $artid) |
d28aa62d |
544 | { |
ab02e8a9 |
545 | Banana::$spool->delId($artid); |
546 | if ($group == $_SESSION['banana_group']) { |
7972645b |
547 | if (!Banana::$profile['display']) { |
548 | $_SESSION['banana_spool'] = serialize(Banana::$spool); |
549 | } |
ab02e8a9 |
550 | if ($artid == $_SESSION['banana_artid']) { |
551 | unset($_SESSION['banana_message']); |
552 | unset($_SESSION['banana_showhdr']); |
553 | unset($_SESSION['banana_artid']); |
d28aa62d |
554 | } |
d28aa62d |
555 | } |
ab02e8a9 |
556 | return true; |
d28aa62d |
557 | } |
f12fdb59 |
558 | |
ab02e8a9 |
559 | static private function load($file) |
f12fdb59 |
560 | { |
ab02e8a9 |
561 | $file = strtolower($file) . '.inc.php'; |
562 | if (!@include_once dirname(__FILE__) . "/$file") { |
563 | require_once $file; |
564 | } |
f12fdb59 |
565 | } |
78cd27b3 |
566 | } |
567 | |
d8d416c4 |
568 | // vim:set et sw=4 sts=4 ts=4 enc=utf-8: |
78cd27b3 |
569 | ?> |