Etiket arşivi: Exec

php ile ip adresinden şehir bilgisi bulmak

 <?php 
$ip=$_GET['ip'];
$curl_oturumu =curl_init("http://www.ip-adress.com/");
curl_setopt($curl_oturumu, CURLOPT_HEADER, 0);
curl_setopt($curl_oturumu, CURLOPT_POSTFIELDS, "QRY=$ip");
curl_setopt($curl_oturumu, CURLOPT_RETURNTRANSFER  ,1);
curl_setopt($curl_oturumu, CURLOPT_FOLLOWLOCATION  ,1);
$output= curl_exec($curl_oturumu);
curl_close($curl_oturumu);  
$desc = '#IP Location:(.*?)</b>#si';
preg_match_all($desc,$output,$ddesc);
$sonuc = $ddesc[0][0];
print_r(strip_tags($sonuc)); 
?>

Php Curl ile Proxy örneği

<?php
	function chs(){
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, "http://www.mehmetmutlu.com.tr/ip.php");
		curl_setopt($ch, CURLOPT_HEADER, 0);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_POST,true);
		curl_setopt($ch, CURLOPT_TIMEOUT, 10);

		//http://hidemyass.com/proxy-list/
		curl_setopt($ch, CURLOPT_PROXYPORT, '8080');
		curl_setopt($ch, CURLOPT_USERAGENT, "bots");
		curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');
		curl_setopt($ch, CURLOPT_PROXY,'12.174.27.73');
		curl_setopt($ch, CURLOPT_PROXYUSERPWD,'');
		
		$output = curl_exec($ch);
		curl_close($ch);
		return $output;
	}
	print_r(chs());

?>