image_board.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. require "misc/tools.php";
  3. require "misc/header.php";
  4. ?>
  5. <title>
  6. <?php
  7. $query = htmlspecialchars(trim($_REQUEST["q"]));
  8. echo $query;
  9. ?> - Binternet</title>
  10. </head>
  11. <body>
  12. <form class="searchContainer" method="get" autocomplete="off">
  13. <h1><a class="no-decoration" href="./"><span>B</span>inter<span>n</span>et</a></h1>
  14. <input type="text" name="q"
  15. <?php
  16. $query_encoded = urlencode($query);
  17. if (1 > strlen($query) || strlen($query) > 64)
  18. {
  19. // header("Location: ./");
  20. // die();
  21. }
  22. echo "value=\"$query\"";
  23. ?>
  24. <br>
  25. <hr>
  26. </form>
  27. <div class="imageBoard">
  28. <?php
  29. if (!$_REQUEST["imgurl"])
  30. {
  31. $imgurl = $_REQUEST["imgurl"];
  32. }
  33. else
  34. {
  35. $imgurl = "/404.jpg";
  36. }
  37. $instance_url = getenv('HTTP_HOST');
  38. echo $instance_url;
  39. $allowed_domains = array("pinimg.com", "i.pinimg.com", "pinterest.com", "localhost", "$instance_url"); # TODO
  40. if (!$imgurl)
  41. {
  42. echo "No URL passed, showing images matching query.";
  43. }
  44. else
  45. {
  46. if (in_array(get_root_domain($imgurl), $allowed_domains))
  47. {
  48. // header("Content-type: image/jpeg");
  49. echo "<img src='/image_proxy.php?url=", $imgurl, "'></a>";
  50. }
  51. }
  52. echo "</div>";
  53. echo "<br><br><br><br>";
  54. include "misc/footer.php";
  55. ?>
  56. <style>
  57. .imageBoard img {
  58. display: block;
  59. margin-left: auto;
  60. margin-right: auto;
  61. width: auto;
  62. height: auto;
  63. }
  64. </style>