Miscellaneous
|
|
|
|
<?
/**
denic.class.php
=================================================================================================
Description:
this class will check a domain if the domain isn't register
follow tld's will be checked by the class
.de, .com, .net, .ord, .edu, .uk.com
-------------------------------------------------------------------------------------------------
Methods:
-> initChecker ~ build a instance
-> openInternic ~ connect denic or internic host
-> showResult ~ show result from connection
-> showError ~ show if error's tryed
-------------------------------------------------------------------------------------------------
Variables:
-> denicHost ~ hostname of denic or internic server
-> portHost ~ portnumber of denic or internic server
-> hostHandler ~ connection handler
-> domainName ~ domain that is given from formular
-> domainTld ~ tld that is given from formular
-> returnContent ~ returnCodes from connection
-> domainStatus ~ status 0 = domain is register / 1 = domain is not register
-> errorNumber ~ errorNumber
-> errorText ~ errorText
=================================================================================================
*/
class XpcDenicCheck{
var $denicHost;
var $portHost;
var $hostHandler;
var $domainName;
var $domainTld;
var $returnContent;
var $domainStatus;
var $errorNumber;
var $errorText;
/**
build a instance
*/
function initChecker( $denicHost, $portDenic, $domainName, $domainTld ){
$this -> denicHost = $denicHost;
$this -> portHost = $portDenic;
$this -> hostHandler = "";
$this -> domainName = $domainName;
$this -> domainTld = $domainTld;
$this -> returnContent = "";
$this -> domainStatus = 0;
$this -> errorNumber = "";
$this -> errorText = "";
}
/**
connect
*/
function openInternic(){
//-> try a connect
$this -> hostHandler = fsockopen ( $this -> denicHost, $this -> portHost, $this -> errorNumber, $this -> errorText );
//-> errorcheck because that isn't a connection given
if ($this -> errorNumber and $this -> errorText){
$this -> showError();
}
//-> send the host the domainname and tld
fputs( $this -> hostHandler, $this -> domainName.".".$this -> domainTld."n" );
while ( !feof ( $this -> hostHandler )) {
//-> get returnCode from host
$this -> returnContent = fgets ( $this -> hostHandler, 200);
//-> if no match of these word then the domain is not register
if(ereg("(No match|No entries found)",$this -> returnContent)) {
$this -> domainStatus = 1;
break;
}
}
//-> connection close
fclose( $this -> hostHandler );
}
/**
show the result of connection
*/
function showResult(){
echo $this -> domainStatus;
}
/**
show if error's given
*/
function showError(){
echo $this -> errorNumber."<br>";
echo $this -> errorText ."<br>";
exit;
}
}
?>
|
|
|
Usage Example
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>denic.php</title>
</head>
<body>
<table>
<tr><form action="<?php echo $PHP_SELF; ?>" method="post">
<td><input type="text" name="domainName" value="<?php echo $domainName; ?>"></td>
<td><select name="domainTld">
<option value="com">.com</option>
<option value="net">.net</option>
<option value="edu">.edu</option>
<option value="org">.org</option>
<option value="de">.de</option>
</select>
<input type="submit" value="Checken"></td></form>
</tr>
</table>
<font face="Verdana" size="-1" color="Black">
0 = Domain besetzt / 1 = Domain noch Frei<br> <br>
Ergebnis: </font><font face="Verdana" size="-1" color="red">
</body>
</html>
<?
if (isset($domainName)){
//-> who host we will connect?
$ripeHost = (preg_match("/com|net|edu|org/",$domainTld)) ? "whois.crsnic.net" : "whois.denic.de";
//-> include the denic.class.php4
include ( "denic.class.php4" );
//-> build a object
$denicChecker = new XpcDenicCheck();
//-> build a instance for the object
$denicChecker -> initChecker( $ripeHost, "43", $domainName, $domainTld );
//-> try to connect the denic or internic host
$denicChecker -> openInternic();
//-> show the result 0 or 1
$denicChecker -> showResult();
} ?>
|
|
|
Rate This Script
|
|
|
|