Add no results messages

This commit is contained in:
davidovski 2023-08-30 17:26:34 +01:00
parent a00da6eb65
commit 12f02198f9
3 changed files with 25 additions and 10 deletions

View file

@ -70,6 +70,12 @@
);
}
if (empty($results) && !str_contains($response, "Our systems have detected unusual traffic from your computer network.")) {
$results["error"] = array(
"message" => "There are no results. Please try different keywords!"
);
}
return $results;
}
}

View file

@ -36,23 +36,31 @@
$results = $this->engine_request->get_results();
if ($this->special_request) {
$special_result = $this->special_request->get_results();
if ($special_result)
$results = array_merge(array($special_result), $results);
}
if (count($results) <= 1)
if (empty(count($results))) {
set_cooldown($this->engine, ($opts->request_cooldown ?? "1") * 60, $this->opts->cooldowns);
} else {
if ($this->special_request) {
$special_result = $this->special_request->get_results();
if ($special_result)
$results = array_merge(array($special_result), $results);
}
}
return $results;
}
public static function print_results($results) {
if (empty($results))
if (empty($results)) {
echo "<div class=\"text-result-container\"><p>An error occured fetching results</p></div>";
return;
}
if (array_key_exists("error", $results)) {
echo "<div class=\"text-result-container\"><p>" . $results["error"]["message"] . "</p></div>";
return;
}
$special = $results[0];

View file

@ -152,8 +152,9 @@
} while ($running);
$results = $search_category->get_results();
error_log(print_r($results, true));
if (count($results) <= 1) {
if (empty($results)) {
require "engines/librex/fallback.php";
$results = get_librex_results($opts);
}