forked from pluck-cms/pluck_search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.site.php
74 lines (64 loc) · 2.25 KB
/
search.site.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/**
* Pluck Search
* @fileinfo: /data/modules/search
*/
// main search functions
require_once ('data/modules/search/functions.php');
/**
* @brief Insert Content into search page
*/
function search_theme_main()
{
global $lang;
$numresults = false;
$query = false;
if (isset($_REQUEST['q'])) {
$query = sanitize($_REQUEST['q']);
if (!preg_match("/[\~\!\@\#\$\%\^\&\*\(\)\_\+\=\-\{\}\[\]\;\:\'\"\<\>\/\?\/\*]/", $query)) {
if (strlen($query) >= 3) {
echo "<div id=\"results\">";
echo "<h2>" . $lang["search"]["results for"] . """ . $query . ""</h2>";
//removes the space in beginning or ending
$query = trim($query);
$directory = "";
// regular pages
$directory_pages = $directory."data/settings/pages";
$results = searchcontent($query, $directory, $directory_pages, "pages");
// blog pages
$directory_blog = $directory."data/settings/modules/blog/posts";
$results .= searchcontent($query, $directory, $directory_blog, "blog");
// albums
$results .= search_albums($query, $directory);
//removes the empty beginning element
$results = substr($results, 5);
if ($results != "") {
$results_list = explode('**7**', $results);
$results = array_unique($results_list);
foreach ($results_list as $result) {
echo $result;
}
$numresults = sizeof($results_list);
}
if (!$numresults) {
echo "<ul><li>" . $lang["search"]["no results"] . "</li></ul>";
}
echo "</div>";
} else {
// search query is too small
echo "<p class=\"error\">". $lang["search"]["enter a larger search term"]."</p>";
}
} else {
// contains symbols
echo "<p class=\"error\">" . $lang["search"]["cannot search symbols"] . "</p>";
}
}?>
<form method="post" action="" id="SearchForm">
<h1></h1>
<div class="iwrap">
<label for="SearchFormQuery"><?php echo $lang['search']['label']; ?></label>
<input name="q" id="SearchFormQuery" type="search" value="<?php echo $query; ?>"/>
<input type="submit" name="submit" value="<?php echo $lang['search']['search']; ?>" />
</div>
</form>
<?php }