1
Fork 1
mirror of https://git.lolcat.ca/lolcat/4get.git synced 2024-09-13 17:28:08 -04:00

bug fixes (without google support)

This commit is contained in:
lolcat 2023-07-27 23:06:49 -04:00
parent 16ee0b368f
commit 7c771c82c8
11 changed files with 219 additions and 214 deletions

View file

@ -60,7 +60,7 @@ $left =
Provide users with a privacy oriented, extremely lightweight, ad free, free as in freedom (and free beer!) way to search for documents around the internet, with minimal, optional javascript code. My long term goal would be to build my own index (that doesn\'t suck) and provide users with an unbiased search engine, with no political inclinations. Provide users with a privacy oriented, extremely lightweight, ad free, free as in freedom (and free beer!) way to search for documents around the internet, with minimal, optional javascript code. My long term goal would be to build my own index (that doesn\'t suck) and provide users with an unbiased search engine, with no political inclinations.
<a href="#logs"><h2 id="logs">Do you keep logs?</h2></a> <a href="#logs"><h2 id="logs">Do you keep logs?</h2></a>
I store data temporarly to get the next page of results. This might include search queries, tokens and other parameters. These parameters are encrypted using <div class="code-inline">aes-256-gcm</div> on the serber, for which I give you a key (also known internally as <div class="code-inline">npt</div> token). When you make a request to get the next page, you supply the token, the data is decrypted and the request is fulfilled. This encrypted data is deleted after 7 minutes, or after it\'s used, whichever comes first.<br><br> I store data temporarly to get the next page of results. This might include search queries, tokens and other parameters. These parameters are encrypted using <div class="code-inline">aes-256-gcm</div> on the serber, for which I give you a key (also known internally as <div class="code-inline">npt</div> token). When you make a request to get the next page, you supply the token, the data is decrypted and the request is fulfilled. This encrypted data is deleted after 15 minutes, or after it\'s used, whichever comes first.<br><br>
I <b>don\'t</b> log IP addresses, user agents, or anything else. The <div class="code-inline">npt</div> tokens are the only thing that are stored (in RAM, mind you), temporarly, encrypted. I <b>don\'t</b> log IP addresses, user agents, or anything else. The <div class="code-inline">npt</div> tokens are the only thing that are stored (in RAM, mind you), temporarly, encrypted.

View file

@ -73,8 +73,8 @@
impossible for a 4get operator to peek at the private data of the impossible for a 4get operator to peek at the private data of the
user after a request has been made. user after a request has been made.
The tokens will expire as soon as they are used or after a 7 minutes The tokens will expire as soon as they are used or after a 15
inactivity period, whichever comes first. minutes inactivity period, whichever comes first.
+ Beware of null values! + Beware of null values!

View file

@ -878,7 +878,7 @@ class frontend{
"option" => [ "option" => [
"ddg" => "DuckDuckGo", "ddg" => "DuckDuckGo",
"brave" => "Brave", "brave" => "Brave",
"google" => "Google", //"google" => "Google",
"mojeek" => "Mojeek", "mojeek" => "Mojeek",
"marginalia" => "Marginalia", "marginalia" => "Marginalia",
"wiby" => "wiby" "wiby" => "wiby"
@ -892,7 +892,7 @@ class frontend{
"option" => [ "option" => [
"ddg" => "DuckDuckGo", "ddg" => "DuckDuckGo",
"yandex" => "Yandex", "yandex" => "Yandex",
"google" => "Google" //"google" => "Google"
] ]
]; ];
break; break;
@ -903,7 +903,7 @@ class frontend{
"option" => [ "option" => [
"yt" => "YouTube", "yt" => "YouTube",
"ddg" => "DuckDuckGo", "ddg" => "DuckDuckGo",
"google" => "Google" //"google" => "Google"
] ]
]; ];
break; break;
@ -914,7 +914,7 @@ class frontend{
"option" => [ "option" => [
"ddg" => "DuckDuckGo", "ddg" => "DuckDuckGo",
"brave" => "Brave", "brave" => "Brave",
"google" => "Google", //"google" => "Google",
"mojeek" => "Mojeek" "mojeek" => "Mojeek"
] ]
]; ];
@ -1285,7 +1285,7 @@ class frontend{
return htmlspecialchars($image); return htmlspecialchars($image);
} }
return "/proxy.php?i=" . urlencode($image) . "&s=" . $format; return "/proxy?i=" . urlencode($image) . "&s=" . $format;
} }
public function htmlnextpage($gets, $npt, $page){ public function htmlnextpage($gets, $npt, $page){

View file

@ -28,7 +28,7 @@ class nextpage{
$this->scraper . $this->scraper .
(string)($key), (string)($key),
gzdeflate($salt.$iv.$out.$tag), gzdeflate($salt.$iv.$out.$tag),
420 // cache information for 7 minutes blaze it 900 // cache information for 15 minutes blaze it
); );
return return

View file

@ -109,6 +109,7 @@ try{
$image->stripImage(); $image->stripImage();
$image->setFormat("jpeg"); $image->setFormat("jpeg");
$image->setImageCompressionQuality(90);
$image->setImageCompression(Imagick::COMPRESSION_JPEG2000); $image->setImageCompression(Imagick::COMPRESSION_JPEG2000);
$proxy->getfilenameheader($payload["headers"], $_GET["i"]); $proxy->getfilenameheader($payload["headers"], $_GET["i"]);

View file

@ -1565,18 +1565,17 @@ class google{
} }
/* /*
Fallback to parsing it as an embed Detect if its a wikipedia thing
*/ */
$h3 =
$this->fuckhtml
->getElementsByTagName("h3");
$table = [
"title" => null,
"description" => [],
"url" => null,
"thumb" => null,
"table" => [],
"sublink" => []
];
/*
Fallback to parsing the word definitions
*/
$parts = $parts =
$this->fuckhtml $this->fuckhtml
->getElementsByClassName( ->getElementsByClassName(
@ -1596,12 +1595,17 @@ class google{
$head = $parts[0]; $head = $parts[0];
$h3 =
$this->fuckhtml
->getElementsByTagName("h3");
if(count($h3) !== 0){ if(count($h3) !== 0){
$table = [
"title" => null,
"description" => [],
"url" => null,
"thumb" => null,
"table" => [],
"sublink" => []
];
$h3 = $h3[0]; $h3 = $h3[0];
$table["title"] = $table["title"] =
@ -1626,201 +1630,201 @@ class google{
$head $head
) )
]; ];
}
$audio =
$this->fuckhtml
->getElementsByTagName("audio");
if(count($audio) !== 0){
$table["description"][] = [ $audio =
"type" => "audio",
"url" =>
str_replace(
"http://",
"https://",
$this->fuckhtml
->getTextContent(
$audio[0]["attributes"]["src"]
)
)
];
}
if(count($parts) >= 2){
$this->fuckhtml->load($parts[1]);
$parts =
$this->fuckhtml $this->fuckhtml
->getElementsByClassName( ->getElementsByTagName("audio");
$this->findstyles(
[
"padding-bottom" => "12px"
],
self::is_class
),
"div"
);
foreach($parts as $part){ if(count($audio) !== 0){
$this->fuckhtml->load($part); $table["description"][] = [
"type" => "audio",
$lists = "url" =>
$this->fuckhtml str_replace(
->getElementsByTagName("ol"); "http://",
"https://",
if(count($lists) !== 0){
foreach($lists as $list){
$this->fuckhtml->load($list);
$list_items =
$this->fuckhtml $this->fuckhtml
->getElementsByTagName("li"); ->getTextContent(
$audio[0]["attributes"]["src"]
$index = 0; )
if(count($list_items) !== 0){
foreach($list_items as $list_item){
$index++;
$this->fuckhtml->load($list_item);
$list_subitems =
$this->fuckhtml
->getElementsByTagName("div");
foreach($list_subitems as $subitem){
if($subitem["level"] !== 1){ continue; }
$this->fuckhtml->load($subitem);
$spans =
$this->fuckhtml
->getElementsByTagName("span");
if(count($spans) !== 0){
$type = "quote";
}else{
$type = "text";
}
$value =
$this->fuckhtml
->getTextContent(
$subitem
);
if($type == "text"){
$value = $index . ". " . $value;
}
$table["description"][] = [
"type" => $type,
"value" => $value
];
}
}
}
}
continue;
}
// get title
$spans =
$this->fuckhtml
->getElementsByTagName("span");
if(count($spans) !== 0){
foreach($spans as $span){
$part["innerHTML"] =
str_replace(
$span["outerHTML"],
"",
$part["innerHTML"]
);
}
if(
$this->fuckhtml
->getTextContent(
$part
) )
== "" ];
){ }
$table["description"][] = [ if(count($parts) >= 2){
"type" => "title",
"value" =>
$this->fuckhtml
->getTextContent(
$spans[0]
)
];
continue;
}
}
// fallback to getting non-numbered list $this->fuckhtml->load($parts[1]);
$nlist =
$parts =
$this->fuckhtml $this->fuckhtml
->getElementsByClassName( ->getElementsByClassName(
$this->findstyles( $this->findstyles(
[ [
"white-space" => "pre-line", "padding-bottom" => "12px"
"word-wrap" => "break-word"
], ],
self::is_class self::is_class
), ),
"div" "div"
); );
if(count($nlist) !== 0){ foreach($parts as $part){
foreach($nlist as $nlist_item){ $this->fuckhtml->load($part);
$lists =
$this->fuckhtml
->getElementsByTagName("ol");
if(count($lists) !== 0){
$text = foreach($lists as $list){
$this->fuckhtml->load($list);
$list_items =
$this->fuckhtml
->getElementsByTagName("li");
$index = 0;
if(count($list_items) !== 0){
foreach($list_items as $list_item){
$index++;
$this->fuckhtml->load($list_item);
$list_subitems =
$this->fuckhtml
->getElementsByTagName("div");
foreach($list_subitems as $subitem){
if($subitem["level"] !== 1){ continue; }
$this->fuckhtml->load($subitem);
$spans =
$this->fuckhtml
->getElementsByTagName("span");
if(count($spans) !== 0){
$type = "quote";
}else{
$type = "text";
}
$value =
$this->fuckhtml
->getTextContent(
$subitem
);
if($type == "text"){
$value = $index . ". " . $value;
}
$table["description"][] = [
"type" => $type,
"value" => $value
];
}
}
}
}
continue;
}
// get title
$spans =
$this->fuckhtml
->getElementsByTagName("span");
if(count($spans) !== 0){
foreach($spans as $span){
$part["innerHTML"] =
str_replace(
$span["outerHTML"],
"",
$part["innerHTML"]
);
}
if(
$this->fuckhtml $this->fuckhtml
->getTextContent($nlist_item); ->getTextContent(
$part
if($text == ""){ )
== ""
){
$table["description"][] = [
"type" => "title",
"value" =>
$this->fuckhtml
->getTextContent(
$spans[0]
)
];
continue; continue;
} }
}
// fallback to getting non-numbered list
$nlist =
$this->fuckhtml
->getElementsByClassName(
$this->findstyles(
[
"white-space" => "pre-line",
"word-wrap" => "break-word"
],
self::is_class
),
"div"
);
if(count($nlist) !== 0){
$this->fuckhtml->load($nlist_item); foreach($nlist as $nlist_item){
$spans =
$this->fuckhtml
->getElementsByTagName("span");
if(count($spans) !== 0){
// is a quote node $text =
$type = "quote"; $this->fuckhtml
}else{ ->getTextContent($nlist_item);
$type = "text"; if($text == ""){
continue;
}
$this->fuckhtml->load($nlist_item);
$spans =
$this->fuckhtml
->getElementsByTagName("span");
if(count($spans) !== 0){
// is a quote node
$type = "quote";
}else{
$type = "text";
}
$table["description"][] = [
"type" => $type,
"value" => $text
];
} }
$table["description"][] = [
"type" => $type,
"value" => $text
];
} }
} }
} }

View file

@ -70,10 +70,10 @@ $settings = [
"value" => "brave", "value" => "brave",
"text" => "Brave" "text" => "Brave"
], ],
[ //[
"value" => "google", // "value" => "google",
"text" => "Google" // "text" => "Google"
], //],
[ [
"value" => "mojeek", "value" => "mojeek",
"text" => "Mojeek" "text" => "Mojeek"
@ -99,11 +99,11 @@ $settings = [
[ [
"value" => "yandex", "value" => "yandex",
"text" => "Yandex" "text" => "Yandex"
], ]//,
[ //[
"value" => "google", // "value" => "google",
"text" => "Google" // "text" => "Google"
] //]
] ]
], ],
[ [
@ -117,11 +117,11 @@ $settings = [
[ [
"value" => "ddg", "value" => "ddg",
"text" => "DuckDuckGo" "text" => "DuckDuckGo"
], ]//,
[ //[
"value" => "google", // "value" => "google",
"text" => "Google" // "text" => "Google"
] //]
] ]
], ],
[ [
@ -136,10 +136,10 @@ $settings = [
"value" => "brave", "value" => "brave",
"text" => "Brave" "text" => "Brave"
], ],
[ //[
"value" => "google", // "value" => "google",
"text" => "Google" // "text" => "Google"
], //],
[ [
"value" => "mojeek", "value" => "mojeek",
"text" => "Mojeek" "text" => "Mojeek"
@ -219,7 +219,7 @@ echo
'<head>' . '<head>' .
'<meta http-equiv="Content-Type" content="text/html;charset=utf-8">' . '<meta http-equiv="Content-Type" content="text/html;charset=utf-8">' .
'<title>Settings</title>' . '<title>Settings</title>' .
'<link rel="stylesheet" href="/static/style.css">' . '<link rel="stylesheet" href="/static/style.css?v2">' .
'<meta name="viewport" content="width=device-width,initial-scale=1">' . '<meta name="viewport" content="width=device-width,initial-scale=1">' .
'<meta name="robots" content="index,follow">' . '<meta name="robots" content="index,follow">' .
'<link rel="icon" type="image/x-icon" href="/favicon.ico">' . '<link rel="icon" type="image/x-icon" href="/favicon.ico">' .

View file

@ -3,7 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>{%title%}</title> <title>{%title%}</title>
<link rel="stylesheet" href="/static/style.css"> <link rel="stylesheet" href="/static/style.css?v2">
<meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="robots" content="{%index%}index,{%index%}follow"> <meta name="robots" content="{%index%}index,{%index%}follow">
<link rel="icon" type="image/x-icon" href="/favicon.ico"> <link rel="icon" type="image/x-icon" href="/favicon.ico">

View file

@ -4,7 +4,7 @@
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>4get</title> <title>4get</title>
<meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="/static/style.css"> <link rel="stylesheet" href="/static/style.css?v2">
<meta name="robots" content="index,follow"> <meta name="robots" content="index,follow">
<link rel="icon" type="image/x-icon" href="/favicon.ico"> <link rel="icon" type="image/x-icon" href="/favicon.ico">
<meta name="description" content="4get.ca: They live in our walls!"> <meta name="description" content="4get.ca: They live in our walls!">
@ -31,6 +31,6 @@
Report a problem: <a href="https://lolcat.ca/contact">lolcat.ca/contact</a> Report a problem: <a href="https://lolcat.ca/contact">lolcat.ca/contact</a>
</div> </div>
</div> </div>
<script src="/static/client.js"></script> <script src="/static/client.js?v2"></script>
</body> </body>
</html> </html>

View file

@ -2,6 +2,6 @@
{%images%} {%images%}
</div> </div>
{%nextpage%} {%nextpage%}
<script src="/static/client.js"></script> <script src="/static/client.js?v2"></script>
</body> </body>
</html> </html>

View file

@ -11,6 +11,6 @@
{%left%} {%left%}
</div> </div>
</div> </div>
<script src="/static/client.js"></script> <script src="/static/client.js?v2"></script>
</body> </body>
</html> </html>