Yet another small update.
[iDB.git] / inc / lowforums.php
blobd682039a82265be6427aa0cc734a851330f57916
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: lowforums.php - Last Update: 12/07/2010 SVN 600 - 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 $_SESSION['ViewingPage'] = url_maker(null,"no+ext","act=lowview","&","=",$prexqstr['index'],$exqstr['index']);
25 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
26 $_SESSION['ViewingFile'] = $exfile['index'].$Settings['file_ext']; }
27 if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
28 $_SESSION['ViewingFile'] = $exfile['index']; }
29 $_SESSION['PreViewingTitle'] = "Viewing";
30 $_SESSION['ViewingTitle'] = "Board index";
32 <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>
33 <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></div>
34 <div>&nbsp;</div>
35 <div style="padding: 10px; border: 1px solid gray;">
36 <ul style="list-style-type: none;">
37 <?php
38 while ($prei < $prenum) {
39 $CategoryID=sql_result($preresult,$prei,"id");
40 $CategoryName=sql_result($preresult,$prei,"Name");
41 $CategoryShow=sql_result($preresult,$prei,"ShowCategory");
42 $CategoryType=sql_result($preresult,$prei,"CategoryType");
43 $SubShowForums=sql_result($preresult,$prei,"SubShowForums");
44 $CategoryDescription=sql_result($preresult,$prei,"Description");
45 $CategoryType = strtolower($CategoryType); $SubShowForums = strtolower($SubShowForums);
46 $CategoryPostCountView=sql_result($preresult,0,"PostCountView");
47 $CategoryKarmaCountView=sql_result($preresult,0,"KarmaCountView");
48 if($MyPostCountChk==null) { $MyPostCountChk = 0; }
49 if($MyKarmaCount==null) { $MyKarmaCount = 0; }
50 if($GroupInfo['HasAdminCP']!="yes"||$GroupInfo['HasModCP']!="yes") {
51 if($CategoryPostCountView!=0&&$MyPostCountChk<$CategoryPostCountView) {
52 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); }
53 if($CategoryKarmaCountView!=0&&$MyKarmaCount<$CategoryKarmaCountView) {
54 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); } }
55 if(isset($CatPermissionInfo['CanViewCategory'][$CategoryID])&&
56 $CatPermissionInfo['CanViewCategory'][$CategoryID]=="yes") {
57 $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));
58 $result=sql_query($query,$SQLStat);
59 $num=sql_num_rows($result);
60 $i=0;
61 if($num>=1) {
63 <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>
64 <?php }
65 while ($i < $num) {
66 $ForumID=sql_result($result,$i,"id");
67 $ForumName=sql_result($result,$i,"Name");
68 $ForumShow=sql_result($result,$i,"ShowForum");
69 $ForumType=sql_result($result,$i,"ForumType");
70 $ForumShowTopics=sql_result($result,$i,"CanHaveTopics");
71 $ForumShowTopics = strtolower($ForumShowTopics);
72 $NumTopics=sql_result($result,$i,"NumTopics");
73 $NumPosts=sql_result($result,$i,"NumPosts");
74 $NumRedirects=sql_result($result,$i,"Redirects");
75 $ForumDescription=sql_result($result,$i,"Description");
76 $ForumType = strtolower($ForumType); $sflist = null;
77 $gltf = array(null); $gltf[0] = $ForumID;
78 if ($ForumType=="subforum") {
79 $apcquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"ShowForum\"='yes' AND \"InSubForum\"=%i".$ForumIgnoreList2." ORDER BY \"OrderID\" ASC, \"id\" ASC", array($ForumID));
80 $apcresult=sql_query($apcquery,$SQLStat);
81 $apcnum=sql_num_rows($apcresult);
82 $apci=0; $apcl=1; if($apcnum>=1) {
83 while ($apci < $apcnum) {
84 $NumsTopics=sql_result($apcresult,$apci,"NumTopics");
85 $NumTopics = $NumsTopics + $NumTopics;
86 $NumsPosts=sql_result($apcresult,$apci,"NumPosts");
87 $NumPosts = $NumsPosts + $NumPosts;
88 $SubsForumID=sql_result($apcresult,$apci,"id");
89 $SubsForumName=sql_result($apcresult,$apci,"Name");
90 $SubsForumType=sql_result($apcresult,$apci,"ForumType");
91 $SubsForumShowTopics=sql_result($result,$i,"CanHaveTopics");
92 if(isset($PermissionInfo['CanViewForum'][$SubsForumID])&&
93 $PermissionInfo['CanViewForum'][$SubsForumID]=="yes") {
94 $ExStr = ""; if ($SubsForumType!="redirect"&&
95 $SubsForumShowTopics!="no") { $ExStr = "&page=1"; }
96 $shownum = null;
97 if ($SubsForumType=="redirect") { $shownum = "(".$NumRedirects." redirects)"; }
98 if ($SubsForumType!="redirect") { $shownum = "(".$NumsPosts." posts)"; }
99 $sfurl = "<a href=\"";
100 $sfurl = url_maker($exfile[$SubsForumType],$Settings['file_ext'],"act=lowview&id=".$SubsForumID.$ExStr,$Settings['qstr'],$Settings['qsep'],$prexqstr[$SubsForumType],$exqstr[$SubsForumType]);
101 $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>";
102 if($apcl==1) {
103 $sflist = null;
104 $sflist = $sflist." ".$sfurl; }
105 if($apcl>1) {
106 $sflist = $sflist." ".$sfurl; }
107 $gltf[$apcl] = $SubsForumID; ++$apcl; }
108 ++$apci; }
109 sql_free_result($apcresult); } }
110 if(isset($PermissionInfo['CanViewForum'][$ForumID])&&
111 $PermissionInfo['CanViewForum'][$ForumID]=="yes") {
112 $LastTopic = "&nbsp;<br />&nbsp;<br />&nbsp;";
113 if(!isset($LastTopic)) { $LastTopic = null; }
114 $gltnum = count($gltf); $glti = 0;
115 $OldUpdateTime = 0; $UseThisFonum = null;
116 if ($ForumType=="subforum") {
117 while ($glti < $gltnum) {
118 $ExtraIgnores = null;
119 if($PermissionInfo['CanModForum'][$gltf[$glti]]=="no") {
120 $ExtraIgnores = " AND \"Closed\"<>3"; }
121 $gltfoquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."topics\" WHERE \"ForumID\"=%i".$ExtraIgnores." ORDER BY \"LastUpdate\" DESC LIMIT 1", array($gltf[$glti]));
122 $gltforesult=sql_query($gltfoquery,$SQLStat);
123 $gltfonum=sql_num_rows($gltforesult);
124 if($gltfonum>0) {
125 $NewUpdateTime=sql_result($gltforesult,0,"LastUpdate");
126 if($NewUpdateTime>$OldUpdateTime) {
127 $UseThisFonum = $gltf[$glti];
128 $OldUpdateTime = $NewUpdateTime; } }
129 sql_free_result($gltforesult);
130 ++$glti; } }
131 $shownum = null;
132 if ($ForumType=="redirect") { $shownum = "(".$NumRedirects." redirects)"; }
133 if ($ForumType!="redirect") { $shownum = "(".$NumPosts." posts)"; }
134 $PreForum = $ThemeSet['ForumIcon'];
135 if ($ForumType=="forum") { $PreForum=$ThemeSet['ForumIcon']; }
136 if ($ForumType=="subforum") { $PreForum=$ThemeSet['SubForumIcon']; }
137 if ($ForumType=="redirect") { $PreForum=$ThemeSet['RedirectIcon']; }
138 $ExStr = ""; if ($ForumType!="redirect"&&
139 $ForumShowTopics!="no") { $ExStr = "&page=1"; }
141 <ul style="list-style-type: none;"><li>
142 <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>
143 <?php echo $sflist; ?></ul>
144 <?php } ++$i; } sql_free_result($result);
145 if($num>=1) {
147 <?php } }
148 ?></li><?php
149 ++$prei; }
150 sql_free_result($preresult); ?>
151 </ul></div>
152 <div>&nbsp;</div>