From 9fad27104b5c3c2ab25e029feba68df58900642c Mon Sep 17 00:00:00 2001 From: hnhx Date: Fri, 13 Jan 2023 09:31:48 +0100 Subject: [PATCH] added google language and safe search settings, made the codebase prettier --- engines/google/text.php | 11 ++++++++++- search.php | 14 +++++++------- settings.php | 18 ++++++++++++++++-- static/css/styles.css | 4 ++-- .../{text_result.png => general_result.png} | Bin .../{image_result.png => images_result.png} | Bin ...torrent_result.png => torrents_result.png} | Bin .../{video_result.png => videos_result.png} | Bin 8 files changed, 35 insertions(+), 12 deletions(-) rename static/images/{text_result.png => general_result.png} (100%) rename static/images/{image_result.png => images_result.png} (100%) rename static/images/{torrent_result.png => torrents_result.png} (100%) rename static/images/{video_result.png => videos_result.png} (100%) diff --git a/engines/google/text.php b/engines/google/text.php index c5270b1..b406b32 100644 --- a/engines/google/text.php +++ b/engines/google/text.php @@ -7,7 +7,16 @@ $query_encoded = urlencode($query); $results = array(); - $url = "https://www.google.$config->google_domain/search?&q=$query_encoded&start=$page&hl=$config->google_language"; + $domain = $config->google_domain; + $language = isset($_COOKIE["google_language"]) ? htmlspecialchars($_COOKIE["google_language"]) : $config->google_language; + + $url = "https://www.google.$domain/search?&q=$query_encoded&start=$page&hl=$language&lr=lang_$language"; + + if (isset($_COOKIE["safe_search"])) + { + $url .= "&safe=medium"; + } + $google_ch = curl_init($url); curl_setopt_array($google_ch, $config->curl_settings); curl_multi_add_handle($mh, $google_ch); diff --git a/search.php b/search.php index 1c19049..61f9239 100644 --- a/search.php +++ b/search.php @@ -39,13 +39,13 @@
\"textGeneral - \"imageImages - \"videoVideos - \"torrentTorrents - \"torTor - "; + $categories = array("general", "images", "videos", "torrents", "tor"); + + foreach ($categories as $category) + { + $category_index = array_search($category, $categories); + echo "\""" . ucfirst($category) . ""; + } ?>

diff --git a/settings.php b/settings.php index 36f7b13..5d6296f 100644 --- a/settings.php +++ b/settings.php @@ -77,7 +77,7 @@

Privacy friendly frontends

For an example if you want to view YouTube without getting spied on, click on "Invidious", find the instance that is most suitable for you then paste it in (correct format: https://example.com)

-
+
"; echo "" . ucfirst($frontend) . ""; echo ""; echo "
"; } @@ -107,6 +107,20 @@ >
+

Google settings

+
+
+ Google language + google_language; + ?>"> +
+
+ + > +
+
diff --git a/static/css/styles.css b/static/css/styles.css index db0b5ae..bea4dbb 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -164,12 +164,12 @@ a:hover, text-decoration: underline; } -.instances-container div { +.settings-textbox-container div { text-align: left; margin-bottom: 25px; } -.instances-container input { +.settings-textbox-container input { color: inherit; background-color: inherit; padding: 5px; diff --git a/static/images/text_result.png b/static/images/general_result.png similarity index 100% rename from static/images/text_result.png rename to static/images/general_result.png diff --git a/static/images/image_result.png b/static/images/images_result.png similarity index 100% rename from static/images/image_result.png rename to static/images/images_result.png diff --git a/static/images/torrent_result.png b/static/images/torrents_result.png similarity index 100% rename from static/images/torrent_result.png rename to static/images/torrents_result.png diff --git a/static/images/video_result.png b/static/images/videos_result.png similarity index 100% rename from static/images/video_result.png rename to static/images/videos_result.png