images.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /*
  3. Initialize random shit
  4. */
  5. include "data/config.php";
  6. include "lib/frontend.php";
  7. $frontend = new frontend();
  8. [$scraper, $filters] = $frontend->getscraperfilters("images");
  9. $get = $frontend->parsegetfilters($_GET, $filters);
  10. /*
  11. Captcha
  12. */
  13. include "lib/bot_protection.php";
  14. new bot_protection($frontend, $get, $filters, "images", true);
  15. $payload = [
  16. "timetaken" => microtime(true),
  17. "images" => "",
  18. "nextpage" => ""
  19. ];
  20. try{
  21. $results = $scraper->image($get);
  22. }catch(Exception $error){
  23. $frontend->drawscrapererror($error->getMessage(), $get, "images", $payload["timetaken"]);
  24. }
  25. if(count($results["image"]) === 0){
  26. $payload["images"] =
  27. '<div class="infobox">' .
  28. "<h1>Nobody here but us chickens!</h1>" .
  29. 'Have you tried:' .
  30. '<ul>' .
  31. '<li>Using a different scraper</li>' .
  32. '<li>Using fewer keywords</li>' .
  33. '<li>Defining broader filters (Is NSFW turned off?)</li>' .
  34. '</ul>' .
  35. '</div>';
  36. }
  37. foreach($results["image"] as $image){
  38. $payload["images"] .=
  39. '<div class="image-wrapper" title="' . htmlspecialchars($image["title"]) .'" data-json="' . htmlspecialchars(json_encode($image["source"])) . '">' .
  40. '<div class="image">' .
  41. '<a href="' . htmlspecialchars($image["source"][0]["url"]) . '" rel="noreferrer nofollow" class="thumb">' .
  42. '<img src="' . $frontend->htmlimage($image["source"][count($image["source"]) - 1]["url"], "thumb") . '" alt="thumbnail">';
  43. if($image["source"][0]["width"] !== null){
  44. $payload["images"] .= '<div class="duration">' . $image["source"][0]["width"] . 'x' . $image["source"][0]["height"] . '</div>';
  45. }
  46. $payload["images"] .=
  47. '</a>' .
  48. '<a href="' . htmlspecialchars($image["url"]) . '" rel="noreferrer nofollow">' .
  49. '<div class="title">' . htmlspecialchars(parse_url($image["url"], PHP_URL_HOST)) . '</div>' .
  50. '<div class="description">' . $frontend->highlighttext($get["s"], $image["title"]) . '</div>' .
  51. '</a>' .
  52. '</div>' .
  53. '</div>';
  54. }
  55. if($results["npt"] !== null){
  56. $payload["nextpage"] =
  57. '<a href="' . $frontend->htmlnextpage($get, $results["npt"], "images") . '" class="nextpage img">Next page &gt;</a>';
  58. }
  59. echo $frontend->load("images.html", $payload);