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
|
<?php
/*
____ _
/ __ \ | |
| | | |_ __ ___ _ __ ___ ___ __ _ _ __ ___| |__
| | | | '_ \ / _ \ '_ \/ __|/ _ \/ _` | '__/ __| '_ \
| |__| | |_) | __/ | | \__ \ __/ (_| | | | (__| | | |
\____/| .__/ \___|_| |_|___/\___|\__,_|_| \___|_| |_|
| | v0.2
|_|
Copyright : Sumale.nin
Kontakt : ben88b@googlemail.com
Credits : V@no
*/
$main_template = 0;
$nozip = 1;
$nocache = 1;
define('GET_CACHES', (isset($_GET['s'])));
define('ROOT_PATH', '../');
include(ROOT_PATH.'global.php');
$url = "http://".$_SERVER['HTTP_HOST'].str_replace("//", "/", "/".dirname($PHP_SELF)."/")."";
$favicon = ROOT_PATH."favicon.ico";
function get_opensearch_favicon($favicon) {
global $config;
if (file_exists($favicon)) {
return $favicon;
}
else {
return ROOT_PATH."/opensearch/img/opensearch_favicon.png";
}
}
/*
Einstellungen > Start
*/
$url_suggestions = $url."opensearch.php?s=";
$num = 10;
$show_num_results = 1;
/*
Einstellungen > Ende
*/
if (isset($HTTP_GET_VARS['s']))
{
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
include(ROOT_PATH.'includes/search_utils.php');
$r = "";
$n = "";
if (strlen($HTTP_GET_VARS['s']))
{
$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
$cat_id_sql = $cat_id_sql !== 0 ? "AND i.cat_id NOT IN (".$cat_id_sql.")" : "";
$sql = "SELECT DISTINCT w.word_text".($show_num_results ? ", COUNT(w.word_text) as num" : "")."
FROM (".WORDLIST_TABLE." w, ".WORDMATCH_TABLE." m)
LEFT JOIN ".IMAGES_TABLE." i ON (i.image_id = m.image_id)
WHERE w.word_text LIKE '".addslashes(str_replace("*", "%", $HTTP_GET_VARS['s']))."%'
AND m.word_id = w.word_id $cat_id_sql
GROUP BY w.word_text
".($show_num_results ? "ORDER BY num DESC" : "")."
LIMIT $num";
$result = $site_db->query($sql);
while($row = $site_db->fetch_array($result))
{
$r .= ($r?',':'').'"'.str_replace('"', """, stripslashes($row['word_text'])).'"';
if ($show_num_results)
$n .= ($n?',':'').'"'.number_format($row['num']).' '.$lang['opensearch_results'].'"';
}
}
echo '["'.str_replace('"', """, stripslashes($HTTP_GET_VARS['s'])).'",['.$r.'], ['.$n.']]';
}
elseif (isset($HTTP_GET_VARS['xml']))
{
header ("content-type: text/xml");
$array = array("x-ico", "gif", "jpg", "png");
echo ' <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">\n';
echo ' <ShortName>'.htmlspecialchars($config['site_name'], ENT_QUOTES).'</ShortName>\n';
echo ' <Description>'.$lang['search'].'</Description>\n';
echo ' <InputEncoding>'.$lang['charset'].'</InputEncoding>\n';
$favicon_info = getimagesize(get_opensearch_favicon($favicon));
if (!isset($favicon_info[2]) || !isset($array[$favicon_info[2]]))
$favicon_info[2] = 0;
echo ' <Image width="16" height="16" type="image/'.$array[$favicon_info[2]].'">'.$url.get_opensearch_favicon($favicon).'</Image>\n';
echo ' <Url type="text/html" method="get" template="'.$url.'search.php?search_keywords={searchTerms}"/>\n';
if (isset($url_suggestions) && $url_suggestions)
{
echo ' <Url type="application/x-suggestions+json" template="'.$url_suggestions.'{searchTerms}"/>\n';
}
echo ' </OpenSearchDescription>';
}
elseif (isset($HTTP_GET_VARS['js']))
{
echo '
function addEngine()
{
if (window.external && ("AddSearchProvider" in window.external))
{
window.external.AddSearchProvider("'.$url.'opensearch.php?xml" );
}
else if (window.sidebar && ("addSearchEngine" in window.sidebar))
{
window.sidebar.addSearchEngine("'.$url.'opensearch.php?xml",
"'.$url.get_opensearch_favicon($favicon).'",
"opensearch.xml",
"(c) by Sumale.nin"
);
}
else
{
alert("'.$lang['opensearch_support'].'");
}
}
';
}
?>
|