Small update
[iDB.git] / inc / lowsubforums.php
blobd0016b79ab8752a764b3bf53097fb4a9009c550c
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: lowsubforums.php - Last Update: 08/02/2019 SVN 905 - 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=="no") { $_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 $CategoryName=sql_result($preresult,0,"Name");
70 $CategoryShow=sql_result($preresult,0,"ShowCategory");
71 $CategoryType=sql_result($preresult,0,"CategoryType");
72 $InSubCategory=sql_result($preresult,0,"InSubCategory");
73 if($CategoryShow=="no") { $_SESSION['ShowActHidden'] = "yes"; }
74 $CategoryDescription=sql_result($preresult,0,"Description");
75 if($InSubForum!="0") {
76 $isfquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"id\"=%i".$ForumIgnoreList2." LIMIT 1", array($InSubForum));
77 $isfresult=sql_query($isfquery,$SQLStat);
78 $isfnum=sql_num_rows($isfresult);
79 if($isfnum>=1) {
80 $isfForumID=sql_result($isfresult,0,"id");
81 $isfForumCatID=sql_result($isfresult,0,"CategoryID");
82 $isfForumName=sql_result($isfresult,0,"Name");
83 $isfForumType=sql_result($isfresult,0,"ForumType");
84 $isfForumType = strtolower($isfForumType);
85 $isfRedirectURL=sql_result($isfresult,0,"RedirectURL"); }
86 if($isfnum<1) { $InSubForum = "0"; }
87 sql_free_result($isfresult); }
88 if(isset($_SESSION['OldViewingPage'])) { $_SESSION['AncientViewingPage'] = $_SESSION['OldViewingPage']; } else { $_SESSION['AncientViewingPage'] = url_maker(null,"no+ext","act=view","&","=",$prexqstr['index'],$exqstr['index']); }
89 if(isset($_SESSION['OldViewingFile'])) { $_SESSION['AncientViewingFile'] = $_SESSION['OldViewingFile']; } else {
90 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
91 $_SESSION['AncientViewingFile'] = $exfile['index'].$Settings['file_ext']; }
92 if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
93 $_SESSION['AncientViewingFile'] = $exfile['index']; } }
94 if(isset($_SESSION['OldPreViewingTitle'])) { $_SESSION['AncientPreViewingTitle'] = $_SESSION['OldPreViewingTitle']; } else { $_SESSION['AncientPreViewingTitle'] = "Viewing"; }
95 if(isset($_SESSION['OldViewingTitle'])) { $_SESSION['AncientViewingTitle'] = $_SESSION['OldViewingTitle']; } else { $_SESSION['AncientViewingTitle'] = "Board index"; }
96 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;"; }
97 if(isset($_SESSION['ViewingPage'])) { $_SESSION['OldViewingPage'] = $_SESSION['ViewingPage']; } else { $_SESSION['OldViewingPage'] = url_maker(null,"no+ext","act=view","&","=",$prexqstr['index'],$exqstr['index']); }
98 if(isset($_SESSION['ViewingFile'])) { $_SESSION['OldViewingFile'] = $_SESSION['ViewingFile']; } else {
99 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
100 $_SESSION['OldViewingFile'] = $exfile['index'].$Settings['file_ext']; }
101 if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
102 $_SESSION['OldViewingFile'] = $exfile['index']; } }
103 if(isset($_SESSION['PreViewingTitle'])) { $_SESSION['OldPreViewingTitle'] = $_SESSION['PreViewingTitle']; } else { $_SESSION['OldPreViewingTitle'] = "Viewing"; }
104 if(isset($_SESSION['ViewingTitle'])) { $_SESSION['OldViewingTitle'] = $_SESSION['ViewingTitle']; } else { $_SESSION['OldViewingTitle'] = "Board index"; }
105 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;"; }
106 $_SESSION['ViewingPage'] = url_maker(null,"no+ext","act=lowview&id=".$ForumID."&page=".$_GET['page'],"&","=",$prexqstr[$ForumType],$exqstr[$ForumType]);
107 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
108 $_SESSION['ViewingFile'] = $exfile[$ForumType].$Settings['file_ext']; }
109 if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
110 $_SESSION['ViewingFile'] = $exfile[$ForumType]; }
111 $_SESSION['PreViewingTitle'] = "Viewing SubForum:";
112 $_SESSION['ViewingTitle'] = $ForumName;
113 $_SESSION['ExtraData'] = "currentact:".$_GET['act']."; currentcategoryid:".$InSubCategory.",".$CategoryID."; currentforumid:".$InSubForum.",".$ForumID."; currenttopicid:0; currentmessageid:0; currenteventid:0; currentmemberid:0;";
115 <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>
116 <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>
117 <div>&nbsp;</div>
118 <?php
119 if(!isset($CatPermissionInfo['CanViewCategory'][$CategoryID])) {
120 $CatPermissionInfo['CanViewCategory'][$CategoryID] = "no"; }
121 if($CatPermissionInfo['CanViewCategory'][$CategoryID]=="no"||
122 $CatPermissionInfo['CanViewCategory'][$CategoryID]!="yes") {
123 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
124 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
125 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
126 if(!isset($PermissionInfo['CanViewForum'][$_GET['id']])) {
127 $PermissionInfo['CanViewForum'][$_GET['id']] = "no"; }
128 if($PermissionInfo['CanViewForum'][$_GET['id']]=="no"||
129 $PermissionInfo['CanViewForum'][$_GET['id']]!="yes") {
130 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
131 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
132 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
133 if($CatPermissionInfo['CanViewCategory'][$CategoryID]=="yes"&&
134 $PermissionInfo['CanViewForum'][$_GET['id']]=="yes") {
135 $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']));
136 $result=sql_query($query,$SQLStat);
137 $num=sql_num_rows($result);
138 $i=0;
139 if($num>=1) {
141 <div style="padding: 10px; border: 1px solid gray;">
142 <ul style="list-style-type: none;">
143 <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>
144 <?php
145 while ($i < $num) {
146 $ForumID=sql_result($result,$i,"id");
147 $ForumName=sql_result($result,$i,"Name");
148 $ForumShow=sql_result($result,$i,"ShowForum");
149 $ForumType=sql_result($result,$i,"ForumType");
150 $ForumShowTopics=sql_result($result,$i,"CanHaveTopics");
151 $ForumShowTopics = strtolower($ForumShowTopics);
152 $NumTopics=sql_result($result,$i,"NumTopics");
153 $NumPosts=sql_result($result,$i,"NumPosts");
154 $NumRedirects=sql_result($result,$i,"Redirects");
155 $ForumDescription=sql_result($result,$i,"Description");
156 $ForumType = strtolower($ForumType); $sflist = null;
157 $gltf = array(null); $gltf[0] = $ForumID;
158 if ($ForumType=="subforum") {
159 $apcquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"ShowForum\"='yes' AND \"InSubForum\"=%i".$ForumIgnoreList2." ORDER BY \"OrderID\" ASC, \"id\" ASC", array($ForumID));
160 $apcresult=sql_query($apcquery);
161 $apcnum=sql_num_rows($apcresult);
162 $apci=0; $apcl=1; if($apcnum>=1) {
163 while ($apci < $apcnum) {
164 $NumsTopics=sql_result($apcresult,$apci,"NumTopics");
165 $NumTopics = $NumsTopics + $NumTopics;
166 $NumsPosts=sql_result($apcresult,$apci,"NumPosts");
167 $NumPosts = $NumsPosts + $NumPosts;
168 $SubsForumID=sql_result($apcresult,$apci,"id");
169 $SubsForumName=sql_result($apcresult,$apci,"Name");
170 $SubsForumType=sql_result($apcresult,$apci,"ForumType");
171 $SubsForumShowTopics=sql_result($result,$i,"CanHaveTopics");
172 if(isset($PermissionInfo['CanViewForum'][$SubsForumID])&&
173 $PermissionInfo['CanViewForum'][$SubsForumID]=="yes") {
174 $ExStr = ""; if ($SubsForumType!="redirect"&&
175 $SubsForumShowTopics!="no") { $ExStr = "&page=1"; }
176 $shownum = null;
177 if ($SubsForumType=="redirect") { $shownum = "(".$NumRedirects." redirects)"; }
178 if ($SubsForumType!="redirect") { $shownum = "(".$NumsPosts." posts)"; }
179 $sfurl = "<a href=\"";
180 $sfurl = url_maker($exfile[$SubsForumType],$Settings['file_ext'],"act=lowview&id=".$SubsForumID.$ExStr,$Settings['qstr'],$Settings['qsep'],$prexqstr[$SubsForumType],$exqstr[$SubsForumType]);
181 $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>";
182 if($apcl==1) {
183 $sflist = "Subforums:";
184 $sflist = $sflist." ".$sfurl; }
185 if($apcl>1) {
186 $sflist = $sflist." ".$sfurl; }
187 $gltf[$apcl] = $SubsForumID; ++$apcl; }
188 ++$apci; }
189 sql_free_result($apcresult); } }
190 $shownum = null;
191 if ($ForumType=="redirect") { $shownum = "(".$NumRedirects." redirects)"; }
192 if ($ForumType!="redirect") { $shownum = "(".$NumPosts." posts)"; }
193 $PreForum = $ThemeSet['ForumIcon'];
194 if ($ForumType=="forum") { $PreForum=$ThemeSet['ForumIcon']; }
195 if ($ForumType=="subforum") { $PreForum=$ThemeSet['SubForumIcon']; }
196 if ($ForumType=="redirect") { $PreForum=$ThemeSet['RedirectIcon']; }
197 $ExStr = ""; if ($ForumType!="redirect"&&
198 $ForumShowTopics!="no") { $ExStr = "&page=1"; }
200 <ul style="list-style-type: none;"><li>
201 <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>
202 <?php echo $sflist; ?></ul>
203 <?php ++$i; } sql_free_result($result);
205 </li></ul></div>
206 <div>&nbsp;</div>
207 <?php } } sql_free_result($preresult);
208 $ForumCheck = "skip";
209 if($CanHaveTopics!="yes") {
210 $ForumName = $SForumName; }
211 if($CanHaveTopics!="no") {
212 require($SettDir['inc'].'lowtopics.php'); } }