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