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