Small update
[iDB.git] / inc / lowcategories.php
blobd738c4c89a0145288ce0f2c612c133e4eb4e3607
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: lowcategories.php - Last Update: 08/02/2019 SVN 905 - Author: cooldude2k $
16 $File3Name = basename($_SERVER['SCRIPT_NAME']);
17 if ($File3Name=="lowcategories.php"||$File3Name=="/lowcategories.php") {
18 require('index.php');
19 exit(); }
20 if(!is_numeric($_GET['id'])) { $_GET['id'] = null; }
21 $prequery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."categories\" WHERE \"id\"=%i".$CatIgnoreList2." LIMIT 1", array($_GET['id']));
22 $preresult=sql_query($prequery,$SQLStat);
23 $prenum=sql_num_rows($preresult);
24 if($prenum==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($preresult);
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($prenum>=1) {
28 $CategoryID=sql_result($preresult,0,"id");
29 $CategoryName=sql_result($preresult,0,"Name");
30 $CategoryShow=sql_result($preresult,0,"ShowCategory");
31 if($CategoryShow=="no") { $_SESSION['ShowActHidden'] = "yes"; }
32 $CategoryType=sql_result($preresult,0,"CategoryType");
33 $InSubCategory=sql_result($preresult,0,"InSubCategory");
34 $SubShowForums=sql_result($preresult,0,"SubShowForums");
35 $CategoryDescription=sql_result($preresult,0,"Description");
36 $CategoryType = strtolower($CategoryType); $SubShowForums = strtolower($SubShowForums);
37 $CategoryPostCountView=sql_result($preresult,0,"PostCountView");
38 $CategoryKarmaCountView=sql_result($preresult,0,"KarmaCountView");
39 if($MyPostCountChk==null) { $MyPostCountChk = 0; }
40 if($MyKarmaCount==null) { $MyKarmaCount = 0; }
41 if($GroupInfo['HasAdminCP']!="yes"||$GroupInfo['HasModCP']!="yes") {
42 if($CategoryPostCountView!=0&&$MyPostCountChk<$CategoryPostCountView) {
43 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); }
44 if($CategoryKarmaCountView!=0&&$MyKarmaCount<$CategoryKarmaCountView) {
45 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); } }
46 if(!isset($CatPermissionInfo['CanViewCategory'][$CategoryID])) {
47 $CatPermissionInfo['CanViewCategory'][$CategoryID] = "no"; }
48 if($CatPermissionInfo['CanViewCategory'][$CategoryID]=="no"||
49 $CatPermissionInfo['CanViewCategory'][$CategoryID]!="yes") {
50 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
51 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
52 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
53 if($CatPermissionInfo['CanViewCategory'][$CategoryID]=="yes") {
54 if(!isset($CatCheck)) { $CatCheck = null; }
55 if($CatCheck!="skip") {
56 if(isset($_SESSION['OldViewingPage'])) { $_SESSION['AncientViewingPage'] = $_SESSION['OldViewingPage']; } else { $_SESSION['AncientViewingPage'] = url_maker(null,"no+ext","act=view","&","=",$prexqstr['index'],$exqstr['index']); }
57 if(isset($_SESSION['OldViewingFile'])) { $_SESSION['AncientViewingFile'] = $_SESSION['OldViewingFile']; } else {
58 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
59 $_SESSION['AncientViewingFile'] = $exfile['index'].$Settings['file_ext']; }
60 if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
61 $_SESSION['AncientViewingFile'] = $exfile['index']; } }
62 if(isset($_SESSION['OldPreViewingTitle'])) { $_SESSION['AncientPreViewingTitle'] = $_SESSION['OldPreViewingTitle']; } else { $_SESSION['AncientPreViewingTitle'] = "Viewing"; }
63 if(isset($_SESSION['OldViewingTitle'])) { $_SESSION['AncientViewingTitle'] = $_SESSION['OldViewingTitle']; } else { $_SESSION['AncientViewingTitle'] = "Board index"; }
64 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;"; }
65 if(isset($_SESSION['ViewingPage'])) { $_SESSION['OldViewingPage'] = $_SESSION['ViewingPage']; } else { $_SESSION['OldViewingPage'] = url_maker(null,"no+ext","act=view","&","=",$prexqstr['index'],$exqstr['index']); }
66 if(isset($_SESSION['ViewingFile'])) { $_SESSION['OldViewingFile'] = $_SESSION['ViewingFile']; } else {
67 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
68 $_SESSION['OldViewingFile'] = $exfile['index'].$Settings['file_ext']; }
69 if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
70 $_SESSION['OldViewingFile'] = $exfile['index']; } }
71 if(isset($_SESSION['PreViewingTitle'])) { $_SESSION['OldPreViewingTitle'] = $_SESSION['PreViewingTitle']; } else { $_SESSION['OldPreViewingTitle'] = "Viewing"; }
72 if(isset($_SESSION['ViewingTitle'])) { $_SESSION['OldViewingTitle'] = $_SESSION['ViewingTitle']; } else { $_SESSION['OldViewingTitle'] = "Board index"; }
73 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;"; }
74 $_SESSION['ViewingPage'] = url_maker(null,"no+ext","act=lowview&id=".$CategoryID,"&","=",$prexqstr[$CategoryType],$exqstr[$CategoryType]);
75 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
76 $_SESSION['ViewingFile'] = $exfile[$CategoryType].$Settings['file_ext']; }
77 if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
78 $_SESSION['ViewingFile'] = $exfile[$CategoryType]; }
79 $_SESSION['PreViewingTitle'] = "Viewing Category:";
80 $_SESSION['ViewingTitle'] = $CategoryName;
81 $_SESSION['ExtraData'] = "currentact:".$_GET['act']."; currentcategoryid:".$InSubCategory.",".$CategoryID."; currentforumid:0; currenttopicid:0; currentmessageid:0; currenteventid:0; currentmemberid:0;";
82 if($InSubCategory!="0") {
83 $iscquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."categories\" WHERE \"id\"=%i".$CatIgnoreList2." LIMIT 1", array($InSubCategory));
84 $iscresult=sql_query($iscquery,$SQLStat);
85 $iscnum=sql_num_rows($iscresult);
86 if($iscnum>=1) {
87 $iscCategoryID=sql_result($iscresult,0,"id");
88 $iscCategoryName=sql_result($iscresult,0,"Name");
89 $iscCategoryShow=sql_result($iscresult,0,"ShowCategory");
90 $iscCategoryType=sql_result($iscresult,0,"CategoryType");
91 $iscCategoryType = strtolower($iscCategoryType); }
92 if($iscnum<1) { $InSubCategory = "0"; }
93 sql_free_result($iscresult); }
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[$CategoryType],$Settings['file_ext'],"act=view&id=".$CategoryID,$Settings['qstr'],$Settings['qsep'],$prexqstr[$CategoryType],$exqstr[$CategoryType]); ?>"><?php echo $CategoryName; ?></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 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>
97 <div>&nbsp;</div>
98 <div style="padding: 10px; border: 1px solid gray;">
99 <ul style="list-style-type: none;">
100 <?php
101 if($CategoryType=="subcategory") {
102 redirect("location",$rbasedir.url_maker($exfile['subcategory'],$Settings['file_ext'],"act=".$_GET['act']."&id=".$_GET['id'],$Settings['qstr'],$Settings['qsep'],$prexqstr['subcategory'],$exqstr['subcategory'],FALSE));
103 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
104 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); } }
105 $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));
106 $result=sql_query($query,$SQLStat);
107 $num=sql_num_rows($result);
108 $i=0;
109 if($num>=1) {
111 <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>
112 <?php }
113 while ($i < $num) {
114 $ForumID=sql_result($result,$i,"id");
115 $ForumName=sql_result($result,$i,"Name");
116 $ForumShow=sql_result($result,$i,"ShowForum");
117 $ForumType=sql_result($result,$i,"ForumType");
118 $ForumShowTopics=sql_result($result,$i,"CanHaveTopics");
119 $ForumShowTopics = strtolower($ForumShowTopics);
120 $NumTopics=sql_result($result,$i,"NumTopics");
121 $NumPosts=sql_result($result,$i,"NumPosts");
122 $NumRedirects=sql_result($result,$i,"Redirects");
123 $ForumDescription=sql_result($result,$i,"Description");
124 $ForumType = strtolower($ForumType); $sflist = null;
125 $gltf = array(null); $gltf[0] = $ForumID;
126 if ($ForumType=="subforum") {
127 $apcquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"ShowForum\"='yes' AND \"InSubForum\"=%i".$ForumIgnoreList2." ORDER BY \"OrderID\" ASC, \"id\" ASC", array($ForumID));
128 $apcresult=sql_query($apcquery,$SQLStat);
129 $apcnum=sql_num_rows($apcresult);
130 $apci=0; $apcl=1; if($apcnum>=1) {
131 while ($apci < $apcnum) {
132 $NumsTopics=sql_result($apcresult,$apci,"NumTopics");
133 $NumTopics = $NumsTopics + $NumTopics;
134 $NumsPosts=sql_result($apcresult,$apci,"NumPosts");
135 $NumPosts = $NumsPosts + $NumPosts;
136 $SubsForumID=sql_result($apcresult,$apci,"id");
137 $SubsForumName=sql_result($apcresult,$apci,"Name");
138 $SubsForumType=sql_result($apcresult,$apci,"ForumType");
139 $SubsForumShowTopics=sql_result($result,$i,"CanHaveTopics");
140 if(isset($PermissionInfo['CanViewForum'][$SubsForumID])&&
141 $PermissionInfo['CanViewForum'][$SubsForumID]=="yes") {
142 $ExStr = ""; if ($SubsForumType!="redirect"&&
143 $SubsForumShowTopics!="no") { $ExStr = "&page=1"; }
144 $shownum = null;
145 if ($SubsForumType=="redirect") { $shownum = "(".$NumRedirects." redirects)"; }
146 if ($SubsForumType!="redirect") { $shownum = "(".$NumsPosts." posts)"; }
147 $sfurl = "<a href=\"";
148 $sfurl = url_maker($exfile[$SubsForumType],$Settings['file_ext'],"act=lowview&id=".$SubsForumID.$ExStr,$Settings['qstr'],$Settings['qsep'],$prexqstr[$SubsForumType],$exqstr[$SubsForumType]);
149 $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>";
150 if($apcl==1) {
151 $sflist = $sflist." ".$sfurl; }
152 if($apcl>1) {
153 $sflist = $sflist." ".$sfurl; }
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 $shownum = null;
162 if ($ForumType=="redirect") { $shownum = "(".$NumRedirects." redirects)"; }
163 if ($ForumType!="redirect") { $shownum = "(".$NumPosts." posts)"; }
164 $PreForum = $ThemeSet['ForumIcon'];
165 if ($ForumType=="forum") { $PreForum=$ThemeSet['ForumIcon']; }
166 if ($ForumType=="subforum") { $PreForum=$ThemeSet['SubForumIcon']; }
167 if ($ForumType=="redirect") { $PreForum=$ThemeSet['RedirectIcon']; }
168 $ExStr = ""; if ($ForumType!="redirect"&&
169 $ForumShowTopics!="no") { $ExStr = "&page=1"; }
171 <ul style="list-style-type: none;"><li>
172 <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>
173 <?php echo $sflist; ?></ul>
174 <?php } ++$i; } sql_free_result($result);
175 if($num>=1) { ?>
176 </li></ul></div>
177 <div>&nbsp;</div>
178 <?php } } }
179 sql_free_result($preresult); ?>