<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Subesh Pokhrel&#039;s Blog - Magento Development Tips &#187; whois</title>
	<atom:link href="http://subesh.com.np/tag/whois/feed/" rel="self" type="application/rss+xml" />
	<link>http://subesh.com.np</link>
	<description>PHP &#38; Magento Tips and Tutorials</description>
	<lastBuildDate>Wed, 01 Feb 2012 04:09:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Checking if the domain is registered or not ?</title>
		<link>http://subesh.com.np/2008/06/checking-if-the-domain-is-registered-or-not/</link>
		<comments>http://subesh.com.np/2008/06/checking-if-the-domain-is-registered-or-not/#comments</comments>
		<pubDate>Tue, 17 Jun 2008 06:32:40 +0000</pubDate>
		<dc:creator>Subesh Pokhrel</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[domain]]></category>
		<category><![CDATA[whois]]></category>

		<guid isPermaLink="false">http://subesh.com.np/?p=24</guid>
		<description><![CDATA[On doing one of my project, I came across this situation when I need to find out whether the domain name supplied by the user is available or not? I then came up with a solution, here&#8217;s is what I did. But before that let me explain somethings. There is something called WHOIS LOOKUP. WHOIS [...]]]></description>
			<content:encoded><![CDATA[<p>On doing one of my project, I came across this situation when I need to find out whether the domain name supplied by the user is available or not? I then came up with a solution, here&#8217;s is what I did. But before that let me explain somethings. There is something called WHOIS LOOKUP. WHOIS LOOKUP is action relating to look on official WHOIS database server for the information related to domain name.</p>
<p>According to wikipedia WHOIS &#8220;WHOIS  is a TCP-based query-response  protocol for querying an official database in order to determine the owner of a domain name, an IP address, or an autonomous system number on the Internet&#8221;. ICAAN is presently undertaking the task for managing the WHOIS information.</p>
<p>For querying WHOIS servers here is the PHP code.</p>
<pre class="brush: php; title: ; notranslate">
function check_domain($domain,$ext)
{

	/************************	SERVER DEFINITIONS	************************************/
	$serverdefs= array(
							&quot;com&quot; =&gt; array(&quot;whois.crsnic.net&quot;,&quot;No match for&quot;),
							&quot;net&quot; =&gt; array(&quot;whois.crsnic.net&quot;,&quot;No match for&quot;),
							&quot;org&quot; =&gt; array(&quot;whois.pir.org&quot;,&quot;NOT FOUND&quot;),
							&quot;biz&quot; =&gt; array(&quot;whois.biz&quot;,&quot;Not found&quot;),
							&quot;info&quot; =&gt; array(&quot;whois.afilias.net&quot;,&quot;NOT FOUND&quot;),

					);
	/*********************** 	END SERVER DEFINITIONS	*********************************/

    $server = $serverdefs[$ext][0];
    $nomatch = $serverdefs[$ext][1];

	$output=&quot;&quot;;
    if(($sc = fsockopen($server,43))==false){return 2;}
           fputs($sc,&quot;$domain.$ext\n&quot;);

	while(!feof($sc)){$output.=fgets($sc,128);}
    fclose($sc);
    //compare what has been returned by the server
    if (eregi($nomatch,$output)){
		return true; // if matched
    }else{
        return false;
    }
}
</pre>
<p><strong>Code #04 &#8211; #13</strong> defines the array of official WHOIS server for respective extensions of domains and the respective responses (a chunk of) we get after querying the database servers. For example if we query <em>whois.crsnic.net</em> we get response which contains the phrase &#8220;<em>No match for</em>&#8221; if the domain does not exists.<br />
<strong>Code #19 &#8211; #23</strong> requests the respective server on the basis of extension  and gets the response in form of string on variable <em>$output</em>.<br />
Then the response is matched with the respective value of response defined in the array (which contains the phrase when the domain does not exists). Then it outputs the boolean value accordingly if the domain does not exists or can be registered it returns <em>true</em>, <em>false </em>otherwise.</p>
]]></content:encoded>
			<wfw:commentRss>http://subesh.com.np/2008/06/checking-if-the-domain-is-registered-or-not/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

