This repository was archived by the owner on Jul 4, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsearch.php
More file actions
executable file
·81 lines (58 loc) · 2.56 KB
/
Copy pathsearch.php
File metadata and controls
executable file
·81 lines (58 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
require_once("inc/include.php");
$title = T_("Message search") .' - '. $cfg['fp_title']; // Site title
include("inc/header.php"); // Html-header
echo '
<div id="padded">
<h2>'. T_("Message search") .'</h2>
<form action="'. $cfg['htmldir'] .'/search/" method="post">
<fieldset>
<label for="term">'. T_("Search term") .'</label>
<input class="wide" type="text" name="term" id="term"'. (!empty($_POST['term']) ? ' value="'. $_POST['term'] .'"' : '') .' />
<input type="submit" value="'. T_("Search") .'" />
</fieldset>
</form>';
if( !empty( $_POST['term'] ) AND strlen($_POST['term']) >= 4 )
{
$maxcount = 10;
$term = mysql_real_escape_string($_POST['term']);
$cq = mysql_query("SELECT COUNT(`id`) AS `count` FROM `posts` WHERE MATCH(`subject`, `message`) AGAINST ('\"". $term ."\"' IN BOOLEAN MODE) AND `deleted_time` = '0' LIMIT 1");
$count = mysql_result($cq, 0, "count");
if($count >= 1)
{
echo '
<p><strong>'. sprintf( T_("%s %s found"), $count, ($count == 1 ? T_("result") : T_("results"))) .'</strong></p>';
if($count > $maxcount)
echo '
<p><strong>'. sprintf( T_("However, only the newest %s posts will be shown."), $maxcount) .'</strong></p>';
echo '
<hr class="line" />';
$q = mysql_query("SELECT * FROM `posts` WHERE MATCH(`subject`, `message`) AGAINST ('\"". $term ."\"' IN BOOLEAN MODE) AND `deleted_time` = '0' ORDER BY `id` DESC LIMIT ". $maxcount);
while($res = mysql_fetch_assoc($q))
{
$board = mysql_query("SELECT * FROM `boards` WHERE `id` = '". $res['board'] ."' LIMIT 1");
$board = mysql_fetch_assoc($board);
// Try determine which page message is on
if($res['thread'] == 0) {
$res['on_page'] = 1;
} else {
$countQuery = mysql_query("SELECT count(id) as postno FROM posts WHERE thread = " . $res['thread'] . " AND id < " . $res['id'] . "");
$postsOnThread = mysql_fetch_assoc($countQuery);
$res['on_page'] = floor($postsOnThread['postno'] / $cfg['ppp']) + 1;
}
print_post($res, 'thread', $board);
echo '
<hr class="line" />';
}
}
else
echo '<p>'. T_("No matching posts found.") .'</p>';
}
else
echo '<p>'. sprintf( T_("The search term has to be over or exactly %d characters long."), 4 ) .'</p>';
echo '
</div>
</div>
';
include("inc/footer.php"); // Html-footer
?>