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..
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..
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: