added google language and safe search settings, made the codebase prettier

This commit is contained in:
hnhx 2023-01-13 09:31:48 +01:00
parent 3afd3ec769
commit 9fad27104b
8 changed files with 35 additions and 12 deletions

View File

@ -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);

View File

@ -39,13 +39,13 @@
<input type="hidden" name="p" value="0">
<div class="sub-search-button-wrapper">
<?php
echo "
<a href=\"/search.php?q=$query&p=0&t=0\"><img src=\"static/images/text_result.png\" alt=\"text result\" />General</a>
<a href=\"/search.php?q=$query&p=0&t=1\"><img src=\"static/images/image_result.png\" alt=\"image result\" />Images</a>
<a href=\"/search.php?q=$query&p=0&t=2\"><img src=\"static/images/video_result.png\" alt=\"video result\" />Videos</a>
<a href=\"/search.php?q=$query&p=0&t=3\"><img src=\"static/images/torrent_result.png\" alt=\"torrent result\" />Torrents</a>
<a href=\"/search.php?q=$query&p=0&t=4\"><img src=\"static/images/tor_result.png\" alt=\"tor result\" />Tor</a>
";
$categories = array("general", "images", "videos", "torrents", "tor");
foreach ($categories as $category)
{
$category_index = array_search($category, $categories);
echo "<a href=\"/search.php?q=" . $query . "&p=0&t=" . $category_index . "\"><img src=\"static/images/" . $category . "_result.png\" alt=\"" . $category . " result\" />" . ucfirst($category) . "</a>";
}
?>
</div>
<hr>

View File

@ -77,7 +77,7 @@
</div>
<h2>Privacy friendly frontends</h2>
<p>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)</p>
<div class="instances-container">
<div class="settings-textbox-container">
<?php
$frontends = array(
@ -97,7 +97,7 @@
echo "<div>";
echo "<a for=\"$frontend\" href=\"" . $info[0] . "\" target=\"_blank\">" . ucfirst($frontend) . "</a>";
echo "<input type=\"text\" name=\"$frontend\" placeholder=\"Replace " . $info[1] . "\" value=";
echo isset($_COOKIE["$frontend"]) ? htmlspecialchars($_COOKIE["$frontend"]) : json_decode(json_encode($config), true)[$frontend];
echo isset($_COOKIE["$frontend"]) ? htmlspecialchars($_COOKIE["$frontend"]) : json_decode(json_encode($config), true)[$frontend];
echo ">";
echo "</div>";
}
@ -107,6 +107,20 @@
<label>Disable frontends</label>
<input type="checkbox" name="disable_frontends" <?php echo isset($_COOKIE["disable_frontends"]) ? "checked" : ""; ?> >
</div>
<h2>Google settings</h2>
<div class="settings-textbox-container">
<div>
<span>Google language</span>
<?php
echo "<input type=\"text\" name=\"google_language\" placeholder=\"E.g.: de\" value=\"";
echo isset($_COOKIE["google_language"]) ? htmlspecialchars($_COOKIE["google_language"]) : $config->google_language;
?>">
</div>
<div>
<label>Safe search</label>
<input type="checkbox" name="safe_search" <?php echo isset($_COOKIE["safe_search"]) ? "checked" : ""; ?> >
</div>
</div>
<div>
<button type="submit" name="save" value="1">Save</button>
<button type="submit" name="reset" value="1">Reset</button>

View File

@ -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;

View File

Before

Width:  |  Height:  |  Size: 598 B

After

Width:  |  Height:  |  Size: 598 B

View File

Before

Width:  |  Height:  |  Size: 704 B

After

Width:  |  Height:  |  Size: 704 B

View File

Before

Width:  |  Height:  |  Size: 657 B

After

Width:  |  Height:  |  Size: 657 B

View File

Before

Width:  |  Height:  |  Size: 360 B

After

Width:  |  Height:  |  Size: 360 B