-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautocomplete.php
73 lines (64 loc) · 1.75 KB
/
autocomplete.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
<?php
/* --------------------------------------------------------------
autocomplete.php 2015-05-06
Gambio GmbH
http://www.gambio.de
Copyright (c) 2014 Gambio GmbH
Released under the GNU General Public License (Version 2)
[http://www.gnu.org/licenses/gpl-2.0.html]
--------------------------------------------------------------
*/
/* File: autocomplete.php
* Version: 4.1
* Date: 21.Jan.2010
* $Revision: 216 $
* FINDOLOGIC GmbH
*/
require_once 'includes/application_top.php';
require_once('./findologic_config.inc.php');
function getUrl($url, $timeout = 5)
{
$curl_opts = array(
CURLOPT_URL => $url,
CURLOPT_TIMEOUT => $timeout,
CURLOPT_RETURNTRANSFER => true,
);
$ch = curl_init();
curl_setopt_array($ch, $curl_opts);
$response = curl_exec($ch);
$errno = curl_errno($ch);
$error = curl_error($ch);
$info = curl_getinfo($ch);
curl_close($ch);
$result = array(
'response' => $response,
'info' => $info,
'errno' => $errno,
'error' => $error,
);
return $result;
}
/*
* do http-request
*/
$parameters = $_GET;
$parameters['shopkey'] = FL_SHOP_ID;
$parameters['revision_timestamp'] = FL_REVISION;
/* manually pass the arg_separator as '&' to avoid problems with different configurations */
if(strpos(FL_SERVICE_URL, 'http') === false)
{
$scheme_prefix = "http://";
}
else {
$scheme_prefix = '';
}
$url = $scheme_prefix.FL_SERVICE_URL."/autocomplete.php?" . http_build_query($parameters, '', '&');
$result = getUrl($url);
if($result['error'] > 0)
{
die('Could not connect to search service, please check your shop config');
}
header('Content-Type: ' . $result['info']['content_type']);
$content = $result['response'];
echo $content;
xtc_db_close();