/
viewforum.php
executable file
·184 lines (160 loc) · 5.7 KB
/
viewforum.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
/**************************************************************************
* 0xBB ~ Bullettin Board *
**************************************************************************
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* =========================================================================*
* Software: 0xBB
* Software version: 2.0
* Author: KinG-InFeT
* Copyleft: GNU General Public License
* =========================================================================*
* viewforum.php
***************************************************************************/
include "kernel.php";
show_header();
show_menu ();
list ($username, $password) = get_data ();
if (!check_forum_id ($_GET ['id']) || !($_GET ['id']))
_err("ID non Specificato!");
$id = (int) $_GET ['id'];
// controllo se il forum è protetto
if(check_access_forum($id) != NULL && check_access_forum($id) != 'user') {
if(login($username, $password) == TRUE) {
if(level($username) != 'admin' && level($username) != 'mod')
if(level($username) != check_access_forum($id))
_err('Non hai i permessi per visualizzare questo topic!');
}else{
if((check_access_forum($id) != NULL) && (check_access_forum($id) != 'user'))
header('Location: index.php');
}
}
if (isset($_GET['page']) && is_numeric($_GET['page']) && ((int) $_GET['page']) > 0 )
$page = (int) $_GET['page'];
else
$page = 1;
$query = "SELECT *
FROM ". __PREFIX__ ."topic
WHERE f_id = '". $id ."'
AND replyof < 0
ORDER by last DESC";
$res = mysql_query ($query);
$limit = 10; //quanti topic per pagina?
$Pager = new Pagination();
$pager = $Pager->paginazione($res, $limit, $page);
$offset = $pager['offset'];
$limit = $pager['limit'];
?>
<br />
<div class = 'path' id = 'path'>
<table>
<tr>
<td><b><a href = 'index.php'>Indice Forum</a></b></td>
<td><?php patch_forum($id, 2); ?></td>
</tr>
<tr>
<td>Pagine: <?php print print_pagination($pager['numPages'], $page, $id); ?></td>
</tr>
</table>
</div>
<br />
<?php
// se loggato visualizzo il pulsante per la creazione di un nuovo topic
if(login($username, $password) == TRUE) {
?>
<!-- New Topic -->
<table align="center">
<tr>
<td>
<form method="GET" action="post.php" />
<input type="hidden" value="<?php print $id; ?>" name="id"/>
<input type="submit" value="Nuovo Topic" />
</form>
</td>
</tr>
</table>
<!-- end new topic -->
<?php
}
?>
<table class="main">
<tr class="forums" >
<td class="forums"><b>Nome Topic</b></td>
<td class="forums"><b>Autore</b></td>
<td class="forums"><b>Risposte</b></td>
</tr>
<tr>
<td colspan="3"><hr style="margin:1px;height:1px;border:none;background-color:white;"></td>
</tr>
<?php
// print topic announcement and important
$query_2 = "SELECT *
FROM ". __PREFIX__ ."topic
WHERE f_id = '". $id ."'
AND replyof < 0
AND (important = 1
OR announcement = 1)
ORDER by last DESC
LIMIT ".$limit."
OFFSET ".$offset;
$result = mysql_query($query_2) or _err(mysql_error());
while ($row = mysql_fetch_row ($result)) {
$query = "SELECT id FROM ". __PREFIX__ ."topic WHERE replyof = '". $row[0] ."'";
$res2 = mysql_query ($query);
$replies = 0;
while(mysql_fetch_row($res2))
$replies++;
?>
<tr>
<td class="forums"><a href = 'viewtopic.php?id=<?php print $row [0]."'>".$row [4]."</a> ".check_graphic_block_topic($row[0]) . check_graphic_important_topic($row[0]) . check_graphic_announcement_topic($row[0]); ?></td>
<td class="forums"><a href = 'profile.php?id=<?php print nick2uid ($row [3])."'>".$row [3]; ?></a></td>
<td class="forums"><?php print $replies; ?></td>
</tr>
<tr>
<td colspan="3"><hr style="margin:1px;height:1px;border:none;background-color:white;"></td>
</tr>
<?php
}// end while write topics announcement and important
$query_2 = "SELECT *
FROM ". __PREFIX__ ."topic
WHERE f_id = '". $id ."'
AND replyof < 0
AND ((important = 0 OR important = NULL)
AND (announcement = 0 OR announcement = NULL))
ORDER by last DESC
LIMIT ".$limit."
OFFSET ".$offset;
$result = mysql_query($query_2) or _err(mysql_error());
while ($row = mysql_fetch_row ($result)) {
$query = "SELECT id FROM ". __PREFIX__ ."topic WHERE replyof = '". $row[0] ."'";
$res2 = mysql_query ($query);
$replies = 0;
while(mysql_fetch_row($res2))
$replies++;
?>
<tr>
<td class="forums"><a href = 'viewtopic.php?id=<?php print $row [0]."'>".$row [4]."</a> ".check_graphic_block_topic($row[0]); ?></td>
<td class="forums"><a href = 'profile.php?id=<?php print nick2uid ($row [3])."'>".$row [3]; ?></a></td>
<td class="forums"><?php print $replies; ?></td>
</tr>
<tr>
<td colspan="3"><hr style="margin:1px;height:1px;border:none;background-color:white;"></td>
</tr>
<?php
}// end while write topics
print "</table>\n";
footer();
?>
</body>
</html>