-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
147 lines (141 loc) · 4.2 KB
/
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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
include("./config.php");
$fl = new TemplatePower("./templates/search.tpl");
require("./header.php");
$fl->assign("_ROOT.SITENAAM", $sitenaam." / Search");
if(isset($_REQUEST['search']))
{
if(!isset($_REQUEST['searchquery'])||$_REQUEST['searchquery']=="")
{
$fl->newBlock("error");
$fl->assign("ERROR", "You can not search for nothing. Please enter a search string and try again");
}
else
{
$fl->assignGlobal("SEARCHQUERY", opmaak($_REQUEST['searchquery']));
$_REQUEST['searchquery']=str_replace("'", "", $_REQUEST['searchquery']);
$_REQUEST['searchquery']=str_replace("\"", "", $_REQUEST['searchquery']);
$searcharray=explode(" ", $_REQUEST['searchquery']);
$aantal=count($searcharray);
// search books
$query="SELECT DISTINCT id, title FROM fl_books WHERE approved!='0000-00-00 00:00:00' AND (title=''";
for($i=0;$i<$aantal;$i++)
{
if(strlen($searcharray[$i])>3)
{
$query.=" OR title LIKE '%".invoer($searcharray[$i])."%' OR summary LIKE '%".invoer($searcharray[$i])."%'";
}
}
$query.=") ORDER BY title ASC";
$result=mysql_query($query);
$fl->newBlock("result");
$fl->assign("SECTION", "Books");
if(mysql_num_rows($result)==0)
{
$fl->newBlock("noresults");
$fl->assign("SECTION", "Books");
}
else
{
$fl->newBlock("yesresults");
while($row=mysql_fetch_row($result))
{
$fl->newBlock("item");
$fl->assign("TITLE", opmaak($row[1]));
$fl->assign("LINK", "book.php/".$row[0]);
}
}
reset($searcharray);
// search authors
$query="SELECT DISTINCT id, firstname, name FROM fl_authors WHERE approved='1' AND (name=''";
for($i=0;$i<$aantal;$i++)
{
if(strlen($searcharray[$i])>3)
{
$query.=" OR name LIKE '%".invoer($searcharray[$i])."%' OR firstname LIKE '%".invoer($searcharray[$i])."' OR bio LIKE '%".invoer($searcharray[$i])."%'";
}
}
$query.=") ORDER BY name ASC";
$result=mysql_query($query);
$fl->newBlock("result");
$fl->assign("SECTION", "Authors");
if(mysql_num_rows($result)==0)
{
$fl->newBlock("noresults");
$fl->assign("SECTION", "Authors");
}
else
{
$fl->newBlock("yesresults");
while($row=mysql_fetch_row($result))
{
$fl->newBlock("item");
$fl->assign("TITLE", opmaak($row[1]." ".$row[2]));
$fl->assign("LINK", "author.php/".$row[0]);
}
}
reset($searcharray);
// search publishers
$query="SELECT DISTINCT id, name FROM fl_publishers WHERE approved='1' AND (name=''";
for($i=0;$i<$aantal;$i++)
{
if(strlen($searcharray[$i])>3)
{
$query.=" OR name LIKE '%".invoer($searcharray[$i])."%' OR description LIKE '%".invoer($searcharray[$i])."%'";
}
}
$query.=") ORDER BY name ASC";
$result=mysql_query($query);
echo mysql_error();
$fl->newBlock("result");
$fl->assign("SECTION", "Publishers");
if(mysql_num_rows($result)==0)
{
$fl->newBlock("noresults");
$fl->assign("SECTION", "Publishers");
}
else
{
$fl->newBlock("yesresults");
while($row=mysql_fetch_row($result))
{
$fl->newBlock("item");
$fl->assign("TITLE", opmaak($row[1]));
$fl->assign("LINK", "publisher.php/".$row[0]);
}
}
reset($searcharray);
// search themes
$query="SELECT DISTINCT id, name FROM fl_worlds WHERE approved='1' AND (name=''";
for($i=0;$i<$aantal;$i++)
{
if(strlen($searcharray[$i])>3)
{
$query.=" OR name LIKE '%".invoer($searcharray[$i])."%' OR description LIKE '%".invoer($searcharray[$i])."%'";
}
}
$query.=") ORDER BY name ASC";
$result=mysql_query($query);
echo mysql_error();
$fl->newBlock("result");
$fl->assign("SECTION", "Themes");
if(mysql_num_rows($result)==0)
{
$fl->newBlock("noresults");
$fl->assign("SECTION", "Themes");
}
else
{
$fl->newBlock("yesresults");
while($row=mysql_fetch_row($result))
{
$fl->newBlock("item");
$fl->assign("TITLE", opmaak($row[1]));
$fl->assign("LINK", "theme.php/".$row[0]);
}
}
reset($searcharray);
}
}
$fl->printToScreen();
?>