tools.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. function get_base_url($url)
  3. {
  4. $split_url = explode("/", $url);
  5. $base_url = $split_url[0] . "//" . $split_url[2] . "/";
  6. return $base_url;
  7. }
  8. function get_xpath($response)
  9. {
  10. $htmlDom = new DOMDocument;
  11. @$htmlDom->loadHTML($response);
  12. $xpath = new DOMXPath($htmlDom);
  13. return $xpath;
  14. }
  15. function request($url)
  16. {
  17. require "config.php";
  18. $ch = curl_init($url);
  19. curl_setopt_array($ch, $config_curl_settings);
  20. $response = curl_exec($ch);
  21. return $response;
  22. }
  23. function print_next_page_button($text, $page, $query, $type)
  24. {
  25. echo "<form id=\"page\" action=\"search.php\" target=\"_top\" method=\"post\" enctype=\"multipart/form-data\" autocomplete=\"off\">";
  26. echo "<input type=\"hidden\" name=\"p\" value=\"" . $page . "\" />";
  27. echo "<input type=\"hidden\" name=\"q\" value=\"$query\" />";
  28. echo "<input type=\"hidden\" name=\"type\" value=\"$type\" />";
  29. echo "<button type=\"submit\">$text</button>";
  30. echo "</form>";
  31. }
  32. ?>