forked from flan/hymmnoserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
69 lines (61 loc) · 1.79 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
<?php
header("Expires: Mon, 20 Dec 1998 01:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<?php/*
All code, unless otherwise indicated, is original, and subject to the terms of
the GNU GPLv3 or, at your option, any later version of the GPL.
All content is derived from public domain, promotional, or otherwise-compatible
sources and published uniformly under the
Creative Commons Attribution-Share Alike 3.0 license.
See license.README for details.
(C) Neil Tallim, 2009
*/?>
<?php include 'common/constants.php'; ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Hymmnoserver - Search results</title>
<?php include 'common/resources.xml'; ?>
</head>
<body>
<?php include 'common/header.xml'; ?>
<div>
<?php
$query = '';
if(isset($_REQUEST['word'])){
$query = trim($_REQUEST['word']);
}
if($query == ''){
echo 'No search terms specified.';
exit();
}
$words = split(
"[\t ,]+",
preg_replace(
'/,/', '', preg_replace(
'/\\s+\\.\\s+/', ' ', preg_replace(
'/^\\s*|[?!,:\'"\/\\\\]|\\.\\.+||\\s*\\.*\\s*$/', '', $query
)
)
)
);
require 'secure/db.php';
if($mysql->connect_error){
die('Failed to connect to database: '.htmlentities($mysql->connect_error));
}
if(count($words) > 1){#If more than one token is provided, translate; else, search.
include 'common/translate.php';
}else{
include 'common/search.php';
}
$mysql->close();
?>
</div>
<?php include 'common/footer.xml'; ?>
</body>
</html>