add support for displaying cucked urls
This commit is contained in:
1 parent
b120d441d5
commit
eca698c94d
4 files changed
+85
-41
No files matched your search
+1
-1
@@ -5,7 +5,7 @@ class config{
|
||||
// any parameters.
|
||||
|
||||
// 4get version. Please keep this updated
|
||||
const VERSION = 9;
|
||||
const VERSION = 10;
|
||||
|
||||
// Will be shown pretty much everywhere.
|
||||
const SERVER_NAME = "4get";
|
||||
|
||||
+68
-40
@@ -238,7 +238,17 @@ class frontend{
|
||||
$payload = '<div class="text-result">';
|
||||
|
||||
// add favicon, link and archive links
|
||||
$payload .= $this->drawlink($site["url"]);
|
||||
|
||||
// add cucked URL if /resolver is present
|
||||
$cucked =
|
||||
isset($site["cuckurl"]) &&
|
||||
preg_match(
|
||||
'/\/resolver/',
|
||||
$site["url"]
|
||||
) !== 0 ?
|
||||
$site["cuckurl"] : null;
|
||||
|
||||
$payload .= $this->drawlink($site["url"], $cucked);
|
||||
|
||||
/*
|
||||
Draw title + description + filetype
|
||||
@@ -290,7 +300,7 @@ class frontend{
|
||||
$payload .=
|
||||
'</div>';
|
||||
}
|
||||
|
||||
|
||||
$payload .=
|
||||
'<div class="title">';
|
||||
|
||||
@@ -487,11 +497,24 @@ class frontend{
|
||||
return $text;
|
||||
}
|
||||
|
||||
public function drawlink($link){
|
||||
public function drawlink(string $link, $cucked = null){
|
||||
|
||||
/*
|
||||
Add favicon
|
||||
*/
|
||||
$f404_host = "404";
|
||||
|
||||
if($cucked !== null){
|
||||
|
||||
// attempt to get the host from the cucked URL
|
||||
$host = parse_url($cucked);
|
||||
|
||||
if(isset($host["host"])){
|
||||
|
||||
$f404_host = "https://" . $host["host"];
|
||||
}
|
||||
}
|
||||
|
||||
$host = parse_url($link);
|
||||
|
||||
// special case for when we're not drawing a full url
|
||||
@@ -500,7 +523,7 @@ class frontend{
|
||||
$payload =
|
||||
'<div class="url">' .
|
||||
'<button class="favicon" tabindex="-1">' .
|
||||
'<img src="/favicon?s=404" alt="xx">' .
|
||||
'<img src="/favicon?s=' . urlencode($f404_host) . '" alt="xx">' .
|
||||
'</button>';
|
||||
}else{
|
||||
|
||||
@@ -529,7 +552,7 @@ class frontend{
|
||||
$payload =
|
||||
'<div class="url">' .
|
||||
'<button class="favicon" tabindex="-1">' .
|
||||
'<img src="/favicon?s=' . htmlspecialchars($host["scheme"] . "://" . $host["host"]) . '" alt="' . htmlspecialchars($esc) . '">' .
|
||||
'<img src="/favicon?s=' . urlencode($host["scheme"] . "://" . $host["host"]) . '" alt="' . htmlspecialchars($esc) . '">' .
|
||||
//'<img src="/404.php" alt="' . htmlspecialchars($esc) . '">' .
|
||||
'</button>' .
|
||||
'<div class="favicon-dropdown">';
|
||||
@@ -1023,46 +1046,51 @@ class frontend{
|
||||
/*
|
||||
Draw link
|
||||
*/
|
||||
$parts = explode("/", $link);
|
||||
$clickurl = "";
|
||||
|
||||
// remove trailing /
|
||||
$c = count($parts) - 1;
|
||||
if($parts[$c] == ""){
|
||||
if($cucked === null){
|
||||
$parts = explode("/", $link);
|
||||
$clickurl = "";
|
||||
|
||||
$parts[$c - 1] = $parts[$c - 1] . "/";
|
||||
unset($parts[$c]);
|
||||
}
|
||||
|
||||
// merge https://site together
|
||||
if(isset($host["host"])){
|
||||
$parts = [
|
||||
$parts[0] . $parts[1] . '//' . $parts[2],
|
||||
...array_slice($parts, 3, count($parts) - 1)
|
||||
];
|
||||
}
|
||||
|
||||
$c = count($parts);
|
||||
for($i=0; $i<$c; $i++){
|
||||
|
||||
if($i !== 0){ $clickurl .= "/"; }
|
||||
|
||||
$clickurl .= $parts[$i];
|
||||
|
||||
if($i === $c - 1){
|
||||
// remove trailing /
|
||||
$c = count($parts) - 1;
|
||||
if($parts[$c] == ""){
|
||||
|
||||
$parts[$i] = rtrim($parts[$i], "/");
|
||||
$parts[$c - 1] = $parts[$c - 1] . "/";
|
||||
unset($parts[$c]);
|
||||
}
|
||||
|
||||
$payload .=
|
||||
'<a class="part" href="' . htmlspecialchars($clickurl) . '" rel="noreferrer nofollow" tabindex="-1">' .
|
||||
htmlspecialchars(urldecode($parts[$i])) .
|
||||
'</a>';
|
||||
|
||||
if($i !== $c - 1){
|
||||
|
||||
$payload .= '<span class="separator"></span>';
|
||||
// merge https://site together
|
||||
if(isset($host["host"])){
|
||||
$parts = [
|
||||
$parts[0] . $parts[1] . '//' . $parts[2],
|
||||
...array_slice($parts, 3, count($parts) - 1)
|
||||
];
|
||||
}
|
||||
|
||||
$c = count($parts);
|
||||
for($i=0; $i<$c; $i++){
|
||||
|
||||
if($i !== 0){ $clickurl .= "/"; }
|
||||
|
||||
$clickurl .= $parts[$i];
|
||||
|
||||
if($i === $c - 1){
|
||||
|
||||
$parts[$i] = rtrim($parts[$i], "/");
|
||||
}
|
||||
|
||||
$payload .=
|
||||
'<a class="part" href="' . htmlspecialchars($clickurl) . '" rel="noreferrer nofollow" tabindex="-1">' .
|
||||
htmlspecialchars(urldecode($parts[$i])) .
|
||||
'</a>';
|
||||
|
||||
if($i !== $c - 1){
|
||||
|
||||
$payload .= '<span class="separator"></span>';
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
$payload .= '<a class="url-cucked" href="' . $link . '" rel="noreferrer nofollow" tabindex="-1" title="This URL was cucked by the upstream search engine. The full URL is only available by following their redirect endpoint. 4get will proxy your click to prevent tracking.">' . htmlspecialchars($cucked) . '</a>';
|
||||
}
|
||||
|
||||
return $payload . '</div>';
|
||||
|
||||
@@ -473,6 +473,8 @@ class brave{
|
||||
$this->fuckhtml->load($html);
|
||||
$datas = $this->get_js();
|
||||
|
||||
//print_r($datas);
|
||||
|
||||
$has_found_body = false;
|
||||
|
||||
foreach($datas as $data){
|
||||
@@ -865,6 +867,14 @@ class brave{
|
||||
)
|
||||
),
|
||||
"url" => $this->convert_goto_to_resolver($result["url"]),
|
||||
"cuckurl" =>
|
||||
$result["meta_url"]["scheme"] . "://" .
|
||||
$result["meta_url"]["hostname"] .
|
||||
preg_replace(
|
||||
'/ *› */',
|
||||
"/",
|
||||
$result["meta_url"]["path"]
|
||||
),
|
||||
"date" => $date,
|
||||
"type" => "web",
|
||||
"thumb" => $thumb,
|
||||
|
||||
@@ -423,6 +423,12 @@ h3,h4,h5,h6{
|
||||
color:var(--928374);
|
||||
}
|
||||
|
||||
.web .url-cucked{
|
||||
font-size:15px;
|
||||
color:var(--string);
|
||||
cursor:help;
|
||||
}
|
||||
|
||||
.web .separator::before{
|
||||
content:"/";
|
||||
padding:0 4px;
|
||||
|
||||
Reference in new issue
Block a user