I were looking for a snippet of code for someone when I came across an old tool. This isn’t a parser or a tool like phois or similar, its just a usable snippet of code to do a job. Really I should update it, and maybe use a function to handle the job, but it works just fine for its use.
The job in this instance were to monitor my domains for changes in status, in a few situations.
1, When a domain were sold, I monitored the tag and registrant name (now I’m using the DAC I only monitor the tag for .uk).
2, When using another registrar/registry I monitored expiry to avoid losing domains due to non-renewal or errors.
In order to do this, I needed code to (1), connect to a whois server (this is easy), (2), split the required bits of info from the result (not so easy) and (3), place it in a database (easy). Then work on the data from there, (4), load the “watched”, “sold” or “close to expiry” domains, (5), scan the whois and compare, then (6), act on the result.
90% of the various registries whois outputs, out there are fairly uniform, but much like Nominets EPP, their whois is non-standard, so I needed a custom splitter. I’m not sure I would do it the same if I wrote the code now… some years later.
I have updated the code a little to include a ROFR (Right of First Refusal) detection, this won’t be needed come june (2019) when the period expires.
switch(trim($ext)){ case "uk": $def = array(); if(preg_grep("/Right of reg/", $arr)){ $def['domain'] = $arr[1]; $def["rofr"] = $arr[3]; $type = "rofr"; break; } $def['domain'] = $arr[1]; $def['registrant'] = $arr[3]; preg_match('/Tag = (.*)]/', $res, $matches); $def['tag'] = trim($matches[1]); preg_match("/Registered on: (.*)/", $res, $matches); $def['created'] = date("Y-m-d",strtotime(trim($matches[1]))); preg_match("/Last updated: (.*)/", $res, $matches); $def['updated'] = date("Y-m-d",strtotime(trim($matches[1]))); preg_match("/Expiry date: (.*)/", $res, $matches); $def['expiry'] = date("Y-m-d",strtotime(trim($matches[1]))); $type = "uk"; break; default: break; }
This will produce an array called $def, which when calling a valid name would look like…
Array ( [domain] => steven.uk [registrant] => Steve Morley [tag] => MORLEY [created] => 2014-06-12 [updated] => 2016-02-29 [expiry] => 2024-06-12 )
or if the the .UK has right of first registration intact…
Array ( [domain] => steven.uk [rofr] => steven.co.uk )
Working from this array, you can you can put these into a database, compare them to the database return and act on it from there. I suggest sending yourself an email or text message (api’s are easy to follow).
A Manchester Based Photographer and Website Developer with interests in Strongman, Fitness and Geekery.
One comment