mirror of
https://github.com/hnhx/librex.git
synced 2025-04-29 14:09:27 -04:00
Added suggestions and fixed drag and drop
This commit is contained in:
parent
dec8c3ed8e
commit
ba589f8361
3 changed files with 30 additions and 4 deletions
16
engines/google/suggestions.php
Normal file
16
engines/google/suggestions.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
function get_suggestions_results($query) {
|
||||
global $config;
|
||||
$query_encoded = urlencode($query);
|
||||
$url = "https://www.google.$config->google_domain/complete/search?q=$query_encoded&output=firefox&hl=$config->google_language";
|
||||
|
||||
// Make request
|
||||
$ch = curl_init($url);
|
||||
curl_setopt_array($ch, $config->curl_settings);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function print_suggestions_results($result) {
|
||||
echo $result;
|
||||
}
|
|
@ -4,11 +4,11 @@
|
|||
<Description>A meta search engine for Google.</Description>
|
||||
<InputEncoding>UTF-8</InputEncoding>
|
||||
<LongName>LibreX search</LongName>
|
||||
<Url rel="results" type="text/html" method="post" template="http://localhost/search.php">
|
||||
<Param name="q" value="{searchTerms}" />
|
||||
</Url>
|
||||
<Url rel="results" type="text/html" method="get" template="http://localhost/search.php?q={searchTerms}" />
|
||||
|
||||
<Url rel="suggestions" type="application/x-suggestions+json" method="get" template="http://localhost/suggestions.php?q={searchTerms}" />
|
||||
|
||||
<Url type="application/opensearchdescription+xml"
|
||||
rel="self"
|
||||
template="/opensearch.xml?method=POST" />
|
||||
</OpenSearchDescription>
|
||||
</OpenSearchDescription>
|
||||
|
|
10
suggestions.php
Normal file
10
suggestions.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
$config = require "config.php";
|
||||
require "engines/google/suggestions.php";
|
||||
|
||||
header('Content-Type: application/x-suggestions+xml');
|
||||
header('Content-Disposition: attachment; filename="suggestions.json"');
|
||||
|
||||
$q = isset($_REQUEST['q']) ? htmlspecialchars(trim($_REQUEST["q"])) : '';
|
||||
$result = get_suggestions_results($q);
|
||||
echo print_suggestions_results($result, $q);
|
Loading…
Add table
Reference in a new issue