typo
[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
90962c86 10require("include/session.inc.php");
11require("include/encoding.inc.php");
12require("include/format.inc.php");
13require("include/config.inc.php");
14require("include/NetNNTP.inc.php");
15include("include/post.inc.php");
16require("include/spool.inc.php");
17require("include/password.inc.php");
18require("include/profile.inc.php");
19include("include/wrapper.inc.php");
20
e2625e72 21$profile=getprofile();
22require($profile['locale']);
90962c86 23
e2625e72 24require("include/header.inc.php");
90962c86 25
26if (isset($_REQUEST['group'])) {
27 $group=htmlentities(strtolower($_REQUEST['group']));
28} else {
29 $group=htmlentities(strtolower(strtok(str_replace(" ","",$_REQUEST['newsgroups']),",")));
30}
5c33c608 31
32if (isset($_REQUEST['id'])) {
33 $id=htmlentities(strtolower($_REQUEST['id']));
34}
90962c86 35
36//$mynntp = new nntp($news['server'],120,1);
37$mynntp = new nntp($news['server']);
38if (!$mynntp) {
39 echo "<p class=\"error\">\n\t".$locale['error']['connect']."\n</p>";
40 require("include/footer.inc.php");
41 exit;
42}
43
44if ($news['user']!="anonymous") {
45 $result = $mynntp->authinfo($news["user"],$news["pass"]);
46 if (!$result) {
47 echo "<p class=\"error\">\n\t".$locale['error']['credentials']
48 ."\n</p>";
49 require("include/footer.inc.php");
50 exit;
51 }
52}
53$spool = new spool($mynntp,$group,$profile['display'],
54 $profile['lastnews']);
55if (!$spool) {
56 echo "<p class=\"error\">\n\t".$locale['error']['group']."\n</p>";
57 require("footer.inc.php");
58 exit;
59}
60$max = 50;
5c33c608 61if (isset($_REQUEST['first']) && ($_REQUEST['first']>sizeof($spool->overview)))
90962c86 62 $_REQUEST['first']=sizeof($spool->overview);
63$first = (isset($_REQUEST['first'])?
64 (floor($_REQUEST['first']/$max)*$max+1):1);
65$last = (isset($_REQUEST['first'])?
66 (floor($_REQUEST['first']/$max+1)*$max):$max);
67
25d27cb7 68if (isset($_REQUEST['action']) && (isset($_REQUEST['type'])) &&
69(isset($_SESSION['bananapostok'])) && ($_SESSION['bananapostok'])) {
90962c86 70 switch ($_REQUEST['type']) {
71 case 'cancel':
72 $mid = array_search($id,$spool->ids);
73 $mynntp->group($group);
74 $post = new post($mynntp,$id);
75
76 if (checkcancel($post->headers)) {
77 $message = 'From: '.$profile['name']."\n"
78 ."Newsgroups: $group\n"
79 ."Subject: cmsg $mid\n"
80 .$news['customhdr']
81 ."Control: cancel $mid\n"
82 ."\n"
83 ."Message canceled with Banana";
84 $result = $mynntp->post($message);
85 if ($result) {
86 $spool->delid($id);
87 $text="<p class=\"normal\">".$locale['post']['canceled']
88 ."</p>";
89 } else {
90 $text="<p class=\"error\">".$locale['post']['badcancel']
91 ."</p>";
92 }
93 } else {
94 $text="<p class=\"error\">\n\t".$locale['post']['rghtcancel']
95 ."\n</p>";
96 }
97 break;
98 case 'new':
4ea94c33 99 $body = preg_replace("/\n\.[ \t\r]*\n/m","\n..\n",stripslashes($_REQUEST['body']));
90962c86 100 $message = 'From: '.$profile['name']."\n"
101 ."Newsgroups: ".stripslashes(str_replace(" ","",
102 $_REQUEST['newsgroups']))."\n"
103 ."Subject: ".stripslashes($_REQUEST['subject'])."\n"
4ea94c33 104 .(isset($profile['org'])?"Organization: ".$profile['org']."\n":"")
90962c86 105 .($_REQUEST['followup']!=''?'Followup-To: '
106 .stripslashes($_REQUEST['followup'])."\n":"")
107 .$news['customhdr']
108 ."\n"
4ea94c33 109 .wrap($body,"",$news['wrap']);
90962c86 110 $result = $mynntp->post($message);
111 if ($result) {
112 $text="<p class=\"normal\">".$locale['post']['posted']."</p>";
113 } else {
114 $text="<p class=\"error\">".$locale['post']['badpost']."</p>";
115 }
116 break;
117 case 'followupok':
118 $rq=$mynntp->group($group);
119 $post = new post($mynntp,$id);
120 if ($post) {
4ea94c33 121 $refs = (isset($post->headers->references)?
122 $post->headers->references." ":"").$post->headers->msgid;
90962c86 123 }
124
4ea94c33 125 $body = preg_replace("/\n\.[ \t\r]*\n/m","\n..\n",stripslashes($_REQUEST['body']));
90962c86 126 $message = 'From: '.$profile['name']."\n"
127 ."Newsgroups: ".stripslashes($_REQUEST['newsgroups'])."\n"
128 ."Subject: ".stripslashes($_REQUEST['subject'])."\n"
4ea94c33 129 .(isset($profile['org'])?"Organization: ".$profile['org']."\n":"")
90962c86 130 .($_REQUEST['followup']!=''?'Followup-To: '
131 .stripslashes($_REQUEST['followup'])."\n":"")
132 ."References: $refs\n"
133 .$news['customhdr']
134 ."\n"
4ea94c33 135 .wrap($body,"",$news['wrap']);
90962c86 136 $result = $mynntp->post($message);
137 if ($result) {
138 $text="<p class=\"normal\">".$locale['post']['posted']."</p>";
139 } else {
140 $text="<p class=\"error\">".$locale['post']['badpost']."</p>";
141 }
142 break;
143 }
25d27cb7 144 $_SESSION['bananapostok']=false;
90962c86 145 $spool = new spool($mynntp,$group,$profile['display'],
146 $profile['lastnews']);
147 if (!$spool) {
148 echo "<p class=\"error\">\n\t".$locale['error']['group']."\n</p>";
149 require("include/footer.inc.php");
150 exit;
151 }
152}
153
154
155?>
4ea94c33 156<div class="<?php echo $css['title']?>">
90962c86 157 <?php echo $locale['thread']['group_b'].$group
158 .$locale['thread']['group_a'];?>
159</div>
160<?php
5c33c608 161if (isset($text)) {
162 echo $text;
163}
90962c86 164displayshortcuts();
165
166?>
167
4ea94c33 168<table class="<?php echo $css['bicol']?>" cellpadding="0" cellspacing="0" border="0"
90962c86 169 summary="<?php echo $locale['thread']['summary'];?>">
170 <tr>
4ea94c33 171 <th class="<?php echo $css['date']?>">
90962c86 172 <?php echo $locale['thread']['date'];?>
173 </th>
4ea94c33 174 <th class="<?php echo $css['subject']?>">
90962c86 175 <?php echo $locale['thread']['subject'];?>
176 </th>
4ea94c33 177 <th class="<?php echo $css['from']?>">
90962c86 178 <?php echo $locale['thread']['author'];?>
179 </th>
180 </tr>
181<?php
182$spool->disp($first,$last);
183$mynntp->quit();
184echo "</table>";
185
186displayshortcuts();
187
188require("include/footer.inc.php");
189?>