Small update to iBBCode / iBBTags.
[iDB.git] / inc / lowsubcategories.php
blob7dfad59b6aaeb8c92352975c03c51d62a41fbdbc
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: lowsubcategories.php - Last Update: 12/07/2010 SVN 600 - Author: cooldude2k $
16 $File3Name = basename($_SERVER['SCRIPT_NAME']);
17 if ($File3Name=="lowsubcategories.php"||$File3Name=="/lowsubcategories.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']."categories\" WHERE \"id\"=%i".$CatIgnoreList2." 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']);
26 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
27 if($checknum>=1) {
28 $CategoryID=sql_result($checkresult,0,"id");
29 $CategoryName=sql_result($checkresult,0,"Name");
30 $CategoryShow=sql_result($checkresult,0,"ShowCategory");
31 $CategoryType=sql_result($checkresult,0,"CategoryType");
32 $InSubCategory=sql_result($checkresult,0,"InSubCategory");
33 $SubShowForums=sql_result($checkresult,0,"SubShowForums");
34 $CategoryType = strtolower($CategoryType); $SubShowForums = strtolower($SubShowForums);
35 $SCategoryName = $CategoryName;
36 if(!isset($CatPermissionInfo['CanViewCategory'][$CategoryID])) {
37 $CatPermissionInfo['CanViewCategory'][$CategoryID] = "no"; }
38 if($CatPermissionInfo['CanViewCategory'][$CategoryID]=="no"||
39 $CatPermissionInfo['CanViewCategory'][$CategoryID]!="yes") {
40 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
41 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']);
42 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
43 if($CatPermissionInfo['CanViewCategory'][$CategoryID]=="yes") {
44 $_SESSION['ViewingPage'] = url_maker(null,"no+ext","act=lowview&id=".$CategoryID,"&","=",$prexqstr[$CategoryType],$exqstr[$CategoryType]);
45 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
46 $_SESSION['ViewingFile'] = $exfile[$CategoryType].$Settings['file_ext']; }
47 if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
48 $_SESSION['ViewingFile'] = $exfile[$CategoryType]; }
49 $_SESSION['PreViewingTitle'] = "Viewing SubCategory:";
50 $_SESSION['ViewingTitle'] = $CategoryName;
51 if($InSubCategory!="0") {
52 $iscquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."categories\" WHERE \"id\"=%i".$CatIgnoreList2." LIMIT 1", array($InSubCategory));
53 $iscresult=sql_query($iscquery,$SQLStat);
54 $iscnum=sql_num_rows($iscresult);
55 if($iscnum>=1) {
56 $iscCategoryID=sql_result($iscresult,0,"id");
57 $iscCategoryName=sql_result($iscresult,0,"Name");
58 $iscCategoryShow=sql_result($iscresult,0,"ShowCategory");
59 $iscCategoryType=sql_result($iscresult,0,"CategoryType");
60 $iscCategoryType = strtolower($iscCategoryType); }
61 if($iscnum<1) { $InSubCategory = "0"; }
62 sql_free_result($iscresult); }
64 <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[$CategoryType],$Settings['file_ext'],"act=view&id=".$CategoryID,$Settings['qstr'],$Settings['qsep'],$prexqstr[$CategoryType],$exqstr[$CategoryType]); ?>"><?php echo $CategoryName; ?></a></div>
65 <div style="font-size: 11px; font-weight: bold; padding: 10px; border: 1px solid gray;"><?php echo $ThemeSet['NavLinkIcon']; ?><a href="<?php echo url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index']); ?>">Board index</a><?php if($InSubCategory!="0") { echo $ThemeSet['NavLinkDivider']; ?><a href="<?php echo url_maker($exfile[$iscCategoryType],$Settings['file_ext'],"act=view&id=".$iscCategoryID."&page=1",$Settings['qstr'],$Settings['qsep'],$prexqstr[$iscCategoryType],$exqstr[$iscCategoryType]); ?>"><?php echo $iscCategoryName; ?></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></div>
66 <div>&nbsp;</div>
67 <div style="padding: 10px; border: 1px solid gray;">
68 <ul style="list-style-type: none;">
69 <?php
70 if($CategoryType=="category") {
71 redirect("location",$rbasedir.url_maker($exfile['category'],$Settings['file_ext'],"act=".$_GET['act']."&id=".$_GET['id'],$Settings['qstr'],$Settings['qsep'],$prexqstr['category'],$exqstr['category'],FALSE));
72 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']);
73 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
74 sql_free_result($checkresult);
75 $prequery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."categories\" WHERE \"ShowCategory\"='yes' AND \"InSubCategory\"=%i".$CatIgnoreList2." ORDER BY \"OrderID\" ASC, \"id\" ASC", array($_GET['id']));
76 $preresult=sql_query($prequery,$SQLStat);
77 $prenum=sql_num_rows($preresult);
78 $prei=0;
79 while ($prei < $prenum) {
80 $CategoryID=sql_result($preresult,$prei,"id");
81 $CategoryName=sql_result($preresult,$prei,"Name");
82 $CategoryShow=sql_result($preresult,$prei,"ShowCategory");
83 $CategoryType=sql_result($preresult,$prei,"CategoryType");
84 $SSubShowForums=sql_result($preresult,$prei,"SubShowForums");
85 $CategoryDescription=sql_result($preresult,$prei,"Description");
86 $CategoryType = strtolower($CategoryType); $SubShowForums = strtolower($SubShowForums);
87 if(isset($CatPermissionInfo['CanViewCategory'][$CategoryID])&&
88 $CatPermissionInfo['CanViewCategory'][$CategoryID]=="yes") {
89 $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));
90 $result=sql_query($query,$SQLStat);
91 $num=sql_num_rows($result);
92 $i=0;
93 if($num>=1) {
95 <li style="font-weight: bold;"><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></li><li>
96 <?php }
97 while ($i < $num) {
98 $ForumID=sql_result($result,$i,"id");
99 $ForumName=sql_result($result,$i,"Name");
100 $ForumShow=sql_result($result,$i,"ShowForum");
101 $ForumType=sql_result($result,$i,"ForumType");
102 $ForumShowTopics=sql_result($result,$i,"CanHaveTopics");
103 $ForumShowTopics = strtolower($ForumShowTopics);
104 $NumTopics=sql_result($result,$i,"NumTopics");
105 $NumPosts=sql_result($result,$i,"NumPosts");
106 $NumRedirects=sql_result($result,$i,"Redirects");
107 $ForumDescription=sql_result($result,$i,"Description");
108 $ForumType = strtolower($ForumType); $sflist = null;
109 $gltf = array(null); $gltf[0] = $ForumID;
110 if ($ForumType=="subforum") {
111 $apcquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"ShowForum\"='yes' AND \"InSubForum\"=%i".$ForumIgnoreList2." ORDER BY \"OrderID\" ASC, \"id\" ASC", array($ForumID));
112 $apcresult=sql_query($apcquery,$SQLStat);
113 $apcnum=sql_num_rows($apcresult);
114 $apci=0; $apcl=1; if($apcnum>=1) {
115 while ($apci < $apcnum) {
116 $NumsTopics=sql_result($apcresult,$apci,"NumTopics");
117 $NumTopics = $NumsTopics + $NumTopics;
118 $NumsPosts=sql_result($apcresult,$apci,"NumPosts");
119 $NumPosts = $NumsPosts + $NumPosts;
120 $SubsForumID=sql_result($apcresult,$apci,"id");
121 $SubsForumName=sql_result($apcresult,$apci,"Name");
122 $SubsForumType=sql_result($apcresult,$apci,"ForumType");
123 $SubsForumShowTopics=sql_result($result,$i,"CanHaveTopics");
124 if(isset($PermissionInfo['CanViewForum'][$SubsForumID])&&
125 $PermissionInfo['CanViewForum'][$SubsForumID]=="yes") {
126 $ExStr = ""; if ($SubsForumType!="redirect"&&
127 $SubsForumShowTopics!="no") { $ExStr = "&page=1"; }
128 $shownum = null;
129 if ($SubsForumType=="redirect") { $shownum = "(".$NumRedirects." redirects)"; }
130 if ($SubsForumType!="redirect") { $shownum = "(".$NumsPosts." posts)"; }
131 $sfurl = "<a href=\"";
132 $sfurl = url_maker($exfile[$SubsForumType],$Settings['file_ext'],"act=view&id=".$SubsForumID.$ExStr,$Settings['qstr'],$Settings['qsep'],$prexqstr[$SubsForumType],$exqstr[$SubsForumType]);
133 $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>";
134 if($apcl==1) {
135 $sflist = $sflist." ".$sfurl; }
136 if($apcl>1) {
137 $sflist = $sflist." ".$sfurl; }
138 $gltf[$apcl] = $SubsForumID; ++$apcl; }
139 ++$apci; }
140 sql_free_result($apcresult); } }
141 if ($ForumType=="subforum") {
142 $apcquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"ShowForum\"='yes' AND \"InSubForum\"=%i".$ForumIgnoreList2." ORDER BY \"OrderID\" ASC, \"id\" ASC", array($ForumID));
143 $apcresult=sql_query($apcquery,$SQLStat);
144 $apcnum=sql_num_rows($apcresult);
145 $apci=0; $apcl=1; if($apcnum>=1) {
146 while ($apci < $apcnum) {
147 $NumsTopics=sql_result($apcresult,$apci,"NumTopics");
148 $NumTopics = $NumsTopics + $NumTopics;
149 $NumsPosts=sql_result($apcresult,$apci,"NumPosts");
150 $NumPosts = $NumsPosts + $NumPosts;
151 $SubsForumID=sql_result($apcresult,$apci,"id");
152 if(isset($PermissionInfo['CanViewForum'][$SubsForumID])&&
153 $PermissionInfo['CanViewForum'][$SubsForumID]=="yes") {
154 $gltf[$apcl] = $SubsForumID; ++$apcl; }
155 ++$apci; }
156 sql_free_result($apcresult); } }
157 if(isset($PermissionInfo['CanViewForum'][$ForumID])&&
158 $PermissionInfo['CanViewForum'][$ForumID]=="yes") {
159 $LastTopic = "&nbsp;<br />&nbsp;<br />&nbsp;";
160 if(!isset($LastTopic)) { $LastTopic = null; }
161 $gltnum = count($gltf); $glti = 0;
162 $OldUpdateTime = 0; $UseThisFonum = null;
163 if ($ForumType=="subforum") {
164 while ($glti < $gltnum) {
165 $ExtraIgnores = null;
166 if($PermissionInfo['CanModForum'][$gltf[$glti]]=="no") {
167 $ExtraIgnores = " AND \"Closed\"<>3"; }
168 $gltfoquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."topics\" WHERE \"CategoryID\"=%i AND \"ForumID\"=%i".$ExtraIgnores." ORDER BY \"LastUpdate\" DESC LIMIT 1", array($CategoryID,$gltf[$glti]));
169 $gltforesult=sql_query($gltfoquery,$SQLStat);
170 $gltfonum=sql_num_rows($gltforesult);
171 if($gltfonum>0) {
172 $NewUpdateTime=sql_result($gltforesult,0,"LastUpdate");
173 if($NewUpdateTime>$OldUpdateTime) {
174 $UseThisFonum = $gltf[$glti];
175 $OldUpdateTime = $NewUpdateTime; } }
176 sql_free_result($gltforesult);
177 ++$glti; } }
178 $shownum = null;
179 if ($ForumType=="redirect") { $shownum = "(".$NumRedirects." redirects)"; }
180 if ($ForumType!="redirect") { $shownum = "(".$NumPosts." posts)"; }
181 $PreForum = $ThemeSet['ForumIcon'];
182 if ($ForumType=="forum") { $PreForum=$ThemeSet['ForumIcon']; }
183 if ($ForumType=="subforum") { $PreForum=$ThemeSet['SubForumIcon']; }
184 if ($ForumType=="redirect") { $PreForum=$ThemeSet['RedirectIcon']; }
185 $ExStr = ""; if ($ForumType!="redirect"&&
186 $ForumShowTopics!="no") { $ExStr = "&page=1"; }
188 <ul style="list-style-type: none;"><li>
189 <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>
190 <?php echo $sflist; ?></ul>
191 <?php } ++$i; } sql_free_result($result); } ?>
192 </li></ul>
193 <ul style="list-style-type: none;">
194 <?php ++$prei; } } ?>
195 <?php
196 sql_free_result($preresult);
197 $CatCheck = "skip";
198 if($SubShowForums!="yes") {
199 $CategoryName = $SCategoryName; }
200 if($SubShowForums!="no") {
201 require($SettDir['inc'].'lowcategories.php'); } }