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