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