1
Fork 1
mirror of https://git.lolcat.ca/lolcat/4get.git synced 2024-11-08 17:43:07 -05:00
4get/images.php

78 lines
2.2 KiB
PHP
Raw Normal View History

2023-07-22 13:41:14 -05:00
<?php
/*
Initialize random shit
*/
2023-11-07 08:04:56 -05:00
include "data/config.php";
2023-07-22 13:41:14 -05:00
include "lib/frontend.php";
$frontend = new frontend();
[$scraper, $filters] = $frontend->getscraperfilters("images");
$get = $frontend->parsegetfilters($_GET, $filters);
/*
Captcha
*/
2024-02-17 23:22:19 -05:00
include "lib/bot_protection.php";
new bot_protection($frontend, $get, $filters, "images", true);
2023-07-22 13:41:14 -05:00
$payload = [
2024-02-17 23:22:19 -05:00
"timetaken" => microtime(true),
2023-07-22 13:41:14 -05:00
"images" => "",
"nextpage" => ""
];
try{
$results = $scraper->image($get);
}catch(Exception $error){
2024-03-24 21:31:19 -05:00
$frontend->drawscrapererror($error->getMessage(), $get, "images", $payload["timetaken"]);
2023-07-22 13:41:14 -05:00
}
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">' .
2023-08-08 02:09:47 -05:00
'<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"] .=
2023-07-22 13:41:14 -05:00
'</a>' .
'<a href="' . htmlspecialchars($image["url"]) . '" rel="noreferrer nofollow">' .
2023-07-26 18:03:06 -05:00
'<div class="title">' . htmlspecialchars(parse_url($image["url"], PHP_URL_HOST)) . '</div>' .
2023-07-22 13:41:14 -05:00
'<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);