Commit | Line | Data |
---|---|---|
abd0915a PHM |
1 | <?php |
2 | /******************************************************************************** | |
7027794f | 3 | * banana/banana.inc.php : banana main file |
abd0915a PHM |
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 | { | |
abd0915a | 12 | |
e9360b11 | 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; | |
e95f5b5e | 26 | static public $withtabs = true; |
e9360b11 | 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; | |
8bfa4595 | 33 | static public $spool_boxlist = true; |
e9360b11 | 34 | |
35 | ### Message processing ### | |
36 | static public $msgparse_headers = array('content-disposition', 'content-transfer-encoding', | |
7027794f | 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'); | |
b035d759 | 41 | |
e9360b11 | 42 | ### Message display ### |
43 | static public $msgshow_headers = array('from', 'newsgroups', 'followup-to', 'to', 'cc', 'reply-to', | |
44 | 'organization', 'date', 'references', 'in-reply-to'); | |
3c3a3ce3 | 45 | static public $msgshow_mimeparts = array('multipart/report', 'multipart/mixed', 'text/html', 'text/plain', 'text/enriched', 'text', 'message'); |
e9360b11 | 46 | static public $msgshow_xface = true; |
47 | static public $msgshow_wrap = 78; | |
57efc445 | 48 | static public $msgshow_externalimages = false; |
e95f5b5e | 49 | static public $msgshow_withthread = true; |
abd0915a | 50 | |
e04e6059 | 51 | /** Match an url |
3c3a3ce3 | 52 | * Should be included in a regexp delimited using /, !, , or @ (eg: "/$url_regexp/ui") |
e04e6059 | 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 | */ | |
8bfa4595 | 62 | static public $msgshow_url = '(["\[])?((?:[a-z]+:\/\/|www\.)(?:[\.\,\;\!]*[a-z\@0-9~%$£µ&i#\-+=_\/\?]+)+)(["\]])?'; |
abd0915a | 63 | |
e9360b11 | 64 | ### Message edition ### |
65 | static public $msgedit_canattach = true; | |
66 | static public $msgedit_maxfilesize = 100000; | |
73ab762c | 67 | /** Global headers to use for messages |
2509bf96 | 68 | */ |
e9360b11 | 69 | static public $msgedit_headers = array('Mime-Version' => '1.0', 'User-Agent' => 'Banana @VERSION@'); |
3c3a3ce3 | 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 | ||
e9360b11 | 74 | ### Protocole ### |
2509bf96 | 75 | /** News serveur to use |
76 | */ | |
e9360b11 | 77 | static public $nntp_host = 'news://localhost:119/'; |
7027794f | 78 | |
e9360b11 | 79 | static public $mbox_path = '/var/mail'; |
7027794f | 80 | |
e9360b11 | 81 | ### Debug ### |
7027794f | 82 | static public $debug_nntp = false; |
83 | static public $debug_smarty = false; | |
84 | ||
85 | ||
e9360b11 | 86 | ####### |
87 | # Constants | |
88 | ####### | |
89 | ||
7027794f | 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 | ||
e9360b11 | 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 | ||
7027794f | 124 | /** Class parameters storage |
125 | */ | |
126 | public $params; | |
abd0915a | 127 | |
e9360b11 | 128 | |
129 | ####### | |
130 | # Banana Implementation | |
131 | ####### | |
132 | ||
7027794f | 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 | |
d5588318 | 136 | */ |
7027794f | 137 | public function __construct($params = null, $protocole = 'NNTP', $pageclass = 'BananaPage') |
abd0915a | 138 | { |
7027794f | 139 | Banana::load('text.func'); |
140 | if (is_null($params)) { | |
141 | $this->params = $_GET; | |
5d58099e | 142 | } else { |
7027794f | 143 | $this->params = $params; |
5d58099e | 144 | } |
7027794f | 145 | $this->loadParams(); |
5d58099e | 146 | |
7027794f | 147 | // connect to protocole handler |
7027794f | 148 | $classname = 'Banana' . $protocole; |
e9360b11 | 149 | if (!class_exists($classname)) { |
150 | Banana::load($protocole); | |
151 | } | |
7027794f | 152 | Banana::$protocole = new $classname(Banana::$group); |
abd0915a | 153 | |
7027794f | 154 | // build the page |
155 | if ($pageclass == 'BananaPage') { | |
156 | Banana::load('page'); | |
02198ace | 157 | } |
7027794f | 158 | Banana::$page = new $pageclass; |
159 | } | |
abd0915a | 160 | |
7027794f | 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)) { | |
2f0aa8ce | 172 | if (isset($this->params['action']) && $this->params['action'] == 'subscribe') { |
7027794f | 173 | Banana::$action = Banana::ACTION_BOX_SUBS; |
abd0915a | 174 | } else { |
7027794f | 175 | Banana::$action = Banana::ACTION_BOX_LIST; |
abd0915a | 176 | } |
7027794f | 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; | |
d43ebde4 | 185 | } |
7027794f | 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; | |
abd0915a PHM |
197 | } |
198 | } | |
199 | ||
7027794f | 200 | /** Run Banana |
201 | * This function need user profile to be initialised | |
202 | */ | |
203 | public function run() | |
abd0915a | 204 | { |
7027794f | 205 | // Configure locales |
206 | setlocale(LC_ALL, Banana::$profile['locale']); | |
abd0915a | 207 | |
7027794f | 208 | // Check if the state is valid |
209 | if (Banana::$protocole->lastErrNo()) { | |
598a1c53 | 210 | return Banana::$page->kill(_b_('Une erreur a été rencontrée lors de la connexion au serveur') . '<br />' |
7027794f | 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) { | |
e9360b11 | 217 | if(Banana::$boxpattern && !preg_match('/' . Banana::$boxpattern . '/i', $group)) { |
7027794f | 218 | Banana::$page->setPage('group'); |
598a1c53 | 219 | return Banana::$page->kill(_b_("Ce newsgroup n'existe pas ou vous n'avez pas l'autorisation d'y accéder")); |
7027794f | 220 | } |
221 | } | |
abd0915a | 222 | |
7027794f | 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: | |
598a1c53 | 244 | $error = _b_("L'action demandée n'est pas supportée par Banana"); |
7027794f | 245 | } |
246 | ||
247 | // Generate the page | |
248 | if (is_string($error)) { | |
249 | return Banana::$page->kill($error); | |
250 | } | |
251 | return Banana::$page->run(); | |
abd0915a PHM |
252 | } |
253 | ||
7027794f | 254 | /**************************************************************************/ |
255 | /* actions */ | |
256 | /**************************************************************************/ | |
257 | protected function action_saveSubs($groups) | |
abd0915a | 258 | { |
7027794f | 259 | Banana::$profile['subscribe'] = $groups; |
260 | return true; | |
abd0915a PHM |
261 | } |
262 | ||
7027794f | 263 | protected function action_subscribe() |
abd0915a | 264 | { |
7027794f | 265 | Banana::$page->setPage('subscribe'); |
266 | if (isset($_POST['validsubs'])) { | |
267 | $this->action_saveSubs(array_keys($_POST['subscribe'])); | |
268 | Banana::$page->redirect(); | |
7c111d8d | 269 | } |
7027794f | 270 | $groups = Banana::$protocole->getBoxList(Banana::BOXES_ALL); |
271 | Banana::$page->assign('groups', $groups); | |
272 | return true; | |
abd0915a PHM |
273 | } |
274 | ||
7027794f | 275 | protected function action_listBoxes() |
d43ebde4 | 276 | { |
7027794f | 277 | Banana::$page->setPage('forums'); |
278 | $groups = Banana::$protocole->getBoxList(Banana::BOXES_SUB, Banana::$profile['lastnews'], true); | |
279 | $newgroups = Banana::$protocole->getBoxList(Banana::BOXES_NEW, Banana::$profile['lastnews'], true); | |
280 | Banana::$page->assign('groups', $groups); | |
281 | Banana::$page->assign('newgroups', $newgroups); | |
282 | return true; | |
d43ebde4 | 283 | } |
284 | ||
7027794f | 285 | protected function action_showThread($group, $first) |
abd0915a | 286 | { |
7027794f | 287 | Banana::$page->setPage('thread'); |
288 | if (!$this->loadSpool($group)) { | |
289 | return _b_('Impossible charger la liste des messages de ') . $group; | |
abd0915a | 290 | } |
8bfa4595 | 291 | if (Banana::$spool_boxlist) { |
292 | $groups = Banana::$protocole->getBoxList(Banana::BOXES_SUB, Banana::$profile['lastnews'], true); | |
293 | Banana::$page->assign('groups', $groups); | |
294 | } | |
e9360b11 | 295 | Banana::$page->assign('msgbypage', Banana::$spool_tmax); |
7027794f | 296 | return true; |
abd0915a PHM |
297 | } |
298 | ||
7027794f | 299 | protected function action_showMessage($group, $artid, $partid = 'text') |
abd0915a | 300 | { |
7027794f | 301 | Banana::$page->setPage('message'); |
7a5823f9 | 302 | $istext = $partid == 'text' || $partid == 'source' |
b18124be | 303 | || preg_match('!^[-a-z0-9_]+/[-a-z0-9_]+$!', $partid); |
7a5823f9 | 304 | if ($istext) { |
7027794f | 305 | $this->loadSpool($group); |
306 | } | |
307 | $msg =& $this->loadMessage($group, $artid); | |
308 | if (is_null($msg)) { | |
309 | $this->loadSpool($group); | |
310 | $this->removeMessage($group, $artid); | |
598a1c53 | 311 | return _b_('Le message demandé n\'existe pas. Il est possible qu\'il ait été annulé'); |
7027794f | 312 | } |
313 | if ($partid == 'xface') { | |
314 | $msg->getXFace(); | |
315 | exit; | |
7a5823f9 | 316 | } elseif (!$istext) { |
7027794f | 317 | $part = $msg->getPartById($partid); |
318 | if (!is_null($part)) { | |
319 | $part->send(true); | |
eb31725e | 320 | } |
7027794f | 321 | $part = $msg->getFile($partid); |
322 | if (!is_null($part)) { | |
323 | $part->send(); | |
abd0915a | 324 | } |
7027794f | 325 | exit; |
7a5823f9 | 326 | } elseif ($partid == 'text') { |
327 | Banana::$page->assign('body', $msg->getFormattedBody()); | |
328 | } elseif ($partid == 'source') { | |
7d3f4749 | 329 | $text = Banana::$protocole->getMessageSource($artid); |
330 | if (!is_utf8($text)) { | |
331 | $text = utf8_encode($text); | |
332 | } | |
333 | Banana::$page->assign('body', '<pre>' . banana_htmlentities($text) . '</pre>'); | |
7a5823f9 | 334 | } else { |
335 | Banana::$page->assign('body', $msg->getFormattedBody($partid)); | |
abd0915a | 336 | } |
7a5823f9 | 337 | |
e9360b11 | 338 | if (Banana::$profile['autoup']) { |
339 | Banana::$spool->markAsRead($artid); | |
340 | } | |
8bfa4595 | 341 | if (Banana::$spool_boxlist) { |
342 | $groups = Banana::$protocole->getBoxList(Banana::BOXES_SUB, Banana::$profile['lastnews'], true); | |
343 | Banana::$page->assign('groups', $groups); | |
344 | } | |
7027794f | 345 | Banana::$page->assign_by_ref('message', $msg); |
e9360b11 | 346 | Banana::$page->assign('headers', Banana::$msgshow_headers); |
7027794f | 347 | return true; |
abd0915a PHM |
348 | } |
349 | ||
7027794f | 350 | protected function action_newMessage($group, $artid) |
abd0915a | 351 | { |
7027794f | 352 | Banana::$page->setPage('new'); |
353 | if (!Banana::$protocole->canSend()) { | |
354 | return _b_('Vous n\'avez pas le droit de poster'); | |
355 | } | |
356 | $hdrs = Banana::$protocole->requestedHeaders(); | |
357 | $headers = array(); | |
358 | foreach ($hdrs as $header) { | |
359 | $headers[$header] = array('name' => BananaMessage::translateHeaderName($header)); | |
e9360b11 | 360 | if (isset(Banana::$profile['headers'][$header])) { |
361 | $headers[$header]['fixed'] = Banana::$profile['headers'][$header]; | |
c42efe2f PHM |
362 | } |
363 | } | |
7027794f | 364 | if (isset($_POST['sendmessage'])) { |
365 | $hdr_values = array(); | |
366 | foreach ($hdrs as $header) { | |
367 | $hdr_values[$header] = isset($headers[$header]['fixed']) ? $headers[$header]['fixed'] : @$_POST[$header]; | |
d5588318 | 368 | } |
7027794f | 369 | if ($artid) { |
370 | $old =& $this->loadMessage($group, $artid); | |
371 | $hdr_values['References'] = $old->getHeaderValue('references') . $old->getHeaderValue('message-id'); | |
7c111d8d | 372 | } |
7027794f | 373 | $msg = null; |
374 | if (empty($hdr_values['Subject'])) { | |
375 | Banana::$page->trig(_b_('Le message doit avoir un sujet')); | |
e9360b11 | 376 | } elseif (Banana::$msgedit_canattach && isset($_FILES['attachment'])) { |
7027794f | 377 | $uploaded = $_FILES['attachment']; |
378 | if (!is_uploaded_file($uploaded['tmp_name'])) { | |
598a1c53 | 379 | Banana::$page->trig(_b_('Une erreur est survenue lors du téléchargement du fichier')); |
7027794f | 380 | } else { |
381 | $msg = BananaMessage::newMessage($hdr_values, $_POST['body'], $uploaded); | |
382 | } | |
383 | } else { | |
384 | $msg = BananaMessage::newMessage($hdr_values, $_POST['body']); | |
385 | } | |
386 | if (!is_null($msg)) { | |
387 | if (Banana::$protocole->send($msg)) { | |
388 | Banana::$page->redirect(array('group' => $group, 'artid' => $artid)); | |
389 | } | |
390 | Banana::$page->trig(_b_('Une erreur est survenue lors de l\'envoi du message :') . '<br />' | |
391 | . Banana::$protocole->lastError()); | |
d5588318 | 392 | } |
abd0915a | 393 | } else { |
7027794f | 394 | if (!is_null($artid)) { |
395 | $msg =& $this->loadMessage($group, $artid); | |
598a1c53 | 396 | $body = $msg->getSender() . _b_(' a écrit :') . "\n" . $msg->quote(); |
7027794f | 397 | $subject = $msg->getHeaderValue('subject'); |
398 | $headers['Subject']['user'] = 'Re: ' . preg_replace("/^re\s*:\s*/i", '', $subject); | |
399 | $target = $msg->getHeaderValue($hdrs['reply']); | |
400 | if (empty($target)) { | |
401 | $target = $group; | |
402 | } | |
403 | $headers[$hdrs['dest']]['user'] =& $target; | |
404 | } else { | |
405 | $body = ''; | |
406 | $headers[$hdrs['dest']]['user'] = $group; | |
7c111d8d | 407 | } |
e9360b11 | 408 | if (Banana::$profile['signature']) { |
409 | $body .= "\n\n-- \n" . Banana::$profile['signature']; | |
7027794f | 410 | } |
411 | Banana::$page->assign('body', $body); | |
abd0915a | 412 | } |
7027794f | 413 | |
e9360b11 | 414 | Banana::$page->assign('maxfilesize', Banana::$msgedit_maxfilesize); |
415 | Banana::$page->assign('can_attach', Banana::$msgedit_canattach); | |
7027794f | 416 | Banana::$page->assign('headers', $headers); |
7c111d8d | 417 | return true; |
abd0915a PHM |
418 | } |
419 | ||
7027794f | 420 | protected function action_cancelMessage($group, $artid) |
abd0915a | 421 | { |
7027794f | 422 | Banana::$page->setPage('cancel'); |
423 | $msg =& $this->loadMessage($group, $artid); | |
424 | if (!$msg->canCancel()) { | |
425 | return _b_('Vous n\'avez pas les droits suffisants pour supprimer ce message'); | |
426 | } | |
427 | if (isset($_POST['cancel'])) { | |
428 | $this->loadSpool($group); | |
429 | $ndx = Banana::$spool->getNdX($id) - 1; | |
430 | if (!Banana::$protocole->cancel($msg)) { | |
431 | return _b_('Une erreur s\'est produite lors de l\'annulation du message :') . '<br />' | |
432 | . Banana::$protocole->lastError(); | |
433 | } | |
434 | if ($ndx < 50) { | |
435 | $ndx = 0; | |
436 | } | |
437 | $this->removeMessage($group, $artid); | |
438 | Banana::$page->redirect(Array('group' => $group, 'first' => $ndx)); | |
7c111d8d | 439 | } |
fd57a15c | 440 | |
7027794f | 441 | Banana::$page->assign_by_ref('message', $msg); |
fd57a15c | 442 | Banana::$page->assign('body', $msg->getFormattedBody()); |
443 | Banana::$page->assign('headers', Banana::$msgshow_headers); | |
7c111d8d | 444 | return true; |
abd0915a PHM |
445 | } |
446 | ||
7027794f | 447 | /**************************************************************************/ |
b052aab7 | 448 | /* Spoolgen functions */ |
449 | /**************************************************************************/ | |
450 | ||
451 | private function checkErrors() | |
452 | { | |
453 | if (Banana::$protocole->lastErrno()) { | |
454 | echo "\nL'erreur suivante s'est produite : " | |
455 | . Banana::$protocole->lastErrno() . " " | |
456 | . Banana::$protocole->lastError() . "\n"; | |
457 | return false; | |
458 | } | |
459 | return true; | |
460 | } | |
461 | ||
462 | static public function createAllSpool(array $protos) | |
463 | { | |
464 | foreach ($protos as $proto) { | |
465 | $banana = new Banana(array(), $proto); | |
466 | ||
467 | if (!$banana->checkErrors()) { | |
468 | continue; | |
469 | } | |
470 | $groups = Banana::$protocole->getBoxList(); | |
471 | if (!$banana->checkErrors()) { | |
472 | continue; | |
473 | } | |
474 | ||
475 | print "** $proto **\n"; | |
476 | foreach (array_keys($groups) as $g) { | |
477 | print "Generating spool for $g : "; | |
478 | Banana::$group = $g; | |
479 | $spool = $banana->loadSpool($g); | |
480 | if (!$banana->checkErrors()) { | |
481 | break; | |
482 | } | |
483 | print "done.\n"; | |
484 | unset($spool); | |
485 | } | |
486 | print "\n"; | |
487 | } | |
488 | } | |
489 | ||
490 | /**************************************************************************/ | |
7027794f | 491 | /* Private functions */ |
492 | /**************************************************************************/ | |
493 | ||
0e25d15d | 494 | protected function loadSpool($group) |
abd0915a | 495 | { |
7027794f | 496 | Banana::load('spool'); |
497 | if (!Banana::$spool || Banana::$spool->group != $group) { | |
8bfa4595 | 498 | $clean = false; |
7027794f | 499 | if ($group == @$_SESSION['banana_group'] && isset($_SESSION['banana_spool'])) { |
500 | Banana::$spool = unserialize($_SESSION['banana_spool']); | |
e1debf92 | 501 | $clean = @(Banana::$profile['lastnews'] != $_SESSION['banana_lastnews']); |
dfdf27fc | 502 | } else { |
503 | unset($_SESSION['banana_message']); | |
504 | unset($_SESSION['banana_artid']); | |
505 | unset($_SESSION['banana_showhdr']); | |
e9360b11 | 506 | } |
e1debf92 | 507 | BananaSpool::getSpool($group, Banana::$profile['lastnews'], Banana::$profile['autoup'] || $clean); |
7027794f | 508 | $_SESSION['banana_group'] = $group; |
e9360b11 | 509 | if (!Banana::$profile['display']) { |
510 | $_SESSION['banana_spool'] = serialize(Banana::$spool); | |
e1debf92 | 511 | $_SESSION['banana_lastnews'] = Banana::$profile['lastnews']; |
e9360b11 | 512 | } |
7027794f | 513 | Banana::$spool->setMode(Banana::$profile['display'] ? Banana::SPOOL_UNREAD : Banana::SPOOL_ALL); |
abd0915a | 514 | } |
7027794f | 515 | return true; |
abd0915a PHM |
516 | } |
517 | ||
0e25d15d | 518 | protected function &loadMessage($group, $artid) |
abd0915a | 519 | { |
7027794f | 520 | Banana::load('message'); |
521 | if ($group == @$_SESSION['banana_group'] && $artid == @$_SESSION['banana_artid'] | |
522 | && isset($_SESSION['banana_message'])) { | |
523 | $message = unserialize($_SESSION['banana_message']); | |
e9360b11 | 524 | Banana::$msgshow_headers = $_SESSION['banana_showhdr']; |
7027794f | 525 | } else { |
526 | $message = Banana::$protocole->getMessage($artid); | |
527 | $_SESSION['banana_group'] = $group; | |
528 | $_SESSION['banana_artid'] = $artid; | |
529 | $_SESSION['banana_message'] = serialize($message); | |
e9360b11 | 530 | $_SESSION['banana_showhdr'] = Banana::$msgshow_headers; |
7027794f | 531 | } |
532 | Banana::$message =& $message; | |
533 | return $message; | |
abd0915a | 534 | } |
9e223b38 | 535 | |
0e25d15d | 536 | protected function removeMessage($group, $artid) |
9e223b38 | 537 | { |
7027794f | 538 | Banana::$spool->delId($artid); |
539 | if ($group == $_SESSION['banana_group']) { | |
e9360b11 | 540 | if (!Banana::$profile['display']) { |
541 | $_SESSION['banana_spool'] = serialize(Banana::$spool); | |
542 | } | |
7027794f | 543 | if ($artid == $_SESSION['banana_artid']) { |
544 | unset($_SESSION['banana_message']); | |
545 | unset($_SESSION['banana_showhdr']); | |
546 | unset($_SESSION['banana_artid']); | |
9e223b38 | 547 | } |
9e223b38 | 548 | } |
7027794f | 549 | return true; |
9e223b38 | 550 | } |
73ab762c | 551 | |
7027794f | 552 | static private function load($file) |
73ab762c | 553 | { |
7027794f | 554 | $file = strtolower($file) . '.inc.php'; |
555 | if (!@include_once dirname(__FILE__) . "/$file") { | |
556 | require_once $file; | |
557 | } | |
73ab762c | 558 | } |
abd0915a PHM |
559 | } |
560 | ||
598a1c53 | 561 | // vim:set et sw=4 sts=4 ts=4 enc=utf-8: |
abd0915a | 562 | ?> |