BTC USD 81,244.1 Gold USD 4,378.12
Time now: Jun 1, 12:00 AM

[PHP CODING] DOMAIN CHECKER - Help Me!

smileyjawa

Active+ Member
Messages
3,697
Joined
Jan 3, 2007
Messages
3,697
Reaction score
27
Points
30
sape tau coding php yang mana 2 perkataan digabungkan untuk disimpan dlm satu pembolehubah (variable)?

cth aku wat form dan dlm tu ada 2 item, satu textbox satu lagi listbox..

cth:

input dlm textbox = smileyjawa [name:txtdomainname]
input dlm listbox = .com [name:drpdomains]

aku nak post kan die jadi mcm nie

$domain = smileyjawa.com

---> $domain simpan nilai smileyjawa.com
---> coding yang aku tau : $domain = $_POST['txtDomainName'];

cmne nak letakkan .com [drpdomains] tu selepas smileyjawa?

sape tau coding die? tlong aku.. ~X( aku beginner lagi nie..

nie cth coding lengkap die.. :D


Code:
<? 
#bina form untuk masukkan domain#####

$domain = smileyjawa.com  ###bantu aku kat sini!###

###############

$whois = new whois;
$result = $whois->available($domain);

switch($result){
case true: echo $domain.' : Domain is available'; break;
case false: echo $domain.' : Domain is already registered'; break;
}

class whois {

public $ext = array(
'.com' => array('whois.crsnic.net','No match for'),
'.net' => array('whois.crsnic.net','No match for'),
'.org' => array('whois.publicinterestregistry.net','NOT FOUND'),
'.us' => array('whois.nic.us','Not Found'),
'.biz' => array('whois.biz','Not found'),
'.info' => array('whois.afilias.net','NOT FOUND'),
'.eu' => array('whois.eurid.eu','FREE'),
'.mobi' => array('whois.dotmobiregistry.net', 'NOT FOUND'),
'.tv' => array('whois.nic.tv', 'No match for'),
'.in' => array('whois.inregistry.net', 'NOT FOUND'),
'.co.uk' => array('whois.nic.uk','No match'),
'.co.ug' => array('wawa.eahd.or.ug','No entries found'),
'.or.ug' => array('wawa.eahd.or.ug','No entries found'),
'.sg' => array('whois.nic.net.sg','NOMATCH'),
'.com.sg' => array('whois.nic.net.sg','NOMATCH'),
'.per.sg' => array('whois.nic.net.sg','NOMATCH'),
'.org.sg' => array('whois.nic.net.sg','NOMATCH'),
'.com.my' => array('whois.mynic.net.my','does not Exist in database'),
'.net.my' => array('whois.mynic.net.my','does not Exist in database'),
'.org.my' => array('whois.mynic.net.my','does not Exist in database'),
'.edu.my' => array('whois.mynic.net.my','does not Exist in database'),
'.my' => array('whois.mynic.net.my','does not Exist in database'),
'.nl' => array('whois.domain-registry.nl','not a registered domain'),
'.ro' => array('whois.rotld.ro','No entries found for the selected'),
'.com.au' => array('whois.ausregistry.net.au','No data Found'),
'.ca' => array('whois.cira.ca', 'AVAIL'),
'.org.uk' => array('whois.nic.uk','No match'),
'.name' => array('whois.nic.name','No match'),
'.ac.ug' => array('wawa.eahd.or.ug','No entries found'),
'.ne.ug' => array('wawa.eahd.or.ug','No entries found'),
'.sc.ug' => array('wawa.eahd.or.ug','No entries found'),
'.ws' => array('whois.website.ws','No Match'),
'.be' => array('whois.ripe.net','No entries'),
'.com****' => array('whois****nic****','no matching record'),
'.net****' => array('whois****nic****','no matching record'),
'.org****' => array('whois****nic****','no matching record'),
'.no' => array('whois.norid.no','no matches'),
'.se' => array('whois.nic-se.se','No data found'),
'.nu' => array('whois.nic.nu','NO MATCH for'),
'.com.tw' => array('whois.twnic.net','No such Domain Name'),
'.net.tw' => array('whois.twnic.net','No such Domain Name'),
'.org.tw' => array('whois.twnic.net','No such Domain Name'),
'.cc' => array('whois.nic.cc','No match'),
'.nl' => array('whois.domain-registry.nl','is free'),
'.pl' => array('whois.dns.pl','No information about'),
'.pt' => array('whois.dns.pt','No match')
);

public $error;

function available($domain){
$domain = trim($domain);
if (eregi('^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)*[a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?$',$domain) != 1){
$error = 'Invalid domain (Letters, numbers and hypens only) ('.$domain.')';
return false;
}
preg_match('@^(http://www\.|http://|www\.)?([^/]+)@i', $domain, $preg_metch_result);
$f_result = '';
$domain = $preg_metch_result[2];
$domain_name_array = explode('.', $domain);
$domain_domain = strtolower(trim($domain_name_array[count($domain_name_array)-1]));
$ext_in_list = false;

if (array_key_exists('.'.$domain_domain, $this->ext)){
$ext_in_list = true;
}

if(strlen($domain) > 0 && $ext_in_list){
$server = '';
$server = $this->ext['.' .$domain_domain][0];
$lookup_result = gethostbyname($server);

if ($lookup_result == $server){
$error = 'Error: Invalid extension - '.$domain_domain.'. / server has outgoing connections blocked to '.$server.'.';
return false;
}

$fs = fsockopen($server, 43,$errno,$errstr,10);

if (!$fs || ($errstr != "")){
$error = 'Error: ('.$server.') '.$errstr.' ('.$errno.')';
return false;
}

fputs($fs, "$domain\r\n");
while( !feof($fs) ) {
$f_result .= fgets($fs,128);
}

fclose($fs);

if($domain_domain == 'org'){
nl2br($f_result);
}

if(eregi($this->ext['.'.$domain_domain][1], $f_result)){
return true;
} else {
return false;
}

} else {
$error = 'Invalid Domain and/or TLD server entry does not exist';
}
return false;
}

}

?>
 
Last edited:
help me... ~X(

tolong2.. aku tau nie simple tp aku tak tau.. CGrians mesti ada yang terer nye... :D
 
dlm koleksi aku. cuba test :D

PHP:
<?php
	// Listkan server whois kat sini
	$serverList[0]['top']      = 'com';
	$serverList[0]['server']   = 'whois.crsnic.net';
	$serverList[0]['response'] = 'No match for';
	$serverList[0]['check']    = true;
	
	$serverList[1]['top']      = 'net';
	$serverList[1]['server']   = 'whois.crsnic.net';
	$serverList[1]['response'] = 'No match for';
	$serverList[1]['check']    = false;

	$serverList[2]['top']      = 'org';
	$serverList[2]['server']   = 'whois.publicinterestregistry.net';
	$serverList[2]['response'] = 'NOT FOUND';
	$serverList[2]['check']    = false;
	

    function checkDomain($domain,$server,$findText){
        // Connect ke server whois

        $con = fsockopen($server, 43);
        if (!$con) return false;
        
        // Hantar nama domain yg direquest
        fputs($con, $domain."\r\n");
        
        // terima dan menyimpan respon dari server
        $response = ' :';
        while(!feof($con)) {
            $response .= fgets($con,128); 
        }
        
        // X connect
        fclose($con);
        
        // Periksa domain ada atau tak
        if (strpos($response, $findText)){
            return true;
        }
        else {
            return false;   
        }
    }

    function showDomainResult($domain,$server,$findText){
       if (checkDomain($domain,$server,$findText)){
          echo "<tr><td>$domain</td><td>AVAILABLE</td></tr>";
       }
       else echo "<tr><td>$domain</td><td>TAKEN</td></tr>";
    }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
   <title>Domain Checker</title>
</head>
<body>
<?php if (!isset($_POST['submitBtn'])) { ?>
      <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="domain" id="domain">
        Domain name:
        <table>
          <tr><td><input class="text" name="domainname" type="text" size="36"/></td></tr>
          <tr>
            <td>
                <input type="checkbox" name="all" />All
            <?php
            	foreach ($serverList as $value) {
            		if ($value['check'] == true) $checked=" checked ";
            		else $checked = " ";
            		
            		echo '<input type="checkbox" name="top_'.$value['top'].'"'.$checked.'/>.'.$value['top'];
            	}
            ?>
            </td></tr>
            <tr><td align="center"><br/><input class="text" type="submit" name="submitBtn" value="Check domain"/></td></tr>
        </table>  
      </form>
<?php    
} else {
    $domainName = (isset($_POST['domainname'])) ? $_POST['domainname'] : '';
    if (isset($_POST['all'])) {
      	// Periksa semua jika ALL selected
       	for ($i = 0; $i < sizeof($serverList); $i++) {
       		$serverList[$i]['check'] = true;
       	}
    }
    else{
       	for ($i = 0; $i < sizeof($serverList); $i++) {
       		$actTop = "top_".$serverList[$i]['top'];
       		$serverList[$i]['check'] = isset($_POST[$actTop]) ? true : false;
       	}
    }


    if (strlen($domainName)>2){
        echo '<table>';
		
       	for ($i = 0; $i < sizeof($serverList); $i++) {
			if ($serverList[$i]['check']){
				showDomainResult($domainName.".".$serverList[$i]['top'],$serverList[$i]['server'],$serverList[$i]['response']);
			}
		}
        
		echo '</table>';
    }
}
?>    
</body>
 
try jgn tak try..

um ni kodek macam mana?
 
huhu aku dah jumpe penyelesaian:

$domain = $_POST['txtDomainName'] . $_POST['drpDomains']

:D
 
coding ko tak lengkap la bro.. aku nak yg bleh cek .com.my, .net.my, .my, .edu.my

tp papehal aku dh jumpe aku nye jalan penyelesaian.. :D tq!

dlm koleksi aku. cuba test :D

PHP:
<?php
	// Listkan server whois kat sini
	$serverList[0]['top']      = 'com';
	$serverList[0]['server']   = 'whois.crsnic.net';
	$serverList[0]['response'] = 'No match for';
	$serverList[0]['check']    = true;
	
	$serverList[1]['top']      = 'net';
	$serverList[1]['server']   = 'whois.crsnic.net';
	$serverList[1]['response'] = 'No match for';
	$serverList[1]['check']    = false;

	$serverList[2]['top']      = 'org';
	$serverList[2]['server']   = 'whois.publicinterestregistry.net';
	$serverList[2]['response'] = 'NOT FOUND';
	$serverList[2]['check']    = false;
	

    function checkDomain($domain,$server,$findText){
        // Connect ke server whois

        $con = fsockopen($server, 43);
        if (!$con) return false;
        
        // Hantar nama domain yg direquest
        fputs($con, $domain."\r\n");
        
        // terima dan menyimpan respon dari server
        $response = ' :';
        while(!feof($con)) {
            $response .= fgets($con,128); 
        }
        
        // X connect
        fclose($con);
        
        // Periksa domain ada atau tak
        if (strpos($response, $findText)){
            return true;
        }
        else {
            return false;   
        }
    }

    function showDomainResult($domain,$server,$findText){
       if (checkDomain($domain,$server,$findText)){
          echo "<tr><td>$domain</td><td>AVAILABLE</td></tr>";
       }
       else echo "<tr><td>$domain</td><td>TAKEN</td></tr>";
    }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
   <title>Domain Checker</title>
</head>
<body>
<?php if (!isset($_POST['submitBtn'])) { ?>
      <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="domain" id="domain">
        Domain name:
        <table>
          <tr><td><input class="text" name="domainname" type="text" size="36"/></td></tr>
          <tr>
            <td>
                <input type="checkbox" name="all" />All
            <?php
            	foreach ($serverList as $value) {
            		if ($value['check'] == true) $checked=" checked ";
            		else $checked = " ";
            		
            		echo '<input type="checkbox" name="top_'.$value['top'].'"'.$checked.'/>.'.$value['top'];
            	}
            ?>
            </td></tr>
            <tr><td align="center"><br/><input class="text" type="submit" name="submitBtn" value="Check domain"/></td></tr>
        </table>  
      </form>
<?php    
} else {
    $domainName = (isset($_POST['domainname'])) ? $_POST['domainname'] : '';
    if (isset($_POST['all'])) {
      	// Periksa semua jika ALL selected
       	for ($i = 0; $i < sizeof($serverList); $i++) {
       		$serverList[$i]['check'] = true;
       	}
    }
    else{
       	for ($i = 0; $i < sizeof($serverList); $i++) {
       		$actTop = "top_".$serverList[$i]['top'];
       		$serverList[$i]['check'] = isset($_POST[$actTop]) ? true : false;
       	}
    }


    if (strlen($domainName)>2){
        echo '<table>';
		
       	for ($i = 0; $i < sizeof($serverList); $i++) {
			if ($serverList[$i]['check']){
				showDomainResult($domainName.".".$serverList[$i]['top'],$serverList[$i]['server'],$serverList[$i]['response']);
			}
		}
        
		echo '</table>';
    }
}
?>    
</body>
 
coding ko tak lengkap la bro.. aku nak yg bleh cek .com.my, .net.my, .my, .edu.my

tp papehal aku dh jumpe aku nye jalan penyelesaian.. :D tq!

bole tambah kat listing server tu, contoh:

PHP:
    $serverList[3]['top']      = 'com.my';
    $serverList[3]['server']   = 'whois.mynic.net.my';
    $serverList[3]['response'] = 'No match for';
    $serverList[3]['check']    = true;

yg penting masalah ko dh setel kan. slamat bercoding! :D :)cgrock
 
Back
Top
Log in Register