Small update
[iDB.git] / inc / subforums.php
blobdc6227e96d2c91d920389a22b533103faf9c48e5
1 <?php
2 /*
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-2019 iDB Support - https://idb.osdn.jp/support/category.php?act=view&id=1
12 Copyright 2004-2019 Game Maker 2k - https://idb.osdn.jp/support/category.php?act=view&id=2
14 $FileInfo: subforums.php - Last Update: 08/02/2019 SVN 905 - Author: cooldude2k $
16 $File3Name = basename($_SERVER['SCRIPT_NAME']);
17 if ($File3Name=="subforums.php"||$File3Name=="/subforums.php") {
18 require('index.php');
19 exit(); }
20 if(!is_numeric($_GET['id'])) { $_GET['id'] = null; }
21 if(!isset($ThemeSet['ForumStyle'])) { $ThemeSet['ForumStyle'] = 1; }
22 if(!is_numeric($ThemeSet['ForumStyle'])) { $ThemeSet['ForumStyle'] = 1; }
23 if($ThemeSet['ForumStyle']>2||$ThemeSet['ForumStyle']<1) {
24 $ThemeSet['ForumStyle'] = 1; }
25 $checkquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"id\"=%i".$ForumIgnoreList2." LIMIT 1", array($_GET['id']));
26 $checkresult=sql_query($checkquery,$SQLStat);
27 $checknum=sql_num_rows($checkresult);
28 if($checknum==0) { redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); sql_free_result($checkresult);
29 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
30 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
31 if($checknum>=1) {
32 $ForumID=sql_result($checkresult,0,"id");
33 $SForumID=$ForumID;
34 $ForumName=sql_result($checkresult,0,"Name");
35 $ForumType=sql_result($checkresult,0,"ForumType");
36 $ForumShow=sql_result($checkresult,0,"ShowForum");
37 if($ForumShow=="no") { $_SESSION['ShowActHidden'] = "yes"; }
38 $InSubForum=sql_result($checkresult,0,"InSubForum");
39 $SFInSubForum=$InSubForum;
40 $CategoryID=sql_result($checkresult,0,"CategoryID");
41 $RedirectURL=sql_result($checkresult,0,"RedirectURL");
42 $RedirectTimes=sql_result($checkresult,0,"Redirects");
43 $CanHaveTopics=sql_result($checkresult,0,"CanHaveTopics");
44 $NumberViews=sql_result($checkresult,0,"NumViews");
45 $SForumName = $ForumName;
46 $ForumType = strtolower($ForumType); $CanHaveTopics = strtolower($CanHaveTopics);
47 if($CanHaveTopics!="yes"&&$ForumType!="redirect") {
48 if($NumberViews==0||$NumberViews==null) { $NewNumberViews = 1; }
49 if($NumberViews!=0&&$NumberViews!=null) { $NewNumberViews = $NumberViews + 1; }
50 $viewup = sql_pre_query("UPDATE \"".$Settings['sqltable']."forums\" SET \"NumViews\"='%s' WHERE \"id\"=%i", array($NewNumberViews,$_GET['id']));
51 sql_query($viewup,$SQLStat); }
52 if($ForumType=="redirect") {
53 if($RedirectTimes==0||$RedirectTimes==null) { $NewRedirTime = 1; }
54 if($RedirectTimes!=0&&$RedirectTimes!=null) { $NewRedirTime = $RedirectTimes + 1; }
55 $redirup = sql_pre_query("UPDATE \"".$Settings['sqltable']."forums\" SET \"Redirects\"='%s' WHERE \"id\"=%i", array($NewRedirTime,$_GET['id']));
56 sql_query($redirup,$SQLStat);
57 if($RedirectURL!="http://"&&$RedirectURL!="") {
58 redirect("location",$RedirectURL,0,null,false); ob_clean();
59 header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
60 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
61 if($RedirectURL=="http://"||$RedirectURL=="") {
62 redirect("location",url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
63 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
64 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); } }
65 if($ForumType=="forum") {
66 redirect("location",$rbasedir.url_maker($exfile['forum'],$Settings['file_ext'],"act=".$_GET['act']."&id=".$_GET['id'],$Settings['qstr'],$Settings['qsep'],$prexqstr['forum'],$exqstr['forum'],FALSE));
67 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
68 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
69 sql_free_result($checkresult);
70 $prequery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."categories\" WHERE \"ShowCategory\"='yes' AND \"id\"=%i".$CatIgnoreList2." ORDER BY \"OrderID\" ASC, \"id\" ASC", array($CategoryID));
71 $preresult=sql_query($prequery,$SQLStat);
72 $prenum=sql_num_rows($preresult);
73 $prei=0;
74 $CategoryID=sql_result($preresult,0,"id");
75 $CategoryName=sql_result($preresult,0,"Name");
76 $CategoryShow=sql_result($preresult,0,"ShowCategory");
77 $CategoryType=sql_result($preresult,0,"CategoryType");
78 $InSubCategory=sql_result($preresult,0,"InSubCategory");
79 if($CategoryShow=="no") { $_SESSION['ShowActHidden'] = "yes"; }
80 $CategoryDescription=sql_result($preresult,0,"Description");
81 if($InSubForum!="0") {
82 $isfquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"id\"=%i".$ForumIgnoreList2." LIMIT 1", array($InSubForum));
83 $isfresult=sql_query($isfquery,$SQLStat);
84 $isfnum=sql_num_rows($isfresult);
85 if($isfnum>=1) {
86 $isfForumID=sql_result($isfresult,0,"id");
87 $isfForumCatID=sql_result($isfresult,0,"CategoryID");
88 $isfForumName=sql_result($isfresult,0,"Name");
89 $isfForumType=sql_result($isfresult,0,"ForumType");
90 $isfForumType = strtolower($isfForumType);
91 $isfRedirectURL=sql_result($isfresult,0,"RedirectURL"); }
92 if($isfnum<1) { $InSubForum = "0"; }
93 sql_free_result($isfresult); }
94 if(isset($_SESSION['OldViewingPage'])) { $_SESSION['AncientViewingPage'] = $_SESSION['OldViewingPage']; } else { $_SESSION['AncientViewingPage'] = url_maker(null,"no+ext","act=view","&","=",$prexqstr['index'],$exqstr['index']); }
95 if(isset($_SESSION['OldViewingFile'])) { $_SESSION['AncientViewingFile'] = $_SESSION['OldViewingFile']; } else {
96 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
97 $_SESSION['AncientViewingFile'] = $exfile['index'].$Settings['file_ext']; }
98 if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
99 $_SESSION['AncientViewingFile'] = $exfile['index']; } }
100 if(isset($_SESSION['OldPreViewingTitle'])) { $_SESSION['AncientPreViewingTitle'] = $_SESSION['OldPreViewingTitle']; } else { $_SESSION['AncientPreViewingTitle'] = "Viewing"; }
101 if(isset($_SESSION['OldViewingTitle'])) { $_SESSION['AncientViewingTitle'] = $_SESSION['OldViewingTitle']; } else { $_SESSION['AncientViewingTitle'] = "Board index"; }
102 if(isset($_SESSION['OldExtraData'])) { $_SESSION['AncientExtraData'] = $_SESSION['OldExtraData']; } else { $_SESSION['AncientExtraData'] = "currentact:view; currentcategoryid:0; currentforumid:0; currenttopicid:0; currentmessageid:0; currenteventid:0; currentmemberid:0;"; }
103 if(isset($_SESSION['ViewingPage'])) { $_SESSION['OldViewingPage'] = $_SESSION['ViewingPage']; } else { $_SESSION['OldViewingPage'] = url_maker(null,"no+ext","act=view","&","=",$prexqstr['index'],$exqstr['index']); }
104 if(isset($_SESSION['ViewingFile'])) { $_SESSION['OldViewingFile'] = $_SESSION['ViewingFile']; } else {
105 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
106 $_SESSION['OldViewingFile'] = $exfile['index'].$Settings['file_ext']; }
107 if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
108 $_SESSION['OldViewingFile'] = $exfile['index']; } }
109 if(isset($_SESSION['PreViewingTitle'])) { $_SESSION['OldPreViewingTitle'] = $_SESSION['PreViewingTitle']; } else { $_SESSION['OldPreViewingTitle'] = "Viewing"; }
110 if(isset($_SESSION['ViewingTitle'])) { $_SESSION['OldViewingTitle'] = $_SESSION['ViewingTitle']; } else { $_SESSION['OldViewingTitle'] = "Board index"; }
111 if(isset($_SESSION['ExtraData'])) { $_SESSION['OldExtraData'] = $_SESSION['ExtraData']; } else { $_SESSION['OldExtraData'] = "currentact:view; currentcategoryid:0; currentforumid:0; currenttopicid:0; currentmessageid:0; currenteventid:0; currentmemberid:0;"; }
112 $_SESSION['ViewingPage'] = url_maker(null,"no+ext","act=view&id=".$ForumID."&page=".$_GET['page'],"&","=",$prexqstr[$ForumType],$exqstr[$ForumType]);
113 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
114 $_SESSION['ViewingFile'] = $exfile[$ForumType].$Settings['file_ext']; }
115 if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
116 $_SESSION['ViewingFile'] = $exfile[$ForumType]; }
117 $_SESSION['PreViewingTitle'] = "Viewing SubForum:";
118 $_SESSION['ViewingTitle'] = $ForumName;
119 $_SESSION['ExtraData'] = "currentact:".$_GET['act']."; currentcategoryid:".$InSubCategory.",".$CategoryID."; currentforumid:".$InSubForum.",".$ForumID."; currenttopicid:0; currentmessageid:0; currenteventid:0; currentmemberid:0;";
121 <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><?php echo $ThemeSet['NavLinkDivider']; ?><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><?php if($InSubForum!="0") { echo $ThemeSet['NavLinkDivider']; ?><a href="<?php echo url_maker($exfile[$isfForumType],$Settings['file_ext'],"act=view&id=".$isfForumID."&page=1",$Settings['qstr'],$Settings['qsep'],$prexqstr[$isfForumType],$exqstr[$isfForumType]); ?>"><?php echo $isfForumName; ?></a><?php } echo $ThemeSet['NavLinkDivider']; ?><a href="<?php echo url_maker($exfile[$ForumType],$Settings['file_ext'],"act=view&id=".$ForumID."&page=1",$Settings['qstr'],$Settings['qsep'],$prexqstr[$ForumType],$exqstr[$ForumType]); ?>"><?php echo $ForumName; ?></a></div>
122 <div class="DivNavLinks">&nbsp;</div>
123 <?php
124 if(!isset($CatPermissionInfo['CanViewCategory'][$CategoryID])) {
125 $CatPermissionInfo['CanViewCategory'][$CategoryID] = "no"; }
126 if($CatPermissionInfo['CanViewCategory'][$CategoryID]=="no"||
127 $CatPermissionInfo['CanViewCategory'][$CategoryID]!="yes") {
128 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
129 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
130 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
131 if(!isset($PermissionInfo['CanViewForum'][$_GET['id']])) {
132 $PermissionInfo['CanViewForum'][$_GET['id']] = "no"; }
133 if($PermissionInfo['CanViewForum'][$_GET['id']]=="no"||
134 $PermissionInfo['CanViewForum'][$_GET['id']]!="yes") {
135 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
136 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
137 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
138 if($CatPermissionInfo['CanViewCategory'][$CategoryID]=="yes"&&
139 $PermissionInfo['CanViewForum'][$_GET['id']]=="yes") {
140 $query = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"ShowForum\"='yes' AND \"CategoryID\"=%i AND \"InSubForum\"=%i".$ForumIgnoreList2." ORDER BY \"OrderID\" ASC, \"id\" ASC", array($CategoryID,$_GET['id']));
141 $result=sql_query($query,$SQLStat);
142 $num=sql_num_rows($result);
143 $i=0;
144 if($num>=1) {
146 <div class="Table1Border">
147 <?php if($ThemeSet['TableStyle']=="div") { ?>
148 <div class="TableRow1">
149 <span style="text-align: left;">
150 <?php echo $ThemeSet['TitleIcon']; ?><a href="<?php echo url_maker($exfile['category'],$Settings['file_ext'],"act=view&id=".$CategoryID,$Settings['qstr'],$Settings['qsep'],$prexqstr['category'],$exqstr['category']); ?>"><?php echo $CategoryName; ?></a></span></div>
151 <?php } ?>
152 <table class="Table1" id="Cat<?php echo $CategoryID; ?>">
153 <?php if($ThemeSet['TableStyle']=="table") { ?>
154 <tr class="TableRow1" id="CatStart<?php echo $CategoryID; ?>">
155 <td class="TableColumn1" colspan="5"><span style="text-align: left;">
156 <?php echo $ThemeSet['TitleIcon']; ?><a href="<?php echo url_maker($exfile['category'],$Settings['file_ext'],"act=view&id=".$CategoryID,$Settings['qstr'],$Settings['qsep'],$prexqstr['category'],$exqstr['category']); ?>"><?php echo $CategoryName; ?></a></span>
157 </td>
158 </tr><?php } ?>
159 <tr id="ForumStatRow<?php echo $CategoryID; ?>" class="TableRow2">
160 <th class="TableColumn2" style="width: 4%;">&nbsp;</th>
161 <th class="TableColumn2" style="width: 58%;">Forum</th>
162 <th class="TableColumn2" style="width: 7%;">Topics</th>
163 <th class="TableColumn2" style="width: 7%;">Posts</th>
164 <th class="TableColumn2" style="width: 24%;">Last Topic</th>
165 </tr>
166 <?php
167 while ($i < $num) {
168 $ForumID=sql_result($result,$i,"id");
169 $ForumName=sql_result($result,$i,"Name");
170 $ForumShow=sql_result($result,$i,"ShowForum");
171 $ForumType=sql_result($result,$i,"ForumType");
172 $ForumShowTopics=sql_result($result,$i,"CanHaveTopics");
173 $ForumShowTopics = strtolower($ForumShowTopics);
174 $NumTopics=sql_result($result,$i,"NumTopics");
175 $NumPosts=sql_result($result,$i,"NumPosts");
176 $NumRedirects=sql_result($result,$i,"Redirects");
177 $ForumDescription=sql_result($result,$i,"Description");
178 $ForumType = strtolower($ForumType); $sflist = null;
179 $gltf = array(null); $gltf[0] = $ForumID;
180 if ($ForumType=="subforum") {
181 $apcquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"ShowForum\"='yes' AND \"InSubForum\"=%i".$ForumIgnoreList2." ORDER BY \"OrderID\" ASC, \"id\" ASC", array($ForumID));
182 $apcresult=sql_query($apcquery,$SQLStat);
183 $apcnum=sql_num_rows($apcresult);
184 $apci=0; $apcl=1; if($apcnum>=1) {
185 while ($apci < $apcnum) {
186 $NumsTopics=sql_result($apcresult,$apci,"NumTopics");
187 $NumTopics = $NumsTopics + $NumTopics;
188 $NumsPosts=sql_result($apcresult,$apci,"NumPosts");
189 $NumPosts = $NumsPosts + $NumPosts;
190 $SubsForumID=sql_result($apcresult,$apci,"id");
191 $SubsForumName=sql_result($apcresult,$apci,"Name");
192 $SubsForumType=sql_result($apcresult,$apci,"ForumType");
193 $SubsForumShowTopics=sql_result($apcresult,$apci,"CanHaveTopics");
194 $SubsForumDescription=sql_result($apcresult,$apci,"Description");
195 if(isset($PermissionInfo['CanViewForum'][$SubsForumID])&&
196 $PermissionInfo['CanViewForum'][$SubsForumID]=="yes") {
197 $ExStr = ""; if ($SubsForumType!="redirect"&&
198 $SubsForumShowTopics!="no") { $ExStr = "&page=1"; }
199 //$sfurl = "<a href=\"";
200 $sfurl = url_maker($exfile[$SubsForumType],$Settings['file_ext'],"act=view&id=".$SubsForumID.$ExStr,$Settings['qstr'],$Settings['qsep'],$prexqstr[$SubsForumType],$exqstr[$SubsForumType]);
201 $sfurl = "<a title=\"".$SubsForumDescription."\" href=\"".$sfurl."\">".$SubsForumName."</a>";
202 if($apcl==1) {
203 $sflist = "Subforums:";
204 $sflist = $sflist." ".$sfurl; }
205 if($apcl>1) {
206 $sflist = $sflist.", ".$sfurl; }
207 $gltf[$apcl] = $SubsForumID; ++$apcl; }
208 ++$apci; }
209 sql_free_result($apcresult); } }
210 if(isset($PermissionInfo['CanViewForum'][$ForumID])&&
211 $PermissionInfo['CanViewForum'][$ForumID]=="yes") {
212 $LastTopic = "&nbsp;<br />&nbsp;<br />&nbsp;";
213 if(!isset($LastTopic)) { $LastTopic = null; }
214 $gltnum = count($gltf); $glti = 0;
215 $OldUpdateTime = 0; $UseThisFonum = null;
216 if ($ForumType=="subforum") {
217 while ($glti < $gltnum) {
218 $ExtraIgnores = null;
219 if($PermissionInfo['CanModForum'][$gltf[$glti]]=="no") {
220 $ExtraIgnores = " AND \"Closed\"<>3"; }
221 $gltfoquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."topics\" WHERE \"CategoryID\"=%i".$ExtraIgnores.$ForumIgnoreList4." AND \"ForumID\"=%i ORDER BY \"LastUpdate\" DESC LIMIT 1", array($CategoryID,$gltf[$glti]));
222 $gltforesult=sql_query($gltfoquery,$SQLStat);
223 $gltfonum=sql_num_rows($gltforesult);
224 if($gltfonum>0) {
225 $NewUpdateTime=sql_result($gltforesult,0,"LastUpdate");
226 if($NewUpdateTime>$OldUpdateTime) {
227 $UseThisFonum = $gltf[$glti];
228 $OldUpdateTime = $NewUpdateTime; }
229 sql_free_result($gltforesult); }
230 ++$glti; }
231 if($UseThisFonum==0) {
232 $UseThisFonum = $gltf[0]; } }
233 if ($ForumType!="subforum"&&$ForumType!="redirect") { $UseThisFonum = $gltf[0]; }
234 if ($ForumType!="redirect") {
235 $ExtraIgnores = null;
236 if($PermissionInfo['CanModForum'][$UseThisFonum]=="no") {
237 $ExtraIgnores = " AND \"Closed\"<>3"; }
238 $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));
239 $gltresult=sql_query($gltquery,$SQLStat);
240 $gltnum=sql_num_rows($gltresult);
241 if($gltnum>0){
242 $TopicID=sql_result($gltresult,0,"id");
243 $TopicName=sql_result($gltresult,0,"TopicName");
244 $NumReplys=sql_result($gltresult,0,"NumReply");
245 $TopicName1 = pre_substr($TopicName,0,20);
246 $oldtopicname=$TopicName; $NumRPosts = $NumReplys + 1;
247 if(!isset($Settings['max_posts'])) { $Settings['max_posts'] = 10; }
248 if($NumRPosts>$Settings['max_posts']) {
249 $NumPages = ceil($NumRPosts/$Settings['max_posts']); }
250 if($NumRPosts<=$Settings['max_posts']) { $NumPages = 1; }
251 if (pre_strlen($TopicName)>20) {
252 $TopicName1 = $TopicName1."..."; $TopicName=$TopicName1; }
253 $glrquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."posts\" WHERE \"TopicID\"=%i ORDER BY \"TimeStamp\" DESC LIMIT 1", array($TopicID));
254 $glrresult=sql_query($glrquery,$SQLStat);
255 $glrnum=sql_num_rows($glrresult);
256 if($glrnum>0){
257 $ReplyID=sql_result($glrresult,0,"id");
258 $UsersID=sql_result($glrresult,0,"UserID");
259 $GuestsName=sql_result($glrresult,0,"GuestName");
260 $TimeStamp=sql_result($glrresult,0,"TimeStamp");
261 $tmpusrcurtime = new DateTime();
262 $tmpusrcurtime->setTimestamp($TimeStamp);
263 $tmpusrcurtime->setTimezone($usertz);
264 $TimeStamp=$tmpusrcurtime->format($_SESSION['iDBDateFormat'].", ".$_SESSION['iDBTimeFormat']);
265 sql_free_result($glrresult); }
266 $PreUsersName = GetUserName($UsersID,$Settings['sqltable'],$SQLStat);
267 if($PreUsersName['Name']===null) { $UsersID = -1;
268 $PreUsersName = GetUserName($UsersID,$Settings['sqltable'],$SQLStat); }
269 $UsersName = $PreUsersName['Name'];
270 $UsersHidden = $PreUsersName['Hidden'];
271 $UsersName1 = pre_substr($UsersName,0,20);
272 if($UsersName=="Guest") { $UsersName=$GuestsName;
273 if($UsersName==null) { $UsersName="Guest"; } }
274 $oldusername=$UsersName;
275 if (pre_strlen($UsersName)>20) {
276 $UsersName1 = $UsersName1."..."; $UsersName=$UsersName1; }
277 $lul = null;
278 if($UsersID>0&&$UsersHidden=="no") {
279 $lul = url_maker($exfile['member'],$Settings['file_ext'],"act=view&id=".$UsersID,$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member']);
280 $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."&#35;reply".$NumRPosts."\" title=\"".$oldtopicname."\">".$TopicName."</a><br />\nUser: <a href=\"".$lul."\" title=\"".$oldusername."\">".$UsersName."</a>"; }
281 if($UsersID<=0||$UsersHidden=="yes") {
282 if($UsersID==-1) { $UserPre = "Guest:"; }
283 if(($UsersID<-1&&$UsersHidden=="yes")||$UsersID==0||($UsersID>0&&$UsersHidden=="yes")) {
284 $UserPre = "Hidden:"; }
285 $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."&#35;reply".$NumRPosts."\" title=\"".$oldtopicname."\">".$TopicName."</a><br />\n".$UserPre." <span title=\"".$oldusername."\">".$UsersName."</span>"; } }
286 if($LastTopic==null) { $LastTopic = "&nbsp;<br />&nbsp;<br />&nbsp;"; }
287 sql_free_result($gltresult); }
288 if ($ForumType=="redirect") { $LastTopic="&nbsp;<br />Redirects: ".$NumRedirects."<br />&nbsp;"; }
289 $PreForum = $ThemeSet['ForumIcon'];
290 if ($ForumType=="forum") { $PreForum=$ThemeSet['ForumIcon']; }
291 if ($ForumType=="subforum") { $PreForum=$ThemeSet['SubForumIcon']; }
292 if ($ForumType=="redirect") { $PreForum=$ThemeSet['RedirectIcon']; }
293 $ExStr = ""; if ($ForumType!="redirect"&&
294 $ForumShowTopics!="no") { $ExStr = "&page=1"; }
295 if($ThemeSet['ForumStyle']==1) {
296 $ForumClass[1] = " class=\"TableColumn3\" ";
297 $ForumClass[2] = " class=\"TableColumn3\" ";
298 $ForumClass[3] = " class=\"TableColumn3\" ";
299 $ForumClass[4] = " class=\"TableColumn3\" ";
300 $ForumClass[5] = " class=\"TableColumn3\" "; }
301 if($ThemeSet['ForumStyle']==2) {
302 $ForumClass[1] = " class=\"TableColumn3\" ";
303 $ForumClass[2] = " class=\"TableColumn3\" ";
304 $ForumClass[3] = " class=\"TableColumn3Alt\" ";
305 $ForumClass[4] = " class=\"TableColumn3Alt\" ";
306 $ForumClass[5] = " class=\"TableColumn3Alt\" "; }
308 <tr class="TableRow3" id="SubForum<?php echo $ForumID; ?>">
309 <td<?php echo $ForumClass[1]; ?>><div class="forumicon">
310 <?php echo $PreForum; ?></div></td>
311 <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>
312 <div class="forumdescription">
313 <?php echo $ForumDescription; ?><br />
314 <?php echo $sflist; ?></div></td>
315 <td<?php echo $ForumClass[3]; ?>style="text-align: center;"><?php echo $NumTopics; ?></td>
316 <td<?php echo $ForumClass[4]; ?>style="text-align: center;"><?php echo $NumPosts; ?></td>
317 <td<?php echo $ForumClass[5]; ?>><?php echo $LastTopic; ?></td>
318 </tr>
319 <?php } ++$i; } sql_free_result($result);
321 <tr id="CatEnd<?php echo $CategoryID; ?>" class="TableRow4">
322 <td class="TableColumn4" colspan="5">&nbsp;</td>
323 </tr>
324 </table></div>
325 <div class="DivSubForums">&nbsp;</div>
326 <?php } } sql_free_result($preresult);
327 $ForumCheck = "skip";
328 if($CanHaveTopics!="yes") {
329 $ForumName = $SForumName; $ForumID = $SForumID; $InSubForum = $SFInSubForum;
330 $uviewlcuttime = $utccurtime->getTimestamp();
331 $uviewltime = $uviewlcuttime - ini_get("session.gc_maxlifetime");
332 if($InSubForum==0) {
333 $uviewlquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."sessions\" WHERE \"expires\" >= %i AND \"session_id\"<>'%s' AND (\"serialized_data\" LIKE '%s' OR \"serialized_data\" LIKE '%s') ORDER BY \"expires\" DESC", array($uviewltime, session_id(), "%currentforumid:0,".$ForumID.";%", "%currentforumid:".$ForumID.",%")); }
334 if($InSubForum!=0) {
335 $uviewlquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."sessions\" WHERE \"expires\" >= %i AND \"session_id\"<>'%s' AND (\"serialized_data\" LIKE '%s' OR \"serialized_data\" LIKE '%s') ORDER BY \"expires\" DESC", array($uviewltime, session_id(), "%currentforumid:".$InSubForum.",".$ForumID.";%", "%currentforumid:0,".$ForumID.";")); }
336 $uviewlresult=sql_query($uviewlquery,$SQLStat);
337 $uviewlnum=sql_num_rows($uviewlresult);
338 $uviewli=0; $uviewlmn = 0; $uviewlgn = 0; $uviewlan = 0; $uviewlmbn = 0;
339 $MembersViewList = null; $GuestsOnline = null;
340 while ($uviewli < $uviewlnum) {
341 $session_data=sql_result($uviewlresult,$uviewli,"session_data");
342 $serialized_data=sql_result($uviewlresult,$uviewli,"serialized_data");
343 $session_user_agent=sql_result($uviewlresult,$uviewli,"user_agent");
344 $session_ip_address=sql_result($uviewlresult,$uviewli,"ip_address");
345 //$UserSessInfo = unserialize_session($session_data);
346 $UserSessInfo = unserialize($serialized_data);
347 if(!isset($UserSessInfo['UserGroup'])) { $UserSessInfo['UserGroup'] = $Settings['GuestGroup']; }
348 $AmIHiddenUser = "no";
349 $user_agent_check = false;
350 if(user_agent_check($session_user_agent)) {
351 $user_agent_check = user_agent_check($session_user_agent); }
352 if($UserSessInfo['UserGroup']!=$Settings['GuestGroup']||$user_agent_check!==false) {
353 $PreAmIHiddenUser = GetUserName($UserSessInfo['UserID'],$Settings['sqltable'],$SQLStat);
354 $AmIHiddenUser = $PreAmIHiddenUser['Hidden'];
355 if(($AmIHiddenUser=="no"&&$UserSessInfo['UserID']>0)||$user_agent_check!==false) {
356 if($uviewlmbn>0) { $MembersViewList .= ", "; }
357 if($user_agent_check===false) {
358 $uatitleadd = null;
359 if($GroupInfo['CanViewUserAgent']=="yes") { $uatitleadd = " title=\"".htmlentities($session_user_agent, ENT_QUOTES, $Settings['charset'])."\""; }
360 $MembersViewList .= "<a".$uatitleadd." href=\"".url_maker($exfile['member'],$Settings['file_ext'],"act=view&id=".$UserSessInfo['UserID'],$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member'])."\">".$UserSessInfo['MemberName']."</a>";
361 if($GroupInfo['CanViewIPAddress']=="yes") {
362 $MembersViewList .= " (<a title=\"".$session_ip_address."\" onclick=\"window.open(this.href);return false;\" href=\"".sprintf($IPCheckURL,$session_ip_address)."\">".$session_ip_address."</a>)"; }
363 ++$uviewlmn; ++$uviewlmbn; }
364 if($user_agent_check!==false) {
365 $uatitleadd = null;
366 if($GroupInfo['CanViewUserAgent']=="yes") { $uatitleadd = " title=\"".htmlentities($session_user_agent, ENT_QUOTES, $Settings['charset'])."\""; }
367 $MembersViewList .= "<span".$uatitleadd.">".$user_agent_check."</span>";
368 if($GroupInfo['CanViewIPAddress']=="yes") {
369 $MembersViewList .= " (<a title=\"".$session_ip_address."\" onclick=\"window.open(this.href);return false;\" href=\"".sprintf($IPCheckURL,$session_ip_address)."\">".$session_ip_address."</a>)"; }
370 ++$uviewlmbn; } }
371 if($UserSessInfo['UserID']<=0||$AmIHiddenUser=="yes") {
372 if($user_agent_check===false) {
373 ++$uviewlan; } } }
374 if($UserSessInfo['UserGroup']==$Settings['GuestGroup']) {
375 /*$uatitleadd = null;
376 if($GroupInfo['CanViewUserAgent']=="yes") { $uatitleadd = " title=\"".htmlentities($session_user_agent, ENT_QUOTES, $Settings['charset'])."\""; }
377 $GuestsViewList .= "<a".$uatitleadd." href=\"".url_maker($exfile['member'],$Settings['file_ext'],"act=view&id=".$MemList['ID'],$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member'])."\">".$MemList['Name']."</a>";
378 if($GroupInfo['CanViewIPAddress']=="yes") {
379 $GuestsViewList .= " (<a title=\"".$session_ip_address."\" onclick=\"window.open(this.href);return false;\" href=\"".sprintf($IPCheckURL,$session_ip_address)."\">".$session_ip_address."</a>)"; } */
380 ++$uviewlgn; }
381 ++$uviewli; }
382 if(!isset($_SESSION['UserGroup'])) { $_SESSION['UserGroup'] = $Settings['GuestGroup']; }
383 $AmIHiddenUser = "no";
384 $user_agent_check = false;
385 if(user_agent_check($_SERVER['HTTP_USER_AGENT'])) {
386 $user_agent_check = user_agent_check($_SERVER['HTTP_USER_AGENT']); }
387 if($_SESSION['UserGroup']!=$Settings['GuestGroup']||$user_agent_check!==false) {
388 $PreAmIHiddenUser = GetUserName($_SESSION['UserID'],$Settings['sqltable'],$SQLStat);
389 $AmIHiddenUser = $PreAmIHiddenUser['Hidden'];
390 if(($AmIHiddenUser=="no"&&$_SESSION['UserID']>0)||$user_agent_check!==false) {
391 if($uviewlmbn>0) { $MembersViewList = ", ".$MembersViewList; }
392 if($user_agent_check===false) {
393 $uatitleadd = null;
394 if($GroupInfo['CanViewUserAgent']=="yes") { $uatitleadd = " title=\"".htmlentities($_SERVER['HTTP_USER_AGENT'], ENT_QUOTES, $Settings['charset'])."\""; }
395 if($GroupInfo['CanViewIPAddress']=="yes") {
396 $MembersViewList = " (<a title=\"".$_SERVER['REMOTE_ADDR']."\" onclick=\"window.open(this.href);return false;\" href=\"".sprintf($IPCheckURL,$_SERVER['REMOTE_ADDR'])."\">".$_SERVER['REMOTE_ADDR']."</a>)".$MembersViewList; }
397 $MembersViewList = "<a".$uatitleadd." href=\"".url_maker($exfile['member'],$Settings['file_ext'],"act=view&id=".$_SESSION['UserID'],$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member'])."\">".$_SESSION['MemberName']."</a>".$MembersViewList;
398 ++$uviewlmn; ++$uviewlmbn; }
399 if($user_agent_check!==false) {
400 $uatitleadd = null;
401 if($GroupInfo['CanViewIPAddress']=="yes") {
402 $MembersViewList = " (<a title=\"".$_SERVER['REMOTE_ADDR']."\" onclick=\"window.open(this.href);return false;\" href=\"".sprintf($IPCheckURL,$_SERVER['REMOTE_ADDR'])."\">".$_SERVER['REMOTE_ADDR']."</a>)".$MembersViewList; }
403 if($GroupInfo['CanViewUserAgent']=="yes") { $uatitleadd = " title=\"".htmlentities($_SERVER['HTTP_USER_AGENT'], ENT_QUOTES, $Settings['charset'])."\""; }
404 $MembersViewList = "<span".$uatitleadd.">".$user_agent_check."</span>".$MembersViewList;
405 ++$uviewlmbn; } }
406 if($_SESSION['UserID']<=0||$AmIHiddenUser=="yes") {
407 if($user_agent_check===false) {
408 ++$uviewlan; } } }
409 if($_SESSION['UserGroup']==$Settings['GuestGroup']) {
410 /*$uatitleadd = null;
411 if($GroupInfo['CanViewUserAgent']=="yes") { $uatitleadd = " title=\"".htmlentities($_SERVER['HTTP_USER_AGENT'], ENT_QUOTES, $Settings['charset'])."\""; }
412 if($GroupInfo['CanViewIPAddress']=="yes") {
413 $GuestsViewList = " (<a title=\"".$_SERVER['REMOTE_ADDR']."\" onclick=\"window.open(this.href);return false;\" href=\"".sprintf($IPCheckURL,$_SERVER['REMOTE_ADDR'])."\">".$_SERVER['REMOTE_ADDR']."</a>)".$GuestsViewList; }
414 $GuestsViewList = "<a".$uatitleadd." href=\"".url_maker($exfile['member'],$Settings['file_ext'],"act=view&id=".$MemList['ID'],$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member'])."\">".$MemList['Name']."</a>".$GuestsViewList; */
415 ++$uviewlgn; }
416 ++$uviewlnum;
418 <div class="StatsBorder">
419 <?php if($ThemeSet['TableStyle']=="div") { ?>
420 <div class="TableStatsRow1">
421 <span style="text-align: left;">
422 <?php echo $ThemeSet['TitleIcon']; ?><a href="<?php echo url_maker($exfile[$ForumType],$Settings['file_ext'],"act=view&id=".$ForumID."&page=1",$Settings['qstr'],$Settings['qsep'],$prexqstr[$ForumType],$exqstr[$ForumType]); ?>">Forum Statistics</a></span></div>
423 <?php } ?>
424 <table id="BoardStats" class="TableStats1">
425 <?php if($ThemeSet['TableStyle']=="table") { ?>
426 <tr class="TableStatsRow1">
427 <td class="TableStatsColumn1" colspan="2"><span style="text-align: left;">
428 <?php echo $ThemeSet['TitleIcon']; ?><a href="<?php echo url_maker($exfile[$ForumType],$Settings['file_ext'],"act=view&id=".$ForumID."&page=1",$Settings['qstr'],$Settings['qsep'],$prexqstr[$ForumType],$exqstr[$ForumType]); ?>">Forum Statistics</a></span>
429 </td>
430 </tr><?php } ?>
431 <tr id="Stats1" class="TableStatsRow2">
432 <td class="TableStatsColumn2" colspan="2" style="width: 100%; font-weight: bold;"><?php echo $uviewlnum; ?> users viewing forum</td>
433 </tr>
434 <tr class="TableStatsRow3" id="Stats2">
435 <td style="width: 4%;" class="TableStatsColumn3"><div class="statsicon">
436 <?php echo $ThemeSet['BoardStatsIcon']; ?></div></td>
437 <td style="width: 96%;" class="TableStatsColumn3"><div class="statsinfo">
438 &nbsp;<span style="font-weight: bold;"><?php echo $uviewlgn; ?></span> guests, <span style="font-weight: bold;"><?php echo $uviewlmn; ?></span> members, <span style="font-weight: bold;"><?php echo $uviewlan; ?></span> anonymous members <br />
439 <?php if($MembersViewList!=null) { ?>&nbsp;<?php echo $MembersViewList."\n<br />"; } ?>
440 </div></td>
441 </tr>
442 <tr id="Stats7" class="TableStatsRow4">
443 <td class="TableStatsColumn4" colspan="2">&nbsp;</td>
444 </tr>
445 </table></div>
446 <div class="DivStats">&nbsp;</div>
447 <?php }
448 if($CanHaveTopics!="no") {
449 require($SettDir['inc'].'topics.php'); } }