Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.

PHP + whois question

Status
Not open for further replies.

peter

Level 9
Legacy Exclusive Member
Joined
Oct 18, 2002
Messages
3,491
Reaction score
17
Hey!

OK, lets say I have dnforum.com as a variable. Is there any URL I can call with the name in the call which returns the expiry date?

Or how do you guys do?
 
Dynadot - Expired Domain Auctions
D

domains1357

Guest
use this function:
it will return complete whois reply (if it fails it will return empty string)

PHP:
function whois($query, $server='whois.networksolutions.com', $port=43)
{
	$query = strtolower(str_replace(array('www.','http://'), array('',''), $query));

	$f = @fsockopen($server,$port);
	if(!$f)
	{
		return '';
	}

	$result = '';
	fputs($f,"$query\r\n");
	while(!feof($f))
	{
		$result.=fgets($f,128);
	}
	fclose($f);

	return $result;
}
 

peter

Level 9
Legacy Exclusive Member
Joined
Oct 18, 2002
Messages
3,491
Reaction score
17
domains: yeah thanks, but I know how to get the whole whois. I will check hotscripts!

Thanks
 
D

domains1357

Guest
ohh.. sorry. i thought you will be able to extract expiration date from whois reply. here is function that can do it (will return empty string if cannot find expiration date):

note: it uses whois() function that i wrote in previous message.

PHP:
function expiration_date($domain)
{
	$res = whois($domain);
	$arr = explode("\n", $res);
	for($i=0; $i<count($arr); $i++)
	{
		$pos = strpos($arr[$i],'Record expires on ');
		if($pos !== false)
		{
			$str = substr($arr[$i],$pos+18,11);
			return $str;
		}
	}
	return '';
}
 

peter

Level 9
Legacy Exclusive Member
Joined
Oct 18, 2002
Messages
3,491
Reaction score
17
oh of course.
Thanks!

My mind isn't really working today after spending all of the day on the damn crowded copenhagen airport (snowstorms)
 

Sheva

Level 7
Legacy Exclusive Member
Joined
Jul 27, 2002
Messages
852
Reaction score
0
icehole, I just saw on the news in Italy the Copenhagen airport with all people waiting and snow too. :)

Mike
 
Status
Not open for further replies.

Who has viewed this thread (Total: 1) View details

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Sedo - it.com Premiums

IT.com

Premium Members

MariaBuy

Upcoming events

Our Mods' Businesses

UrlPick.com

*the exceptional businesses of our esteemed moderators

Top Bottom