hidden_service.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. function get_hidden_service_results($query)
  3. {
  4. global $config;
  5. // Randomly choose a instance
  6. $results = array();
  7. $num = array_rand($config->instances);
  8. $instance = $config->instances[$num];
  9. $url = "https://$instance/api.php";
  10. // API POST field
  11. $post_string = "q=$query&t=4";
  12. $api_ch = curl_init($url);
  13. curl_setopt_array($api_ch, $config->curl_settings);
  14. curl_setopt($api_ch, CURLOPT_CUSTOMREQUEST, "POST");
  15. curl_setopt($api_ch, CURLOPT_COOKIE, http_build_query($cookies, '', ';'));
  16. curl_setopt($api_ch, CURLOPT_POSTFIELDS, $post_string);
  17. $results = json_decode(curl_exec($api_ch),true);
  18. if($results == null) $results = "$instance is broken";
  19. return $results;
  20. }
  21. function print_hidden_service_results($results)
  22. {
  23. echo "<div class=\"text-result-container\">";
  24. foreach($results as $result)
  25. {
  26. $title = $result["title"];
  27. $url = $result["url"];
  28. $base_url = $result["base_url"];
  29. $description = $result["description"];
  30. echo "<div class=\"text-result-wrapper\">";
  31. echo "<a href=\"$url\">";
  32. echo "$base_url";
  33. echo "<h2>$title</h2>";
  34. echo "</a>";
  35. echo "<span>$description</span>";
  36. echo "</div>";
  37. }
  38. echo "</div>";
  39. }
  40. ?>