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