refresh-post protection
[banana.git] / thread.php
index ca57ef6..abade85 100644 (file)
@@ -28,7 +28,10 @@ if (isset($_REQUEST['group'])) {
 } else {
   $group=htmlentities(strtolower(strtok(str_replace(" ","",$_REQUEST['newsgroups']),",")));
 }
-$id=htmlentities(strtolower($_REQUEST['id']));
+
+if (isset($_REQUEST['id'])) {
+  $id=htmlentities(strtolower($_REQUEST['id']));
+}
 
 //$mynntp = new nntp($news['server'],120,1);
 $mynntp = new nntp($news['server']);
@@ -55,14 +58,15 @@ if (!$spool) {
   exit;
 }
 $max = 50;
-if ($_REQUEST['first']>sizeof($spool->overview))
+if (isset($_REQUEST['first']) && ($_REQUEST['first']>sizeof($spool->overview)))
   $_REQUEST['first']=sizeof($spool->overview);
 $first = (isset($_REQUEST['first'])?
   (floor($_REQUEST['first']/$max)*$max+1):1);
 $last  = (isset($_REQUEST['first'])?
   (floor($_REQUEST['first']/$max+1)*$max):$max);
 
-if (isset($_REQUEST['action']) && (isset($_REQUEST['type']))) {
+if (isset($_REQUEST['action']) && (isset($_REQUEST['type'])) && 
+(isset($_SESSION['bananapostok'])) && ($_SESSION['bananapostok'])) {
   switch ($_REQUEST['type']) {  
     case 'cancel':
       $mid = array_search($id,$spool->ids);
@@ -92,15 +96,17 @@ if (isset($_REQUEST['action']) && (isset($_REQUEST['type']))) {
       }
       break;
     case 'new':
+      $body = preg_replace("/\n\.[ \t\r]*\n/m","\n..\n",stripslashes($_REQUEST['body']));
       $message = 'From: '.$profile['name']."\n"
         ."Newsgroups: ".stripslashes(str_replace(" ","",
           $_REQUEST['newsgroups']))."\n"
         ."Subject: ".stripslashes($_REQUEST['subject'])."\n"
+        .(isset($profile['org'])?"Organization: ".$profile['org']."\n":"")
         .($_REQUEST['followup']!=''?'Followup-To: '
         .stripslashes($_REQUEST['followup'])."\n":"")
         .$news['customhdr']
         ."\n"
-        .wrap(stripslashes($_REQUEST['body']),"",$news['wrap']);
+        .wrap($body,"",$news['wrap']);
       $result = $mynntp->post($message);
       if ($result) {
         $text="<p class=\"normal\">".$locale['post']['posted']."</p>";
@@ -112,18 +118,21 @@ if (isset($_REQUEST['action']) && (isset($_REQUEST['type']))) {
       $rq=$mynntp->group($group);
       $post = new post($mynntp,$id);
       if ($post) {
-        $refs = $post->headers->references." ".$post->headers->msgid;
+        $refs = (isset($post->headers->references)?
+                $post->headers->references." ":"").$post->headers->msgid;
       }
     
+      $body = preg_replace("/\n\.[ \t\r]*\n/m","\n..\n",stripslashes($_REQUEST['body']));
       $message = 'From: '.$profile['name']."\n"
         ."Newsgroups: ".stripslashes($_REQUEST['newsgroups'])."\n"
         ."Subject: ".stripslashes($_REQUEST['subject'])."\n"
+        .(isset($profile['org'])?"Organization: ".$profile['org']."\n":"")
         .($_REQUEST['followup']!=''?'Followup-To: '
         .stripslashes($_REQUEST['followup'])."\n":"")
         ."References: $refs\n"
         .$news['customhdr']
         ."\n"
-        .wrap(stripslashes($_REQUEST['body']),"",$news['wrap']);
+        .wrap($body,"",$news['wrap']);
       $result = $mynntp->post($message);
       if ($result) {
         $text="<p class=\"normal\">".$locale['post']['posted']."</p>";
@@ -132,6 +141,7 @@ if (isset($_REQUEST['action']) && (isset($_REQUEST['type']))) {
       }
       break;
   }
+  $_SESSION['bananapostok']=false;
   $spool = new spool($mynntp,$group,$profile['display'],
     $profile['lastnews']);
   if (!$spool) {
@@ -143,26 +153,28 @@ if (isset($_REQUEST['action']) && (isset($_REQUEST['type']))) {
 
 
 ?>
-<div class="title">
+<div class="<?php echo $css['title']?>">
   <?php echo $locale['thread']['group_b'].$group
     .$locale['thread']['group_a'];?>
 </div>
 <?php
-echo $text;
+if (isset($text)) {
+    echo $text;
+}
 displayshortcuts();
 
 ?>
 
-<table class="bicol" cellpadding="0" cellspacing="0" border="0" 
+<table class="<?php echo $css['bicol']?>" cellpadding="0" cellspacing="0" border="0" 
   summary="<?php echo $locale['thread']['summary'];?>">
   <tr>
-    <th class="date">
+    <th class="<?php echo $css['date']?>">
       <?php echo $locale['thread']['date'];?>
     </th>
-    <th class="subject">
+    <th class="<?php echo $css['subject']?>">
       <?php echo $locale['thread']['subject'];?>
     </th>
-    <th class="from">
+    <th class="<?php echo $css['from']?>">
       <?php echo $locale['thread']['author'];?>
     </th>
   </tr>