OSDN Git Service

Big update to iDB timezone system. (php5 datetime instance)
[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/21/2014 SVN 791 - 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)||$_GET['type']=="getactive") {
89 if(pre_strlen($_GET['msearch'])>="25") { 
90         $_GET['msearch'] = null; }
91 if(isset($_GET['msearch'])&&$_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']=="normal") {
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']=="normal") {
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 if($_GET['type']=="getactive") {
138 $active_month = $usercurtime->format("m");
139 $active_day = $usercurtime->format("d");
140 $active_year = $usercurtime->format("Y");
141 $active_start = mktime(0,0,0,$active_month,$active_day,$active_year);
142 $active_end = mktime(23,59,59,$active_month,$active_day,$active_year);
143 $query = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."topics\" WHERE (\"TimeStamp\">=%i AND \"TimeStamp\"<=%i) OR (\"LastUpdate\">=%i AND \"LastUpdate\"<=%i)".$ForumIgnoreList4." ORDER BY \"LastUpdate\" DESC ".$SQLimit, array($active_start,$active_end,$active_start,$active_end,$PageLimit,$Settings['max_topics']));
144 $rnquery = sql_pre_query("SELECT COUNT(*) FROM \"".$Settings['sqltable']."topics\" WHERE (\"TimeStamp\">=%i AND \"TimeStamp\"<=%i) OR (\"LastUpdate\">=%i AND \"LastUpdate\"<=%i)".$ForumIgnoreList4."", array($active_start,$active_end,$active_start,$active_end)); }
145 $result=sql_query($query,$SQLStat);
146 $rnresult=sql_query($rnquery,$SQLStat);
147 $NumberTopics = sql_result($rnresult,0);
148 sql_free_result($rnresult);
149 if($NumberTopics==null) { 
150         $NumberTopics = 0; }
151 $num = $NumberTopics;
152 //Start Topic Page Code
153 if(!isset($Settings['max_topics'])) { $Settings['max_topics'] = 10; }
154 if($_GET['page']==null) { $_GET['page'] = 1; } 
155 if($_GET['page']<=0) { $_GET['page'] = 1; }
156 $nums = $_GET['page'] * $Settings['max_topics'];
157 if($nums>$num) { $nums = $num; }
158 $numz = $nums - $Settings['max_topics'];
159 if($numz<=0) { $numz = 0; }
160 //$i=$numz;
161 if($nums<$num) { $nextpage = $_GET['page'] + 1; }
162 if($nums>=$num) { $nextpage = $_GET['page']; }
163 if($numz>=$Settings['max_topics']) { $backpage = $_GET['page'] - 1; }
164 if($_GET['page']<=1) { $backpage = 1; }
165 $pnum = $num; $l = 1; $Pages = null;
166 while ($pnum>0) {
167 if($pnum>=$Settings['max_topics']) { 
168         $pnum = $pnum - $Settings['max_topics']; 
169         $Pages[$l] = $l; ++$l; }
170 if($pnum<$Settings['max_topics']&&$pnum>0) { 
171         $pnum = $pnum - $pnum; 
172         $Pages[$l] = $l; ++$l; } }
173 //End Topic Page Code
174 $num=sql_num_rows($result);
175 if($num<=0) { 
176 redirect("location",$rbasedir.url_maker($exfile['search'],$Settings['file_ext'],"act=topics",$Settings['qstr'],$Settings['qsep'],$prexqstr['search'],$exqstr['search'],false));
177 header("Content-Type: text/plain; charset=".$Settings['charset']); $urlstatus = 302;
178 ob_clean(); echo "Sorry could not find any search results."; sql_free_result($result);
179 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
180 $i=0;
181 //List Page Number Code Start
182 $pagenum=count($Pages);
183 if($_GET['page']>$pagenum) {
184         $_GET['page'] = $pagenum; }
185 $pagei=0; $pstring = null;
186 if($pagenum>1) {
187 $pstring = "<div class=\"PageList\"><span class=\"pagelink\">".$pagenum." Pages:</span> "; }
188 if($_GET['page']<4) { $Pagez[0] = null; }
189 if($_GET['page']>=4) { $Pagez[0] = "First"; }
190 if($_GET['page']>=3) {
191 $Pagez[1] = $_GET['page'] - 2; }
192 if($_GET['page']<3) {
193 $Pagez[1] = null; }
194 if($_GET['page']>=2) {
195 $Pagez[2] = $_GET['page'] - 1; }
196 if($_GET['page']<2) {
197 $Pagez[2] = null; }
198 $Pagez[3] = $_GET['page'];
199 if($_GET['page']<$pagenum) {
200 $Pagez[4] = $_GET['page'] + 1; }
201 if($_GET['page']>=$pagenum) {
202 $Pagez[4] = null; }
203 $pagenext = $_GET['page'] + 1;
204 if($pagenext<$pagenum) {
205 $Pagez[5] = $_GET['page'] + 2; }
206 if($pagenext>=$pagenum) {
207 $Pagez[5] = null; }
208 if($_GET['page']<$pagenum) { $Pagez[6] = "Last"; }
209 if($_GET['page']>=$pagenum) { $Pagez[6] = null; }
210 $pagenumi=count($Pagez);
211 if($num==0) {
212 $pagenumi = 0;
213 if($_GET['msearch']==null) { 
214 $pstring = null; }
215 if($_GET['msearch']!=null) {
216 $pstring = null; }
217 }
218 if($pagenum>1) {
219 while ($pagei < $pagenumi) {
220 if($_GET['msearch']==null) {
221 if($_GET['page']!=1&&$pagei==1) {
222 $Pback = $_GET['page'] - 1;
223 $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> "; } }
224 if($_GET['msearch']!=null) {
225 if($_GET['page']!=1&&$pagei==1) {
226 $Pback = $_GET['page'] - 1;
227 $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> "; } }
228 if($Pagez[$pagei]!=null&&
229    $Pagez[$pagei]!="First"&&
230    $Pagez[$pagei]!="Last") {
231 if($_GET['msearch']==null) {
232 if($pagei!=3) { 
233 $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> "; }
234 if($pagei==3) { 
235 $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> "; } }
236 if($_GET['msearch']!=null) {
237 if($pagei!=3) { 
238 $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> "; } 
239 if($pagei==3) { 
240 $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> "; } } }
241 if($Pagez[$pagei]=="First") {
242 if($_GET['msearch']==null) {
243 $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> "; }
244 if($_GET['msearch']!=null) {
245 $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> "; } }
246 if($Pagez[$pagei]=="Last") {
247 if($_GET['msearch']==null) {
248 $ptestnext = $pagenext + 1;
249 $paget = $pagei - 1;
250 $Pnext = $_GET['page'] + 1;
251 $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> "; 
252 if($ptestnext<$pagenum) {
253 $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> "; } }
254 if($_GET['msearch']!=null) {
255 $ptestnext = $pagenext + 1;
256 $paget = $pagei - 1;
257 $Pnext = $_GET['page'] + 1;
258 $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> "; 
259 if($ptestnext<$pagenum) {
260 $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> "; } } }
261         ++$pagei; } $pstring = $pstring."</div>"; }
262 ?>
263 <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>
264 <div class="DivNavLinks">&nbsp;</div>
265 <?php
266 echo $pstring;
267 //List Page Number Code end
268 if($pagenum>1) {
269 ?>
270 <div class="DivPageLinks">&nbsp;</div>
271 <?php } ?>
272 <div class="Table1Border">
273 <?php if($ThemeSet['TableStyle']=="div") { ?>
274 <div class="TableRow1">
275 <span style="text-align: left;">
276 <?php echo $ThemeSet['TitleIcon'];
277 if($_GET['msearch']==null&&$_GET['search']!=null) { ?>
278 <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>
279 <?php } if($_GET['msearch']!=null&&$_GET['search']!=null) { ?>
280 <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>
281 <?php } if($_GET['type']=="getactive") { ?>
282 <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']); ?>">Todays Active Topics</a>
283 <?php } ?></span></div>
284 <?php } ?>
285 <table class="Table1">
286 <?php if($ThemeSet['TableStyle']=="table") { ?>
287 <tr id="SearchStart" class="TableRow1">
288 <td class="TableColumn1" colspan="6"><span style="text-align: left;">
289 <?php echo $ThemeSet['TitleIcon'];
290 if($_GET['msearch']==null&&$_GET['search']!=null) { ?>
291 <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>
292 <?php } if($_GET['msearch']!=null&&$_GET['search']!=null) { ?>
293 <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>
294 <?php } if($_GET['type']=="getactive") { ?>
295 <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']); ?>">Todays Active Topics</a>
296 <?php } ?></span>
297 </td>
298 </tr><?php } ?>
299 <tr id="SearchStatRow" class="TableRow2">
300 <th class="TableColumn2" style="width: 4%;">State</th>
301 <th class="TableColumn2" style="width: 36%;">Topic Name</th>
302 <th class="TableColumn2" style="width: 15%;">Author</th>
303 <th class="TableColumn2" style="width: 15%;">Time</th>
304 <th class="TableColumn2" style="width: 5%;">Replys</th>
305 <th class="TableColumn2" style="width: 25%;">Last Reply</th>
306 </tr>
307 <?php
308 while ($i < $num) {
309 $TopicID=sql_result($result,$i,"id");
310 $ForumID=sql_result($result,$i,"ForumID");
311 $prequery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."forums\" WHERE \"id\"=%i".$ForumIgnoreList2." LIMIT 1", array($ForumID));
312 $preresult=sql_query($prequery,$SQLStat);
313 $prenum=sql_num_rows($preresult);
314 $HotTopicPosts = $Settings['hot_topic_num'];
315 if($prenum > 0) {
316 $HotTopicPosts = sql_result($preresult,0,"HotTopicPosts"); }
317 sql_free_result($preresult);
318 if($HotTopicPosts!=0&&is_numeric($HotTopicPosts)) {
319         $Settings['hot_topic_num'] = $HotTopicPosts; }
320 if(!is_numeric($Settings['hot_topic_num'])) {
321         $Settings['hot_topic_num'] = 15; }
322 $CategoryID=sql_result($result,$i,"CategoryID");
323 $UsersID=sql_result($result,$i,"UserID");
324 $GuestsName=sql_result($result,$i,"GuestName");
325 $TheTime=sql_result($result,$i,"TimeStamp");
326 $tmpusrcurtime = new DateTime();
327 $tmpusrcurtime->setTimestamp($TheTime);
328 $tmpusrcurtime->setTimezone($usertz);
329 $TheTime=$tmpusrcurtime->format($_SESSION['iDBDateFormat'].", ".$_SESSION['iDBTimeFormat']);
330 $NumReply=sql_result($result,$i,"NumReply");
331 $NumberPosts=$NumReply + 1;
332 $prepagelist = null;
333 if(!isset($Settings['max_posts'])) { 
334         $Settings['max_posts'] = 10; }
335 if(!isset($ThemeSet['MiniPageAltStyle'])) { 
336         $ThemeSet['MiniPageAltStyle'] = "off"; }
337 if($ThemeSet['MiniPageAltStyle']!="on"&&
338         $ThemeSet['MiniPageAltStyle']!="off") { 
339         $ThemeSet['MiniPageAltStyle'] = "off"; }
340 if($NumberPosts>$Settings['max_posts']) {
341 $NumberPages = ceil($NumberPosts/$Settings['max_posts']); }
342 if($NumberPosts<=$Settings['max_posts']) {
343 $NumberPages = 1; }
344 if($NumberPages>4) {
345         $prepagelist = " &nbsp;"; }
346 if($NumberPages>=2) {
347         if($ThemeSet['MiniPageAltStyle']=="off") { 
348         $prepagelist = "<span class=\"small\">(Pages: "; }
349         if($ThemeSet['MiniPageAltStyle']=="on") {
350         $prepagelist = $prepagelist."<span class=\"minipagelink\">"; }
351         $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>";
352         if($ThemeSet['MiniPageAltStyle']=="on") {
353         $prepagelist = $prepagelist."</span>"; }
354         if($ThemeSet['MiniPageAltStyle']=="off") { $prepagelist = $prepagelist." "; }
355         if($ThemeSet['MiniPageAltStyle']=="on") {
356         $prepagelist = $prepagelist."<span class=\"minipagelink\">"; }
357         $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>";
358         if($ThemeSet['MiniPageAltStyle']=="on") {
359         $prepagelist = $prepagelist."</span>"; }
360         if($NumberPages>=3) {
361         if($ThemeSet['MiniPageAltStyle']=="off") { $prepagelist = $prepagelist." "; }
362         if($ThemeSet['MiniPageAltStyle']=="on") {
363         $prepagelist = $prepagelist."<span class=\"minipagelink\">"; }
364         $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>";
365         if($ThemeSet['MiniPageAltStyle']=="on") {
366         $prepagelist = $prepagelist."</span>"; } }
367         if($NumberPages==4) {
368         if($ThemeSet['MiniPageAltStyle']=="off") { $prepagelist = $prepagelist." "; }
369         if($ThemeSet['MiniPageAltStyle']=="on") {
370         $prepagelist = $prepagelist."<span class=\"minipagelinklast\">"; }
371         if($ThemeSet['MiniPageAltStyle']=="on") {
372         $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>"; }
373         if($ThemeSet['MiniPageAltStyle']=="off") {
374         $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>"; }
375         if($ThemeSet['MiniPageAltStyle']=="on") {
376         $prepagelist = $prepagelist."</span>"; } }
377         if($NumberPages>4) {
378         if($ThemeSet['MiniPageAltStyle']=="off") { $prepagelist = $prepagelist." "; }
379         if($ThemeSet['MiniPageAltStyle']=="on") {
380         $prepagelist = $prepagelist."<span class=\"minipagelinklast\">"; }
381         if($ThemeSet['MiniPageAltStyle']=="on") {
382         $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>"; }
383         if($ThemeSet['MiniPageAltStyle']=="off") {
384         $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>"; }
385         if($ThemeSet['MiniPageAltStyle']=="on") {
386         $prepagelist = $prepagelist."</span>"; } }
387         if($ThemeSet['MiniPageAltStyle']=="off") { 
388         $prepagelist = $prepagelist.")</span>"; } }
389 $TopicName=sql_result($result,$i,"TopicName");
390 $TopicDescription=sql_result($result,$i,"Description");
391 $PinnedTopic=sql_result($result,$i,"Pinned");
392 if ($PinnedTopic>2) { $PinnedTopic = 1; } 
393 if ($PinnedTopic<0) { $PinnedTopic = 0; }
394 if(!is_numeric($PinnedTopic)) { $PinnedTopic = 0; }
395 $TopicStat=sql_result($result,$i,"Closed");
396 if ($TopicStat>3) { $TopicStat = 1; } 
397 if ($TopicStat<0) { $TopicStat = 0; }
398 if(!is_numeric($TopicStat)) { $TopicStat = 1; }
399 $PreUsersName = GetUserName($UsersID,$Settings['sqltable'],$SQLStat);
400 if($PreUsersName['Name']===null) { $UsersID = -1;
401 $PreUsersName = GetUserName($UsersID,$Settings['sqltable'],$SQLStat); }
402 $UsersName = $PreUsersName['Name'];
403 $UsersHidden = $PreUsersName['Hidden'];
404 if($UsersName=="Guest") { $UsersName=$GuestsName;
405 if($UsersName==null) { $UsersName="Guest"; } }
406 if(($PermissionInfo['CanViewForum'][$ForumID]=="yes"&&
407         $CatPermissionInfo['CanViewCategory'][$CategoryID]=="yes"&&
408         $TopicStat>=0&&$TopicStat<3)||
409         ($PermissionInfo['CanViewForum'][$ForumID]=="yes"&&
410         $CatPermissionInfo['CanViewCategory'][$CategoryID]=="yes"&&
411         $PermissionInfo['CanModForum'][$ForumID]=="yes"&&$TopicStat==3)) {
412 $LastReply = "&nbsp;<br />&nbsp;";
413 $glrquery = sql_pre_query("SELECT * FROM \"".$Settings['sqltable']."posts\" WHERE \"TopicID\"=%i ORDER BY \"TimeStamp\" DESC LIMIT 1", array($TopicID));
414 $glrresult=sql_query($glrquery,$SQLStat);
415 $glrnum=sql_num_rows($glrresult);
416 if($glrnum>0){
417 $ReplyID1=sql_result($glrresult,0,"id");
418 $UsersID1=sql_result($glrresult,0,"UserID");
419 $GuestsName1=sql_result($glrresult,0,"GuestName");
420 $TimeStamp1=sql_result($glrresult,0,"TimeStamp");
421 $tmpusrcurtime = new DateTime();
422 $tmpusrcurtime->setTimestamp($TimeStamp1);
423 $tmpusrcurtime->setTimezone($usertz);
424 $TimeStamp1=$tmpusrcurtime->format($_SESSION['iDBDateFormat'].", ".$_SESSION['iDBTimeFormat']);
425 $PreUsersName1 = GetUserName($UsersID1,$Settings['sqltable'],$SQLStat);
426 if($PreUsersName1['Name']===null) { $UsersID1 = -1;
427 $PreUsersName1 = GetUserName($UsersID1,$Settings['sqltable'],$SQLStat); }
428 $UsersName1 = $PreUsersName1['Name'];
429 $UsersHidden1 = $PreUsersName1['Hidden']; }
430 $NumPages = null; $NumRPosts = $NumReply + 1;
431 if(!isset($Settings['max_posts'])) { $Settings['max_posts'] = 10; }
432 if($NumRPosts>$Settings['max_posts']) {
433 $NumPages = ceil($NumRPosts/$Settings['max_posts']); }
434 if($NumRPosts<=$Settings['max_posts']) { $NumPages = 1; }
435 $Users_Name1 = pre_substr($UsersName1,0,20);
436 if($UsersName1=="Guest") { $UsersName1=$GuestsName1;
437 if($UsersName1==null) { $UsersName1="Guest"; } }
438 if (pre_strlen($UsersName1)>20) { $Users_Name1 = $Users_Name1."...";
439 $oldusername=$UsersName1; $UsersName1=$Users_Name1; } $lul = null;
440 if($TimeStamp1!=null) { $lul = null;
441 if($UsersID1>0&&$UsersHidden1=="no") {
442 $lul = url_maker($exfile['member'],$Settings['file_ext'],"act=view&id=".$UsersID1,$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member']);
443 $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;
444 $LastReply = "Time: <a href=\"".$luln."\">".$TimeStamp1."</a><br />\nUser: <a href=\"".$lul."\" title=\"".$oldusername."\">".$UsersName1."</a>"; }
445 if($UsersID1<=0||$UsersHidden1=="yes") {
446 if($UsersID1==-1) { $UserPre = "Guest:"; }
447 if(($UsersID1<-1&&$UsersHidden1=="yes")||$UsersID1==0||($UsersID1>0&&$UsersHidden1=="yes")) { 
448         $UserPre = "Hidden:"; }
449 $lul = url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index']);
450 $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;
451 $LastReply = "Time: <a href=\"".$luln."\">".$TimeStamp1."</a><br />\n".$UserPre." <span title=\"".$oldusername."\">".$UsersName1."</span>"; } }
452 sql_free_result($glrresult);
453 if($TimeStamp1==null) { $LastReply = "&nbsp;<br />&nbsp;"; }
454 $PreTopic = $ThemeSet['TopicIcon'];
455 if ($PinnedTopic>0&&$PinnedTopic<3&&$TopicStat==0) {
456         if($NumReply>=$Settings['hot_topic_num']) {
457                 $PreTopic=$ThemeSet['HotPinTopic']; }
458         if($NumReply<$Settings['hot_topic_num']) {
459                 $PreTopic=$ThemeSet['PinTopic']; } }
460 if ($TopicStat>=0&&$TopicStat<=3&&$PinnedTopic==0) {
461         if($NumReply>=$Settings['hot_topic_num']) {
462                 $PreTopic=$ThemeSet['HotClosedTopic']; }
463         if($NumReply<$Settings['hot_topic_num']) {
464                 $PreTopic=$ThemeSet['ClosedTopic']; } }
465 if ($PinnedTopic==0&&$TopicStat==0) {
466                 if($NumReply>=$Settings['hot_topic_num']) {
467                         $PreTopic=$ThemeSet['HotTopic']; }
468                 if($NumReply<$Settings['hot_topic_num']) {
469                         $PreTopic=$ThemeSet['TopicIcon']; } }
470 if ($PinnedTopic>0&&$PinnedTopic<3&&$TopicStat>=0&&$TopicStat<=3) {
471                 if($NumReply>=$Settings['hot_topic_num']) {
472                         $PreTopic=$ThemeSet['HotPinClosedTopic']; }
473                 if($NumReply<$Settings['hot_topic_num']) {
474                         $PreTopic=$ThemeSet['PinClosedTopic']; } }
475 ?>
476 <tr class="TableRow3" id="Topic<?php echo $TopicID; ?>">
477 <td class="TableColumn3"><div class="topicstate">
478 <?php echo $PreTopic; ?></div></td>
479 <td class="TableColumn3"><div class="topicname">
480 <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>
481 <?php if($prepagelist!==null) { echo $prepagelist; } ?></div>
482 <div class="topicdescription"><?php echo $TopicDescription; ?></div></td>
483 <td class="TableColumn3" style="text-align: center;"><?php
484 if($UsersID>0) {
485 echo "<a href=\"";
486 echo url_maker($exfile['member'],$Settings['file_ext'],"act=view&id=".$UsersID,$Settings['qstr'],$Settings['qsep'],$prexqstr['member'],$exqstr['member']);
487 echo "\">".$UsersName."</a>"; }
488 if($UsersID<=0) {
489 echo "<span>".$UsersName."</span>"; }
490 ?></td>
491 <td class="TableColumn3" style="text-align: center;"><?php echo $TheTime; ?></td>
492 <td class="TableColumn3" style="text-align: center;"><?php echo $NumReply; ?></td>
493 <td class="TableColumn3"><?php echo $LastReply; ?></td>
494 </tr>
495 <?php } ++$i; }
496 ?>
497 <tr id="SearchEnd" class="TableRow4">
498 <td class="TableColumn4" colspan="6">&nbsp;</td>
499 </tr>
500 </table></div>
501 <?php if($pagenum>1) { ?>
502 <div class="DivSearch">&nbsp;</div>
503 <?php }
504 echo $pstring;
505 //List Page Number Code end
506 if($pagenum>1) {
507 ?>
508 <div class="DivPageLinks">&nbsp;</div>
509 <?php }
510 sql_free_result($result); } } } 
511 if($pagenum<=1) { ?>
512 <div class="DivSearch">&nbsp;</div>
513 <?php } ?>