Advertisement
Guest User

Untitled

a guest
Nov 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. function Pars($starttag, $source, $endtag){
  2. $a;
  3. $b;
  4.  
  5. $a= strpos($source, $starttag);
  6. $a = $a + strlen($starttag);
  7.  
  8. $source = substr($source, $a, strlen($source) - $a);
  9. $b = strpos($source, $endtag);
  10.  
  11. return substr($source, 0, $b);
  12.  
  13. }
  14.  
  15. function GetCountryIP($url){
  16. $uagent = "Opera/9.80 (Windows NT 6.1; WOW64) Presto/2.12.388 Version/12.14";
  17.  
  18. $ch = curl_init($url);
  19.  
  20. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // возвращает веб-страницу
  21. curl_setopt($ch, CURLOPT_HEADER, 0); // не возвращает заголовки
  22. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // переходит по редиректам
  23. curl_setopt($ch, CURLOPT_ENCODING, ""); // обрабатывает все кодировки
  24. curl_setopt($ch, CURLOPT_USERAGENT, $uagent); // useragent
  25. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120); // таймаут соединения
  26. curl_setopt($ch, CURLOPT_TIMEOUT, 120); // таймаут ответа
  27. curl_setopt($ch, CURLOPT_MAXREDIRS, 10); // останавливаться после 10-ого редиректа
  28. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  29.  
  30. $content = curl_exec( $ch );
  31.  
  32. $country = Pars('<h1>http://speed-tester.info/site_location.php?host=', $content, '</table>');
  33. $country = Pars('<img src=', $country, 'td>');
  34. $country = Pars('>', $country, '<');
  35. $country = trim($country);
  36.  
  37. return $country;
  38. }
  39.  
  40. $country_add_ip = GetCountryIP('http://speed-tester.info/site_location.php?host='.$name);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement