5 * @author Anthony Parsons (xmpp:ant@specialops.ath.cx)
6 * @license file://../COPYING
9 require_once 'iface.Boardlist.php';
11 class Boardlist_IRC
implements Boardlist
14 const Name
= 'Special Ops';
15 private $ircchan = array('##');
21 $boards = $DB->query('SELECT `group_name`, `boardid`, `board_name` AS `name`, `caption`, `view_restrict`
22 FROM `boards` LEFT JOIN `board-groups` USING(`groupid`)
23 ORDER BY `groupid` ASC, `boardid` ASC', MYSQLI_USE_RESULT
);
25 // Really bad multidimensional array hack
26 while ( $tmp = $boards->fetch_assoc() ) {
27 $groups[array_shift($tmp)][array_shift($tmp)] = $tmp;
32 <col
/><col
/><col
/><col
/>
35 <th scope
="col">Board
</th
>
36 <th scope
="col">Posts
</th
>
37 <th scope
="col">Topics
</th
>
38 <th scope
="col">Last Post
</th
>
42 foreach ( $groups as $groupname => $boards ) {
43 echo '<tbody class="boardgroup">',"\n",
44 '<tr><th scope="rowgroup" colspan="4">',$groupname,"</th></tr>\n";
46 foreach ( $boards as $boardid => $board ) {
47 $DB->query('SET @boardid = '.$boardid);
49 list($postcount, $lastpost) = $DB->query('SELECT COUNT(*), MAX(`messageid`) FROM `messages` WHERE `topicid` IN
50 (SELECT `topicid` FROM `topics` WHERE `boardid` = @boardid)')->fetch_row();
51 list($topiccount) = $DB->query('SELECT COUNT(*) FROM `topics` WHERE `boardid` = @boardid')->fetch_row();
54 $postinfo = $DB->query('SELECT `messages`.`userid`, `alias`, `mtime`, `topics`.`topicid`, `topic_title`
56 LEFT JOIN `topics` USING(`topicid`)
57 LEFT JOIN `users` ON `messages`.`userid` = `users`.`userid`
58 WHERE `messageid` = '.$lastpost)->fetch_assoc();
63 echo '<tr class="content">',"\n",
65 $user->has_priv('viewboard', $board['view_restrict']) ?
66 '<a href="topiclist?'.$boardid.'">'.$board['name'].'</a>' : $board['name']
68 ' <small style="margin-left:1em">',$board['caption'],"</small></td>\n",
69 ' <td>',$postcount,"</td>\n",
70 ' <td>',$topiccount,"</td>\n";
72 if ( $postinfo && $user->has_priv('viewboard', $board['view_restrict']) ) {
75 " <strong>From:</strong> %s\n".
76 " <strong>at</strong> %s<br/>\n".
77 ' <strong>in topic:</strong> <a class="topic" href="messagelist?%d">%s</a></small></td>'."\n".
79 $user->namelink($postinfo['userid'],
81 $user->fdate($postinfo['mtime']),
83 $postinfo['topic_title']
86 echo "\t<td>N/A</td>\n</tr>\n";
92 echo '<tbody class="boardgroup">',"\n",
93 '<tr><th scope="rowgroup" colspan="4">IRC</th></tr>',"\n";
95 foreach ( $this->ircchan
as $channel ) {
96 $chan = IRCLOGS
.'-'.$channel.'.log';
97 $last = `tail
-n100
"$chan" | grep
-o
'^.*<' | tail
-n1`
;
98 echo '<tr class="content">',"\n",
99 ' <td><a href="irc://specialops.ath.cx/',$channel,'">',$channel,"</a></td>\n",
100 ' <td>',`wc
-l
"$chan" | grep
-o ^
[0-9]*`
,"</td>\n",
102 ' <td>',$user->fdate(strtotime(substr($last, 0, -2))),"</td>\n",
106 echo "</tbody>\n</table>\n";