hidden_service.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. function get_hidden_service_results($query)
  3. {
  4. global $config;
  5. $url = "https://ahmia.fi/search/?q=$query";
  6. $response = request($url);
  7. $xpath = get_xpath($response);
  8. $results = array();
  9. foreach($xpath->query("//ol[@class='searchResults']//li[@class='result']") as $result)
  10. {
  11. $url = "http://" . $xpath->evaluate(".//cite", $result)[0]->textContent;
  12. $title = remove_special($xpath->evaluate(".//h4", $result)[0]->textContent);
  13. $description = $xpath->evaluate(".//p", $result)[0]->textContent;
  14. array_push($results,
  15. array (
  16. "title" => $title ? htmlspecialchars($title) : "No description provided",
  17. "url" => htmlspecialchars($url),
  18. "base_url" => htmlspecialchars(get_base_url($url)),
  19. "description" => htmlspecialchars($description)
  20. )
  21. );
  22. }
  23. return $results;
  24. }
  25. function print_hidden_service_results($results)
  26. {
  27. echo "<div class=\"text-result-container\">";
  28. foreach($results as $result)
  29. {
  30. $title = $result["title"];
  31. $url = $result["url"];
  32. $base_url = $result["base_url"];
  33. $description = $result["description"];
  34. echo "<div class=\"text-result-wrapper\">";
  35. echo "<a href=\"$url\">";
  36. echo "$base_url";
  37. echo "<h2>$title</h2>";
  38. echo "</a>";
  39. echo "<span>$description</span>";
  40. echo "</div>";
  41. }
  42. echo "</div>";
  43. }
  44. ?>