20b296cab2c23a80275176e45b89aa3e76c57195
[banana.git] / index.php
1 <?php
2 /********************************************************************************
3 * index.php : main page (newsgroups list)
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("include/session.inc.php");
11 require("include/password.inc.php");
12 require("include/NetNNTP.inc.php");
13 require("include/groups.inc.php");
14 require("include/format.inc.php");
15 require("include/config.inc.php");
16 require("include/profile.inc.php");
17 require("include/error.inc.php");
18
19 $profile=getprofile();
20 require($profile['locale']);
21
22 require("include/header.inc.php");
23
24 $nntp = new nntp($news['server']);
25 if (!$nntp) error("nntpsock");
26 if ($news['user']!="anonymous") {
27 $result = $nntp->authinfo($news["user"],$news["pass"]);
28 if (!$result) error("nntpauth");
29 }
30 $groups = new groups($nntp,0);
31 if (!count($groups->overview)) $groups=new groups($nntp,2);
32
33 $newgroups = new groups($nntp,1);
34 ?>
35
36 <div class="<?php echo $css["title"];?>">
37 <?php echo $locale['index']['title'];?>
38 </div>
39
40 <?php
41 if (!sizeof($groups->overview)) error("nntpgroups");
42
43 displayshortcuts();
44 ?>
45
46 <table class="<?php echo $css["bicol"];?>" cellspacing="0" cellpadding="2"
47 summary="<?php echo $locale['index']['summary'];?>">
48 <tr>
49 <th>
50 <?php echo $locale['index']['total'];?>
51 </th>
52 <th>
53 <?php echo $locale['index']['unread'];?>
54 </th>
55 <th>
56 <?php echo $locale['index']['name'];?>
57 </th>
58 <th>
59 <?php echo $locale['index']['description'];?>
60 </th>
61 </tr>
62 <?php
63 $pair = true;
64 foreach ($groups->overview as $g => $d) {
65 $pair = !$pair;
66 $groupinfo = $nntp->group($g);
67 $newarts = $nntp->newnews($profile['lastnews'],$g);
68 ?>
69 <tr class="<?php echo ($pair?$css["pair"]:$css["impair"]);?>" >
70 <td class="<?php echo $css["total"]; ?>">
71 <?php echo $groupinfo[0]; ?>
72 </td>
73 <td class="<?php echo $css["unread"]; ?>">
74 <?php echo sizeof($newarts); ?>
75 </td>
76 <td class="<?php echo $css["group"]; ?>">
77 <?php echo "<a href=\"thread.php?group=$g\">$g</a>";?>
78 </td>
79 <td class="<?php echo $css["description"]; ?>">
80 <?php echo $d[0];?>
81 </td>
82 </tr>
83 <?php
84 }
85 ?>
86 </table>
87 <?php
88 if (count($newgroups->overview) and count($profile['subscribe'])) {
89 ?>
90 <p class="normal">
91 <?php echo $locale['index']['newgroupstext']; ?>
92 </p>
93 <table class="<?php echo $css["bicol"];?>" cellspacing="0" cellpadding="2"
94 summary="<?php echo $locale['index']['summary'];?>">
95 <tr>
96 <th>
97 <?php echo $locale['index']['total'];?>
98 </th>
99 <th>
100 <?php echo $locale['index']['name'];?>
101 </th>
102 <th>
103 <?php echo $locale['index']['description'];?>
104 </th>
105 </tr>
106 <?php
107 $pair = true;
108 foreach ($newgroups->overview as $g => $d) {
109 $pair = !$pair;
110 $groupinfo = $nntp->group($g);
111 ?>
112 <tr class="<?php echo ($pair?$css["pair"]:$css["impair"]);?>" >
113 <td class="<?php echo $css["total"]; ?>">
114 <?php echo $groupinfo[0]; ?>
115 </td>
116 <td class="<?php echo $css["group"]; ?>">
117 <?php echo "<a href=\"thread.php?group=$g\">$g</a>";?>
118 </td>
119 <td class="<?php echo $css["description"]; ?>">
120 <?php echo $d[0];?>
121 </td>
122 </tr>
123 <?php
124 } //foreach
125 ?>
126 </table>
127 <?php
128 } // new newsgroups ?
129
130 displayshortcuts();
131
132 $nntp->quit();
133 require("include/footer.inc.php");
134 ?>