OSDN Git Service

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