better coding standards
[banana.git] / index.php
CommitLineData
90962c86 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
0d407ce1 10require_once("include/session.inc.php");
11require_once("include/password.inc.php");
12require_once("include/NetNNTP.inc.php");
13require_once("include/groups.inc.php");
14require_once("include/format.inc.php");
15require_once("include/config.inc.php");
16require_once("include/profile.inc.php");
17require_once("include/error.inc.php");
e2625e72 18
19$profile=getprofile();
0d407ce1 20require_once($profile['locale']);
90962c86 21
0d407ce1 22require_once("include/header.inc.php");
90962c86 23
24$nntp = new nntp($news['server']);
a3b667fe 25if (!$nntp) error("nntpsock");
90962c86 26if ($news['user']!="anonymous") {
27 $result = $nntp->authinfo($news["user"],$news["pass"]);
a3b667fe 28 if (!$result) error("nntpauth");
90962c86 29}
8f98c1e8 30$groups = new groups($nntp,0);
7345b395 31if (!count($groups->overview)) $groups=new groups($nntp,2);
a3b667fe 32
8f98c1e8 33$newgroups = new groups($nntp,1);
90962c86 34?>
35
40e27a11 36<h1>
90962c86 37 <?php echo $locale['index']['title'];?>
40e27a11 38</h1>
90962c86 39
40<?php
a3b667fe 41if (!sizeof($groups->overview)) error("nntpgroups");
90962c86 42
43displayshortcuts();
44?>
45
7ce9f53d 46<table class="<?php echo $css["bicol"];?>" cellspacing="0" cellpadding="2"
90962c86 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;
64foreach ($groups->overview as $g => $d) {
65 $pair = !$pair;
66 $groupinfo = $nntp->group($g);
30359882 67 $newarts = $nntp->newnews($profile['lastnews'],$g);
90962c86 68?>
7ce9f53d 69 <tr class="<?php echo ($pair?$css["pair"]:$css["impair"]);?>" >
70 <td class="<?php echo $css["total"]; ?>">
90962c86 71 <?php echo $groupinfo[0]; ?>
72 </td>
7ce9f53d 73 <td class="<?php echo $css["unread"]; ?>">
30359882 74 <?php echo sizeof($newarts); ?>
90962c86 75 </td>
7ce9f53d 76 <td class="<?php echo $css["group"]; ?>">
90962c86 77 <?php echo "<a href=\"thread.php?group=$g\">$g</a>";?>
78 </td>
7ce9f53d 79 <td class="<?php echo $css["description"]; ?>">
90962c86 80 <?php echo $d[0];?>
81 </td>
82 </tr>
83<?php
84}
85?>
86</table>
87<?php
8f98c1e8 88if (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 ?
90962c86 129
130displayshortcuts();
131
132$nntp->quit();
0d407ce1 133require_once("include/footer.inc.php");
90962c86 134?>