123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- function get_root_domain($url)
- {
- $split_url = explode("/", $url);
- $base_url = $split_url[2];
- $base_url_main_split = explode(".", strrev($base_url));
- $root_domain = strrev($base_url_main_split[1]) . "." . strrev($base_url_main_split[0]);
- return $root_domain;
- }
- function check_ddg_bang($query)
- {
- $bangs_json = file_get_contents("static/misc/ddg_bang.json");
- $bangs = json_decode($bangs_json, true);
- if (substr($query, 0, 1) == "!")
- $search_word = substr(explode(" ", $query)[0], 1);
- else
- $search_word = substr(end(explode(" ", $query)), 1);
- $bang_url = null;
- foreach($bangs as $bang)
- {
- if ($bang["t"] == $search_word)
- {
- $bang_url = $bang["u"];
- break;
- }
- }
- if ($bang_url)
- {
- $bang_query_array = explode("!" . $search_word, $query);
- $bang_query = trim(implode("", $bang_query_array));
- $request_url = str_replace("{{{s}}}", $bang_query, $bang_url);
- // $request_url = check_for_privacy_frontend($request_url);
- header("Location: " . $request_url);
- die();
- }
- }
- // Only works in indivious (original), ahmia (original) and image proxy
- function request($url)
- {
- global $config;
- $ch = curl_init($url);
- curl_setopt_array($ch, $config->curl_settings);
- $response = curl_exec($ch);
- return $response;
- }
- function print_elapsed_time($start_time)
- {
- $end_time = number_format(microtime(true) - $start_time, 2, '.', '');
- echo "<p id=\"time\">Fetched the results in $end_time seconds</p>";
- }
- function print_next_page_button($text, $page, $query, $type)
- {
- echo "<form class=\"page\" action=\"search.php\" target=\"_top\" method=\"post\" enctype=\"multipart/form-data\" autocomplete=\"off\">";
- echo "<input type=\"hidden\" name=\"p\" value=\"$page\" />";
- echo "<input type=\"hidden\" name=\"q\" value=\"" . htmlspecialchars($query) ."\" />";
- echo "<input type=\"hidden\" name=\"t\" value=\"$type\" />";
- echo "<button type=\"submit\">$text</button>";
- echo "</form>";
- }
- ?>
|