LibreY

- privacy respecting meta search engine
git clone git://git.acid.vegas/LibreY.git
Log | Files | Refs | Archive | README | LICENSE

search.php (2830B)

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