Small update to stats box. :)
[iDB.git] / inc / searchs.php
blob1be3944197973edeb2605d112db8132f5b32ee16
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-2010 iDB Support - http://idb.berlios.de/
12 Copyright 2004-2010 Game Maker 2k - http://gamemaker2k.org/
14 $FileInfo: searchs.php - Last Update: 09/05/2010 SVN 572 - Author: cooldude2k $
16 $File3Name = basename($_SERVER['SCRIPT_NAME']);
17 if ($File3Name=="searchs.php"||$File3Name=="/searchs.php") {
18 require('index.php');
19 exit(); }
20 if($Settings['enable_search']=="off"||
21 $GroupInfo['CanSearch']=="no") {
22 redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
23 header("Content-Type: text/plain; charset=".$Settings['charset']);
24 ob_clean(); echo "Sorry you do not have permission to do a search.";
25 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
26 $pagenum = null;
27 if($Settings['enable_search']=="on"||
28 $GroupInfo['CanSearch']=="yes") {
29 $_SESSION['ViewingPage'] = url_maker(null,"no+ext","act=topics","&","=",$prexqstr['search'],$exqstr['search']);
30 if($Settings['file_ext']!="no+ext"&&$Settings['file_ext']!="no ext") {
31 $_SESSION['ViewingFile'] = $exfile['search'].$Settings['file_ext']; }
32 if($Settings['file_ext']=="no+ext"||$Settings['file_ext']=="no ext") {
33 $_SESSION['ViewingFile'] = $exfile['search']; }
34 $_SESSION['PreViewingTitle'] = "Searching";
35 $_SESSION['ViewingTitle'] = "Topics";
36 if($_GET['act']=="topics") {
37 if($_GET['search']==null&&$_GET['type']==null) {
39 <div class="NavLinks"><?php echo $ThemeSet['NavLinkIcon']; ?><a href="<?php echo url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index']); ?>">Board index</a><?php echo $ThemeSet['NavLinkDivider']; ?><a href="<?php echo url_maker($exfile['search'],$Settings['file_ext'],"act=topics",$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search']); ?>">Search topics</a></div>
40 <div class="DivNavLinks">&nbsp;</div>
41 <div class="Table1Border">
42 <?php if($ThemeSet['TableStyle']=="div") { ?>
43 <div class="TableRow1">
44 <span style="text-align: left;">
45 <?php echo $ThemeSet['TitleIcon']; ?><a href="<?php echo url_maker($exfile['search'],$Settings['file_ext'],"act=topics",$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search']); ?>">Topic Search</a></span></div>
46 <?php } ?>
47 <table class="Table1">
48 <?php if($ThemeSet['TableStyle']=="table") { ?>
49 <tr id="SearchStart" class="TableRow1">
50 <td class="TableColumn1" colspan="6"><span style="text-align: left;">
51 <?php echo $ThemeSet['TitleIcon']; ?><a href="<?php echo url_maker($exfile['search'],$Settings['file_ext'],"act=topics",$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search']); ?>">Topic Search</a></span>
52 </td>
53 </tr><?php } ?>
54 <tr class="TableRow2">
55 <th class="TableColumn2" style="width: 100%; text-align: left;">&nbsp;Search for topic: </th>
56 </tr>
57 <tr class="TableRow3">
58 <td class="TableColumn3">
59 <form style="display: inline;" method="post" action="<?php echo url_maker($exfile['search'],$Settings['file_ext'],"act=topics",$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search']); ?>">
60 <table style="text-align: left;">
61 <tr style="text-align: left;">
62 <td style="width: 30%;"><label class="TextBoxLabel" for="search">Enter SearchTerm: </label></td>
63 <td style="width: 70%;"><input maxlength="35" class="TextBox" id="search" type="text" name="search" /></td>
64 </tr><tr style="text-align: left;">
65 <td style="width: 30%;"><label class="TextBoxLabel" for="msearch">Filter by Member (optional): </label></td>
66 <td style="width: 70%;"><input maxlength="25" class="TextBox" id="msearch" type="text" name="msearch" /></td>
67 </tr><tr style="text-align: left;">
68 <td style="width: 30%;"><label class="TextBoxLabel" title="Wildcard is %" for="type">Search Type: </label></td>
69 <td style="width: 70%;"><select id="type" name="type" class="TextBox">
70 <option value="normal">Normal Search</option>
71 <option value="wildcard">Wildcard Search</option>
72 </select></td>
73 </tr></table>
74 <table style="text-align: left;">
75 <tr style="text-align: left;">
76 <td style="width: 100%;">
77 <input type="hidden" name="act" value="topics" style="display: none;" />
78 <input class="Button" type="submit" value="Search" />
79 </td></tr></table>
80 </form>
81 </td>
82 </tr>
83 <tr class="TableRow4">
84 <td class="TableColumn4">&nbsp;</td>
85 </tr>
86 </table></div>
87 <?php } if($_GET['search']!=null&&$_GET['type']!=null) {
88 if(pre_strlen($_GET['msearch'])>="25") {
89 $_GET['msearch'] = null; }
90 if($_GET['msearch']!=null) {
91 $memsiquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."members\" WHERE \"Name\"='%s' LIMIT 1", array($_GET['msearch']));
92 $memsiresult=sql_query($memsiquery,$SQLStat);
93 $memsinum=sql_num_rows($memsiresult);
94 $memsi=0;
95 if($memsinum==0) { $memsid = -1; }
96 if($memsinum!=0) {
97 $memsid=sql_result($memsiresult,$memsi,"id");
98 sql_free_result($memsiresult); } }
99 //Get SQL LIMIT Number
100 $nums = $_GET['page'] * $Settings['max_topics'];
101 $PageLimit = $nums - $Settings['max_topics'];
102 if($PageLimit<0) { $PageLimit = 0; }
103 if($_GET['msearch']==null) {
104 if($_GET['type']!="wildcard") {
105 $query = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."topics\" WHERE \"TopicName\"='%s'".$ForumIgnoreList4." ORDER BY \"LastUpdate\" DESC ".$SQLimit, array($_GET['search'],$PageLimit,$Settings['max_topics']));
106 $rnquery = sql_pre_query("SELECT COUNT(*) FROM \"".$Settings['sqltable']."topics\" WHERE \"TopicName\"='%s'".$ForumIgnoreList4."", array($_GET['search'])); }
107 if($_GET['type']=="wildcard") {
108 $query = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."topics\" WHERE \"TopicName\" LIKE '%s'".$ForumIgnoreList4." ORDER BY \"LastUpdate\" DESC ".$SQLimit, array($_GET['search'],$PageLimit,$Settings['max_topics']));
109 $rnquery = sql_pre_query("SELECT COUNT(*) FROM \"".$Settings['sqltable']."topics\" WHERE \"TopicName\" LIKE '%s'".$ForumIgnoreList4."", array($_GET['search'])); } }
110 if($_GET['msearch']!=null) {
111 if($_GET['type']!="wildcard") {
112 $query = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."topics\" WHERE \"TopicName\"='%s' AND \"UserID\"=%i".$ForumIgnoreList4." ORDER BY \"LastUpdate\" DESC ".$SQLimit, array($_GET['search'],$memsid,$PageLimit,$Settings['max_topics']));
113 $rnquery = sql_pre_query("SELECT COUNT(*) FROM \"".$Settings['sqltable']."topics\" WHERE \"TopicName\"='%s' AND \"UserID\"=%i".$ForumIgnoreList4."", array($_GET['search']));
114 if($memsid==-1) {
115 $query = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."topics\" WHERE \"TopicName\"='%s' AND \"GuestName\"='%s'".$ForumIgnoreList4." ORDER BY \"LastUpdate\" DESC ".$SQLimit, array($_GET['search'],$_GET['msearch'],$PageLimit,$Settings['max_topics']));
116 $rnquery = sql_pre_query("SELECT COUNT(*) FROM \"".$Settings['sqltable']."topics\" WHERE \"TopicName\"='%s' AND \"GuestName\"='%s'".$ForumIgnoreList4."", array($_GET['search'],$_GET['msearch'])); } }
117 if($_GET['type']=="wildcard") {
118 $query = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."topics\" WHERE \"TopicName\" LIKE '%s' AND \"UserID\"=%i".$ForumIgnoreList4." ORDER BY \"LastUpdate\" DESC ".$SQLimit, array($_GET['search'],$memsid,$PageLimit,$Settings['max_topics']));
119 $rnquery = sql_pre_query("SELECT COUNT(*) FROM \"".$Settings['sqltable']."topics\" WHERE \"TopicName\" LIKE '%s' AND \"UserID\"=%i".$ForumIgnoreList4."", array($_GET['search'],$_GET['msearch']));
120 if($memsid==-1) {
121 $query = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."topics\" WHERE \"TopicName\" LIKE '%s' AND \"GuestName\"='%s'".$ForumIgnoreList4." ORDER BY \"LastUpdate\" DESC ".$SQLimit, array($_GET['search'],$_GET['msearch'],$PageLimit,$Settings['max_topics']));
122 $rnquery = sql_pre_query("SELECT COUNT(*) FROM \"".$Settings['sqltable']."topics\" WHERE \"TopicName\" LIKE '%s' AND \"GuestName\"='%s'".$ForumIgnoreList4."", array($_GET['search'],$_GET['msearch'])); } } }
123 $result=sql_query($query,$SQLStat);
124 $rnresult=sql_query($rnquery,$SQLStat);
125 $NumberTopics = sql_result($rnresult,0);
126 sql_free_result($rnresult);
127 if($NumberTopics==null) {
128 $NumberTopics = 0; }
129 $num = $NumberTopics;
130 //Start Topic Page Code
131 if(!isset($Settings['max_topics'])) { $Settings['max_topics'] = 10; }
132 if($_GET['page']==null) { $_GET['page'] = 1; }
133 if($_GET['page']<=0) { $_GET['page'] = 1; }
134 $nums = $_GET['page'] * $Settings['max_topics'];
135 if($nums>$num) { $nums = $num; }
136 $numz = $nums - $Settings['max_topics'];
137 if($numz<=0) { $numz = 0; }
138 //$i=$numz;
139 if($nums<$num) { $nextpage = $_GET['page'] + 1; }
140 if($nums>=$num) { $nextpage = $_GET['page']; }
141 if($numz>=$Settings['max_topics']) { $backpage = $_GET['page'] - 1; }
142 if($_GET['page']<=1) { $backpage = 1; }
143 $pnum = $num; $l = 1; $Pages = null;
144 while ($pnum>0) {
145 if($pnum>=$Settings['max_topics']) {
146 $pnum = $pnum - $Settings['max_topics'];
147 $Pages[$l] = $l; ++$l; }
148 if($pnum<$Settings['max_topics']&&$pnum>0) {
149 $pnum = $pnum - $pnum;
150 $Pages[$l] = $l; ++$l; } }
151 //End Topic Page Code
152 $num=sql_num_rows($result);
153 if($num<=0) {
154 redirect("location",$rbasedir.url_maker($exfile['search'],$Settings['file_ext'],"act=topics",$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search'],false));
155 header("Content-Type: text/plain; charset=".$Settings['charset']);
156 ob_clean(); echo "Sorry could not find any search results."; sql_free_result($result);
157 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
158 $i=0;
159 //List Page Number Code Start
160 $pagenum=count($Pages);
161 if($_GET['page']>$pagenum) {
162 $_GET['page'] = $pagenum; }
163 $pagei=0; $pstring = null;
164 if($pagenum>1) {
165 $pstring = "<div class=\"PageList\"><span class=\"pagelink\">".$pagenum." Pages:</span> "; }
166 if($_GET['page']<4) { $Pagez[0] = null; }
167 if($_GET['page']>=4) { $Pagez[0] = "First"; }
168 if($_GET['page']>=3) {
169 $Pagez[1] = $_GET['page'] - 2; }
170 if($_GET['page']<3) {
171 $Pagez[1] = null; }
172 if($_GET['page']>=2) {
173 $Pagez[2] = $_GET['page'] - 1; }
174 if($_GET['page']<2) {
175 $Pagez[2] = null; }
176 $Pagez[3] = $_GET['page'];
177 if($_GET['page']<$pagenum) {
178 $Pagez[4] = $_GET['page'] + 1; }
179 if($_GET['page']>=$pagenum) {
180 $Pagez[4] = null; }
181 $pagenext = $_GET['page'] + 1;
182 if($pagenext<$pagenum) {
183 $Pagez[5] = $_GET['page'] + 2; }
184 if($pagenext>=$pagenum) {
185 $Pagez[5] = null; }
186 if($_GET['page']<$pagenum) { $Pagez[6] = "Last"; }
187 if($_GET['page']>=$pagenum) { $Pagez[6] = null; }
188 $pagenumi=count($Pagez);
189 if($num==0) {
190 $pagenumi = 0;
191 if($_GET['msearch']==null) {
192 $pstring = null; }
193 if($_GET['msearch']!=null) {
194 $pstring = null; }
196 if($pagenum>1) {
197 while ($pagei < $pagenumi) {
198 if($_GET['msearch']==null) {
199 if($_GET['page']!=1&&$pagei==1) {
200 $Pback = $_GET['page'] - 1;
201 $pstring = $pstring."<span class=\"pagelink\"><a href=\"".url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&page=".$Pback,$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search'])."\">&lt;</a></span> "; } }
202 if($_GET['msearch']!=null) {
203 if($_GET['page']!=1&&$pagei==1) {
204 $Pback = $_GET['page'] - 1;
205 $pstring = $pstring."<span class=\"pagelink\"><a href=\"".url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&msearch=".$_GET['msearch']."&page=".$Pback,$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search'])."\">&lt;</a></span> "; } }
206 if($Pagez[$pagei]!=null&&
207 $Pagez[$pagei]!="First"&&
208 $Pagez[$pagei]!="Last") {
209 if($_GET['msearch']==null) {
210 if($pagei!=3) {
211 $pstring = $pstring."<span class=\"pagelink\"><a href=\"".url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&page=".$Pagez[$pagei],$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search'])."\">".$Pagez[$pagei]."</a></span> "; }
212 if($pagei==3) {
213 $pstring = $pstring."<span class=\"pagecurrent\"><a href=\"".url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&page=".$Pagez[$pagei],$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search'])."\">".$Pagez[$pagei]."</a></span> "; } }
214 if($_GET['msearch']!=null) {
215 if($pagei!=3) {
216 $pstring = $pstring."<span class=\"pagelink\"><a href=\"".url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&msearch=".$_GET['msearch']."&page=".$Pagez[$pagei],$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search'])."\">".$Pagez[$pagei]."</a></span> "; }
217 if($pagei==3) {
218 $pstring = $pstring."<span class=\"pagecurrent\"><a href=\"".url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&msearch=".$_GET['msearch']."&page=".$Pagez[$pagei],$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search'])."\">".$Pagez[$pagei]."</a></span> "; } } }
219 if($Pagez[$pagei]=="First") {
220 if($_GET['msearch']==null) {
221 $pstring = $pstring."<span class=\"pagelinklast\"><a href=\"".url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&page=1",$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search'])."\">&laquo;</a></span> "; }
222 if($_GET['msearch']!=null) {
223 $pstring = $pstring."<span class=\"pagelinklast\"><a href=\"".url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&msearch=".$_GET['msearch']."&page=1",$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search'])."\">&laquo;</a></span> "; } }
224 if($Pagez[$pagei]=="Last") {
225 if($_GET['msearch']==null) {
226 $ptestnext = $pagenext + 1;
227 $paget = $pagei - 1;
228 $Pnext = $_GET['page'] + 1;
229 $pstring = $pstring."<span class=\"pagelink\"><a href=\"".url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&page=".$Pnext,$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search'])."\">&gt;</a></span> ";
230 if($ptestnext<$pagenum) {
231 $pstring = $pstring."<span class=\"pagelinklast\"><a href=\"".url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&page=".$pagenum,$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search'])."\">&raquo;</a></span> "; } }
232 if($_GET['msearch']!=null) {
233 $ptestnext = $pagenext + 1;
234 $paget = $pagei - 1;
235 $Pnext = $_GET['page'] + 1;
236 $pstring = $pstring."<span class=\"pagelink\"><a href=\"".url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&msearch=".$_GET['msearch']."&page=".$Pnext,$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search'])."\">&gt;</a></span> ";
237 if($ptestnext<$pagenum) {
238 $pstring = $pstring."<span class=\"pagelinklast\"><a href=\"".url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&msearch=".$_GET['msearch']."&page=".$pagenum,$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search'])."\">&raquo;</a></span> "; } } }
239 ++$pagei; } $pstring = $pstring."</div>"; }
241 <div class="NavLinks"><?php echo $ThemeSet['NavLinkIcon']; ?><a href="<?php echo url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index']); ?>">Board index</a><?php echo $ThemeSet['NavLinkDivider']; ?><a href="<?php echo url_maker($exfile['search'],$Settings['file_ext'],"act=topics",$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search']); ?>">Search topics</a></div>
242 <div class="DivNavLinks">&nbsp;</div>
243 <?php
244 echo $pstring;
245 //List Page Number Code end
246 if($pagenum>1) {
248 <div class="DivPageLinks">&nbsp;</div>
249 <?php } ?>
250 <div class="Table1Border">
251 <?php if($ThemeSet['TableStyle']=="div") { ?>
252 <div class="TableRow1">
253 <span style="text-align: left;">
254 <?php echo $ThemeSet['TitleIcon'];
255 if($_GET['msearch']==null) { ?>
256 <a href="<?php echo url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&page=".$_GET['page'],$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search']); ?>">Searching for <?php echo $_GET['search']; ?></a>
257 <?php } if($_GET['msearch']!=null) { ?>
258 <a href="<?php echo url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&msearch=".$_GET['msearch']."&page=".$_GET['page'],$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search']); ?>">Searching for <?php echo $_GET['search']; ?> by <?php echo $_GET['msearch']; ?></a>
259 <?php } ?></span></div>
260 <?php } ?>
261 <table class="Table1">
262 <?php if($ThemeSet['TableStyle']=="table") { ?>
263 <tr id="SearchStart" class="TableRow1">
264 <td class="TableColumn1" colspan="6"><span style="text-align: left;">
265 <?php echo $ThemeSet['TitleIcon'];
266 if($_GET['msearch']==null) { ?>
267 <a href="<?php echo url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&page=".$_GET['page'],$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search']); ?>">Searching for <?php echo $_GET['search']; ?></a>
268 <?php } if($_GET['msearch']!=null) { ?>
269 <a href="<?php echo url_maker($exfile['search'],$Settings['file_ext'],"act=topics&search=".$_GET['search']."&type=".$_GET['type']."&msearch=".$_GET['msearch']."&page=".$_GET['page'],$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search']); ?>">Searching for <?php echo $_GET['search']; ?> by <?php echo $_GET['msearch']; ?></a>
270 <?php } ?></span>
271 </td>
272 </tr><?php } ?>
273 <tr id="SearchStatRow" class="TableRow2">
274 <th class="TableColumn2" style="width: 4%;">State</th>
275 <th class="TableColumn2" style="width: 36%;">Topic Name</th>
276 <th class="TableColumn2" style="width: 15%;">Author</th>
277 <th class="TableColumn2" style="width: 15%;">Time</th>
278 <th class="TableColumn2" style="width: 5%;">Replys</th>
279 <th class="TableColumn2" style="width: 25%;">Last Reply</th>
280 </tr>
281 <?php
282 while ($i < $num) {
283 $TopicID=sql_result($result,$i,"id");
284 $ForumID=sql_result($result,$i,"ForumID");
285 $prequery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"id\"=%i".$ForumIgnoreList2." LIMIT 1", array($ForumID));
286 $preresult=sql_query($prequery,$SQLStat);
287 $prenum=sql_num_rows($preresult);
288 $HotTopicPosts = $Settings['hot_topic_num'];
289 if($prenum > 0) {
290 $HotTopicPosts = sql_result($preresult,0,"HotTopicPosts"); }
291 sql_free_result($preresult);
292 if($HotTopicPosts!=0&&is_numeric($HotTopicPosts)) {
293 $Settings['hot_topic_num'] = $HotTopicPosts; }
294 if(!is_numeric($Settings['hot_topic_num'])) {
295 $Settings['hot_topic_num'] = 15; }
296 $CategoryID=sql_result($result,$i,"CategoryID");
297 $UsersID=sql_result($result,$i,"UserID");
298 $GuestsName=sql_result($result,$i,"GuestName");
299 $TheTime=sql_result($result,$i,"TimeStamp");
300 $TheTime=GMTimeChange("F j Y, g:i a",$TheTime,$_SESSION['UserTimeZone'],0,$_SESSION['UserDST']);
301 $NumReply=sql_result($result,$i,"NumReply");
302 $NumberPosts=$NumReply + 1;
303 $prepagelist = null;
304 if(!isset($Settings['max_posts'])) {
305 $Settings['max_posts'] = 10; }
306 if(!isset($ThemeSet['MiniPageAltStyle'])) {
307 $ThemeSet['MiniPageAltStyle'] = "off"; }
308 if($ThemeSet['MiniPageAltStyle']!="on"&&
309 $ThemeSet['MiniPageAltStyle']!="off") {
310 $ThemeSet['MiniPageAltStyle'] = "off"; }
311 if($NumberPosts>$Settings['max_posts']) {
312 $NumberPages = ceil($NumberPosts/$Settings['max_posts']); }
313 if($NumberPosts<=$Settings['max_posts']) {
314 $NumberPages = 1; }
315 if($NumberPages>4) {
316 $prepagelist = " &nbsp;"; }
317 if($NumberPages>=2) {
318 if($ThemeSet['MiniPageAltStyle']=="off") {
319 $prepagelist = "<span class=\"small\">(Pages: "; }
320 if($ThemeSet['MiniPageAltStyle']=="on") {
321 $prepagelist = $prepagelist."<span class=\"minipagelink\">"; }
322 $prepagelist = $prepagelist."<a href=\"".url_maker($exfile['topic'],$Settings['file_ext'],"act=view&id=".$TopicID."&page=1",$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic'])."\">1</a>";
323 if($ThemeSet['MiniPageAltStyle']=="on") {
324 $prepagelist = $prepagelist."</span>"; }
325 if($ThemeSet['MiniPageAltStyle']=="off") { $prepagelist = $prepagelist." "; }
326 if($ThemeSet['MiniPageAltStyle']=="on") {
327 $prepagelist = $prepagelist."<span class=\"minipagelink\">"; }
328 $prepagelist = $prepagelist."<a href=\"".url_maker($exfile['topic'],$Settings['file_ext'],"act=view&id=".$TopicID."&page=2",$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic'])."\">2</a>";
329 if($ThemeSet['MiniPageAltStyle']=="on") {
330 $prepagelist = $prepagelist."</span>"; }
331 if($NumberPages>=3) {
332 if($ThemeSet['MiniPageAltStyle']=="off") { $prepagelist = $prepagelist." "; }
333 if($ThemeSet['MiniPageAltStyle']=="on") {
334 $prepagelist = $prepagelist."<span class=\"minipagelink\">"; }
335 $prepagelist = $prepagelist."<a href=\"".url_maker($exfile['topic'],$Settings['file_ext'],"act=view&id=".$TopicID."&page=3",$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic'])."\">3</a>";
336 if($ThemeSet['MiniPageAltStyle']=="on") {
337 $prepagelist = $prepagelist."</span>"; } }
338 if($NumberPages==4) {
339 if($ThemeSet['MiniPageAltStyle']=="off") { $prepagelist = $prepagelist." "; }
340 if($ThemeSet['MiniPageAltStyle']=="on") {
341 $prepagelist = $prepagelist."<span class=\"minipagelinklast\">"; }
342 if($ThemeSet['MiniPageAltStyle']=="on") {
343 $prepagelist = $prepagelist."<a href=\"".url_maker($exfile['topic'],$Settings['file_ext'],"act=view&id=".$TopicID."&page=4",$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic'])."\">4</a>"; }
344 if($ThemeSet['MiniPageAltStyle']=="off") {
345 $prepagelist = $prepagelist."<a href=\"".url_maker($exfile['topic'],$Settings['file_ext'],"act=view&id=".$TopicID."&page=4",$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic'])."\"> ...4</a>"; }
346 if($ThemeSet['MiniPageAltStyle']=="on") {
347 $prepagelist = $prepagelist."</span>"; } }
348 if($NumberPages>4) {
349 if($ThemeSet['MiniPageAltStyle']=="off") { $prepagelist = $prepagelist." "; }
350 if($ThemeSet['MiniPageAltStyle']=="on") {
351 $prepagelist = $prepagelist."<span class=\"minipagelinklast\">"; }
352 if($ThemeSet['MiniPageAltStyle']=="on") {
353 $prepagelist = $prepagelist."<a href=\"".url_maker($exfile['topic'],$Settings['file_ext'],"act=view&id=".$TopicID."&page=".$NumberPages,$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic'])."\">&raquo; ".$NumberPages."</a>"; }
354 if($ThemeSet['MiniPageAltStyle']=="off") {
355 $prepagelist = $prepagelist."<a href=\"".url_maker($exfile['topic'],$Settings['file_ext'],"act=view&id=".$TopicID."&page=".$NumberPages,$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic'])."\"> ...".$NumberPages."</a>"; }
356 if($ThemeSet['MiniPageAltStyle']=="on") {
357 $prepagelist = $prepagelist."</span>"; } }
358 if($ThemeSet['MiniPageAltStyle']=="off") {
359 $prepagelist = $prepagelist.")</span>"; } }
360 $TopicName=sql_result($result,$i,"TopicName");
361 $TopicDescription=sql_result($result,$i,"Description");
362 $PinnedTopic=sql_result($result,$i,"Pinned");
363 if ($PinnedTopic>2) { $PinnedTopic = 1; }
364 if ($PinnedTopic<0) { $PinnedTopic = 0; }
365 if(!is_numeric($PinnedTopic)) { $PinnedTopic = 0; }
366 $TopicStat=sql_result($result,$i,"Closed");
367 if ($TopicStat>3) { $TopicStat = 1; }
368 if ($TopicStat<0) { $TopicStat = 0; }
369 if(!is_numeric($TopicStat)) { $TopicStat = 1; }
370 $PreUsersName = GetUserName($UsersID,$Settings['sqltable'],$SQLStat);
371 if($PreUsersName['Name']===null) { $UsersID = -1;
372 $PreUsersName = GetUserName($UsersID,$Settings['sqltable'],$SQLStat); }
373 $UsersName = $PreUsersName['Name'];
374 $UsersHidden = $PreUsersName['Hidden'];
375 if($UsersName=="Guest") { $UsersName=$GuestsName;
376 if($UsersName==null) { $UsersName="Guest"; } }
377 if(($PermissionInfo['CanViewForum'][$ForumID]=="yes"&&
378 $CatPermissionInfo['CanViewCategory'][$CategoryID]=="yes"&&
379 $TopicStat>=0&&$TopicStat<3)||
380 ($PermissionInfo['CanViewForum'][$ForumID]=="yes"&&
381 $CatPermissionInfo['CanViewCategory'][$CategoryID]=="yes"&&
382 $PermissionInfo['CanModForum'][$ForumID]=="yes"&&$TopicStat==3)) {
383 $LastReply = "&nbsp;<br />&nbsp;";
384 $glrquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."posts\" WHERE \"TopicID\"=%i ORDER BY \"TimeStamp\" DESC LIMIT 1", array($TopicID));
385 $glrresult=sql_query($glrquery,$SQLStat);
386 $glrnum=sql_num_rows($glrresult);
387 if($glrnum>0){
388 $ReplyID1=sql_result($glrresult,0,"id");
389 $UsersID1=sql_result($glrresult,0,"UserID");
390 $GuestsName1=sql_result($glrresult,0,"GuestName");
391 $TimeStamp1=sql_result($glrresult,0,"TimeStamp");
392 $TimeStamp1=GMTimeChange("F j Y, g:i a",$TimeStamp1,$_SESSION['UserTimeZone'],0,$_SESSION['UserDST']);
393 $PreUsersName1 = GetUserName($UsersID1,$Settings['sqltable'],$SQLStat);
394 if($PreUsersName1['Name']===null) { $UsersID1 = -1;
395 $PreUsersName1 = GetUserName($UsersID1,$Settings['sqltable'],$SQLStat); }
396 $UsersName1 = $PreUsersName1['Name'];
397 $UsersHidden1 = $PreUsersName1['Hidden']; }
398 $NumPages = null; $NumRPosts = $NumReply + 1;
399 if(!isset($Settings['max_posts'])) { $Settings['max_posts'] = 10; }
400 if($NumRPosts>$Settings['max_posts']) {
401 $NumPages = ceil($NumRPosts/$Settings['max_posts']); }
402 if($NumRPosts<=$Settings['max_posts']) { $NumPages = 1; }
403 $Users_Name1 = pre_substr($UsersName1,0,20);
404 if($UsersName1=="Guest") { $UsersName1=$GuestsName1;
405 if($UsersName1==null) { $UsersName1="Guest"; } }
406 if (pre_strlen($UsersName1)>20) { $Users_Name1 = $Users_Name1."...";
407 $oldusername=$UsersName1; $UsersName1=$Users_Name1; } $lul = null;
408 if($TimeStamp1!=null) { $lul = null;
409 if($UsersID1>0&&$UsersHidden1=="no") {
410 $lul = url_maker($exfile['member'],$Settings['file_ext'],"act=view&id=".$UsersID1,$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member']);
411 $luln = url_maker($exfile['topic'],$Settings['file_ext'],"act=view&id=".$TopicID."&page=".$NumPages,$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic']).$qstrhtml."&#35;reply".$NumRPosts;
412 $LastReply = "Time: <a href=\"".$luln."\">".$TimeStamp1."</a><br />\nUser: <a href=\"".$lul."\" title=\"".$oldusername."\">".$UsersName1."</a>"; }
413 if($UsersID1<=0||$UsersHidden1=="yes") {
414 if($UsersID1==-1) { $UserPre = "Guest:"; }
415 if(($UsersID1<-1&&$UsersHidden1=="yes")||$UsersID1==0||($UsersID1>0&&$UsersHidden1=="yes")) {
416 $UserPre = "Hidden:"; }
417 $lul = url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index']);
418 $luln = url_maker($exfile['topic'],$Settings['file_ext'],"act=view&id=".$TopicID."&page=".$NumPages,$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic']).$qstrhtml."&#35;reply".$NumRPosts;
419 $LastReply = "Time: <a href=\"".$luln."\">".$TimeStamp1."</a><br />\n".$UserPre." <span title=\"".$oldusername."\">".$UsersName1."</span>"; } }
420 sql_free_result($glrresult);
421 if($TimeStamp1==null) { $LastReply = "&nbsp;<br />&nbsp;"; }
422 $PreTopic = $ThemeSet['TopicIcon'];
423 if ($PinnedTopic>0&&$PinnedTopic<3&&$TopicStat==0) {
424 if($NumReply>=$Settings['hot_topic_num']) {
425 $PreTopic=$ThemeSet['HotPinTopic']; }
426 if($NumReply<$Settings['hot_topic_num']) {
427 $PreTopic=$ThemeSet['PinTopic']; } }
428 if ($TopicStat>=0&&$TopicStat<=3&&$PinnedTopic==0) {
429 if($NumReply>=$Settings['hot_topic_num']) {
430 $PreTopic=$ThemeSet['HotClosedTopic']; }
431 if($NumReply<$Settings['hot_topic_num']) {
432 $PreTopic=$ThemeSet['ClosedTopic']; } }
433 if ($PinnedTopic==0&&$TopicStat==0) {
434 if($NumReply>=$Settings['hot_topic_num']) {
435 $PreTopic=$ThemeSet['HotTopic']; }
436 if($NumReply<$Settings['hot_topic_num']) {
437 $PreTopic=$ThemeSet['TopicIcon']; } }
438 if ($PinnedTopic>0&&$PinnedTopic<3&&$TopicStat>=0&&$TopicStat<=3) {
439 if($NumReply>=$Settings['hot_topic_num']) {
440 $PreTopic=$ThemeSet['HotPinClosedTopic']; }
441 if($NumReply<$Settings['hot_topic_num']) {
442 $PreTopic=$ThemeSet['PinClosedTopic']; } }
444 <tr class="TableRow3" id="Topic<?php echo $TopicID; ?>">
445 <td class="TableColumn3"><div class="topicstate">
446 <?php echo $PreTopic; ?></div></td>
447 <td class="TableColumn3"><div class="topicname">
448 <a href="<?php echo url_maker($exfile['topic'],$Settings['file_ext'],"act=view&id=".$TopicID,$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic']); ?>"><?php echo $TopicName; ?></a>
449 <?php if($prepagelist!==null) { echo $prepagelist; } ?></div>
450 <div class="topicdescription"><?php echo $TopicDescription; ?></div></td>
451 <td class="TableColumn3" style="text-align: center;"><?php
452 if($UsersID>0) {
453 echo "<a href=\"";
454 echo url_maker($exfile['member'],$Settings['file_ext'],"act=view&id=".$UsersID,$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member']);
455 echo "\">".$UsersName."</a>"; }
456 if($UsersID<=0) {
457 echo "<span>".$UsersName."</span>"; }
458 ?></td>
459 <td class="TableColumn3" style="text-align: center;"><?php echo $TheTime; ?></td>
460 <td class="TableColumn3" style="text-align: center;"><?php echo $NumReply; ?></td>
461 <td class="TableColumn3"><?php echo $LastReply; ?></td>
462 </tr>
463 <?php } ++$i; }
465 <tr id="SearchEnd" class="TableRow4">
466 <td class="TableColumn4" colspan="6">&nbsp;</td>
467 </tr>
468 </table></div>
469 <?php if($pagenum>1) { ?>
470 <div class="DivSearch">&nbsp;</div>
471 <?php }
472 echo $pstring;
473 //List Page Number Code end
474 if($pagenum>1) {
476 <div class="DivPageLinks">&nbsp;</div>
477 <?php }
478 sql_free_result($result); } } }
479 if($pagenum<=1) { ?>
480 <div class="DivSearch">&nbsp;</div>
481 <?php } ?>