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