added logo, removed the search frame because it caused form resubmission warning

This commit is contained in:
hnhx 2022-02-20 18:11:15 +01:00
parent 6e7272bf27
commit 4616edc73d
7 changed files with 103 additions and 135 deletions

View File

@ -2,11 +2,12 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>LibreX - Donate</title>
<title>LibreX - Donate ❤️</title>
<meta http-equiv="Content-type" content="application/xhtml+xml;charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="description" content="A privacy respecting meta search engine."/>
<link rel="stylesheet" type="text/css" href="static/styles.css"/>
<link rel="shortcut icon" href="static/librex.png" />
</head>
<body>
<div class="donate-container">

View File

@ -7,10 +7,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="description" content="A privacy respecting meta search engine."/>
<link rel="stylesheet" type="text/css" href="static/styles.css"/>
<link rel="shortcut icon" href="static/librex.png" />
</head>
<body>
<form class="search-container" action="search.php" method="post">
<h1>LibreX</h1>
<form class="search-container" action="search.php" method="post" enctype="multipart/form-data" autocomplete="off">
<h1>Libre<span style="color:#bd93f9;">X</span></h1>
<input type="text" name="q"/>
<input type="hidden" name="p" value="0"/>
<input type="submit" style="display:none"/>

View File

@ -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) // text search
{
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, "&lt;&lt;", $query);
print_next_pages($page - 10, "&lt;", $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, "&gt;", $query);
echo "</div>";
}
else if ($type == 1) // image search
{
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>

View File

@ -1,97 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-type" content="application/xhtml+xml;charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" type="text/css" href="static/styles.css"/>
</head>
<body>
<?php
function print_next_pages($page, $button_val, $q)
{
echo "<form id=\"page\" action=\"search.php\" target=\"_top\" method=\"post\">";
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>";
}
session_start();
require_once "google.php";
require_once "tools.php";
$query = $_SESSION["q"];
$page = (int) htmlspecialchars($_SESSION["p"]);
$type = (int) $_SESSION["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) // text search
{
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\" target=\"_blank\">";
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, "&lt;&lt;", $query);
print_next_pages($page - 10, "&lt;", $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, "&gt;", $query);
echo "</div>";
}
else if ($type == 1) // image search
{
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>";
}
better_session_destroy();
?>
</body>
</html>

BIN
static/librex.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

@ -4,18 +4,14 @@ html {
font-family: Arial, Helvetica, sans-serif;
font-size: 18px;
overflow-x: hidden;
}
hr {
margin-top: 30px;
}
iframe {
width: 100%;
height: 80vh;
max-height: 100vh;
}
img {
border: 1px solid #5f6368;
}
@ -225,7 +221,7 @@ img {
.page-container {
margin-top:50px;
margin-bottom:50px;
margin-bottom:100px;
margin-left:15%;
}
@ -259,7 +255,7 @@ img {
}
.result-change button {
color:#c58af9;
color:#bd93f9;
background-color: inherit;
display: inline;
@ -268,8 +264,6 @@ img {
text-decoration: underline;
font-size: 18px;
margin-top:20px;
}
.result-change button:hover {
@ -346,6 +340,10 @@ img {
margin:10px;
}
#time {
margin-top: 60px;
}
}
@ -411,4 +409,11 @@ img {
padding: 10px;
border: 1px solid #bdc1c6;
width: 500px;
}
#logo {
vertical-align: middle;
width: 80px;
height: 80px;
border: none;
}

View File

@ -6,21 +6,6 @@
return $base_url;
}
function better_session_destroy()
{
$_SESSION = array();
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}
session_destroy();
}
function check_for_special_search($query)
{
$query_lower = strtolower($query);