LibreY

- privacy respecting meta search engine
git clone git://git.acid.vegas/LibreY.git
Log | Files | Refs | Archive | README | LICENSE

commit 9d431ae8c090d0e8e789f6d2758b46402f7f375c
parent ad747d51a123f1926de2b2f0cec7064023a31e04
Author: davidovski <david@davidovski.xyz>
Date: Wed, 30 Aug 2023 20:50:23 +0100

Actually exec fallback requests

Diffstat:
Mengines/librex/fallback.php | 7++++++-
Mmisc/search_engine.php | 5+++--

2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/engines/librex/fallback.php b/engines/librex/fallback.php
@@ -47,13 +47,18 @@
 
             $instance = array_pop($instances);
 
+            if (!$instance)
+                break;
+
             if (parse_url($instance)["host"] == parse_url($_SERVER['HTTP_HOST'])["host"])
                 continue;
 
             $librex_request = new LibreXFallback($instance, $opts, null);
+            error_log($librex_request->url);
+            
             $results = $librex_request->get_results();
 
-            if (count($results) > 0)
+            if (!empty($results))
                 return $results;
 
             // on fail then do this
diff --git a/misc/search_engine.php b/misc/search_engine.php
@@ -5,6 +5,7 @@
         function __construct($opts, $mh) {
             $this->query = $opts->query;
             $this->page = $opts->page;
+            $this->mh = $mh;
             $this->opts = $opts;
 
             $this->url = $this->get_request_url();
@@ -44,10 +45,10 @@
             if (!isset($this->ch))
                 return $this->parse_results(null);
 
-            $response = curl_multi_getcontent($this->ch);
+            $response = $this->mh ? curl_multi_getcontent($this->ch) : curl_exec($this->ch);
             $results = $this->parse_results($response) ?? array();
 
-            if ($this->DO_CACHING)
+            if ($this->DO_CACHING && !empty($results))
                 store_cached_results($this->url, $results, $this->opts->cache_time * 60);
 
             return $results;