OSDN Git Service

Another small update.
[idb/iDB.git.git] / inc / searchs.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-2008 Cool Dude 2k - http://idb.berlios.de/
12     Copyright 2004-2008 Game Maker 2k - http://intdb.sourceforge.net/
13
14     $FileInfo: searchs.php - Last Update: 12/12/2008 SVN 215 - Author: cooldude2k $
15 */
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",$basedir.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']); @mysql_close(); die(); }
26 if($Settings['enable_search']=="on"||
27         $GroupInfo['CanSearch']=="yes") {
28 if($_GET['act']=="topics") {
29         if($_GET['search']==null&&$_GET['type']==null) {
30         ?>
31 <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>
32 <div class="DivNavLinks">&nbsp;</div>
33 <div class="Table1Border">
34 <?php if($ThemeSet['TableStyle']=="div") { ?>
35 <div class="TableRow1">
36 <span style="text-align: left;">
37 <?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>
38 <?php } ?>
39 <table class="Table1">
40 <?php if($ThemeSet['TableStyle']=="table") { ?>
41 <tr id="ForumStart<?php echo $ForumID; ?>" class="TableRow1">
42 <td class="TableColumn1" colspan="6"><span style="text-align: left;">
43 <?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>
44 </td>
45 </tr><?php } ?>
46 <tr class="TableRow2">
47 <th class="TableColumn2" style="width: 100%; text-align: left;">&nbsp;Search for topic: </th>
48 </tr>
49 <tr class="TableRow3">
50 <td class="TableColumn3">
51 <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']); ?>">
52 <table style="text-align: left;">
53 <tr style="text-align: left;">
54         <td style="width: 30%;"><label class="TextBoxLabel" for="search">Enter SearchTerm: </label></td>
55         <td style="width: 70%;"><input maxlength="35" class="TextBox" id="search" type="text" name="search" /></td>
56 </tr><tr style="text-align: left;">
57         <td style="width: 30%;"><label class="TextBoxLabel" for="msearch">Filter by Member (optional): </label></td>
58         <td style="width: 70%;"><input maxlength="25" class="TextBox" id="msearch" type="text" name="msearch" /></td>
59 </tr><tr style="text-align: left;">
60         <td style="width: 30%;"><label class="TextBoxLabel" title="Wildcard is %" for="type">Search Type: </label></td>
61         <td style="width: 70%;"><select id="type" name="type" class="TextBox">
62 <option value="normal">Normal Search</option>
63 <option value="wildcard">Wildcard Search</option>
64 </select></td>
65 </tr></table>
66 <table style="text-align: left;">
67 <tr style="text-align: left;">
68 <td style="width: 100%;">
69 <input type="hidden" name="act" value="topics" style="display: none;" />
70 <input class="Button" type="submit" value="Search" />
71 </td></tr></table>
72 </form>
73 </td>
74 </tr>
75 <tr class="TableRow4">
76 <td class="TableColumn4">&nbsp;</td>
77 </tr>
78 </table></div>
79 <?php } if($_GET['search']!=null&&$_GET['type']!=null) {
80 if(pre_strlen($_GET['msearch'])>="25") { 
81         $_GET['msearch'] = null; }
82 if($_GET['msearch']!=null) {
83 $memsiquery = query("SELECT * FROM `".$Settings['sqltable']."members` WHERE `Name`='%s' LIMIT 1", array($_GET['msearch']));
84 $memsiresult=mysql_query($memsiquery);
85 $memsinum=mysql_num_rows($memsiresult);
86 $memsi=0;
87 if($memsinum==0) { $_GET['msearch'] = null; }
88 if($memsinum!=0) {
89 $memsid=mysql_result($memsiresult,$memsi,"id"); 
90 @mysql_free_result($memsiresult); } }
91 //Get SQL LIMIT Number
92 $nums = $_GET['page'] * $Settings['max_topics'];
93 $PageLimit = $nums - $Settings['max_topics'];
94 if($PageLimit<0) { $PageLimit = 0; }
95 if($_GET['msearch']==null) {
96 if($_GET['type']!="wildcard") {
97 $query = query("SELECT SQL_CALC_FOUND_ROWS * FROM `".$Settings['sqltable']."topics` WHERE `TopicName`='%s' ORDER BY `Pinned` DESC, `LastUpdate` DESC LIMIT %i,%i", array($_GET['search'],$PageLimit,$Settings['max_topics'])); }
98 if($_GET['type']=="wildcard") {
99 $query = query("SELECT SQL_CALC_FOUND_ROWS * FROM `".$Settings['sqltable']."topics` WHERE `TopicName` LIKE '%s' ORDER BY `Pinned` DESC, `LastUpdate` DESC LIMIT %i,%i", array($_GET['search'],$PageLimit,$Settings['max_topics'])); } }
100 if($_GET['msearch']!=null) {
101 if($_GET['type']!="wildcard") {
102 $query = query("SELECT SQL_CALC_FOUND_ROWS * FROM `".$Settings['sqltable']."topics` WHERE `TopicName`='%s' AND `UserID`=%i ORDER BY `Pinned` DESC, `LastUpdate` DESC LIMIT %i,%i", array($_GET['search'],$memsid,$PageLimit,$Settings['max_topics'])); }
103 if($_GET['type']=="wildcard") {
104 $query = query("SELECT SQL_CALC_FOUND_ROWS * FROM `".$Settings['sqltable']."topics` WHERE `TopicName` LIKE '%s' AND `UserID`=%i ORDER BY `Pinned` DESC, `LastUpdate` DESC LIMIT %i,%i", array($_GET['search'],$memsid,$PageLimit,$Settings['max_topics'])); } }
105 $rnquery = query("SELECT FOUND_ROWS();", array(null));
106 $result=mysql_query($query);
107 $rnresult=mysql_query($rnquery);
108 $NumberTopics = mysql_result($rnresult,0);
109 @mysql_free_result($rnresult);
110 if($NumberTopics==null) { 
111         $NumberTopics = 0; }
112 $num = $NumberTopics;
113 //Start Topic Page Code
114 if(!isset($Settings['max_topics'])) { $Settings['max_topics'] = 10; }
115 if($_GET['page']==null) { $_GET['page'] = 1; } 
116 if($_GET['page']<=0) { $_GET['page'] = 1; }
117 $nums = $_GET['page'] * $Settings['max_topics'];
118 if($nums>$num) { $nums = $num; }
119 $numz = $nums - $Settings['max_topics'];
120 if($numz<=0) { $numz = 0; }
121 //$i=$numz;
122 if($nums<$num) { $nextpage = $_GET['page'] + 1; }
123 if($nums>=$num) { $nextpage = $_GET['page']; }
124 if($numz>=$Settings['max_topics']) { $backpage = $_GET['page'] - 1; }
125 if($_GET['page']<=1) { $backpage = 1; }
126 $pnum = $num; $l = 1; $Pages = null;
127 while ($pnum>0) {
128 if($pnum>=$Settings['max_topics']) { 
129         $pnum = $pnum - $Settings['max_topics']; 
130         $Pages[$l] = $l; ++$l; }
131 if($pnum<$Settings['max_topics']&&$pnum>0) { 
132         $pnum = $pnum - $pnum; 
133         $Pages[$l] = $l; ++$l; } }
134 //End Topic Page Code
135 $num=mysql_num_rows($result);
136 if($num<=0) { 
137 redirect("location",$basedir.url_maker($exfile['search'],$Settings['file_ext'],"act=topics",$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search'],false));
138 @header("Content-Type: text/plain; charset=".$Settings['charset']);
139 ob_clean(); echo "Sorry could not find any search results."; @mysql_free_result($result);
140 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); @mysql_close(); die(); }
141 $i=0;
142 //List Page Number Code Start
143 $pagenum=count($Pages);
144 if($_GET['page']>$pagenum) {
145         $_GET['page'] = $pagenum; }
146 $pagei=0; $pstring = "<div class=\"PageList\"><span class=\"pagelink\">Pages:</span> ";
147 if($_GET['page']<4) { $Pagez[0] = null; }
148 if($_GET['page']>=4) { $Pagez[0] = "First"; }
149 if($_GET['page']>=3) {
150 $Pagez[1] = $_GET['page'] - 2; }
151 if($_GET['page']<3) {
152 $Pagez[1] = null; }
153 if($_GET['page']>=2) {
154 $Pagez[2] = $_GET['page'] - 1; }
155 if($_GET['page']<2) {
156 $Pagez[2] = null; }
157 $Pagez[3] = $_GET['page'];
158 if($_GET['page']<$pagenum) {
159 $Pagez[4] = $_GET['page'] + 1; }
160 if($_GET['page']>=$pagenum) {
161 $Pagez[4] = null; }
162 $pagenext = $_GET['page'] + 1;
163 if($pagenext<$pagenum) {
164 $Pagez[5] = $_GET['page'] + 2; }
165 if($pagenext>=$pagenum) {
166 $Pagez[5] = null; }
167 if($_GET['page']<$pagenum) { $Pagez[6] = "Last"; }
168 if($_GET['page']>=$pagenum) { $Pagez[6] = null; }
169 $pagenumi=count($Pagez);
170 if($num==0) {
171 $pagenumi = 0;
172 if($_GET['msearch']==null) { 
173 $pstring = $pstring."<span class=\"pagelink\"><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'])."\">1</a></span> "; }
174 if($_GET['msearch']!=null) {
175 $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=1",$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search'])."\">1</a></span> "; }
176 }
177 while ($pagei < $pagenumi) {
178 if($Pagez[$pagei]!=null&&
179    $Pagez[$pagei]!="First"&&
180    $Pagez[$pagei]!="Last") {
181 if($_GET['msearch']==null) {
182 if($pagei==1&$Pagez[$pagei]!=null&&$Pagez[$pagei]>=2) {
183 $Pback = $Pagez[$pagei] - 1;
184 $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> "; }
185 if($pagei!=3) { 
186 $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> "; }
187 if($pagei==3) { 
188 $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> "; } }
189 if($_GET['msearch']!=null) {
190 if($pagei==1&$Pagez[$pagei]!=null&&$Pagez[$pagei]>=2) {
191 $Pback = $Pagez[$pagei] - 1;
192 $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> "; }
193 if($pagei!=3) { 
194 $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> "; } 
195 if($pagei==3) { 
196 $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> "; } } }
197 if($Pagez[$pagei]=="First") {
198 if($_GET['msearch']==null) {
199 $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> "; }
200 if($_GET['msearch']!=null) {
201 $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> "; } }
202 if($Pagez[$pagei]=="Last") {
203 if($_GET['msearch']==null) {
204 $ptestnext = $pagenext + 1;
205 if($ptestnext<$pagenum) {
206 $paget = $pagei - 1;
207 $Pnext = $Pagez[$paget] + 1;
208 $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> "; }
209 $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> "; }
210 if($_GET['msearch']!=null) {
211 $ptestnext = $pagenext + 1;
212 if($ptestnext<$pagenum) {
213 $paget = $pagei - 1;
214 $Pnext = $Pagez[$paget] + 1;
215 $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> "; }
216 $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> "; } }
217         ++$pagei; } $pstring = $pstring."</div>";
218 ?>
219 <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>
220 <div class="DivNavLinks">&nbsp;</div>
221 <?php
222 echo $pstring;
223 //List Page Number Code end
224 ?>
225 <div class="DivPageLinks">&nbsp;</div>
226 <div class="Table1Border">
227 <?php if($ThemeSet['TableStyle']=="div") { ?>
228 <div class="TableRow1">
229 <span style="text-align: left;">
230 <?php echo $ThemeSet['TitleIcon'];
231 if($_GET['msearch']==null) { ?>
232 <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>
233 <?php } if($_GET['msearch']!=null) { ?>
234 <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>
235 <?php } ?></span></div>
236 <?php } ?>
237 <table class="Table1">
238 <?php if($ThemeSet['TableStyle']=="table") { ?>
239 <tr id="ForumStart<?php echo $ForumID; ?>" class="TableRow1">
240 <td class="TableColumn1" colspan="6"><span style="text-align: left;">
241 <?php echo $ThemeSet['TitleIcon'];
242 if($_GET['msearch']==null) { ?>
243 <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>
244 <?php } if($_GET['msearch']!=null) { ?>
245 <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>
246 <?php } ?></span>
247 </td>
248 </tr><?php } ?>
249 <tr id="SearchStatRow" class="TableRow2">
250 <th class="TableColumn2" style="width: 4%;">State</th>
251 <th class="TableColumn2" style="width: 36%;">Topic Name</th>
252 <th class="TableColumn2" style="width: 15%;">Author</th>
253 <th class="TableColumn2" style="width: 15%;">Time</th>
254 <th class="TableColumn2" style="width: 5%;">Replys</th>
255 <th class="TableColumn2" style="width: 25%;">Last Reply</th>
256 </tr>
257 <?php
258 while ($i < $num) {
259 $TopicID=mysql_result($result,$i,"id");
260 $ForumID=mysql_result($result,$i,"ForumID");
261 $prequery = query("SELECT * FROM `".$Settings['sqltable']."forums` WHERE `id`=%i LIMIT 1", array($ForumID));
262 $preresult=mysql_query($prequery);
263 $prenum=mysql_num_rows($preresult);
264 $HotTopicPosts = $Settings['hot_topic_num'];
265 if($prenum > 0) {
266 $HotTopicPosts = mysql_result($preresult,0,"HotTopicPosts"); }
267 @mysql_free_result($preresult);
268 if($HotTopicPosts!=0&&is_numeric($HotTopicPosts)) {
269         $Settings['hot_topic_num'] = $HotTopicPosts; }
270 if(!is_numeric($Settings['hot_topic_num'])) {
271         $Settings['hot_topic_num'] = 15; }
272 $CategoryID=mysql_result($result,$i,"CategoryID");
273 $UsersID=mysql_result($result,$i,"UserID");
274 $GuestName=mysql_result($result,$i,"GuestName");
275 $TheTime=mysql_result($result,$i,"TimeStamp");
276 $TheTime=GMTimeChange("F j, Y",$TheTime,$_SESSION['UserTimeZone'],0,$_SESSION['UserDST']);
277 $NumReply=mysql_result($result,$i,"NumReply");
278 $TopicName=mysql_result($result,$i,"TopicName");
279 $TopicDescription=mysql_result($result,$i,"Description");
280 $PinnedTopic=mysql_result($result,$i,"Pinned");
281 $TopicStat=mysql_result($result,$i,"Closed");
282 $UsersName = GetUserName($UsersID,$Settings['sqltable']);
283 if($UsersName=="Guest") { $UsersName=$GuestName;
284 if($UsersName==null) { $UsersName="Guest"; } }
285 if(isset($PermissionInfo['CanViewForum'][$ForumID])&&
286         $PermissionInfo['CanViewForum'][$ForumID]=="yes"&&
287         isset($CatPermissionInfo['CanViewCategory'][$CategoryID])&&
288         $CatPermissionInfo['CanViewCategory'][$CategoryID]=="yes") {
289 $glrquery = query("SELECT * FROM `".$Settings['sqltable']."posts` WHERE `TopicID`=%i ORDER BY `TimeStamp` DESC LIMIT 1", array($TopicID));
290 $glrresult=mysql_query($glrquery);
291 $glrnum=mysql_num_rows($glrresult);
292 if($glrnum>0){
293 $ReplyID1=mysql_result($glrresult,0,"id");
294 $UsersID1=mysql_result($glrresult,0,"UserID");
295 $GuestName1=mysql_result($glrresult,0,"GuestName");
296 $TimeStamp1=mysql_result($glrresult,0,"TimeStamp");
297 $TimeStamp1=GMTimeChange("F j, Y",$TimeStamp1,$_SESSION['UserTimeZone'],0,$_SESSION['UserDST']);
298 $UsersName1 = GetUserName($UsersID1,$Settings['sqltable']); }
299 $NumPages = null; $NumRPosts = $NumReply + 1;
300 if(!isset($Settings['max_posts'])) { $Settings['max_posts'] = 10; }
301 if($NumRPosts>$Settings['max_posts']) {
302 $NumPages = ceil($NumRPosts/$Settings['max_posts']); }
303 if($NumRPosts<=$Settings['max_posts']) {
304 $NumPages = 1; }
305 $Users_Name1 = pre_substr($UsersName1,0,20);
306 if($UsersName1=="Guest") { $UsersName1=$GuestName1;
307 if($UsersName1==null) { $UsersName1="Guest"; } }
308 if (pre_strlen($UsersName1)>20) { $Users_Name1 = $Users_Name1."...";
309 $oldusername=$UsersName1; $UsersName1=$Users_Name1; } $lul = null;
310 if($TimeStamp1!=null) { $lul = null;
311 if($UsersID1!="-1") {
312 $lul = url_maker($exfile['member'],$Settings['file_ext'],"act=view&id=".$UsersID1,$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member']);
313 $luln = url_maker($exfile['topic'],$Settings['file_ext'],"act=view&id=".$TopicID."&page=".$NumPages,$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic'])."&#35;reply".$NumRPosts;
314 $LastReply = "User: <a href=\"".$lul."\" title=\"".$oldusername."\">".$UsersName1."</a><br />\nTime: <a href=\"".$luln."\">".$TimeStamp1."</a>"; }
315 if($UsersID1=="-1") {
316 $lul = url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index']);
317 $luln = url_maker($exfile['topic'],$Settings['file_ext'],"act=view&id=".$TopicID."&page=".$NumPages,$Settings['qstr'],$Settings['qsep'],$prexqstr['topic'],$exqstr['topic'])."&#35;reply".$NumRPosts;
318 $LastReply = "Guest: <span title=\"".$oldusername."\">".$UsersName1."</span><br />\nTime: <a href=\"".$luln."\">".$TimeStamp1."</a>"; } }
319 @mysql_free_result($glrresult);
320 if($TimeStamp1==null) { $LastReply = "&nbsp;<br />&nbsp;"; }
321 $PreTopic = $ThemeSet['TopicIcon'];
322 if ($PinnedTopic>1) { $PinnedTopic = 1; } 
323 if ($PinnedTopic<0) { $PinnedTopic = 0; }
324 if(!is_numeric($PinnedTopic)) { $PinnedTopic = 0; }
325 if ($TopicStat>1) { $TopicStat = 1; } 
326 if ($TopicStat<0) { $TopicStat = 0; }
327 if(!is_numeric($TopicStat)) { $TopicStat = 1; }
328 if ($PinnedTopic==1&&$TopicStat==0) {
329         if($NumReply>=$Settings['hot_topic_num']) {
330                 $PreTopic=$ThemeSet['HotPinTopic']; }
331         if($NumReply<$Settings['hot_topic_num']) {
332                 $PreTopic=$ThemeSet['PinTopic']; } }
333 if ($TopicStat==1&&$PinnedTopic==0) {
334         if($NumReply>=$Settings['hot_topic_num']) {
335                 $PreTopic=$ThemeSet['HotClosedTopic']; }
336         if($NumReply<$Settings['hot_topic_num']) {
337                 $PreTopic=$ThemeSet['ClosedTopic']; } }
338 if ($PinnedTopic==0&&$TopicStat==0) {
339                 if($NumReply>=$Settings['hot_topic_num']) {
340                         $PreTopic=$ThemeSet['HotTopic']; }
341                 if($NumReply<$Settings['hot_topic_num']) {
342                         $PreTopic=$ThemeSet['TopicIcon']; } }
343 if ($PinnedTopic==1&&$TopicStat==1) {
344                 if($NumReply>=$Settings['hot_topic_num']) {
345                         $PreTopic=$ThemeSet['HotPinClosedTopic']; }
346                 if($NumReply<$Settings['hot_topic_num']) {
347                         $PreTopic=$ThemeSet['PinClosedTopic']; } }
348 ?>
349 <tr class="TableRow3" id="Topic<?php echo $TopicID; ?>">
350 <td class="TableColumn3"><div class="topicstate">
351 <?php echo $PreTopic; ?></div></td>
352 <td class="TableColumn3"><div class="topicname">
353 <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></div>
354 <div class="topicdescription"><?php echo $TopicDescription; ?></div></td>
355 <td class="TableColumn3" style="text-align: center;"><?php
356 if($UsersID!="-1") {
357 echo "<a href=\"";
358 echo url_maker($exfile['member'],$Settings['file_ext'],"act=view&id=".$UsersID,$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member']);
359 echo "\">".$UsersName."</a>"; }
360 if($UsersID=="-1") {
361 echo "<span>".$UsersName."</span>"; }
362 ?></td>
363 <td class="TableColumn3" style="text-align: center;"><?php echo $TheTime; ?></td>
364 <td class="TableColumn3" style="text-align: center;"><?php echo $NumReply; ?></td>
365 <td class="TableColumn3"><?php echo $LastReply; ?></td>
366 </tr>
367 <?php } ++$i; }
368 ?>
369 <tr id="SearchEnd" class="TableRow4">
370 <td class="TableColumn4" colspan="6">&nbsp;</td>
371 </tr>
372 </table></div>
373 <?php
374 @mysql_free_result($result); } } } 
375 ?>
376 <div class="DivSearch">&nbsp;</div>