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