0
|
1 |
<?php
|
|
2 |
/*
|
|
3 |
* Decir
|
|
4 |
* Version 0.1
|
|
5 |
* Copyright (C) 2007 Dan Fuhry
|
|
6 |
* install.php - Database installation wizard
|
|
7 |
*
|
|
8 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
|
|
9 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
|
|
10 |
*
|
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
12 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
|
|
13 |
*/
|
|
14 |
|
|
15 |
require('common.php');
|
|
16 |
|
|
17 |
$template->header();
|
|
18 |
|
|
19 |
$fid = ( $n = $paths->getParam(1) ) ? $n : ( ( isset($_GET['fid']) ) ? $_GET['fid'] : 0 );
|
|
20 |
$fid = intval($fid);
|
|
21 |
|
|
22 |
if(empty($fid))
|
|
23 |
{
|
|
24 |
echo '<p>Invalid forum ID</p>';
|
|
25 |
$template->footer();
|
|
26 |
return;
|
|
27 |
}
|
|
28 |
|
|
29 |
$perms = $session->fetch_page_acl((string)$fid, 'DecirForum');
|
|
30 |
if ( !$perms->get_permissions('decir_view_forum') )
|
|
31 |
{
|
|
32 |
die_friendly('Access denied', '<p>You are not authorized to view this forum.</p>');
|
|
33 |
}
|
|
34 |
|
|
35 |
$sort_column = ( isset($_GET['sort_column']) && in_array($_GET['sort_column'], array('t.timestamp', 't.topic_title')) ) ? $_GET['sort_column'] : 't.timestamp';
|
|
36 |
$sort_dir = ( isset($_GET['sort_dir']) && in_array($_GET['sort_dir'], array('ASC', 'DESC')) ) ? $_GET['sort_dir'] : 'DESC';
|
|
37 |
|
|
38 |
$q = $db->sql_query('SELECT t.topic_id,t.topic_title,t.topic_type,t.topic_icon,COUNT(p.post_id)-1 AS num_replies,
|
|
39 |
COUNT(h.hit_id) AS num_views,t.topic_starter AS starter_id, u.username AS topic_starter,
|
|
40 |
p.poster_name AS last_post_name, p.timestamp AS last_post_time
|
|
41 |
FROM '.table_prefix.'decir_topics AS t
|
|
42 |
LEFT JOIN '.table_prefix.'decir_posts AS p
|
|
43 |
ON (t.last_post=p.post_id)
|
|
44 |
LEFT JOIN '.table_prefix.'decir_hits AS h
|
|
45 |
ON (t.topic_id=h.topic_id)
|
|
46 |
LEFT JOIN '.table_prefix.'users AS u
|
|
47 |
ON (u.user_id=t.topic_starter)
|
|
48 |
WHERE t.forum_id='.$fid.'
|
|
49 |
GROUP BY t.topic_id
|
|
50 |
ORDER BY '.$sort_column.' '.$sort_dir.';');
|
|
51 |
|
|
52 |
if(!$q)
|
|
53 |
$db->_die();
|
|
54 |
|
|
55 |
echo '<div class="tblholder">
|
|
56 |
<table border="0" cellspacing="1" cellpadding="4">
|
|
57 |
<tr>
|
|
58 |
<th colspan="3">Topic</th>
|
|
59 |
<th>Author</th>
|
|
60 |
<th>Replies</th>
|
|
61 |
<th>Views</th>
|
|
62 |
<th>Last post</th>
|
|
63 |
</th>';
|
|
64 |
|
|
65 |
if ( $row = $db->fetchrow() )
|
|
66 |
{
|
|
67 |
do
|
|
68 |
{
|
|
69 |
echo '<tr>
|
|
70 |
<td class="row2"></td>
|
|
71 |
<td class="row2"></td>
|
|
72 |
<td class="row2" style="width: 100%;"><b><a href="' . makeUrlNS('DecirTopic', $row['topic_id']) . '">' . $row['topic_title'] . '</a></b></td>
|
|
73 |
<td class="row3" style="text-align: center; max-width: 100px;">' . $row['topic_starter'] . '</td>
|
|
74 |
<td class="row1" style="text-align: center; width: 50px;">' . $row['num_replies'] . '</td>
|
|
75 |
<td class="row1" style="text-align: center; width: 50px;">' . $row['num_views'] . '</td>
|
|
76 |
<td class="row3" style="text-align: center;"><small style="white-space: nowrap;">' . date('d M Y h:i a', $row['last_post_time']) . '<br />by '.$row['last_post_name'].'</small></td>
|
|
77 |
</tr>';
|
|
78 |
} while ( $row = $db->fetchrow() );
|
|
79 |
}
|
|
80 |
|
|
81 |
echo '</table></div>';
|
|
82 |
|
|
83 |
$template->footer();
|
|
84 |
|
|
85 |
?>
|