wibble
[banana.git] / thread.php
CommitLineData
90962c86 1<?php
2/********************************************************************************
3* thread.php : group overview
4* ------------
5*
6* This file is part of the banana distribution
7* Copyright: See COPYING files that comes with this distribution
8********************************************************************************/
9
2dbc0167 10require_once("include/banana.inc.php");
0d407ce1 11require_once("include/header.inc.php");
90962c86 12
13if (isset($_REQUEST['group'])) {
2dbc0167 14 $group = htmlentities(strtolower($_REQUEST['group']));
90962c86 15} else {
2dbc0167 16 $group = htmlentities(strtolower(strtok(str_replace(" ","",$_REQUEST['newsgroups']),",")));
90962c86 17}
5c33c608 18
19if (isset($_REQUEST['id'])) {
2dbc0167 20 $id=htmlentities(strtolower($_REQUEST['id']));
5c33c608 21}
90962c86 22
2dbc0167 23$banana->newSpool($group, $banana->profile['display'], $banana->profile['lastnews']);
24$max = $banana->tmax;
25if (isset($_REQUEST['first']) && ($_REQUEST['first']>sizeof($banana->spool->overview))) {
26 $_REQUEST['first'] = sizeof($banana->spool->overview);
90962c86 27}
2dbc0167 28$first = (isset($_REQUEST['first']) ? (floor($_REQUEST['first']/$max)*$max+1) : 1);
29$last = (isset($_REQUEST['first']) ? (floor($_REQUEST['first']/$max+1)*$max) : $max);
30
31if (isset($_REQUEST['action']) && (isset($_REQUEST['type']))
32 && (isset($_SESSION['bananapostok'])) && ($_SESSION['bananapostok']))
33{
34 switch ($_REQUEST['type']) {
35 case 'cancel':
36 $banana->nntp->group($group);
37 $mid = array_search($id, $banana->spool->ids);
38 $post = new BananaPost($id);
39
40 if (checkcancel($post->headers)) {
41 $message = 'From: '.$banana->profile['name']."\n"
42 ."Newsgroups: $group\n"
43 ."Subject: cmsg $mid\n"
44 .$banana->custom
45 ."Control: cancel $mid\n"
46 ."\n"
47 ."Message canceled with Banana";
48 if ($banana->nntp->post($message)) {
49 $banana->spool->delid($id);
50 $text = "<p class=\"normal\">"._b_('Message annulé')."</p>";
51 } else {
52 $text = "<p class=\"error\">"._b_('Impossible d\'annuler le message')."</p>";
53 }
54 } else {
55 $text = "<p class=\"error\">\n\t"._b_('Vous n\'avez pas les permissions pour annuler ce message')."\n</p>";
56 }
57 break;
58
59 case 'new':
60 $body = preg_replace("/\n\.[ \t\r]*\n/m","\n..\n",$_REQUEST['body']);
61 $message = 'From: '.$banana->profile['name']."\n"
62 ."Newsgroups: ".str_replace(" ","", $_REQUEST['newsgroups'])."\n"
63 ."Subject: ".$_REQUEST['subject']."\n"
64 .(isset($banana->profile['org'])?"Organization: ".$banana->profile['org']."\n":"")
65 .($_REQUEST['followup']!=''?'Followup-To: '.$_REQUEST['followup']."\n":"")
66 .$banana->custom
67 ."\n"
68 .wrap($body, "", $banana->wrap);
69 if ($banana->nntp->post($message)) {
70 $text = "<p class=\"normal\">"._b_('Message posté')."</p>";
71 } else {
72 $text = "<p class=\"error\">"._b_('Impossible de poster le message')."</p>";
73 }
74 break;
90962c86 75
2dbc0167 76 case 'followupok':
77 $rq=$banana->nntp->group($group);
78 $post = new BananaPost($id);
79 if ($post) {
80 $refs = (isset($post->headers['references'])?
01681efd 81 $post->headers['references']." ":"").$post->headers['message-id'];
2dbc0167 82 }
90962c86 83
2dbc0167 84 $body = preg_replace("/\n\.[ \t\r]*\n/m","\n..\n",$_REQUEST['body']);
85 $message = 'From: '.$banana->profile['name']."\n"
86 ."Newsgroups: ".$_REQUEST['newsgroups']."\n"
87 ."Subject: ".$_REQUEST['subject']."\n"
88 .(isset($banana->profile['org'])?"Organization: ".$banana->profile['org']."\n":"")
89 .($_REQUEST['followup']!=''?'Followup-To: '.$_REQUEST['followup']."\n":"")
90 ."References: $refs\n"
91 .$banana->custom
92 .$banana->profile['customhdr']
93 ."\n"
94 .wrap($body, "", $banana->wrap);
95 if ($banana->nntp->post($message)) {
96 $text = "<p class=\"normal\">"._b_('Message posté')."</p>";
97 } else {
98 $text = "<p class=\"error\">"._b_('Impossible de poster le message')."</p>";
99 }
100 break;
101 }
102 $_SESSION['bananapostok']=false;
103 $banana->newSpool($group, $banana->profile['display'], $banana->profile['lastnews']);
104}
90962c86 105
106?>
2dbc0167 107<h1><?php echo $group; ?></h1>
90962c86 108<?php
2dbc0167 109if (isset($text)) { echo $text; }
90962c86 110displayshortcuts();
111
112?>
113
e2cae7e3 114<table class="<?php echo $css['bicol']?>" cellpadding="0" cellspacing="0" border="0">
90962c86 115 <tr>
4ea94c33 116 <th class="<?php echo $css['date']?>">
0a65ec9d 117 <?php echo _b_('Date'); ?>
90962c86 118 </th>
4ea94c33 119 <th class="<?php echo $css['subject']?>">
0a65ec9d 120 <?php echo _b_('Sujet'); ?>
90962c86 121 </th>
4ea94c33 122 <th class="<?php echo $css['from']?>">
0a65ec9d 123 <?php echo _b_('Auteur'); ?>
90962c86 124 </th>
125 </tr>
126<?php
2dbc0167 127$banana->spool->disp($first, $last);
128$banana->nntp->quit();
90962c86 129echo "</table>";
130
131displayshortcuts();
132
0d407ce1 133require_once("include/footer.inc.php");
90962c86 134?>