|
@@ -8,15 +8,14 @@
|
|
|
<meta name="description" content="A privacy respecting meta search engine."/>
|
|
|
<link rel="stylesheet" type="text/css" href="static/styles.css"/>
|
|
|
<link title="LibreX search" type="application/opensearchdescription+xml" href="/opensearch.xml?method=POST" rel="search"/>
|
|
|
+ <link rel="shortcut icon" href="static/librex.png" />
|
|
|
</head>
|
|
|
<body>
|
|
|
- <form class="small-search-container" method="post">
|
|
|
- <a href="/"><h1>LibreX</h1></a>
|
|
|
+ <form class="small-search-container" method="post" enctype="multipart/form-data" autocomplete="off">
|
|
|
+ <a href="/"><img id="logo" src="static/librex.png" alt="librex"></a>
|
|
|
<input type="hidden" name="p" value="0">
|
|
|
<input type="text" name="q"
|
|
|
<?php
|
|
|
- session_start();
|
|
|
-
|
|
|
$query = trim($_REQUEST["q"]);
|
|
|
|
|
|
if (1 > strlen($query) || strlen($query) > 256)
|
|
@@ -26,11 +25,6 @@
|
|
|
}
|
|
|
|
|
|
echo "value=\"$query\"";
|
|
|
-
|
|
|
- $_SESSION["q"] = $query;
|
|
|
- $_SESSION["p"] = $_REQUEST["p"];
|
|
|
- $_SESSION["type"] = $_REQUEST["type"];
|
|
|
-
|
|
|
?>
|
|
|
>
|
|
|
<br>
|
|
@@ -47,7 +41,86 @@
|
|
|
<hr>
|
|
|
</form>
|
|
|
|
|
|
- <iframe src="search_frame.php" frameborder="0"></iframe>
|
|
|
+ <?php
|
|
|
+ function print_next_pages($page, $button_val, $q)
|
|
|
+ {
|
|
|
+ echo "<form id=\"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=\"$q\" />";
|
|
|
+ echo "<button type=\"submit\">$button_val</button>";
|
|
|
+ echo "</form>";
|
|
|
+ }
|
|
|
+
|
|
|
+ require_once "google.php";
|
|
|
+ require_once "tools.php";
|
|
|
+
|
|
|
+ $page = (int) htmlspecialchars($_REQUEST["p"]);
|
|
|
+ $type = (int) $_REQUEST["type"];
|
|
|
+
|
|
|
+ $start_time = microtime(true);
|
|
|
+ $results = get_google_results($query, $page, $type);
|
|
|
+ $end_time = number_format(microtime(true) - $start_time, 2, '.', '');
|
|
|
+
|
|
|
+ echo "<p id=\"time\">Fetched the results in $end_time seconds</p>";
|
|
|
+
|
|
|
+ if ($type == 0)
|
|
|
+ {
|
|
|
+ check_for_special_search($query);
|
|
|
+
|
|
|
+ foreach($results as $result)
|
|
|
+ {
|
|
|
+ $title = $result["title"];
|
|
|
+ $url = $result["url"];
|
|
|
+ $base_url = $result["base_url"];
|
|
|
+ $description = $result["description"];
|
|
|
+
|
|
|
+ echo "<div class=\"result-container\">";
|
|
|
+ echo "<a href=\"$url\">";
|
|
|
+ echo "$base_url";
|
|
|
+ echo "<h2>$title</h2>";
|
|
|
+ echo "</a>";
|
|
|
+ echo "<span>$description</span>";
|
|
|
+ echo "</div>";
|
|
|
+ }
|
|
|
+
|
|
|
+ echo "<div class=\"page-container\">";
|
|
|
+
|
|
|
+ if ($page != 0)
|
|
|
+ {
|
|
|
+ print_next_pages(0, "<<", $query);
|
|
|
+ print_next_pages($page - 10, "<", $query);
|
|
|
+ }
|
|
|
+
|
|
|
+ for ($i=$page / 10; $page / 10 + 10 > $i; $i++)
|
|
|
+ {
|
|
|
+ $page_input = $i * 10;
|
|
|
+ $page_button = $i + 1;
|
|
|
+
|
|
|
+ print_next_pages($page_input, $page_button, $query);
|
|
|
+ }
|
|
|
+
|
|
|
+ print_next_pages($page + 10, ">", $query);
|
|
|
+
|
|
|
+ echo "</div>";
|
|
|
+ }
|
|
|
+ else if ($type == 1)
|
|
|
+ {
|
|
|
+
|
|
|
+ echo "<div class=\"image-result-container\">";
|
|
|
+
|
|
|
+ foreach($results as $result)
|
|
|
+ {
|
|
|
+ $src = $result["base64"];
|
|
|
+ $alt = $result["alt"];
|
|
|
+
|
|
|
+ echo "<a title=\"$alt\" href=\"data:image/jpeg;base64,$src\" target=\"_blank\">";
|
|
|
+ echo "<img src=\"data:image/jpeg;base64,$src\" width=\"350\" height=\"200\">";
|
|
|
+ echo "</a>";
|
|
|
+ }
|
|
|
+
|
|
|
+ echo "</div>";
|
|
|
+ }
|
|
|
+ ?>
|
|
|
|
|
|
<div class="info-container">
|
|
|
<a href="/">LibreX</a>
|