Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Pars($starttag, $source, $endtag){
- $a;
- $b;
- $a= strpos($source, $starttag);
- $a = $a + strlen($starttag);
- $source = substr($source, $a, strlen($source) - $a);
- $b = strpos($source, $endtag);
- return substr($source, 0, $b);
- }
- function GetCountryIP($url){
- $uagent = "Opera/9.80 (Windows NT 6.1; WOW64) Presto/2.12.388 Version/12.14";
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // возвращает веб-страницу
- curl_setopt($ch, CURLOPT_HEADER, 0); // не возвращает заголовки
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // переходит по редиректам
- curl_setopt($ch, CURLOPT_ENCODING, ""); // обрабатывает все кодировки
- curl_setopt($ch, CURLOPT_USERAGENT, $uagent); // useragent
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120); // таймаут соединения
- curl_setopt($ch, CURLOPT_TIMEOUT, 120); // таймаут ответа
- curl_setopt($ch, CURLOPT_MAXREDIRS, 10); // останавливаться после 10-ого редиректа
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- $content = curl_exec( $ch );
- $country = Pars('<h1>http://speed-tester.info/site_location.php?host=', $content, '</table>');
- $country = Pars('<img src=', $country, 'td>');
- $country = Pars('>', $country, '<');
- $country = trim($country);
- return $country;
- }
- $country_add_ip = GetCountryIP('http://speed-tester.info/site_location.php?host='.$name);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement