-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
site_search.php
55 lines (49 loc) · 1.83 KB
/
site_search.php
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
<?php
// since qEngine 12, qSearch has been removed. If you modules need qSearch, you have to do it manually.
require_once './includes/user_init.php';
$mod_id = get_param('mod_id');
$p = get_param('p', 1);
$query = get_param('query');
switch ($mod_id) {
case 'mycustomsearch':
// insert your custom search code below!
break;
default:
// simple page search
if (empty($query)) {
msg_die(sprintf($lang['msg']['echo'], $lang['l_search_no_result']));
}
// load tpl
$tpl = load_tpl('site_search.tpl');
$txt['block_page'] = '';
$w = array();
$w[] = create_where('page_title', $query);
$w[] = create_where('page_body', $query);
$w = implode(' OR ', $w);
$page_status_sql = create_page_status_sql();
// perform search
$i = 0;
$foo = sql_multipage($db_prefix.'page', 'permalink, page_id, page_title, page_body', "($page_status_sql) AND ($w) AND (page_list=1)", '', $p);
foreach ($foo as $row) {
$i++;
if ($config['enable_adp'] && $row['permalink']) {
$row['page_url'] = $row['permalink'];
} else {
$row['page_url'] = "page.php?pid=$row[page_id]";
}
$row['title'] = strip_tags($row['page_title']);
$row['body'] = line_wrap(strip_tags($row['page_body']));
$txt['block_page'] .= quick_tpl($tpl_block['page'], $row);
}
if (!$i) {
$no_result = true;
} else {
$no_result = false;
}
$txt['mod_id'] = $mod_id;
$txt['query'] = stripslashes($query);
$txt['main_body'] = quick_tpl(load_tpl('site_search.tpl'), $txt);
generate_html_header("$config[site_name] $config[cat_separator] Site Search");
flush_tpl();
break;
}