3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the Revised BSD License.
6 This program is distributed in the hope that it will be useful,
7 but WITHOUT ANY WARRANTY; without even the implied warranty of
8 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 Revised BSD License for more details.
11 Copyright 2004-2011 iDB Support - http://idb.berlios.de/
12 Copyright 2004-2011 Game Maker 2k - http://gamemaker2k.org/
14 $FileInfo: forums.php - Last Update: 07/18/2011 SVN 720 - Author: cooldude2k $
16 $File3Name = basename($_SERVER['SCRIPT_NAME']);
17 if ($File3Name=="forums.php"||
$File3Name=="/forums.php") {
20 if(!isset($ThemeSet['ForumStyle'])) { $ThemeSet['ForumStyle'] = 1; }
21 if(!is_numeric($ThemeSet['ForumStyle'])) { $ThemeSet['ForumStyle'] = 1; }
22 if($ThemeSet['ForumStyle']>2||
$ThemeSet['ForumStyle']<1) {
23 $ThemeSet['ForumStyle'] = 1; }
24 $prequery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."categories\" WHERE \"ShowCategory\"='yes' AND \"InSubCategory\"=0".$CatIgnoreList2." ORDER BY \"OrderID\" ASC, \"id\" ASC", array());
25 $preresult=sql_query($prequery,$SQLStat);
26 $prenum=sql_num_rows($preresult);
28 $_SESSION['ViewingPage'] = url_maker(null,"no+ext","act=view","&","=",$prexqstr['index'],$exqstr['index']);
29 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
30 $_SESSION['ViewingFile'] = $exfile['index'].$Settings['file_ext']; }
31 if($Settings['file_ext']=="no+ext"||
$Settings['file_ext']=="no ext") {
32 $_SESSION['ViewingFile'] = $exfile['index']; }
33 $_SESSION['PreViewingTitle'] = "Viewing";
34 $_SESSION['ViewingTitle'] = "Board index";
36 <div
class="NavLinks"><?php
echo $ThemeSet['NavLinkIcon']; ?
><a href
="<?php echo url_maker($exfile['index'],$Settings['file_ext'],"act
=view
",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index']); ?>"><?php
echo $Settings['board_name']; ?
></a
></div
>
37 <div
class="DivNavLinks"> 
;</div
>
39 while ($prei < $prenum) {
40 $CategoryID=sql_result($preresult,$prei,"id");
41 $CategoryName=sql_result($preresult,$prei,"Name");
42 $CategoryShow=sql_result($preresult,$prei,"ShowCategory");
43 if($CategoryShow=="yes") { $_SESSION['ShowActHidden'] = "yes"; }
44 $CategoryType=sql_result($preresult,$prei,"CategoryType");
45 $SubShowForums=sql_result($preresult,$prei,"SubShowForums");
46 $CategoryDescription=sql_result($preresult,$prei,"Description");
47 $CategoryType = strtolower($CategoryType); $SubShowForums = strtolower($SubShowForums);
48 $CategoryPostCountView=sql_result($preresult,0,"PostCountView");
49 $CategoryKarmaCountView=sql_result($preresult,0,"KarmaCountView");
50 if($MyPostCountChk==null) { $MyPostCountChk = 0; }
51 if($MyKarmaCount==null) { $MyKarmaCount = 0; }
52 if($GroupInfo['HasAdminCP']!="yes"||
$GroupInfo['HasModCP']!="yes") {
53 if($CategoryPostCountView!=0&&$MyPostCountChk<$CategoryPostCountView) {
54 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); }
55 if($CategoryKarmaCountView!=0&&$MyKarmaCount<$CategoryKarmaCountView) {
56 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); } }
57 if(isset($CatPermissionInfo['CanViewCategory'][$CategoryID])&&
58 $CatPermissionInfo['CanViewCategory'][$CategoryID]=="yes") {
59 $query = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"ShowForum\"='yes' AND \"CategoryID\"=%i AND \"InSubForum\"=0".$ForumIgnoreList2." ORDER BY \"OrderID\" ASC, \"id\" ASC", array($CategoryID));
60 $result=sql_query($query,$SQLStat);
61 $num=sql_num_rows($result);
65 <div
class="Table1Border">
66 <?php
if($ThemeSet['TableStyle']=="div") { ?
>
67 <div
class="TableRow1">
68 <span style
="text-align: left;">
69 <?php
echo $ThemeSet['TitleIcon']; ?
><a href
="<?php echo url_maker($exfile[$CategoryType],$Settings['file_ext'],"act
=view
&id
=".$CategoryID,$Settings['qstr'],$Settings['qsep'],$prexqstr[$CategoryType],$exqstr[$CategoryType]); ?>"><?php
echo $CategoryName; ?
></a
></span
></div
>
71 <table
class="Table1" id
="Cat<?php echo $CategoryID; ?>">
72 <?php
if($ThemeSet['TableStyle']=="table") { ?
>
73 <tr
class="TableRow1" id
="CatStart<?php echo $CategoryID; ?>">
74 <td
class="TableColumn1" colspan
="5"><span style
="text-align: left;">
75 <?php
echo $ThemeSet['TitleIcon']; ?
><a href
="<?php echo url_maker($exfile[$CategoryType],$Settings['file_ext'],"act
=view
&id
=".$CategoryID,$Settings['qstr'],$Settings['qsep'],$prexqstr[$CategoryType],$exqstr[$CategoryType]); ?>"><?php
echo $CategoryName; ?
></a
></span
>
78 <tr id
="ForumStatRow<?php echo $CategoryID; ?>" class="TableRow2">
79 <th
class="TableColumn2" style
="width: 4%;"> 
;</th
>
80 <th
class="TableColumn2" style
="width: 58%;">Forum
</th
>
81 <th
class="TableColumn2" style
="width: 7%;">Topics
</th
>
82 <th
class="TableColumn2" style
="width: 7%;">Posts
</th
>
83 <th
class="TableColumn2" style
="width: 24%;">Last Topic
</th
>
87 $ForumID=sql_result($result,$i,"id");
88 $ForumName=sql_result($result,$i,"Name");
89 $ForumShow=sql_result($result,$i,"ShowForum");
90 if($ForumShow=="yes") { $_SESSION['ShowActHidden'] = "yes"; }
91 $ForumType=sql_result($result,$i,"ForumType");
92 $ForumShowTopics=sql_result($result,$i,"CanHaveTopics");
93 $ForumShowTopics = strtolower($ForumShowTopics);
94 $NumTopics=sql_result($result,$i,"NumTopics");
95 $NumPosts=sql_result($result,$i,"NumPosts");
96 $NumRedirects=sql_result($result,$i,"Redirects");
97 $ForumDescription=sql_result($result,$i,"Description");
98 $ForumType = strtolower($ForumType); $sflist = null;
99 $gltf = array(null); $gltf[0] = $ForumID;
100 if ($ForumType=="subforum") {
101 $apcquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"ShowForum\"='yes' AND \"InSubForum\"=%i".$ForumIgnoreList2." ORDER BY \"OrderID\" ASC, \"id\" ASC", array($ForumID));
102 $apcresult=sql_query($apcquery,$SQLStat);
103 $apcnum=sql_num_rows($apcresult);
104 $apci=0; $apcl=1; if($apcnum>=1) {
105 while ($apci < $apcnum) {
106 $NumsTopics=sql_result($apcresult,$apci,"NumTopics");
107 $NumTopics = $NumsTopics +
$NumTopics;
108 $NumsPosts=sql_result($apcresult,$apci,"NumPosts");
109 $NumPosts = $NumsPosts +
$NumPosts;
110 $SubsForumID=sql_result($apcresult,$apci,"id");
111 $SubsForumName=sql_result($apcresult,$apci,"Name");
112 $SubsForumType=sql_result($apcresult,$apci,"ForumType");
113 $SubsForumShowTopics=sql_result($result,$i,"CanHaveTopics");
114 if(isset($PermissionInfo['CanViewForum'][$SubsForumID])&&
115 $PermissionInfo['CanViewForum'][$SubsForumID]=="yes") {
116 $ExStr = ""; if ($SubsForumType!="redirect"&&
117 $SubsForumShowTopics!="no") { $ExStr = "&page=1"; }
118 $sfurl = "<a href=\"";
119 $sfurl = url_maker($exfile[$SubsForumType],$Settings['file_ext'],"act=view&id=".$SubsForumID.$ExStr,$Settings['qstr'],$Settings['qsep'],$prexqstr[$SubsForumType],$exqstr[$SubsForumType]);
120 $sfurl = "<a href=\"".$sfurl."\">".$SubsForumName."</a>";
122 $sflist = "Subforums:";
123 $sflist = $sflist." ".$sfurl; }
125 $sflist = $sflist.", ".$sfurl; }
126 $gltf[$apcl] = $SubsForumID; ++
$apcl; }
128 sql_free_result($apcresult); } }
129 if(isset($PermissionInfo['CanViewForum'][$ForumID])&&
130 $PermissionInfo['CanViewForum'][$ForumID]=="yes") {
131 $LastTopic = " <br /> <br /> ";
132 if(!isset($LastTopic)) { $LastTopic = null; }
133 $gltnum = count($gltf); $glti = 0;
134 $OldUpdateTime = 0; $UseThisFonum = null;
135 if ($ForumType=="subforum") {
136 while ($glti < $gltnum) {
137 $ExtraIgnores = null;
138 if($PermissionInfo['CanModForum'][$gltf[$glti]]=="no") {
139 $ExtraIgnores = " AND \"Closed\"<>3"; }
140 $gltfoquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."topics\" WHERE \"ForumID\"=%i".$ExtraIgnores." ORDER BY \"LastUpdate\" DESC LIMIT 1", array($gltf[$glti]));
141 $gltforesult=sql_query($gltfoquery,$SQLStat);
142 $gltfonum=sql_num_rows($gltforesult);
144 $NewUpdateTime=sql_result($gltforesult,0,"LastUpdate");
145 if($NewUpdateTime>$OldUpdateTime) {
146 $UseThisFonum = $gltf[$glti];
147 $OldUpdateTime = $NewUpdateTime; } }
148 sql_free_result($gltforesult);
150 if($UseThisFonum==0) {
151 $UseThisFonum = $gltf[0]; } }
152 if ($ForumType!="subforum"&&$ForumType!="redirect") { $UseThisFonum = $gltf[0]; }
153 if ($ForumType!="redirect") {
154 $ExtraIgnores = null;
155 if($PermissionInfo['CanModForum'][$UseThisFonum]=="no") {
156 $ExtraIgnores = " AND \"Closed\"<>3"; }
157 $gltquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."topics\" WHERE (\"ForumID\"=%i".$ExtraIgnores.$ForumIgnoreList4.") OR (\"OldForumID\"=%i".$ExtraIgnores.$ForumIgnoreList4.") ORDER BY \"LastUpdate\" DESC LIMIT 1", array($UseThisFonum,$UseThisFonum));
158 $gltresult=sql_query($gltquery,$SQLStat);
159 $gltnum=sql_num_rows($gltresult);
161 $TopicID=sql_result($gltresult,0,"id");
162 $TopicName=sql_result($gltresult,0,"TopicName");
163 $NumReplys=sql_result($gltresult,0,"NumReply");
164 $NumPages = null; $NumRPosts = $NumReplys +
1;
165 if(!isset($Settings['max_posts'])) { $Settings['max_posts'] = 10; }
166 if($NumRPosts>$Settings['max_posts']) {
167 $NumPages = ceil($NumRPosts/$Settings['max_posts']); }
168 if($NumRPosts<=$Settings['max_posts']) { $NumPages = 1; }
169 $TopicName1 = pre_substr($TopicName,0,20);
170 $oldtopicname=$TopicName;
171 if (pre_strlen($TopicName)>20) {
172 $TopicName1 = $TopicName1."..."; $TopicName=$TopicName1; }
173 $glrquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."posts\" WHERE \"TopicID\"=%i ORDER BY \"TimeStamp\" DESC LIMIT 1", array($TopicID));
174 $glrresult=sql_query($glrquery,$SQLStat);
175 $glrnum=sql_num_rows($glrresult);
177 $ReplyID=sql_result($glrresult,0,"id");
178 $UsersID=sql_result($glrresult,0,"UserID");
179 $GuestsName=sql_result($glrresult,0,"GuestName");
180 $TimeStamp=sql_result($glrresult,0,"TimeStamp");
181 $TimeStamp=GMTimeChange("F j Y, ".$Settings['idb_time_format'],$TimeStamp,$_SESSION['UserTimeZone'],0,$_SESSION['UserDST']);
182 sql_free_result($glrresult); }
183 $PreUsersName = GetUserName($UsersID,$Settings['sqltable'],$SQLStat);
184 if($PreUsersName['Name']===null) { $UsersID = -1;
185 $PreUsersName = GetUserName($UsersID,$Settings['sqltable'],$SQLStat); }
186 $UsersName = $PreUsersName['Name'];
187 $UsersHidden = $PreUsersName['Hidden'];
188 $UsersName1 = pre_substr($UsersName,0,20);
189 if($UsersName=="Guest") { $UsersName=$GuestsName;
190 if($UsersName==null) { $UsersName="Guest"; } }
191 $oldusername=$UsersName;
192 if (pre_strlen($UsersName)>20) {
193 $UsersName1 = $UsersName1."..."; $UsersName=$UsersName1; }
195 if($UsersID>0&&$UsersHidden=="no") {
196 $lul = url_maker($exfile['member'],$Settings['file_ext'],"act=view&id=".$UsersID,$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member']);
197 $LastTopic = $TimeStamp."<br />\nTopic: <a href=\"".url_maker($exfile['topic'],$Settings['file_ext'],"act=view&id=".$TopicID."&page=".$NumPages,$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic']).$qstrhtml."#reply".$NumRPosts."\" title=\"".$oldtopicname."\">".$TopicName."</a><br />\nUser: <a href=\"".$lul."\" title=\"".$oldusername."\">".$UsersName."</a>"; }
198 if($UsersID<=0||
$UsersHidden=="yes") {
199 if($UsersID==-1) { $UserPre = "Guest:"; }
200 if(($UsersID<-1&&$UsersHidden=="yes")||
$UsersID==0||
($UsersID>0&&$UsersHidden=="yes")) {
201 $UserPre = "Hidden:"; }
202 $LastTopic = $TimeStamp."<br />\nTopic: <a href=\"".url_maker($exfile['topic'],$Settings['file_ext'],"act=view&id=".$TopicID."&page=".$NumPages,$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic']).$qstrhtml."#reply".$NumRPosts."\" title=\"".$oldtopicname."\">".$TopicName."</a><br />\n".$UserPre." <span title=\"".$oldusername."\">".$UsersName."</span>"; } }
203 if($LastTopic==null) { $LastTopic=" <br /> "; }
204 sql_free_result($gltresult); }
205 if ($ForumType=="redirect") { $LastTopic=" <br />Redirects: ".$NumRedirects."<br /> "; }
206 $PreForum = $ThemeSet['ForumIcon'];
207 if ($ForumType=="forum") { $PreForum=$ThemeSet['ForumIcon']; }
208 if ($ForumType=="subforum") { $PreForum=$ThemeSet['SubForumIcon']; }
209 if ($ForumType=="redirect") { $PreForum=$ThemeSet['RedirectIcon']; }
210 $ExStr = ""; if ($ForumType!="redirect"&&
211 $ForumShowTopics!="no") { $ExStr = "&page=1"; }
212 if($ThemeSet['ForumStyle']==1) {
213 $ForumClass[1] = " class=\"TableColumn3\" ";
214 $ForumClass[2] = " class=\"TableColumn3\" ";
215 $ForumClass[3] = " class=\"TableColumn3\" ";
216 $ForumClass[4] = " class=\"TableColumn3\" ";
217 $ForumClass[5] = " class=\"TableColumn3\" "; }
218 if($ThemeSet['ForumStyle']==2) {
219 $ForumClass[1] = " class=\"TableColumn3\" ";
220 $ForumClass[2] = " class=\"TableColumn3\" ";
221 $ForumClass[3] = " class=\"TableColumn3Alt\" ";
222 $ForumClass[4] = " class=\"TableColumn3Alt\" ";
223 $ForumClass[5] = " class=\"TableColumn3Alt\" "; }
225 <tr
class="TableRow3" id
="Forum<?php echo $ForumID; ?>">
226 <td
<?php
echo $ForumClass[1]; ?
>><div
class="forumicon">
227 <?php
echo $PreForum; ?
></div
></td
>
228 <td
<?php
echo $ForumClass[2]; ?
>><div
class="forumname"><a href
="<?php echo url_maker($exfile[$ForumType],$Settings['file_ext'],"act
=view
&id
=".$ForumID.$ExStr,$Settings['qstr'],$Settings['qsep'],$prexqstr[$ForumType],$exqstr[$ForumType]); ?>"<?php
if($ForumType=="redirect") { echo " onclick=\"window.open(this.href);return false;\""; } ?
>><?php
echo $ForumName; ?
></a
></div
>
229 <div
class="forumdescription">
230 <?php
echo $ForumDescription; ?
><br
/>
231 <?php
echo $sflist; ?
></div
></td
>
232 <td
<?php
echo $ForumClass[3]; ?
>style
="text-align: center;"><?php
echo $NumTopics; ?
></td
>
233 <td
<?php
echo $ForumClass[4]; ?
>style
="text-align: center;"><?php
echo $NumPosts; ?
></td
>
234 <td
<?php
echo $ForumClass[5]; ?
>><?php
echo $LastTopic; ?
></td
>
236 <?php
} ++
$i; } sql_free_result($result);
239 <tr id
="CatEnd<?php echo $CategoryID; ?>" class="TableRow4">
240 <td
class="TableColumn4" colspan
="5"> 
;</td
>
243 <?php
if($prei < $prenum - 1) { ?
>
244 <div
class="DivForums"> 
;</div
>
245 <?php
} if($prei == $prenum - 1) { ?
>
246 <div
class="DivStsts"> 
;</div
>
247 <?php
} } } ++
$prei; }
248 sql_free_result($preresult); ?
>