forked from lolcat/4get
1
0
Fork 0

felt quirky, might commit later

This commit is contained in:
lolcat 2023-07-26 19:03:06 -04:00
parent bca265aea6
commit 16ee0b368f
7 changed files with 1039 additions and 456 deletions

View File

@ -58,32 +58,15 @@ if(count($results["image"]) === 0){
foreach($results["image"] as $image){ foreach($results["image"] as $image){
$domain = htmlspecialchars(parse_url($image["url"], PHP_URL_HOST));
$c = count($image["source"]) - 1;
if(
preg_match(
'/^data:/',
$image["source"][$c]["url"]
)
){
$src = htmlspecialchars($image["source"][$c]["url"]);
}else{
$src = "/proxy?i=" . urlencode($image["source"][$c]["url"]) . "&s=thumb";
}
$payload["images"] .= $payload["images"] .=
'<div class="image-wrapper" title="' . htmlspecialchars($image["title"]) .'" data-json="' . htmlspecialchars(json_encode($image["source"])) . '">' . '<div class="image-wrapper" title="' . htmlspecialchars($image["title"]) .'" data-json="' . htmlspecialchars(json_encode($image["source"])) . '">' .
'<div class="image">' . '<div class="image">' .
'<a href="' . htmlspecialchars($image["source"][0]["url"]) . '" rel="noreferrer nofollow" class="thumb">' . '<a href="' . htmlspecialchars($image["source"][0]["url"]) . '" rel="noreferrer nofollow" class="thumb">' .
'<img src="' . $src . '" alt="thumbnail">' . '<img src="' . $frontend->htmlimage($image["source"][count($image["source"]) - 1]["url"], "thumb") . '" alt="thumbnail">' .
'<div class="duration">' . $image["source"][0]["width"] . 'x' . $image["source"][0]["height"] . '</div>' . '<div class="duration">' . $image["source"][0]["width"] . 'x' . $image["source"][0]["height"] . '</div>' .
'</a>' . '</a>' .
'<a href="' . htmlspecialchars($image["url"]) . '" rel="noreferrer nofollow">' . '<a href="' . htmlspecialchars($image["url"]) . '" rel="noreferrer nofollow">' .
'<div class="title">' . htmlspecialchars($domain) . '</div>' . '<div class="title">' . htmlspecialchars(parse_url($image["url"], PHP_URL_HOST)) . '</div>' .
'<div class="description">' . $frontend->highlighttext($get["s"], $image["title"]) . '</div>' . '<div class="description">' . $frontend->highlighttext($get["s"], $image["title"]) . '</div>' .
'</a>' . '</a>' .
'</div>' . '</div>' .

View File

@ -143,7 +143,7 @@ class frontend{
$payload .= $payload .=
'">' . '">' .
'<img class="thumb" src="/proxy?i=' . urlencode($site["thumb"]["url"]) . '&s=' . $size . '" alt="thumb">'; '<img class="thumb" src="' . $this->htmlimage($site["thumb"]["url"], $size) . '" alt="thumb">';
if($duration !== null){ if($duration !== null){
@ -1273,6 +1273,21 @@ class frontend{
return http_build_query($out); return http_build_query($out);
} }
public function htmlimage($image, $format){
if(
preg_match(
'/^data:/',
$image
)
){
return htmlspecialchars($image);
}
return "/proxy.php?i=" . urlencode($image) . "&s=" . $format;
}
public function htmlnextpage($gets, $npt, $page){ public function htmlnextpage($gets, $npt, $page){
$query = $this->buildquery($gets); $query = $this->buildquery($gets);

View File

@ -679,7 +679,7 @@ class ddg{
Check for worknik results Check for worknik results
*/ */
preg_match( preg_match(
'/nrj\(\'\/js\/spice\/dictionary\/definition\/([^\']+)\'\)/', '/nrj\(\'\/js\/spice\/dictionary\/definition\/([^\'\)]+)/',
$js, $js,
$wordnik $wordnik
); );

File diff suppressed because it is too large Load Diff

View File

@ -577,7 +577,6 @@ function getproxylink(url){
return htmlspecialchars(url); return htmlspecialchars(url);
}else{ }else{
console.log(url);
return '/proxy?i=' + encodeURIComponent(url); return '/proxy?i=' + encodeURIComponent(url);
} }
} }

View File

@ -50,6 +50,8 @@
audio{ audio{
max-width:100%; max-width:100%;
display:block;
margin-bottom:17px;
} }
body,html{ body,html{

29
web.php
View File

@ -65,7 +65,13 @@ if($results["spelling"]["type"] != "no_correction"){
$payload["left"] .= $payload["left"] .=
'<div class="infobox">' . '<div class="infobox">' .
$type . ' <b>' . htmlspecialchars($results["spelling"]["using"]) . '</b>.<br>' . $type . ' <b>' . htmlspecialchars($results["spelling"]["using"]) . '</b>.<br>' .
'Did you mean <a href="?s=' . urlencode($results["spelling"]["correction"]) . '">' . $results["spelling"]["correction"] . '</a>?' . 'Did you mean <a href="?s=' .
urlencode($results["spelling"]["correction"]) .
'&' .
$frontend->buildquery($get, true) .
'">' .
$results["spelling"]["correction"] .
'</a>?' .
'</div>'; '</div>';
} }
@ -120,24 +126,9 @@ if(count($results["image"]) !== 0){
foreach($results["image"] as $image){ foreach($results["image"] as $image){
$c = count($image["source"]) - 1;
if(
preg_match(
'/^data:/',
$image["source"][$c]["url"]
)
){
$src = htmlspecialchars($image["source"][$c]["url"]);
}else{
$src = "/proxy?i=" . urlencode($image["source"][$c]["url"]) . "&s=square";
}
$right["image"] .= $right["image"] .=
'<a class="image" href="' . htmlspecialchars($image["url"]) . '" rel="noreferrer nofollow" title="' . htmlspecialchars($image["title"]) . '" data-json="' . htmlspecialchars(json_encode($image["source"])) . '" tabindex="-1">' . '<a class="image" href="' . htmlspecialchars($image["url"]) . '" rel="noreferrer nofollow" title="' . htmlspecialchars($image["title"]) . '" data-json="' . htmlspecialchars(json_encode($image["source"])) . '" tabindex="-1">' .
'<img src="' . $src . '" alt="thumb">' . '<img src="' . $frontend->htmlimage($image["source"][count($image["source"]) - 1]["url"], "square") . '" alt="thumb">' .
'<div class="duration">' . $image["source"][0]["width"] . 'x' . $image["source"][0]["height"] . '</div>' . '<div class="duration">' . $image["source"][0]["width"] . 'x' . $image["source"][0]["height"] . '</div>' .
'</a>'; '</a>';
} }
@ -283,7 +274,7 @@ if(count($results["answer"]) !== 0){
$right["answer"] .= $right["answer"] .=
'<a href="' . htmlspecialchars($answer["thumb"]) . '" rel="noreferrer nofollow" class="photo">' . '<a href="' . htmlspecialchars($answer["thumb"]) . '" rel="noreferrer nofollow" class="photo">' .
'<img src="/proxy?i=' . urlencode($answer["thumb"]) . '&s=cover" alt="thumb" class="openimg">' . '<img src="' . $frontend->htmlimage($answer["thumb"], "cover") . '" alt="thumb" class="openimg">' .
'</a>'; '</a>';
} }
@ -337,7 +328,7 @@ if(count($results["answer"]) !== 0){
case "image": case "image":
$right["answer"] .= $right["answer"] .=
'<a href="' . htmlspecialchars($description["url"]) . '" rel="noreferrer nofollow" tabindex="-1"><img src="/proxy?i=' . urlencode($description["url"]) . '&s=thumb" alt="image" class="fullimg openimg"></a>'; '<a href="' . htmlspecialchars($description["url"]) . '" rel="noreferrer nofollow" tabindex="-1"><img src="' . $frontend->htmlimage($description["url"], "thumb") . '" alt="image" class="fullimg openimg"></a>';
break; break;
case "audio": case "audio":