95f1fb2ce71cd8cac5907446fc4a4f0342ab746f
[banana.git] / subscribe.php
1 <?php
2 /********************************************************************************
3 * subscribe.php : subscriptions page
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/password.inc.php");
12 require_once("include/NetNNTP.inc.php");
13 require_once("include/groups.inc.php");
14 require_once("include/format.inc.php");
15 require_once("include/config.inc.php");
16 require_once("include/profile.inc.php");
17 require_once("include/subscribe.inc.php");
18 require_once("include/error.inc.php");
19
20 $profile=getprofile();
21 require_once("include/header.inc.php");
22
23 $nntp = new nntp($news['server']);
24 if (!$nntp) error("nntpsock");
25 if ($news['user']!="anonymous") {
26 $result = $nntp->authinfo($news["user"],$news["pass"]);
27 if (!$result) error("nntpauth");
28 }
29 $groups = new groups($nntp,2);
30 ?>
31
32 <h1>
33 <?php echo _('Abonnements'); ?>
34 </h1>
35
36 <?php
37
38 if (isset($_POST['subscribe']) && isset($_POST['action'])
39 && $_POST['action']=="OK") {
40 update_subscriptions($_POST['subscribe']);
41 $profile['subscribe']=$_POST['subscribe'];
42 }
43
44 if (!sizeof($groups->overview)) error("nntpgroups");
45
46 displayshortcuts();
47 ?>
48
49 <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
50 <table class="<?php echo $css["bicol"];?>" cellspacing="0" cellpadding="2">
51 <tr>
52 <th>
53 <?php echo _('Total'); ?>
54 </th>
55 <th>
56 <?php echo _('Abonné'); ?>
57 </th>
58 <th>
59 <?php echo _('Nom'); ?>
60 </th>
61 <th>
62 <?php echo _('Description'); ?>
63 </th>
64 </tr>
65 <?php
66 $pair = true;
67 foreach ($groups->overview as $g => $d) {
68 $pair = !$pair;
69 $groupinfo = $nntp->group($g);
70 $newarts = $nntp->newnews($profile['lastnews'],$g);
71 ?>
72 <tr class="<?php echo ($pair?$css["pair"]:$css["impair"]);?>" >
73 <td class="<?php echo $css["total"]; ?>">
74 <?php echo $groupinfo[0]; ?>
75 </td>
76 <td class="<?php echo $css["unread"]; ?>">
77 <input type="checkbox" name="subscribe[]" value="<?php echo $g;?>"
78 <?php echo (in_array($g,$profile['subscribe'])?'checked="checked"'
79 :'');?> />
80 </td>
81 <td class="<?php echo $css["group"]; ?>">
82 <?php echo "<a href=\"thread.php?group=$g\">$g</a>";?>
83 </td>
84 <td class="<?php echo $css["description"]; ?>">
85 <?php echo $d[0];?>
86 </td>
87 </tr>
88 <?php
89 }
90 ?>
91 <tr class="<?php echo (!$pair?$css["pair"]:$css["impair"]); ?>">
92 <td colspan="4" class="bouton">
93 <input type="submit" name="action" value="OK" />
94 </td>
95 </tr>
96 </table>
97 </form>
98 <?php
99
100 displayshortcuts();
101
102 $nntp->quit();
103 require_once("include/footer.inc.php");
104 ?>