lunarhotel.co.uk

How about a view of the sea of tranquility?

Sponsored Links
Reliable expiry date finder PDF Print E-mail
Tag it:
Digg
Delicious
De.lirio.us
YahooMyWeb
Reddit

{mosignorehit} 

So if you're looking for domain name drops, you need to know the domain name and of course the expiry date. All well and good, but running a whois query on a few domains you'll soon find that the whois record is not always returned in the same format or layout. This is because of the different companies and top level registrars that look after various aspects of the domain name system. After muchos hunting for something that could reliably extract the date from a whois record, I came up with zip. So here my function for achieveing that. A couple of things before you look at it though

  • it seems fairly reliable, Ive not come across a whois record yet that it wont extract the expiration date from (with the exception of whois records that dont tell you, but I think you can let me off for that!)
  • Many of you regular expression techies out there will look at this and think "Holy s**t! this is horrific!" And of course you would be correct. Im afriad regular expressions arent my forte, so it was a bit of learning exercise
  • If you find a domain name that it cant pick up, you can sort it by just adding a new regular expression to the list

So without further ado, here it is:

 

function expireson($whoisrecord) {

        $regexes=array();
        $regexes[]="/expires (on)*:*\s*/";
        $regexes[]="/Expires\s*:*/";
        $regexes[]="/Expires on:*(\.{5,20}:)*/";
        $regexes[]="/expiration date\s*:/";
        $regexes[]="/Expiration Date\s*:/";
        $regexes[]="/Expiration date\s*:/";
        $regexes[]="/Expiry Date:*(\.{5,11}\s)*/";
        $regexes[]="/Expiration Date\s*(\.{5,17})*:/";
        $regexes[]="/expiration\s*:/";
        $regexes[]="/expiration-date:\s*/";
        $regexes[]="/Expiration Date\s*(\.{5,17})*\s/";
        $regexes[]="/expired on\s*/";
        $regexes[]="/expire:*(\s{1,22})*/";
        $regexes[]="/Expire Date:\s*/";
        $regexes[]="/Expire on(\.{5,17})*\s*/";

        foreach($regexes as $regex) {
                preg_match_all($regex,$whoisrecord,$match,PREG_SET_ORDER);
                if(count($match)>0) {
                        $expirespos=strpos($whoisrecord,$match[0][0])+strlen($match[0][0]);
                        # get the line where the match appears and get the bit from the end of the match to the end of the line
                        # this helps things work when the expiration date is on the last line
                        $whoisrecord .="\n";
                        $expiresline=trim(substr($whoisrecord, $expirespos,strpos($whoisrecord,"\n",$expirespos)-$expirespos));
                        $expiresline=str_replace("(registry time)","",$expiresline);
                        # check to see if there's a . at the end
                        if(substr($expiresline,-1,1)==".") {
                                $expiresline=substr($expiresline,0,strlen($expiresline)-1);
                        } //end if
                        # so , we should now have a date (or something like)
                        # so lets convert it into a php date.
                        $expiresline=returndate($expiresline);
                        return $expiresline;
                } //end if
        } //end foreach
        return false;
} //end function

Usage is pretty simple, just call it, and pass it the full whoisrecord.


Add as favourites (74) | Quote this article on your site

  Comments (2)
Written by admin, on 30-09-2008 18:41
$whoisrecord is the output returned from the whois command on linux or www.who.is (and in one form or another every website that says it can register you a domain name) Google "php whois function" and you should get loads of results on how to do this.
Written by gatewayclicks, on 28-09-2008 22:57
ive been looking for this script everywhere! any chance you could do a full script with the domain name search incorporated in with the expiry date result? that would be magical. if not, does the $whoisrecord = domain.com?

Only registered users can write comments.
Please login or register.

Powered by AkoComment Tweaked Special Edition v.1.4.6
AkoComment © Copyright 2004 by Arthur Konze - www.mamboportal.com
All right reserved

Last Updated ( Sunday, 17 August 2008 )
 
Tag it:
Digg
Delicious
De.lirio.us
YahooMyWeb
Reddit
Main Menu
Home
Links
Search
Projects
Partner Blog

Money saving tips at http://cashsavetips.blogspot.com/ to help beat the global meltdown

Special Offer Item for Virtuemart

Publish the details of a special offer (or something with an expiration date) and dont worry about unpublishing it when the offer expires. Check it out here

 

latest Content
Login Form





Lost Password?
No account yet? Register
Routing over two internet connections

Ive written a three part explaination of how to get it up and running.

Read Part 1 here