aboutsummaryrefslogtreecommitdiffstats
path: root/images.php
diff options
context:
space:
mode:
authorlolcat <will@lolcat.ca>2025-08-11 01:55:15 +0000
committerlolcat <will@lolcat.ca>2025-08-11 01:55:15 +0000
commitcdf958d29333d448f4521f4d2faa2592b58e9b27 (patch)
tree528f2a0ffa789a6f4279d9f54a4a2aaf391f390f /images.php
downloadshittyweb-search-cdf958d29333d448f4521f4d2faa2592b58e9b27.tar.gz
shittyweb-search-cdf958d29333d448f4521f4d2faa2592b58e9b27.tar.bz2
shittyweb-search-cdf958d29333d448f4521f4d2faa2592b58e9b27.zip
fix wikipedia crashgrafted
Diffstat (limited to 'images.php')
-rw-r--r--images.php77
1 files changed, 77 insertions, 0 deletions
diff --git a/images.php b/images.php
new file mode 100644
index 0000000..99fc9d6
--- /dev/null
+++ b/images.php
@@ -0,0 +1,77 @@
+<?php
+
+/*
+ Initialize random shit
+*/
+include "data/config.php";
+
+include "lib/frontend.php";
+$frontend = new frontend();
+
+[$scraper, $filters] = $frontend->getscraperfilters("images");
+
+$get = $frontend->parsegetfilters($_GET, $filters);
+
+/*
+ Captcha
+*/
+include "lib/bot_protection.php";
+new bot_protection($frontend, $get, $filters, "images", true);
+
+$payload = [
+ "timetaken" => microtime(true),
+ "images" => "",
+ "nextpage" => ""
+];
+
+try{
+ $results = $scraper->image($get);
+
+}catch(Exception $error){
+
+ $frontend->drawscrapererror($error->getMessage(), $get, "images", $payload["timetaken"]);
+}
+
+if(count($results["image"]) === 0){
+
+ $payload["images"] =
+ '<div class="infobox">' .
+ "<h1>Nobody here but us chickens!</h1>" .
+ 'Have you tried:' .
+ '<ul>' .
+ '<li>Using a different scraper</li>' .
+ '<li>Using fewer keywords</li>' .
+ '<li>Defining broader filters (Is NSFW turned off?)</li>' .
+ '</ul>' .
+ '</div>';
+}
+
+foreach($results["image"] as $image){
+
+ $payload["images"] .=
+ '<div class="image-wrapper" title="' . htmlspecialchars($image["title"]) .'" data-json="' . htmlspecialchars(json_encode($image["source"])) . '">' .
+ '<div class="image">' .
+ '<a href="' . htmlspecialchars($image["source"][0]["url"]) . '" rel="noreferrer nofollow" class="thumb">' .
+ '<img src="' . $frontend->htmlimage($image["source"][count($image["source"]) - 1]["url"], "thumb") . '" alt="thumbnail">';
+
+ if($image["source"][0]["width"] !== null){
+ $payload["images"] .= '<div class="duration">' . $image["source"][0]["width"] . 'x' . $image["source"][0]["height"] . '</div>';
+ }
+
+ $payload["images"] .=
+ '</a>' .
+ '<a href="' . htmlspecialchars($image["url"]) . '" rel="noreferrer nofollow">' .
+ '<div class="title">' . htmlspecialchars(parse_url($image["url"], PHP_URL_HOST)) . '</div>' .
+ '<div class="description">' . $frontend->highlighttext($get["s"], $image["title"]) . '</div>' .
+ '</a>' .
+ '</div>' .
+ '</div>';
+}
+
+if($results["npt"] !== null){
+
+ $payload["nextpage"] =
+ '<a href="' . $frontend->htmlnextpage($get, $results["npt"], "images") . '" class="nextpage img">Next page &gt;</a>';
+}
+
+echo $frontend->load("images.html", $payload);