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: lowtopics.php - Last Update: 12/07/2010 SVN 600 - Author: cooldude2k $
16 $File3Name = basename($_SERVER['SCRIPT_NAME']);
17 if ($File3Name=="lowtopics.php"||
$File3Name=="/lowtopics.php") {
20 $pstring = null; $pagenum = null;
21 if(!is_numeric($_GET['id'])) { $_GET['id'] = null; }
22 if(!is_numeric($_GET['page'])) { $_GET['page'] = 1; }
23 $prequery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"id\"=%i".$ForumIgnoreList2." LIMIT 1", array($_GET['id']));
24 $preresult=sql_query($prequery,$SQLStat);
25 $prenum=sql_num_rows($preresult);
26 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);
27 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']);
28 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
30 $ForumID=sql_result($preresult,0,"id");
31 $ForumCatID=sql_result($preresult,0,"CategoryID");
32 $ForumName=sql_result($preresult,0,"Name");
33 $ForumType=sql_result($preresult,0,"ForumType");
34 $InSubForum=sql_result($preresult,0,"InSubForum");
35 $RedirectURL=sql_result($preresult,0,"RedirectURL");
36 $RedirectTimes=sql_result($preresult,0,"Redirects");
37 $NumberViews=sql_result($preresult,0,"NumViews");
38 $NumberPosts=sql_result($preresult,0,"NumPosts");
39 $NumberTopics=sql_result($preresult,0,"NumTopics");
40 $PostCountAdd=sql_result($preresult,0,"PostCountAdd");
41 $CanHaveTopics=sql_result($preresult,0,"CanHaveTopics");
42 $HotTopicPosts=sql_result($preresult,0,"HotTopicPosts");
43 if($HotTopicPosts!=0&&is_numeric($HotTopicPosts)) {
44 $Settings['hot_topic_num'] = $HotTopicPosts; }
45 if(!is_numeric($Settings['hot_topic_num'])) {
46 $Settings['hot_topic_num'] = 15; }
47 $ForumPostCountView=sql_result($preresult,0,"PostCountView");
48 $ForumKarmaCountView=sql_result($preresult,0,"KarmaCountView");
49 sql_free_result($preresult);
50 $ForumType = strtolower($ForumType); $CanHaveTopics = strtolower($CanHaveTopics);
51 $catcheck = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."categories\" WHERE \"id\"=%i".$CatIgnoreList2." LIMIT 1", array($ForumCatID));
52 $catresult=sql_query($catcheck,$SQLStat);
53 $CategoryName=sql_result($catresult,0,"Name");
54 $CategoryType=sql_result($catresult,0,"CategoryType");
55 $CategoryPostCountView=sql_result($catresult,0,"PostCountView");
56 $CategoryKarmaCountView=sql_result($catresult,0,"KarmaCountView");
57 sql_free_result($catresult);
58 if($GroupInfo['HasAdminCP']!="yes"||
$GroupInfo['HasModCP']!="yes") {
59 if($MyPostCountChk==null) { $MyPostCountChk = 0; }
60 if($MyKarmaCount==null) { $MyKarmaCount = 0; }
61 if($ForumPostCountView!=0&&$MyPostCountChk<$ForumPostCountView) {
62 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); }
63 if($CategoryPostCountView!=0&&$MyPostCountChk<$CategoryPostCountView) {
64 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); }
65 if($ForumKarmaCountView!=0&&$MyKarmaCount<$ForumKarmaCountView) {
66 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); }
67 if($CategoryKarmaCountView!=0&&$MyKarmaCount<$CategoryKarmaCountView) {
68 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); } }
69 if($InSubForum!="0") {
70 $isfquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"id\"=%i".$ForumIgnoreList2." LIMIT 1", array($InSubForum));
71 $isfresult=sql_query($isfquery,$SQLStat);
72 $isfnum=sql_num_rows($isfresult);
74 $isfForumID=sql_result($isfresult,0,"id");
75 $isfForumCatID=sql_result($isfresult,0,"CategoryID");
76 $isfForumName=sql_result($isfresult,0,"Name");
77 $isfForumType=sql_result($isfresult,0,"ForumType");
78 $isfForumType = strtolower($isfForumType);
79 $isfRedirectURL=sql_result($isfresult,0,"RedirectURL"); }
80 if($isfnum<1) { $InSubForum = "0"; }
81 sql_free_result($isfresult); }
82 $_SESSION['ViewingPage'] = url_maker(null,"no+ext","act=lowview&id=".$ForumID."&page=".$_GET['page'],"&","=",$prexqstr[$ForumType],$exqstr[$ForumType]);
83 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
84 $_SESSION['ViewingFile'] = $exfile[$ForumType].$Settings['file_ext']; }
85 if($Settings['file_ext']=="no+ext"||
$Settings['file_ext']=="no ext") {
86 $_SESSION['ViewingFile'] = $exfile[$ForumType]; }
87 $_SESSION['PreViewingTitle'] = "Viewing Forum:";
88 $_SESSION['ViewingTitle'] = $ForumName;
89 if($ForumCheck!="skip") {
91 <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['forum'],$Settings['file_ext'],"act
=view
&id
=".$ForumID."&page
=".$_GET['page'],$Settings['qstr'],$Settings['qsep'],$prexqstr['forum'],$exqstr['forum']); ?>"><?php
echo $ForumName; ?
></a
></div
>
92 <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
echo $ThemeSet['NavLinkDivider']; ?
><a href
="<?php echo url_maker($exfile[$CategoryType],$Settings['file_ext'],"act
=lowview
&id
=".$ForumCatID,$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
>
95 if(!isset($CatPermissionInfo['CanViewCategory'][$ForumCatID])) {
96 $CatPermissionInfo['CanViewCategory'][$ForumCatID] = "no"; }
97 if($CatPermissionInfo['CanViewCategory'][$ForumCatID]=="no"||
98 $CatPermissionInfo['CanViewCategory'][$ForumCatID]!="yes") {
99 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
100 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']);
101 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
102 if(!isset($PermissionInfo['CanViewForum'][$ForumID])) {
103 $PermissionInfo['CanViewForum'][$ForumID] = "no"; }
104 if($PermissionInfo['CanViewForum'][$ForumID]=="no"||
105 $PermissionInfo['CanViewForum'][$ForumID]!="yes") {
106 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
107 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']);
108 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
109 if($CatPermissionInfo['CanViewCategory'][$ForumCatID]=="yes"&&
110 $PermissionInfo['CanViewForum'][$ForumID]=="yes") {
111 if($ForumType!="redirect") {
112 if($NumberViews==0||
$NumberViews==null) { $NewNumberViews = 1; }
113 if($NumberViews!=0&&$NumberViews!=null) { $NewNumberViews = $NumberViews +
1; }
114 $viewup = sql_pre_query("UPDATE \"".$Settings['sqltable']."forums\" SET \"NumViews\"=%i WHERE \"id\"=%i", array($NewNumberViews,$_GET['id']));
115 sql_query($viewup,$SQLStat); }
116 if($ForumType=="redirect") {
117 if($RedirectTimes==0||
$RedirectTimes==null) { $NewRedirTime = 1; }
118 if($RedirectTimes!=0&&$RedirectTimes!=null) { $NewRedirTime = $RedirectTimes +
1; }
119 $redirup = sql_pre_query("UPDATE \"".$Settings['sqltable']."forums\" SET \"Redirects\"=%i WHERE \"id\"=%i", array($NewRedirTime,$_GET['id']));
120 sql_query($redirup,$SQLStat);
121 if($RedirectURL!="http://"&&$RedirectURL!="") {
122 redirect("location",$RedirectURL,0,null,false); ob_clean();
123 header("Content-Type: text/plain; charset=".$Settings['charset']);
124 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
125 if($RedirectURL=="http://"||
$RedirectURL=="") {
126 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=lowview",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
127 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']);
128 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); } }
129 if($ForumCheck!="skip") {
130 if($ForumType=="subforum") {
131 redirect("location",$rbasedir.url_maker($exfile['subforum'],$Settings['file_ext'],"act=".$_GET['act']."&id=".$_GET['id'],$Settings['qstr'],$Settings['qsep'],$prexqstr['subforum'],$exqstr['subforum'],FALSE));
132 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']);
133 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); } }
134 if($_GET['act']=="lowview") {
135 if($NumberTopics==null) {
138 //Start Topic Page Code
139 if(!isset($Settings['max_topics'])) { $Settings['max_topics'] = 10; }
140 if($_GET['page']==null) { $_GET['page'] = 1; }
141 if($_GET['page']<=0) { $_GET['page'] = 1; }
142 $nums = $_GET['page'] * $Settings['max_topics'];
143 if($nums>$num) { $nums = $num; }
144 $numz = $nums - $Settings['max_topics'];
145 if($numz<=0) { $numz = 0; }
147 if($nums<$num) { $nextpage = $_GET['page'] +
1; }
148 if($nums>=$num) { $nextpage = $_GET['page']; }
149 if($numz>=$Settings['max_topics']) { $backpage = $_GET['page'] - 1; }
150 if($_GET['page']<=1) { $backpage = 1; }
151 $pnum = $num; $l = 1; $Pages = null;
153 if($pnum>=$Settings['max_topics']) {
154 $pnum = $pnum - $Settings['max_topics'];
155 $Pages[$l] = $l; ++
$l; }
156 if($pnum<$Settings['max_topics']&&$pnum>0) {
157 $pnum = $pnum - $pnum;
158 $Pages[$l] = $l; ++
$l; } }
159 $snumber = $_GET['page'] - 1;
160 $PageLimit = $Settings['max_topics'] * $snumber;
161 if($PageLimit<0) { $PageLimit = 0; }
162 //End Topic Page Code
164 $ExtraIgnores = null;
165 if($PermissionInfo['CanModForum'][$_GET['id']]=="no") {
166 $ExtraIgnores = " AND \"Closed\"<>3"; }
167 $query = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."topics\" WHERE \"ForumID\"=%i".$ExtraIgnores.$ForumIgnoreList4." ORDER BY \"Pinned\" DESC, \"LastUpdate\" DESC ".$SQLimit, array($_GET['id'],$PageLimit,$Settings['max_topics']));
168 $result=sql_query($query,$SQLStat);
169 $num=sql_num_rows($result);
170 //List Page Number Code Start
171 $pagenum=count($Pages);
172 if($_GET['page']>$pagenum) {
173 $_GET['page'] = $pagenum; }
174 $pagei=0; $pstring = null;
176 $pstring = "<div class=\"PageList\"><span class=\"pagelink\">".$pagenum." Pages:</span> "; }
177 if($_GET['page']<4) { $Pagez[0] = null; }
178 if($_GET['page']>=4) { $Pagez[0] = "First"; }
179 if($_GET['page']>=3) {
180 $Pagez[1] = $_GET['page'] - 2; }
181 if($_GET['page']<3) {
183 if($_GET['page']>=2) {
184 $Pagez[2] = $_GET['page'] - 1; }
185 if($_GET['page']<2) {
187 $Pagez[3] = $_GET['page'];
188 if($_GET['page']<$pagenum) {
189 $Pagez[4] = $_GET['page'] +
1; }
190 if($_GET['page']>=$pagenum) {
192 $pagenext = $_GET['page'] +
1;
193 if($pagenext<$pagenum) {
194 $Pagez[5] = $_GET['page'] +
2; }
195 if($pagenext>=$pagenum) {
197 if($_GET['page']<$pagenum) { $Pagez[6] = "Last"; }
198 if($_GET['page']>=$pagenum) { $Pagez[6] = null; }
199 $pagenumi=count($Pagez);
200 if($NumberTopics==0) {
204 while ($pagei < $pagenumi) {
205 if($_GET['page']!=1&&$pagei==1) {
206 $Pback = $_GET['page'] - 1;
207 $pstring = $pstring."<span class=\"pagelink\"><a href=\"".url_maker($exfile[$ForumType],$Settings['file_ext'],"act=lowview&id=".$_GET['id']."&page=".$Pback,$Settings['qstr'],$Settings['qsep'],$prexqstr[$ForumType],$exqstr[$ForumType])."\"><</a></span> "; }
208 if($Pagez[$pagei]!=null&&
209 $Pagez[$pagei]!="First"&&
210 $Pagez[$pagei]!="Last") {
212 $pstring = $pstring."<span class=\"pagelink\"><a href=\"".url_maker($exfile[$ForumType],$Settings['file_ext'],"act=lowview&id=".$_GET['id']."&page=".$Pagez[$pagei],$Settings['qstr'],$Settings['qsep'],$prexqstr[$ForumType],$exqstr[$ForumType])."\">".$Pagez[$pagei]."</a></span> "; }
214 $pstring = $pstring."<span class=\"pagecurrent\"><a href=\"".url_maker($exfile[$ForumType],$Settings['file_ext'],"act=lowview&id=".$_GET['id']."&page=".$Pagez[$pagei],$Settings['qstr'],$Settings['qsep'],$prexqstr[$ForumType],$exqstr[$ForumType])."\">".$Pagez[$pagei]."</a></span> "; } }
215 if($Pagez[$pagei]=="First") {
216 $pstring = $pstring."<span class=\"pagelinklast\"><a href=\"".url_maker($exfile[$ForumType],$Settings['file_ext'],"act=lowview&id=".$_GET['id']."&page=1",$Settings['qstr'],$Settings['qsep'],$prexqstr[$ForumType],$exqstr[$ForumType])."\">«</a></span> "; }
217 if($Pagez[$pagei]=="Last") {
218 $ptestnext = $pagenext +
1;
220 $Pnext = $_GET['page'] +
1;
221 $pstring = $pstring."<span class=\"pagelink\"><a href=\"".url_maker($exfile[$ForumType],$Settings['file_ext'],"act=lowview&id=".$_GET['id']."&page=".$Pnext,$Settings['qstr'],$Settings['qsep'],$prexqstr[$ForumType],$exqstr[$ForumType])."\">></a></span> ";
222 if($ptestnext<$pagenum) {
223 $pstring = $pstring."<span class=\"pagelinklast\"><a href=\"".url_maker($exfile[$ForumType],$Settings['file_ext'],"act=lowview&id=".$_GET['id']."&page=".$pagenum,$Settings['qstr'],$Settings['qsep'],$prexqstr[$ForumType],$exqstr[$ForumType])."\">»</a></span> "; } }
224 ++
$pagei; } $pstring = $pstring."</div>"; }
226 <div style
="font-size: 11px; font-weight: bold; padding: 10px; border: 1px solid gray;">
227 <?php
echo $pstring; ?
></div
>
229 <div style
="padding: 10px; border: 1px solid gray;">
230 <?php
if($num<=0) { ?
>
231 <ul style
="list-style-type: none;">
233 <?php
} if($num>0) { ?
>
234 <ul style
="list-style-type: decimal;">
237 $TopicID=sql_result($result,$i,"id");
238 $TForumID=sql_result($result,$i,"ForumID");
239 $OldForumID=sql_result($result,$i,"OldForumID");
240 $UsersID=sql_result($result,$i,"UserID");
241 $GuestsName=sql_result($result,$i,"GuestName");
242 $TheTime=sql_result($result,$i,"TimeStamp");
243 $TheTime=GMTimeChange("F j Y, g:i a",$TheTime,$_SESSION['UserTimeZone'],0,$_SESSION['UserDST']);
244 $NumReply=sql_result($result,$i,"NumReply");
245 $NumberPosts=$NumReply +
1;
247 if(!isset($Settings['max_posts'])) {
248 $Settings['max_posts'] = 10; }
249 $TopicName=sql_result($result,$i,"TopicName");
250 $TopicDescription=sql_result($result,$i,"Description");
251 $PinnedTopic=sql_result($result,$i,"Pinned");
252 $TopicStat=sql_result($result,$i,"Closed");
254 if ($PinnedTopic>2) { $PinnedTopic = 1; }
255 if ($PinnedTopic<0) { $PinnedTopic = 0; }
256 if(!is_numeric($PinnedTopic)) { $PinnedTopic = 0; }
257 if ($TopicStat>3) { $TopicStat = 1; }
258 if ($TopicStat<0) { $TopicStat = 0; }
259 if(!is_numeric($TopicStat)) { $TopicStat = 1; }
260 if ($PinnedTopic>0&&$PinnedTopic<3) { $PreTopic="<span style=\"font-weight: bold;\">Pinned: </span>"; }
261 if ($PinnedTopic==0) { $PreTopic=null; }
262 if ($OldForumID==$ForumID&&$TForumID!=$ForumID) { $PreTopic="<span>Moved: </span>"; }
264 <li
><?php
echo $PreTopic; ?
><a href
="<?php echo url_maker($exfile['topic'],$Settings['file_ext'],"act
=lowview
&id
=".$TopicID."&page
=1",$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic']); ?>"><?php
echo $TopicName; ?
></a
> <span style
="color: gray; font-size: 10px;">(<?php
echo $NumReply; ?
> replies
)</span
></li
>
266 </ul
></div
><div
> 
;</div
>
267 <?php
sql_free_result($result); } } } ?
>