OSDN Git Service

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