PHP Network

1- Is domain name taken
<?php
$recordexists = checkdnsrr(“www.yahoo.com”, “ANY”);
if ($recordexists) 
echo “The domain name has been taken. Sorry!”;
else echo”The domain name is available!”;
?>

2- Get IP address
<?php
$ip = “204.71.200.75”;
$host = “www.yahoo.com”;
$verify_ip = gethostbyaddr($ip);
$verify_name = gethostbyname($host);
echo “$ip resolves to $verify_ip”;
echo “$host resolves to $verify_name”;
?>

3- Port scan
<?php
// set time to complete the task
ini_set(“max_execution_time”,60);
$rangeStart = 0;
$rangeStop = 1024;
$target = “www.yahoo.com”;
$range =range($rangeStart, $rangeStop);
echo “Scan results for $target”;
foreach ($range as $port) {
$result = @fsockopen($target, $port,$errno,$errstr,1);
if ($result)
echo “Socket open at port $port”;
}
?>


4- URL validation by Regular Expression
if (isset($_POST[‘posted’])) {
$url = $_POST[‘url’];
$theresults = ereg(“^[a-zA-Z0-9]+://[^ ]+$”, $url, $trashed);
if ($theresults) { $isamatch = “Valid”;
} else { $isamatch = “Invalid”; }
echo “URL validation says $url is ” . $isamatch;
}

5- DNS and host validation
$hostname = “www.yahoo.com”;

if (!isset($hostname)) {
die(“Hostname value wasn’t properly submitted. Retry.”);
}

if(empty($hostname)){
die(“Hostname field was left blank! Retry.”);
}
echo $hostname;

if(checkdnsrr($hostname)) {
echo “has a valid MX record!”;
} else { die(“does not exist”); }

Post your comment

*

code

 

 

See more website here...

  • Odlinks
  • Farsi-News
  • Advertise Here