From 4d5eefc986861970b041c4d3636ff7e5e03af4cb Mon Sep 17 00:00:00 2001 From: hnhx Date: Wed, 23 Feb 2022 20:47:10 +0100 Subject: [PATCH] added wikipedia results, slightly improved mobile css --- google.php | 6 ++-- results/{ => google}/image.php | 0 results/{ => google}/text.php | 0 results/{ => google}/video.php | 0 results/wikipedia.php | 59 ++++++++++++++++++++++++++++++++++ static/styles.css | 23 +++++++++++++ tools.php | 9 ++++-- 7 files changed, 91 insertions(+), 6 deletions(-) rename results/{ => google}/image.php (100%) rename results/{ => google}/text.php (100%) rename results/{ => google}/video.php (100%) create mode 100644 results/wikipedia.php diff --git a/google.php b/google.php index aa4cd90..8eba48a 100644 --- a/google.php +++ b/google.php @@ -2,9 +2,9 @@ function get_google_results($query, $page, $type=0) { require "config.php"; - require_once "results/image.php"; - require_once "results/text.php"; - require_once "results/video.php"; + require_once "results/google/image.php"; + require_once "results/google/text.php"; + require_once "results/google/video.php"; $query_encoded = urlencode($query); diff --git a/results/image.php b/results/google/image.php similarity index 100% rename from results/image.php rename to results/google/image.php diff --git a/results/text.php b/results/google/text.php similarity index 100% rename from results/text.php rename to results/google/text.php diff --git a/results/video.php b/results/google/video.php similarity index 100% rename from results/video.php rename to results/google/video.php diff --git a/results/wikipedia.php b/results/wikipedia.php new file mode 100644 index 0000000..785ce52 --- /dev/null +++ b/results/wikipedia.php @@ -0,0 +1,59 @@ +"; + + if (array_key_exists("thumbnail", $first_page_image)) + { + $img_src = $first_page_image["thumbnail"]["source"]; + $ch_image = curl_init($first_page_image["thumbnail"]["source"]); + curl_setopt_array($ch_image, $config_curl_settings); + $image_response = curl_exec($ch_image); + $base64_image = base64_encode($image_response); + + echo ""; + echo ""; + echo ""; + } + + echo "$description"; + echo ""; + echo "Wikipedia"; + echo ""; + + echo "

"; + } + } +?> \ No newline at end of file diff --git a/static/styles.css b/static/styles.css index 5a2edce..1cd8025 100644 --- a/static/styles.css +++ b/static/styles.css @@ -336,7 +336,23 @@ button { border: none; } +#wiki-image { + border: none; + display: flex; + width: 50%; + max-height: 200px; + + padding-bottom:10px; + +} + +#wiki-link { + display: flex; + margin-top: 16px; + font-size:14px; + color:#bd93f9; +} /* @media START */ @@ -427,6 +443,9 @@ button { margin-left: auto; margin-right: auto; + + width: 98%; + margin-bottom: 30px; } @@ -441,6 +460,10 @@ button { #time { margin-top: 30px; } + + .page-container { + margin-bottom:130px; + } } /* @media END */ \ No newline at end of file diff --git a/tools.php b/tools.php index 55feae9..30a7153 100644 --- a/tools.php +++ b/tools.php @@ -10,18 +10,21 @@ { $query_lower = strtolower($query); - // Check for currency convesion if (strpos($query_lower, "to")) { require_once "results/currency.php"; currency_results($query); } - - // Check for definition else if (strpos($query_lower, "mean")) { require_once "results/definition.php"; definition_results($query); } + else if (5 > count(explode(" ", $query))) // long queries usually wont return a wiki result thats why this check exists + { + require_once "results/wikipedia.php"; + wikipedia_results($query_lower); + return; + } } ?> \ No newline at end of file