Home

See the related posts

PHP Warning: Call-time pass-by-reference has been deprecated    Working with Database (MySQL)    Cookies in PHP    Session Management Functions in php    Join array elements with a string – implode   

PHP code to find Domains on same ip

This example will show you how to get the list of domain names on same IP. There might be some situations where you want to host your site and may be interested in knowing the other sites hosted on same domain. This code will help you then..,Happy Coding :)

<?php

function reverseIP($IP)
{
	for($f=0; $f <= 2; $f++)
	{
		// this will list the results in the first two page...alter the code to get results from more number of pages
		$url='http://www.bing.com/search?q=ip%3A'.$IP.'&amp;first='.$f.'1&amp;FORM=PORE';
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER[‘HTTP_USER_AGENT’]);
		curl_setopt($ch, CURLOPT_REFERER, "http://yahoo.com/");
		curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 5);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_TIMEOUT, 20); // times out after 15s
		$searchResults= curl_exec($ch);
		curl_close($ch);
		$parsedData=explode("<li>",$searchResults);
		$cntArray=count($parsedData);
		for($x=0;$x<$cntArray;$x++)
		{
			if (preg_match('#<cite>(.*?)</cite>#i',$parsedData[$x], $matches))
			{
				$fullURL[]=$matches[1];
			}
		}

		$cntURL=count($fullURL);

		for($y=0; $y < $cntURL; $y++)
		{
			$result=explode('/',$fullURL[$y]);
			$TLD[]=$result[0];
		}

	}
	$uniqueTLDList=@array_unique($TLD); // we just want the unique domain names
	return $uniqueTLDList;
}
echo '</li>';
// specify the IP of your interest
$arr=reverseIP('69.162.116.154');
$size=sizeof($arr);
for($i=0;$i<$size;$i++) {
echo $arr[$i].'<br>';
}
?>

Home

See the related posts

PHP Warning: Call-time pass-by-reference has been deprecated    Working with Database (MySQL)    Cookies in PHP    Session Management Functions in php    Join array elements with a string – implode   

1 Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment