Small bug fix. :P
[iDB.git] / inc / lowsubforums.php
blobb03bd2369149de75bb8879a9bc3a1e04623acd4b
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-2011 iDB Support - http://idb.berlios.de/
12 Copyright 2004-2011 Game Maker 2k - http://gamemaker2k.org/
14 $FileInfo: lowsubforums.php - Last Update: 07/18/2011 SVN 719 - Author: cooldude2k $
16 $File3Name = basename($_SERVER['SCRIPT_NAME']);
17 if ($File3Name=="lowsubforums.php"||$File3Name=="/lowsubforums.php") {
18 require('index.php');
19 exit(); }
20 if(!is_numeric($_GET['id'])) { $_GET['id'] = null; }
21 $checkquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"id\"=%i".$ForumIgnoreList2." LIMIT 1", array($_GET['id']));
22 $checkresult=sql_query($checkquery,$SQLStat);
23 $checknum=sql_num_rows($checkresult);
24 if($checknum==0) { redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); sql_free_result($checkresult);
25 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
26 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
27 if($checknum>=1) {
28 $ForumID=sql_result($checkresult,0,"id");
29 $ForumName=sql_result($checkresult,0,"Name");
30 $ForumType=sql_result($checkresult,0,"ForumType");
31 $ForumShow=sql_result($checkresult,0,"ShowForum");
32 if($ForumShow=="yes") { $_SESSION['ShowActHidden'] = "yes"; }
33 $InSubForum=sql_result($checkresult,0,"InSubForum");
34 $CategoryID=sql_result($checkresult,0,"CategoryID");
35 $RedirectURL=sql_result($checkresult,0,"RedirectURL");
36 $RedirectTimes=sql_result($checkresult,0,"Redirects");
37 $CanHaveTopics=sql_result($checkresult,0,"CanHaveTopics");
38 $NumberViews=sql_result($checkresult,0,"NumViews");
39 $SForumName = $ForumName;
40 $ForumType = strtolower($ForumType); $CanHaveTopics = strtolower($CanHaveTopics);
41 if($CanHaveTopics!="yes"&&$ForumType!="redirect") {
42 if($NumberViews==0||$NumberViews==null) { $NewNumberViews = 1; }
43 if($NumberViews!=0&&$NumberViews!=null) { $NewNumberViews = $NumberViews + 1; }
44 $viewup = sql_pre_query("UPDATE \"".$Settings['sqltable']."forums\" SET \"NumViews\"='%s' WHERE \"id\"=%i", array($NewNumberViews,$_GET['id']));
45 sql_query($viewup,$SQLStat); }
46 if($ForumType=="redirect") {
47 if($RedirectTimes==0||$RedirectTimes==null) { $NewRedirTime = 1; }
48 if($RedirectTimes!=0&&$RedirectTimes!=null) { $NewRedirTime = $RedirectTimes + 1; }
49 $redirup = sql_pre_query("UPDATE \"".$Settings['sqltable']."forums\" SET \"Redirects\"='%s' WHERE \"id\"=%i", array($NewRedirTime,$_GET['id']));
50 sql_query($redirup,$SQLStat);
51 if($RedirectURL!="http://"&&$RedirectURL!="") {
52 redirect("location",$RedirectURL,0,null,false); ob_clean();
53 header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
54 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
55 if($RedirectURL=="http://"||$RedirectURL=="") {
56 redirect("location",url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
57 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
58 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); } }
59 if($ForumType=="forum") {
60 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));
61 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
62 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
63 sql_free_result($checkresult);
64 $prequery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."categories\" WHERE \"ShowCategory\"='yes' AND \"id\"=%i".$CatIgnoreList2." ORDER BY \"OrderID\" ASC, \"id\" ASC", array($CategoryID));
65 $preresult=sql_query($prequery,$SQLStat);
66 $prenum=sql_num_rows($preresult);
67 $prei=0;
68 $CategoryID=sql_result($preresult,0,"id");
69 $CategoryType=sql_result($preresult,0,"CategoryType");
70 $CategoryName=sql_result($preresult,0,"Name");
71 $CategoryShow=sql_result($preresult,0,"ShowCategory");
72 if($CategoryShow=="yes") { $_SESSION['ShowActHidden'] = "yes"; }
73 $CategoryDescription=sql_result($preresult,0,"Description");
74 if($InSubForum!="0") {
75 $isfquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"id\"=%i".$ForumIgnoreList2." LIMIT 1", array($InSubForum));
76 $isfresult=sql_query($isfquery,$SQLStat);
77 $isfnum=sql_num_rows($isfresult);
78 if($isfnum>=1) {
79 $isfForumID=sql_result($isfresult,0,"id");
80 $isfForumCatID=sql_result($isfresult,0,"CategoryID");
81 $isfForumName=sql_result($isfresult,0,"Name");
82 $isfForumType=sql_result($isfresult,0,"ForumType");
83 $isfForumType = strtolower($isfForumType);
84 $isfRedirectURL=sql_result($isfresult,0,"RedirectURL"); }
85 if($isfnum<1) { $InSubForum = "0"; }
86 sql_free_result($isfresult); }
87 $_SESSION['ViewingPage'] = url_maker(null,"no+ext","act=lowview&id=".$ForumID."&page=".$_GET['page'],"&","=",$prexqstr[$ForumType],$exqstr[$ForumType]);
88 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
89 $_SESSION['ViewingFile'] = $exfile[$ForumType].$Settings['file_ext']; }
90 if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
91 $_SESSION['ViewingFile'] = $exfile[$ForumType]; }
92 $_SESSION['PreViewingTitle'] = "Viewing SubForum:";
93 $_SESSION['ViewingTitle'] = $ForumName;
95 <div style="font-size: 1.0em; font-weight: bold; margin-bottom: 10px; padding-top: 3px; width: auto;">Full Version: <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>
96 <div style="font-size: 11px; font-weight: bold; padding: 10px; border: 1px solid gray;"><a href="<?php echo url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$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=lowview&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=lowview&id=".$ForumID."&page=1",$Settings['qstr'],$Settings['qsep'],$prexqstr[$ForumType],$exqstr[$ForumType]); ?>"><?php echo $ForumName; ?></a></div>
97 <div>&nbsp;</div>
98 <div style="padding: 10px; border: 1px solid gray;">
99 <ul style="list-style-type: none;">
100 <?php
101 if(!isset($CatPermissionInfo['CanViewCategory'][$CategoryID])) {
102 $CatPermissionInfo['CanViewCategory'][$CategoryID] = "no"; }
103 if($CatPermissionInfo['CanViewCategory'][$CategoryID]=="no"||
104 $CatPermissionInfo['CanViewCategory'][$CategoryID]!="yes") {
105 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
106 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
107 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
108 if(!isset($PermissionInfo['CanViewForum'][$_GET['id']])) {
109 $PermissionInfo['CanViewForum'][$_GET['id']] = "no"; }
110 if($PermissionInfo['CanViewForum'][$_GET['id']]=="no"||
111 $PermissionInfo['CanViewForum'][$_GET['id']]!="yes") {
112 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
113 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
114 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
115 if($CatPermissionInfo['CanViewCategory'][$CategoryID]=="yes"&&
116 $PermissionInfo['CanViewForum'][$_GET['id']]=="yes") {
117 $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']));
118 $result=sql_query($query,$SQLStat);
119 $num=sql_num_rows($result);
120 $i=0;
122 <li style="font-weight: bold;"><a href="<?php echo url_maker($exfile[$ForumType],$Settings['file_ext'],"act=lowview&id=".$ForumID."&page=1",$Settings['qstr'],$Settings['qsep'],$prexqstr[$ForumType],$exqstr[$ForumType]); ?>"><?php echo $ForumName; ?></a></li><li>
123 <?php
124 while ($i < $num) {
125 $ForumID=sql_result($result,$i,"id");
126 $ForumName=sql_result($result,$i,"Name");
127 $ForumShow=sql_result($result,$i,"ShowForum");
128 $ForumType=sql_result($result,$i,"ForumType");
129 $ForumShowTopics=sql_result($result,$i,"CanHaveTopics");
130 $ForumShowTopics = strtolower($ForumShowTopics);
131 $NumTopics=sql_result($result,$i,"NumTopics");
132 $NumPosts=sql_result($result,$i,"NumPosts");
133 $NumRedirects=sql_result($result,$i,"Redirects");
134 $ForumDescription=sql_result($result,$i,"Description");
135 $ForumType = strtolower($ForumType); $sflist = null;
136 $gltf = array(null); $gltf[0] = $ForumID;
137 if ($ForumType=="subforum") {
138 $apcquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"ShowForum\"='yes' AND \"InSubForum\"=%i".$ForumIgnoreList2." ORDER BY \"OrderID\" ASC, \"id\" ASC", array($ForumID));
139 $apcresult=sql_query($apcquery);
140 $apcnum=sql_num_rows($apcresult);
141 $apci=0; $apcl=1; if($apcnum>=1) {
142 while ($apci < $apcnum) {
143 $NumsTopics=sql_result($apcresult,$apci,"NumTopics");
144 $NumTopics = $NumsTopics + $NumTopics;
145 $NumsPosts=sql_result($apcresult,$apci,"NumPosts");
146 $NumPosts = $NumsPosts + $NumPosts;
147 $SubsForumID=sql_result($apcresult,$apci,"id");
148 $SubsForumName=sql_result($apcresult,$apci,"Name");
149 $SubsForumType=sql_result($apcresult,$apci,"ForumType");
150 $SubsForumShowTopics=sql_result($result,$i,"CanHaveTopics");
151 if(isset($PermissionInfo['CanViewForum'][$SubsForumID])&&
152 $PermissionInfo['CanViewForum'][$SubsForumID]=="yes") {
153 $ExStr = ""; if ($SubsForumType!="redirect"&&
154 $SubsForumShowTopics!="no") { $ExStr = "&page=1"; }
155 $shownum = null;
156 if ($SubsForumType=="redirect") { $shownum = "(".$NumRedirects." redirects)"; }
157 if ($SubsForumType!="redirect") { $shownum = "(".$NumsPosts." posts)"; }
158 $sfurl = "<a href=\"";
159 $sfurl = url_maker($exfile[$SubsForumType],$Settings['file_ext'],"act=lowview&id=".$SubsForumID.$ExStr,$Settings['qstr'],$Settings['qsep'],$prexqstr[$SubsForumType],$exqstr[$SubsForumType]);
160 $sfurl = "<li><ul style=\"list-style-type: none;\"><li><a href=\"".$sfurl."\">".$SubsForumName."</a> <span style=\"color: gray; font-size: 10px;\">".$shownum."</span></li></ul></li>";
161 if($apcl==1) {
162 $sflist = "Subforums:";
163 $sflist = $sflist." ".$sfurl; }
164 if($apcl>1) {
165 $sflist = $sflist." ".$sfurl; }
166 $gltf[$apcl] = $SubsForumID; ++$apcl; }
167 ++$apci; }
168 sql_free_result($apcresult); } }
169 $shownum = null;
170 if ($ForumType=="redirect") { $shownum = "(".$NumRedirects." redirects)"; }
171 if ($ForumType!="redirect") { $shownum = "(".$NumPosts." posts)"; }
172 $PreForum = $ThemeSet['ForumIcon'];
173 if ($ForumType=="forum") { $PreForum=$ThemeSet['ForumIcon']; }
174 if ($ForumType=="subforum") { $PreForum=$ThemeSet['SubForumIcon']; }
175 if ($ForumType=="redirect") { $PreForum=$ThemeSet['RedirectIcon']; }
176 $ExStr = ""; if ($ForumType!="redirect"&&
177 $ForumShowTopics!="no") { $ExStr = "&page=1"; }
179 <ul style="list-style-type: none;"><li>
180 <a href="<?php echo url_maker($exfile[$ForumType],$Settings['file_ext'],"act=lowview&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> <span style="color: gray; font-size: 10px;"><?php echo $shownum; ?></span></li>
181 <?php echo $sflist; ?></ul>
182 <?php ++$i; } sql_free_result($result);
184 </li></ul></div>
185 <div>&nbsp;</div>
186 <?php } sql_free_result($preresult);
187 $ForumCheck = "skip";
188 if($CanHaveTopics!="yes") {
189 $ForumName = $SForumName; }
190 if($CanHaveTopics!="no") {
191 require($SettDir['inc'].'topics.php'); } }