-
Notifications
You must be signed in to change notification settings - Fork 3
/
latesttopics.php
158 lines (147 loc) · 6.91 KB
/
latesttopics.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
<?php
/*
##########################################################################
# #
# Version 4 / / / #
# -----------__---/__---__------__----__---/---/- #
# | /| / /___) / ) (_ ` / ) /___) / / #
# _|/_|/__(___ _(___/_(__)___/___/_(___ _/___/___ #
# Free Content / Management System #
# / #
# #
# #
# Copyright 2005-2011 by webspell.org #
# #
# visit webSPELL.org, webspell.info to get webSPELL for free #
# - Script runs under the GNU GENERAL PUBLIC LICENSE #
# - It's NOT allowed to remove this copyright-tag #
# -- http://www.fsf.org/licensing/licenses/gpl.html #
# #
# Code based on WebSPELL Clanpackage (Michael Gruber - webspell.at), #
# Far Development by Development Team - webspell.org #
# #
# visit webspell.org #
# #
##########################################################################
##########################################################################
# #
# Version 4 / / / #
# -----------__---/__---__------__----__---/---/- #
# | /| / /___) / ) (_ ` / ) /___) / / #
# _|/_|/__(___ _(___/_(__)___/___/_(___ _/___/___ #
# Society / Edition #
# / #
# #
# modified by webspell|k3rmit (Stefan Giesecke) in 2009 #
# #
# - Modifications are released under the GNU GENERAL PUBLIC LICENSE #
# - It is NOT allowed to remove this copyright-tag #
# - http://www.fsf.org/licensing/licenses/gpl.html #
# #
##########################################################################
*/
$_language->read_module('latesttopics');
$usergroups = array();
if($loggedin){
$usergroups[] = 'user';
$get = safe_query("SELECT * FROM ".PREFIX."user_forum_groups WHERE userID='".$userID."'");
$data = mysql_fetch_row($get);
for($i=2; $i<count($data);$i++){
if($data[$i] == 1){
$info = mysql_fetch_field($get,$i);
$usergroups[] = $info->name;
}
}
}
$userallowedreadgrps = array();
$userallowedreadgrps['boardIDs'] = array();
$userallowedreadgrps['catIDs'] = array();
$get = safe_query("SELECT boardID FROM ".PREFIX."forum_boards WHERE readgrps = ''");
while($ds = mysql_fetch_assoc($get)){
$userallowedreadgrps['boardIDs'][] = $ds['boardID'];
}
$get = safe_query("SELECT catID FROM ".PREFIX."forum_categories WHERE readgrps = ''");
while($ds = mysql_fetch_assoc($get)){
$userallowedreadgrps['catIDs'][] = $ds['catID'];
}
if($loggedin){
$get = safe_query("SELECT boardID, readgrps FROM ".PREFIX."forum_boards WHERE readgrps != ''");
while($ds = mysql_fetch_assoc($get)){
$groups = explode(";",$ds['readgrps']);
$allowed = array_intersect($groups,$usergroups);
if(!count($allowed)) continue;
$userallowedreadgrps['boardIDs'][] = $ds['boardID'];
}
$get = safe_query("SELECT catID, readgrps FROM ".PREFIX."forum_categories WHERE readgrps != ''");
while($ds = mysql_fetch_assoc($get)){
$groups = explode(";",$ds['readgrps']);
$allowed = array_intersect($groups,$usergroups);
if(!count($allowed)) continue;
$userallowedreadgrps['catIDs'][] = $ds['catID'];
}
}
if(empty($userallowedreadgrps['catIDs'])){
$userallowedreadgrps['catIDs'][] = 0;
}
if(empty($userallowedreadgrps['boardIDs'])){
$userallowedreadgrps['boardIDs'][] = 0;
}
$ergebnis=safe_query("SELECT t.*, u.nickname, b.name
FROM ".PREFIX."forum_topics t
LEFT JOIN ".PREFIX."user u ON u.userID = t.lastposter
LEFT JOIN ".PREFIX."forum_boards b ON b.boardID = t.boardID
WHERE b.category IN (".implode(",",$userallowedreadgrps['catIDs']).") AND
t.boardID IN (".implode(",",$userallowedreadgrps['boardIDs']).") AND
t.moveID = '0'
ORDER BY t.lastdate DESC
LIMIT 0,".$maxlatesttopics);
$anz=mysql_num_rows($ergebnis);
if($anz) {
eval ("\$latesttopics_head = \"".gettemplate("latesttopics_head")."\";");
echo $latesttopics_head;
$n=1;
while($ds=mysql_fetch_array($ergebnis)) {
if($ds['readgrps'] != "") {
$usergrps = explode(";", $ds['readgrps']);
$usergrp = 0;
foreach($usergrps as $value) {
if(isinusergrp($value, $userID)) {
$usergrp = 1;
break;
}
}
if(!$usergrp and !ismoderator($userID, $ds['boardID'])) continue;
}
if($n%2) {
$bg1=BG_1;
$bg2=BG_2;
}
else {
$bg1=BG_3;
$bg2=BG_4;
}
$topictitle = unhtmlspecialchars(clearfromtags($ds['topic']));
$topictitletooltip = htmlspecialchars($topictitle);
if(mb_strlen($topictitle)>$maxlatesttopicchars) {
$topictitle=mb_substr($topictitle, 0, $maxlatesttopicchars);
$topictitle.='...';
}
$topictitle = htmlspecialchars($topictitle);
$last_poster = $ds['nickname'];
$board = $ds['name'];
$date = date('d.m.Y - H:i', $ds['lastdate']);
$small_date = date('d.m H:i', $ds['lastdate']);
$latesticon = '<img src="images/icons/'.$ds['icon'].'" width="15" height="15" alt="" />';
$boardlink = '<a href="index.php?site=forum&board='.$ds['boardID'].'">'.$board.'</a>';
$topiclink = '<a href="index.php?site=forum_topic&topic='.$ds['topicID'].'&type=ASC&page='.ceil(($ds['replys']+1)/$maxposts).'" onmouseover="showWMTT(\'latesttopics_'.$n.'\')" onmouseout="hideWMTT()">'.$topictitle.'</a>';
$replys = $ds['replys'];
$replys_text = ($replys == 1) ? $_language->module['reply'] : $_language->module['replies'];
eval ("\$latesttopics_content = \"".gettemplate("latesttopics_content")."\";");
echo $latesttopics_content;
$n++;
}
eval ("\$latesttopics_foot = \"".gettemplate("latesttopics_foot")."\";");
echo $latesttopics_foot;
}
unset($board);
?>