| 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/banana.inc.php"); |
| 11 | require_once("include/header.inc.php"); |
| 12 | |
| 13 | if (isset($_REQUEST['group'])) { |
| 14 | $group = htmlentities(strtolower($_REQUEST['group'])); |
| 15 | } else { |
| 16 | $group = htmlentities(strtolower(strtok(str_replace(" ","",$_REQUEST['newsgroups']),","))); |
| 17 | } |
| 18 | |
| 19 | if (isset($_REQUEST['id'])) { |
| 20 | $id=htmlentities(strtolower($_REQUEST['id'])); |
| 21 | } |
| 22 | |
| 23 | $banana->newSpool($group, $banana->profile['display'], $banana->profile['lastnews']); |
| 24 | $max = $banana->tmax; |
| 25 | if (isset($_REQUEST['first']) && ($_REQUEST['first']>sizeof($banana->spool->overview))) { |
| 26 | $_REQUEST['first'] = sizeof($banana->spool->overview); |
| 27 | } |
| 28 | $first = (isset($_REQUEST['first']) ? (floor($_REQUEST['first']/$max)*$max+1) : 1); |
| 29 | $last = (isset($_REQUEST['first']) ? (floor($_REQUEST['first']/$max+1)*$max) : $max); |
| 30 | |
| 31 | if (isset($_REQUEST['action']) && (isset($_REQUEST['type'])) |
| 32 | && (isset($_SESSION['bananapostok'])) && ($_SESSION['bananapostok'])) |
| 33 | { |
| 34 | switch ($_REQUEST['type']) { |
| 35 | case 'cancel': |
| 36 | $banana->nntp->group($group); |
| 37 | $mid = array_search($id, $banana->spool->ids); |
| 38 | $post = new BananaPost($id); |
| 39 | |
| 40 | if (checkcancel($post->headers)) { |
| 41 | $message = 'From: '.$banana->profile['name']."\n" |
| 42 | ."Newsgroups: $group\n" |
| 43 | ."Subject: cmsg $mid\n" |
| 44 | .$banana->custom |
| 45 | ."Control: cancel $mid\n" |
| 46 | ."\n" |
| 47 | ."Message canceled with Banana"; |
| 48 | if ($banana->nntp->post($message)) { |
| 49 | $banana->spool->delid($id); |
| 50 | $text = "<p class=\"normal\">"._b_('Message annulé')."</p>"; |
| 51 | } else { |
| 52 | $text = "<p class=\"error\">"._b_('Impossible d\'annuler le message')."</p>"; |
| 53 | } |
| 54 | } else { |
| 55 | $text = "<p class=\"error\">\n\t"._b_('Vous n\'avez pas les permissions pour annuler ce message')."\n</p>"; |
| 56 | } |
| 57 | break; |
| 58 | |
| 59 | case 'new': |
| 60 | $body = preg_replace("/\n\.[ \t\r]*\n/m","\n..\n",$_REQUEST['body']); |
| 61 | $message = 'From: '.$banana->profile['name']."\n" |
| 62 | ."Newsgroups: ".str_replace(" ","", $_REQUEST['newsgroups'])."\n" |
| 63 | ."Subject: ".$_REQUEST['subject']."\n" |
| 64 | .(isset($banana->profile['org'])?"Organization: ".$banana->profile['org']."\n":"") |
| 65 | .($_REQUEST['followup']!=''?'Followup-To: '.$_REQUEST['followup']."\n":"") |
| 66 | .$banana->custom |
| 67 | ."\n" |
| 68 | .wrap($body, "", $banana->wrap); |
| 69 | if ($banana->nntp->post($message)) { |
| 70 | $text = "<p class=\"normal\">"._b_('Message posté')."</p>"; |
| 71 | } else { |
| 72 | $text = "<p class=\"error\">"._b_('Impossible de poster le message')."</p>"; |
| 73 | } |
| 74 | break; |
| 75 | |
| 76 | case 'followupok': |
| 77 | $rq=$banana->nntp->group($group); |
| 78 | $post = new BananaPost($id); |
| 79 | if ($post) { |
| 80 | $refs = (isset($post->headers['references'])? |
| 81 | $post->headers['references']." ":"").$post->headers['message-id']; |
| 82 | } |
| 83 | |
| 84 | $body = preg_replace("/\n\.[ \t\r]*\n/m","\n..\n",$_REQUEST['body']); |
| 85 | $message = 'From: '.$banana->profile['name']."\n" |
| 86 | ."Newsgroups: ".$_REQUEST['newsgroups']."\n" |
| 87 | ."Subject: ".$_REQUEST['subject']."\n" |
| 88 | .(isset($banana->profile['org'])?"Organization: ".$banana->profile['org']."\n":"") |
| 89 | .($_REQUEST['followup']!=''?'Followup-To: '.$_REQUEST['followup']."\n":"") |
| 90 | ."References: $refs\n" |
| 91 | .$banana->custom |
| 92 | .$banana->profile['customhdr'] |
| 93 | ."\n" |
| 94 | .wrap($body, "", $banana->wrap); |
| 95 | if ($banana->nntp->post($message)) { |
| 96 | $text = "<p class=\"normal\">"._b_('Message posté')."</p>"; |
| 97 | } else { |
| 98 | $text = "<p class=\"error\">"._b_('Impossible de poster le message')."</p>"; |
| 99 | } |
| 100 | break; |
| 101 | } |
| 102 | $_SESSION['bananapostok']=false; |
| 103 | $banana->newSpool($group, $banana->profile['display'], $banana->profile['lastnews']); |
| 104 | } |
| 105 | |
| 106 | ?> |
| 107 | <h1><?php echo $group; ?></h1> |
| 108 | <?php |
| 109 | if (isset($text)) { echo $text; } |
| 110 | displayshortcuts(); |
| 111 | |
| 112 | ?> |
| 113 | |
| 114 | <table class="<?php echo $css['bicol']?>" cellpadding="0" cellspacing="0" border="0"> |
| 115 | <tr> |
| 116 | <th class="<?php echo $css['date']?>"> |
| 117 | <?php echo _b_('Date'); ?> |
| 118 | </th> |
| 119 | <th class="<?php echo $css['subject']?>"> |
| 120 | <?php echo _b_('Sujet'); ?> |
| 121 | </th> |
| 122 | <th class="<?php echo $css['from']?>"> |
| 123 | <?php echo _b_('Auteur'); ?> |
| 124 | </th> |
| 125 | </tr> |
| 126 | <?php |
| 127 | $banana->spool->disp($first, $last); |
| 128 | $banana->nntp->quit(); |
| 129 | echo "</table>"; |
| 130 | |
| 131 | displayshortcuts(); |
| 132 | |
| 133 | require_once("include/footer.inc.php"); |
| 134 | ?> |