Fix Marginalia (Sync)

c42e62cb09
cdf9164113
This commit is contained in:
FbIN Support 2026-02-25 12:48:38 +05:30
commit 944f6c731b

View file

@ -196,7 +196,7 @@ class marginalia{
return $data; return $data;
} }
public function web($get){ public function web($get, $ss = ""){
$search = [$get["s"]]; $search = [$get["s"]];
if(strlen($get["s"]) === 0){ if(strlen($get["s"]) === 0){
@ -390,28 +390,35 @@ class marginalia{
} }
}else{ }else{
$params = [
"query" => $search
];
foreach(["adtech", "recent", "intitle"] as $v){ if($ss == ""){
if($get[$v] == "yes"){ $params = [
"query" => $search
];
switch($v){ foreach(["adtech", "recent", "intitle"] as $v){
case "adtech": $params["adtech"] = "reduce"; break; if($get[$v] == "yes"){
case "recent": $params["recent"] = "recent"; break;
case "adtech": $params["searchTitle"] = "title"; break; switch($v){
case "adtech": $params["adtech"] = "reduce"; break;
case "recent": $params["recent"] = "recent"; break;
case "adtech": $params["searchTitle"] = "title"; break;
}
} }
} }
}else{
$params = [];
} }
try{ try{
$html = $html =
$this->get( $this->get(
$proxy, $proxy,
"https://old-search.marginalia.nu/search", "https://old-search.marginalia.nu/search" . $ss,
$params, $params,
//$anubis_key //$anubis_key
); );
@ -423,6 +430,66 @@ class marginalia{
$this->fuckhtml->load($html); $this->fuckhtml->load($html);
// detect meta redirect
$title =
$this->fuckhtml
->getElementsByTagName(
"title"
);
if(
count($title) !== 0 &&
$this->fuckhtml
->getTextContent(
$title[0]
) == "Error"
){
// redirect detected
// get timeout
$timeout =
$this->fuckhtml
->getElementById(
"countdown",
"b"
);
if(count($timeout) === null){
throw new Exception("Failed to find timeout value");
}
$timeout =
$this->fuckhtml
->getTextContent(
$timeout
);
preg_match(
'/location\.replace\(\'([^\']+)\'\)/',
$html,
$redirect
);
if(!isset($redirect[1])){
throw new Exception("Failed to grep redirect value");
}
$one = 1;
$redirect =
str_replace(
"/search",
"",
$redirect[1],
$one
);
sleep((int)$timeout);
return $this->web($get, $redirect);
}
$sections = $sections =
$this->fuckhtml $this->fuckhtml
->getElementsByClassName( ->getElementsByClassName(