search.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. require_once "misc/header.php";
  3. require_once "misc/tools.php";
  4. require_once "misc/search_engine.php";
  5. $opts = load_opts();
  6. function print_page_buttons($type, $query, $page) {
  7. if ($type > 1)
  8. return;
  9. echo "<div class=\"next-page-button-wrapper\">";
  10. if ($page != 0)
  11. {
  12. print_next_page_button("&lt;&lt;", 0, $query, $type);
  13. print_next_page_button("&lt;", $page - 10, $query, $type);
  14. }
  15. for ($i=$page / 10; $page / 10 + 10 > $i; $i++)
  16. print_next_page_button($i + 1, $i * 10, $query, $type);
  17. print_next_page_button("&gt;", $page + 10, $query, $type);
  18. echo "</div>";
  19. }
  20. ?>
  21. <title>
  22. <?php
  23. echo $opts->query;
  24. ?> - <?php printtext("page_title");?></title>
  25. </head>
  26. <body>
  27. <form class="sub-search-container" method="get" autocomplete="off">
  28. <h1 class="logomobile"><a class="no-decoration" href="./">Libre<span class="Y">Y</span></a></h1>
  29. <input type="text" name="q"
  30. <?php
  31. if (1 > strlen($opts->query) || strlen($opts->query) > 256)
  32. {
  33. header("Location: ./");
  34. die();
  35. }
  36. echo "value=\"" . htmlspecialchars($opts->query) . "\"";
  37. ?>
  38. >
  39. <br>
  40. <?php
  41. echo "<button class=\"hide\" name=\"t\" value=\"$opts->type\"/></button>";
  42. ?>
  43. <button type="submit" class="hide"></button>
  44. <input type="hidden" name="p" value="0">
  45. <div class="sub-search-button-wrapper">
  46. <?php
  47. $categories = array("general", "images", "videos", "torrents", "tor", "maps");
  48. foreach ($categories as $category)
  49. {
  50. $category_index = array_search($category, $categories);
  51. if (($opts->disable_bittorrent_search && $category_index == 3) ||
  52. ($opts->disable_hidden_service_search && $category_index ==4))
  53. {
  54. continue;
  55. }
  56. echo "<a " . (($category_index == $opts->type) ? "class=\"active\" " : "") . "href=\"./search.php?q=" . urlencode($opts->query) . "&p=0&t=" . $category_index . "\"><img src=\"static/images/" . $category . "_result.webp\" alt=\"" . $category . " result\" />" . TEXTS["category_$category"] . "</a>";
  57. }
  58. ?>
  59. </div>
  60. </form>
  61. <?php
  62. fetch_search_results($opts, true);
  63. print_page_buttons($opts->type, $opts->query, $opts->page);
  64. ?>
  65. <?php require_once "misc/footer.php"; ?>