google web, videos and news, various other fixes

This commit is contained in:
2023-11-27 01:01:56 -05:00
parent 9fd993b47b
commit 2519666e1c
22 changed files with 2913 additions and 1118 deletions

View File

@@ -7,6 +7,7 @@ class captcha{
// check if we want captcha
if(config::BOT_PROTECTION !== 1){
apcu_inc("real_requests");
if($output === true){
$frontend->loadheader(
$get,
@@ -45,6 +46,8 @@ class captcha{
}else{
// the cookie is OK! dont die() and give results
apcu_inc("real_requests");
if($output === true){
$frontend->loadheader(
$get,
@@ -175,6 +178,8 @@ class captcha{
apcu_inc($key, 1, $stupid, 86400);
apcu_inc("real_requests");
setcookie(
"pass",
$key,
@@ -197,7 +202,7 @@ class captcha{
$error = "<div class=\"quote\">You were <a href=\"https://www.youtube.com/watch?v=e1d7fkQx2rk\" target=\"_BLANK\" rel=\"noreferrer nofollow\">kicked out of Mensa.</a> Please try again.</div>";
}
}
// get the positions for the answers
// will return between 3 and 6 answer positions
$range = range(0, 15);

View File

@@ -25,7 +25,7 @@ class frontend{
if($theme != "Dark"){
$replacements["style"] = '<link rel="stylesheet" href="/static/themes/' . $theme . '.css?v' . config::VERSION . '">';
$replacements["style"] = '<link rel="stylesheet" href="/static/themes/' . rawurlencode($theme) . '.css?v' . config::VERSION . '">';
}else{
$replacements["style"] = "";
@@ -84,6 +84,8 @@ class frontend{
){
// bot detected !!
apcu_inc("captcha_gen");
$this->drawerror(
"Tshh, blocked!",
'You were blocked from viewing this page. If you wish to scrape data from 4get, please consider running <a href="https://git.lolcat.ca/lolcat/4get" rel="noreferrer nofollow">your own 4get instance</a> or using <a href="/api.txt">the API</a>.',
@@ -889,7 +891,7 @@ class frontend{
"ddg" => "DuckDuckGo",
"brave" => "Brave",
"yandex" => "Yandex",
//"google" => "Google",
"google" => "Google",
"mojeek" => "Mojeek",
"marginalia" => "Marginalia",
"wiby" => "wiby"
@@ -921,8 +923,8 @@ class frontend{
//"fb" => "Facebook videos",
"ddg" => "DuckDuckGo",
"brave" => "Brave",
"yandex" => "Yandex"
//"google" => "Google"
"yandex" => "Yandex",
"google" => "Google"
]
];
break;
@@ -933,7 +935,7 @@ class frontend{
"option" => [
"ddg" => "DuckDuckGo",
"brave" => "Brave",
//"google" => "Google",
"google" => "Google",
"mojeek" => "Mojeek"
]
];

View File

@@ -15,7 +15,7 @@ class fuckhtml{
if(!isset($html["innerHTML"])){
throw new Exception("(load) Supplied array doesn't contain a innerHTML index");
throw new Exception("(load) Supplied array doesn't contain an innerHTML index");
}
$html = $html["innerHTML"];
}
@@ -35,6 +35,11 @@ class fuckhtml{
$this->strlen = strlen($this->html);
}
public function getloadedhtml(){
return $this->html;
}
public function getElementsByTagName(string $tagname){
$out = [];
@@ -46,7 +51,7 @@ class fuckhtml{
if($tagname == "*"){
$tagname = '[^\/<>\s]+';
$tagname = '[A-Za-z0-9._-]+';
}else{
$tagname = preg_quote(strtolower($tagname));
@@ -126,7 +131,7 @@ class fuckhtml{
}
);
// computer the indent level for each element
// compute the indent level for each element
$level = [];
$count = count($out);
@@ -314,7 +319,7 @@ class fuckhtml{
if(!isset($html["innerHTML"])){
throw new Exception("(getTextContent) Supplied array doesn't contain a innerHTML index");
throw new Exception("(getTextContent) Supplied array doesn't contain an innerHTML index");
}
$html = $html["innerHTML"];
}
@@ -441,4 +446,27 @@ class fuckhtml{
return json_decode($json_out, true);
}
public function parseJsString($string){
return
preg_replace_callback(
'/\\\u[A-Fa-f0-9]{4}|\\\x[A-Fa-f0-9]{2}/',
function($match){
if($match[0][1] == "u"){
return json_decode('"' . $match[0] . '"');
}else{
return mb_convert_encoding(
stripcslashes($match[0]),
"utf-8",
"windows-1252"
);
}
},
$string
);
}
}