Yet another small bug fix. :o
[iDB.git] / inc / lowcategories.php
blobc5f205287719526678b85e718d1dad85bdd6299e
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: lowcategories.php - Last Update: 06/14/2011 SVN 672 - 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 $CategoryType=sql_result($preresult,0,"CategoryType");
32 $InSubCategory=sql_result($preresult,0,"InSubCategory");
33 $SubShowForums=sql_result($preresult,0,"SubShowForums");
34 $CategoryDescription=sql_result($preresult,0,"Description");
35 $CategoryType = strtolower($CategoryType); $SubShowForums = strtolower($SubShowForums);
36 $CategoryPostCountView=sql_result($preresult,0,"PostCountView");
37 $CategoryKarmaCountView=sql_result($preresult,0,"KarmaCountView");
38 if($MyPostCountChk==null) { $MyPostCountChk = 0; }
39 if($MyKarmaCount==null) { $MyKarmaCount = 0; }
40 if($GroupInfo['HasAdminCP']!="yes"||$GroupInfo['HasModCP']!="yes") {
41 if($CategoryPostCountView!=0&&$MyPostCountChk<$CategoryPostCountView) {
42 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); }
43 if($CategoryKarmaCountView!=0&&$MyKarmaCount<$CategoryKarmaCountView) {
44 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); } }
45 if(!isset($CatPermissionInfo['CanViewCategory'][$CategoryID])) {
46 $CatPermissionInfo['CanViewCategory'][$CategoryID] = "no"; }
47 if($CatPermissionInfo['CanViewCategory'][$CategoryID]=="no"||
48 $CatPermissionInfo['CanViewCategory'][$CategoryID]!="yes") {
49 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
50 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
51 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
52 if($CatPermissionInfo['CanViewCategory'][$CategoryID]=="yes") {
53 if(!isset($CatCheck)) { $CatCheck = null; }
54 if($CatCheck!="skip") {
55 $_SESSION['ViewingPage'] = url_maker(null,"no+ext","act=lowview&id=".$CategoryID,"&","=",$prexqstr[$CategoryType],$exqstr[$CategoryType]);
56 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
57 $_SESSION['ViewingFile'] = $exfile[$CategoryType].$Settings['file_ext']; }
58 if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
59 $_SESSION['ViewingFile'] = $exfile[$CategoryType]; }
60 $_SESSION['PreViewingTitle'] = "Viewing Category:";
61 $_SESSION['ViewingTitle'] = $CategoryName;
62 if($InSubCategory!="0") {
63 $iscquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."categories\" WHERE \"id\"=%i".$CatIgnoreList2." LIMIT 1", array($InSubCategory));
64 $iscresult=sql_query($iscquery,$SQLStat);
65 $iscnum=sql_num_rows($iscresult);
66 if($iscnum>=1) {
67 $iscCategoryID=sql_result($iscresult,0,"id");
68 $iscCategoryName=sql_result($iscresult,0,"Name");
69 $iscCategoryShow=sql_result($iscresult,0,"ShowCategory");
70 $iscCategoryType=sql_result($iscresult,0,"CategoryType");
71 $iscCategoryType = strtolower($iscCategoryType); }
72 if($iscnum<1) { $InSubCategory = "0"; }
73 sql_free_result($iscresult); }
75 <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>
76 <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']); ?>">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>
77 <div>&nbsp;</div>
78 <div style="padding: 10px; border: 1px solid gray;">
79 <ul style="list-style-type: none;">
80 <?php
81 if($CategoryType=="subcategory") {
82 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));
83 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
84 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); } }
85 $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));
86 $result=sql_query($query,$SQLStat);
87 $num=sql_num_rows($result);
88 $i=0;
89 if($num>=1) {
91 <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>
92 <?php }
93 while ($i < $num) {
94 $ForumID=sql_result($result,$i,"id");
95 $ForumName=sql_result($result,$i,"Name");
96 $ForumShow=sql_result($result,$i,"ShowForum");
97 $ForumType=sql_result($result,$i,"ForumType");
98 $ForumShowTopics=sql_result($result,$i,"CanHaveTopics");
99 $ForumShowTopics = strtolower($ForumShowTopics);
100 $NumTopics=sql_result($result,$i,"NumTopics");
101 $NumPosts=sql_result($result,$i,"NumPosts");
102 $NumRedirects=sql_result($result,$i,"Redirects");
103 $ForumDescription=sql_result($result,$i,"Description");
104 $ForumType = strtolower($ForumType); $sflist = null;
105 $gltf = array(null); $gltf[0] = $ForumID;
106 if ($ForumType=="subforum") {
107 $apcquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"ShowForum\"='yes' AND \"InSubForum\"=%i".$ForumIgnoreList2." ORDER BY \"OrderID\" ASC, \"id\" ASC", array($ForumID));
108 $apcresult=sql_query($apcquery,$SQLStat);
109 $apcnum=sql_num_rows($apcresult);
110 $apci=0; $apcl=1; if($apcnum>=1) {
111 while ($apci < $apcnum) {
112 $NumsTopics=sql_result($apcresult,$apci,"NumTopics");
113 $NumTopics = $NumsTopics + $NumTopics;
114 $NumsPosts=sql_result($apcresult,$apci,"NumPosts");
115 $NumPosts = $NumsPosts + $NumPosts;
116 $SubsForumID=sql_result($apcresult,$apci,"id");
117 $SubsForumName=sql_result($apcresult,$apci,"Name");
118 $SubsForumType=sql_result($apcresult,$apci,"ForumType");
119 $SubsForumShowTopics=sql_result($result,$i,"CanHaveTopics");
120 if(isset($PermissionInfo['CanViewForum'][$SubsForumID])&&
121 $PermissionInfo['CanViewForum'][$SubsForumID]=="yes") {
122 $ExStr = ""; if ($SubsForumType!="redirect"&&
123 $SubsForumShowTopics!="no") { $ExStr = "&page=1"; }
124 $shownum = null;
125 if ($SubsForumType=="redirect") { $shownum = "(".$NumRedirects." redirects)"; }
126 if ($SubsForumType!="redirect") { $shownum = "(".$NumsPosts." posts)"; }
127 $sfurl = "<a href=\"";
128 $sfurl = url_maker($exfile[$SubsForumType],$Settings['file_ext'],"act=lowview&id=".$SubsForumID.$ExStr,$Settings['qstr'],$Settings['qsep'],$prexqstr[$SubsForumType],$exqstr[$SubsForumType]);
129 $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>";
130 if($apcl==1) {
131 $sflist = $sflist." ".$sfurl; }
132 if($apcl>1) {
133 $sflist = $sflist." ".$sfurl; }
134 $gltf[$apcl] = $SubsForumID; ++$apcl; }
135 ++$apci; }
136 sql_free_result($apcresult); } }
137 if(isset($PermissionInfo['CanViewForum'][$ForumID])&&
138 $PermissionInfo['CanViewForum'][$ForumID]=="yes") {
139 $LastTopic = "&nbsp;<br />&nbsp;<br />&nbsp;";
140 if(!isset($LastTopic)) { $LastTopic = null; }
141 $shownum = null;
142 if ($ForumType=="redirect") { $shownum = "(".$NumRedirects." redirects)"; }
143 if ($ForumType!="redirect") { $shownum = "(".$NumPosts." posts)"; }
144 $PreForum = $ThemeSet['ForumIcon'];
145 if ($ForumType=="forum") { $PreForum=$ThemeSet['ForumIcon']; }
146 if ($ForumType=="subforum") { $PreForum=$ThemeSet['SubForumIcon']; }
147 if ($ForumType=="redirect") { $PreForum=$ThemeSet['RedirectIcon']; }
148 $ExStr = ""; if ($ForumType!="redirect"&&
149 $ForumShowTopics!="no") { $ExStr = "&page=1"; }
151 <ul style="list-style-type: none;"><li>
152 <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>
153 <?php echo $sflist; ?></ul>
154 <?php } ++$i; } sql_free_result($result);
155 if($num>=1) { ?>
156 </li></ul></div>
157 <div>&nbsp;</div>
158 <?php } } }
159 sql_free_result($preresult); ?>