Browse Source

code cleanup, removed an instance that broke the rules

hnhx 2 years ago
parent
commit
d909552dbf
8 changed files with 17 additions and 37 deletions
  1. 0 1
      README.md
  2. 1 1
      config.php.example
  3. 1 1
      image_proxy.php
  4. 4 10
      instances.json
  5. 2 2
      misc/header.php
  6. 2 11
      misc/tools.php
  7. 6 10
      search.php
  8. 1 1
      settings.php

+ 0 - 1
README.md

@@ -22,7 +22,6 @@
 | [search.milivojevic.in.rs](https://search.milivojevic.in.rs/) | [✅](http://librex2xsek6qnh2i4yufuzqjumfdwtw7io7omgmimpzna6llqudqzyd.onion/) | ❌ | 🇳🇱 NL |
 | [librex.nekus.gay](https://librex.nekus.gay/) | [✅](http://5yblccekvswxl4n43bn5eg4pr7c4xygvu5lhhdb6ulzmislvahmhitad.onion/) | ❌ | 🇵🇱 PL |
 | [search.davidovski.xyz](https://search.davidovski.xyz/) | ❌ | ❌ | 🇬🇧 UK |
-| [search.funami.tech](https://search.funami.tech/) | ❌ | ❌ | 🇰🇷 KR |
 | [search.madreyk.xyz](https://search.madreyk.xyz/) | ❌ | ❌ | 🇩🇪 DE |
 | [search.pabloferreiro.es](https://search.pabloferreiro.es/) | ❌ | ❌ | 🇩🇪 DE |
 | [buscar.weblibre.org](https://buscar.weblibre.org/) | ❌ | ❌ | 🇨🇱 CL |

+ 1 - 1
config.php.example

@@ -7,7 +7,7 @@
         // Google results will be in this language
         "google_language" => "en",
 
-        // If you have a local instance you can change this to http://localhost:3000
+        // You can use any Invidious instance here
         "invidious_instance_for_video_results" => "https://invidious.namazso.eu",
 
         "disable_bittorent_search" => false,

+ 1 - 1
image_proxy.php

@@ -13,7 +13,7 @@
       $image = $url;
       $image_src = request($image);
 
-      header("Content-Type: image/jpeg");
+      header("Content-Type: image/png");
       echo $image_src;
     }
 ?>

+ 4 - 10
instances.json

@@ -48,12 +48,6 @@
               "i2p": null,
               "country": "UK"
           },
-          {
-              "clearnet": "https://search.funami.tech/",
-              "tor": null,
-              "i2p": null,
-              "country": "KR"
-          },
           {
               "clearnet": "https://search.madreyk.xyz/",
               "tor": null,
@@ -115,10 +109,10 @@
               "country": "IN"
           },
           {
-               "clearnet": "https://lx.drain.win",
-               "tor": null,
-               "i2p": null,
-               "country": "SG"
+              "clearnet": "https://lx.drain.win",
+              "tor": null,
+              "i2p": null,
+              "country": "SG"
 	  }
     ]
 }

+ 2 - 2
misc/header.php

@@ -9,8 +9,8 @@
         <link title="LibreX search" type="application/opensearchdescription+xml" href="/opensearch.xml?method=POST" rel="search"/>
         <link rel="stylesheet" type="text/css" href="<?php
                 echo "static/css/";
-                if (isset($_COOKIE["theme"]) || isset($_REQUEST["theme"]))
-                    echo htmlspecialchars((isset($_COOKIE["theme"]) ? $_COOKIE["theme"] : $_REQUEST["theme"]) . ".css");
+                if (isset($_COOKIE["theme"]))
+                    echo htmlspecialchars($_COOKIE["theme"] . ".css");
                 else
                     echo "dark.css";
         ?>"/>

+ 2 - 11
misc/tools.php

@@ -21,12 +21,10 @@
     {
         $config = require "config.php";
 
-        if (isset($_COOKIE[$frontend]) || isset($_REQUEST[$frontend]) || !empty($config->$frontend))
+        if (isset($_COOKIE[$frontend]) || !empty($config->$frontend))
         {
             if (isset($_COOKIE[$frontend]))
                 $frontend = $_COOKIE[$frontend];
-            else if (isset($_REQUEST[$frontend]))
-                $frontend = $_REQUEST[$frontend];
             else if (!empty($config->$frontend))
                 $frontend = $config->$frontend;
 
@@ -140,7 +138,7 @@
 
     function check_for_special_search($query)
     {
-        if (isset($_COOKIE["disable_special"]) || isset($_REQUEST["disable_special"]))
+        if (isset($_COOKIE["disable_special"]))
             return 0;
 
          $query_lower = strtolower($query);
@@ -226,13 +224,6 @@
     function print_next_page_button($text, $page, $query, $type)
     {
         echo "<form class=\"page\" action=\"search.php\" target=\"_top\" method=\"get\" autocomplete=\"off\">";
-        foreach($_REQUEST as $key=>$value)
-        {
-            if ($key != "q" && $key != "p" && $key != "t")
-            {
-                echo "<input type=\"hidden\" name=\"$key\" value=\"$value\"/>";
-            }
-        }
         echo "<input type=\"hidden\" name=\"p\" value=\"" . $page . "\" />";
         echo "<input type=\"hidden\" name=\"q\" value=\"$query\" />";
         echo "<input type=\"hidden\" name=\"t\" value=\"$type\" />";

+ 6 - 10
search.php

@@ -29,14 +29,6 @@
             >
             <br>
             <?php
-                foreach($_REQUEST as $key=>$value)
-                {
-                    if ($key != "q" && $key != "p" && $key != "t")
-                    {
-                        echo "<input type=\"hidden\" name=\"" . htmlspecialchars($key) . "\" value=\"" . htmlspecialchars($value) . "\"/>";
-                    }
-                }
-
                 $type = isset($_REQUEST["t"]) ? (int) $_REQUEST["t"] : 0;
                 echo "<button class=\"hide\" name=\"t\" value=\"$type\"/></button>";
             ?>
@@ -120,10 +112,14 @@
                     break;
 
                 default:
+                    $query_parts = explode(" ", $query);
+                    $last_word_query = end($query_parts);
+                    if (substr($query, 0, 1) == "!" || substr($last_word_query, 0, 1) == "!")
+                        check_ddg_bang($query);
                     require "engines/google/text.php";
-                    $results = get_text_results($query_encoded, $page);
-                    print_text_results($results);
+                    $results = get_text_results($query, $page);
                     print_elapsed_time($start_time);
+                    print_text_results($results);
                     break;
             }
 

+ 1 - 1
settings.php

@@ -30,7 +30,7 @@
 
                 if (isset($_REQUEST["save"]) || isset($_REQUEST["reset"]))
                 {
-                    header("Location: ./settings.php");
+                    header("Location: ./");
                     die();
                 }