use h1
[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");
a3b667fe 20include("include/error.inc.php");
90962c86 21
e2625e72 22$profile=getprofile();
23require($profile['locale']);
90962c86 24
e2625e72 25require("include/header.inc.php");
90962c86 26
27if (isset($_REQUEST['group'])) {
28 $group=htmlentities(strtolower($_REQUEST['group']));
29} else {
30 $group=htmlentities(strtolower(strtok(str_replace(" ","",$_REQUEST['newsgroups']),",")));
31}
5c33c608 32
33if (isset($_REQUEST['id'])) {
34 $id=htmlentities(strtolower($_REQUEST['id']));
35}
90962c86 36
a3b667fe 37//$nntp = new nntp($news['server'],120,1);
38$nntp = new nntp($news['server']);
39if (!$nntp) error("nntpsock");
90962c86 40if ($news['user']!="anonymous") {
a3b667fe 41 $result = $nntp->authinfo($news["user"],$news["pass"]);
42 if (!$result) error("nntpauth");
90962c86 43}
a3b667fe 44$spool = new spool($nntp,$group,$profile['display'],
90962c86 45 $profile['lastnews']);
a3b667fe 46if (!$spool) error("nntpspool");
90962c86 47$max = 50;
5c33c608 48if (isset($_REQUEST['first']) && ($_REQUEST['first']>sizeof($spool->overview)))
90962c86 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
25d27cb7 55if (isset($_REQUEST['action']) && (isset($_REQUEST['type'])) &&
56(isset($_SESSION['bananapostok'])) && ($_SESSION['bananapostok'])) {
90962c86 57 switch ($_REQUEST['type']) {
58 case 'cancel':
59 $mid = array_search($id,$spool->ids);
a3b667fe 60 $nntp->group($group);
61 $post = new post($nntp,$id);
90962c86 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";
a3b667fe 71 $result = $nntp->post($message);
90962c86 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':
4ea94c33 86 $body = preg_replace("/\n\.[ \t\r]*\n/m","\n..\n",stripslashes($_REQUEST['body']));
90962c86 87 $message = 'From: '.$profile['name']."\n"
88 ."Newsgroups: ".stripslashes(str_replace(" ","",
89 $_REQUEST['newsgroups']))."\n"
90 ."Subject: ".stripslashes($_REQUEST['subject'])."\n"
4ea94c33 91 .(isset($profile['org'])?"Organization: ".$profile['org']."\n":"")
90962c86 92 .($_REQUEST['followup']!=''?'Followup-To: '
93 .stripslashes($_REQUEST['followup'])."\n":"")
94 .$news['customhdr']
95 ."\n"
4ea94c33 96 .wrap($body,"",$news['wrap']);
a3b667fe 97 $result = $nntp->post($message);
90962c86 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':
a3b667fe 105 $rq=$nntp->group($group);
106 $post = new post($nntp,$id);
90962c86 107 if ($post) {
4ea94c33 108 $refs = (isset($post->headers->references)?
109 $post->headers->references." ":"").$post->headers->msgid;
90962c86 110 }
111
4ea94c33 112 $body = preg_replace("/\n\.[ \t\r]*\n/m","\n..\n",stripslashes($_REQUEST['body']));
90962c86 113 $message = 'From: '.$profile['name']."\n"
114 ."Newsgroups: ".stripslashes($_REQUEST['newsgroups'])."\n"
115 ."Subject: ".stripslashes($_REQUEST['subject'])."\n"
4ea94c33 116 .(isset($profile['org'])?"Organization: ".$profile['org']."\n":"")
90962c86 117 .($_REQUEST['followup']!=''?'Followup-To: '
118 .stripslashes($_REQUEST['followup'])."\n":"")
119 ."References: $refs\n"
120 .$news['customhdr']
0c7b4992 121 .$profile['customhdr']
90962c86 122 ."\n"
4ea94c33 123 .wrap($body,"",$news['wrap']);
a3b667fe 124 $result = $nntp->post($message);
90962c86 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 }
25d27cb7 132 $_SESSION['bananapostok']=false;
a3b667fe 133 $spool = new spool($nntp,$group,$profile['display'],
90962c86 134 $profile['lastnews']);
a3b667fe 135 if (!$spool) error("nntpspool");
90962c86 136}
137
138
139?>
40e27a11 140<h1>
90962c86 141 <?php echo $locale['thread']['group_b'].$group
142 .$locale['thread']['group_a'];?>
40e27a11 143</h1>
90962c86 144<?php
5c33c608 145if (isset($text)) {
146 echo $text;
147}
90962c86 148displayshortcuts();
149
150?>
151
4ea94c33 152<table class="<?php echo $css['bicol']?>" cellpadding="0" cellspacing="0" border="0"
90962c86 153 summary="<?php echo $locale['thread']['summary'];?>">
154 <tr>
4ea94c33 155 <th class="<?php echo $css['date']?>">
90962c86 156 <?php echo $locale['thread']['date'];?>
157 </th>
4ea94c33 158 <th class="<?php echo $css['subject']?>">
90962c86 159 <?php echo $locale['thread']['subject'];?>
160 </th>
4ea94c33 161 <th class="<?php echo $css['from']?>">
90962c86 162 <?php echo $locale['thread']['author'];?>
163 </th>
164 </tr>
165<?php
166$spool->disp($first,$last);
a3b667fe 167$nntp->quit();
90962c86 168echo "</table>";
169
170displayshortcuts();
171
172require("include/footer.inc.php");
173?>