author | Dan |
Wed, 17 Oct 2007 23:44:22 -0400 | |
changeset 4 | c31210950118 |
parent 2 | 253118325c65 |
child 6 | 3f66ec435f08 |
permissions | -rw-r--r-- |
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 |
||
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
38 |
$q = $db->sql_query('SELECT t.topic_id,t.topic_title,t.topic_type,t.topic_icon, |
2
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
39 |
t.num_views,t.topic_starter AS starter_id, u.username AS topic_starter, |
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
40 |
p.poster_name AS last_post_name, p.timestamp AS last_post_time, t.topic_deleted, u2.username AS deletor, |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
41 |
t.topic_delete_reason |
0 | 42 |
FROM '.table_prefix.'decir_topics AS t |
43 |
LEFT JOIN '.table_prefix.'decir_posts AS p |
|
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
44 |
ON (t.topic_id = p.topic_id) |
0 | 45 |
LEFT JOIN '.table_prefix.'decir_hits AS h |
46 |
ON (t.topic_id=h.topic_id) |
|
47 |
LEFT JOIN '.table_prefix.'users AS u |
|
48 |
ON (u.user_id=t.topic_starter) |
|
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
49 |
LEFT JOIN '.table_prefix.'users AS u2 |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
50 |
ON (u2.user_id = t.topic_deletor OR t.topic_deletor IS NULL) |
0 | 51 |
WHERE t.forum_id='.$fid.' |
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
52 |
GROUP BY p.post_id |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
53 |
ORDER BY '.$sort_column.' '.$sort_dir.', p.timestamp DESC;'); |
0 | 54 |
|
55 |
if(!$q) |
|
56 |
$db->_die(); |
|
57 |
||
58 |
echo '<div class="tblholder"> |
|
59 |
<table border="0" cellspacing="1" cellpadding="4"> |
|
60 |
<tr> |
|
61 |
<th colspan="3">Topic</th> |
|
62 |
<th>Author</th> |
|
63 |
<th>Replies</th> |
|
64 |
<th>Views</th> |
|
65 |
<th>Last post</th> |
|
66 |
</th>'; |
|
67 |
||
68 |
if ( $row = $db->fetchrow() ) |
|
69 |
{ |
|
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
70 |
$last_row = $row; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
71 |
$i = 0; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
72 |
$num_replies = -1; |
0 | 73 |
do |
74 |
{ |
|
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
75 |
$i++; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
76 |
if ( $last_row['topic_id'] != $row['topic_id'] || $i == $db->numrows() ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
77 |
{ |
2
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
78 |
if ( $num_replies < 0 ) |
253118325c65
Pagination on topics and a whole crapload of other stuff.
Dan
parents:
1
diff
changeset
|
79 |
$num_replies = 0; |
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
80 |
if ( $last_row['topic_deleted'] == 1 ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
81 |
{ |
4
c31210950118
Some access controls implemented... we'll see how well this works
Dan
parents:
2
diff
changeset
|
82 |
$thread_link = '<Deleted>'; |
c31210950118
Some access controls implemented... we'll see how well this works
Dan
parents:
2
diff
changeset
|
83 |
if ( $session->get_permissions('decir_see_deleted_topic_full') ) |
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
84 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
85 |
$thread_link = '<b><a class="wikilink-nonexistent" href="' . makeUrlNS('DecirTopic', $last_row['topic_id']) . '">' . $last_row['topic_title'] . '</a></b>'; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
86 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
87 |
echo '<tr> |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
88 |
<td class="row2"></td> |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
89 |
<td class="row2"></td> |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
90 |
<td class="row2" style="width: 100%;">' . $thread_link . '</td> |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
91 |
<td class="row3" style="text-align: center;" colspan="4">Thread deleted by <b>' . htmlspecialchars($row['deletor']) . '</b><br />Reason: <i>' . htmlspecialchars($row['topic_delete_reason']) . '</i></td> |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
92 |
</tr>'; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
93 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
94 |
else |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
95 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
96 |
echo '<tr> |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
97 |
<td class="row2"></td> |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
98 |
<td class="row2"></td> |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
99 |
<td class="row2" style="width: 100%;"><b><a href="' . makeUrlNS('DecirTopic', $last_row['topic_id']) . '">' . $last_row['topic_title'] . '</a></b></td> |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
100 |
<td class="row3" style="text-align: center; max-width: 100px;">' . $last_row['topic_starter'] . '</td> |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
101 |
<td class="row1" style="text-align: center; width: 50px;">' . $num_replies . '</td> |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
102 |
<td class="row1" style="text-align: center; width: 50px;">' . $last_row['num_views'] . '</td> |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
103 |
<td class="row3" style="text-align: center;"><small style="white-space: nowrap;">' . date('d M Y h:i a', $last_row['last_post_time']) . '<br />by '.$last_row['last_post_name'].'</small></td> |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
104 |
</tr>'; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
105 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
106 |
$num_replies = 0; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
107 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
108 |
$num_replies++; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
109 |
$last_row = $row; |
0 | 110 |
} while ( $row = $db->fetchrow() ); |
111 |
} |
|
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
112 |
else |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
113 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
114 |
echo '<tr> |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
115 |
<td colspan="7" style="text-align: center;" class="row1">There are no topics in this forum.</td> |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
116 |
</tr>'; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
117 |
} |
0 | 118 |
|
119 |
echo '</table></div>'; |
|
120 |
||
1
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
121 |
if ( $perms->get_permissions('decir_post') ) |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
122 |
{ |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
123 |
echo '<p><a href="' . makeUrlNS('Special', 'Forum/New/Topic/' . $fid) . '">Post new topic</a></p>'; |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
124 |
} |
6f8b7c6fac02
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents:
0
diff
changeset
|
125 |
|
0 | 126 |
$template->footer(); |
127 |
||
128 |
?> |