|
 |
|
เรื่อง code check domain ครับ มีปัญหาตรงพวกดอทในประเทศไทยอ่ะครับ |
|
 |
|
|
 |
 |
|
Code นะครับ
Code (PHP)
<?php
function checkDomain($domain,$server,$findText){
// Open a socket connection to the whois server
$con = fsockopen($server, 43);
if (!$con) return false;
// Send the requested doman name
fputs($con, $domain."\r\n");
// Read and store the server response
$response = ' :';
while(!feof($con)) {
$response .= fgets($con,128);
}
// Close the connection
fclose($con);
// Check the response stream whether the domain is available
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><span style='color:#0C3'>AVAILABLE</span></td></tr>";
}
else echo "<tr><td>$domain</td><td><span style='color:#F00'>TAKEN</span></td></tr>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>MicroWhois domain checker</title>
</head>
<body>
<div id="main">
<div id="caption">DOMAIN LOOKUP</div>
<div id="icon"> </div>
<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" checked />
<input type="checkbox"name="com"/>.com
<input type="checkbox" name="net"/>.net
<input type="checkbox" name="org"/>.org
<input type="checkbox" name="info"/>.info
<input type="checkbox" name="coth"/>.coth
<input type="checkbox" name="inth"/>.int.h
</td></tr>
<tr><td align="center"><br/><input class="text" type="submit" name="submitBtn" value="Check domain"/></td></tr>
</table>
</form>
<?php
if (isset($_POST['submitBtn'])){
$domainbase = (isset($_POST['domainname'])) ? $_POST['domainname'] : '';
$d_all = (isset($_POST['all'])) ? 'all' : '';
$d_com = (isset($_POST['com'])) ? 'com' : '';
$d_net = (isset($_POST['net'])) ? 'net' : '';
$d_org = (isset($_POST['org'])) ? 'org' : '';
$d_info = (isset($_POST['info'])) ? 'info' : '';
$d_coth = (isset($_POST['coth'])) ? 'coth' : '';
$d_inth = (isset($_POST['inth'])) ? 'inth' : '';
$d_inth = (isset($_POST['goth'])) ? 'goth' : '';
// Check domains only if the base name is big enough
if (strlen($domainbase)>1){
?>
<div id="caption">RESULT</div>
<div id="icon2"> </div>
<div id="result">
<table width="100%">
<?php
if (($d_com != '') || ($d_all != '') ) showDomainResult($domainbase.".com",'whois.crsnic.net','No match for');
if (($d_net != '') || ($d_all != '') ) showDomainResult($domainbase.".net",'whois.crsnic.net','No match for');
if (($d_org != '') || ($d_all != '') ) showDomainResult($domainbase.".org",'whois.publicinterestregistry.net','NOT FOUND');
if (($d_info != '') || ($d_all != '') ) showDomainResult($domainbase.".info",'whois.afilias.net','NOT FOUND');
if (($d_coth != '') || ($d_all != '') ) showDomainResult($domainbase.".co.th",'whois.thnic.net','No entries');
if (($d_inth != '') || ($d_all != '') ) showDomainResult($domainbase.".in.th",'whois.thnic.net','No entries found');
?>
</table>
</div>
<?php
}
}
?>
<div id="source">Micro Whois 1.1</div>
</div>
</body>
คือจริงๆ ผมโหลดมา แล้วปรับให้มี .co.th กับ .in.th อ่ะครับ โดยเปลี่ยน whois.crsnic.net ให้ เป็น whois.thnic.net ตามความรู้ทั่วไปที่หาทาง net ผลคือ ทุกครั้งที่ check เว็บอะไร ที่เป็น .co.th กับ .in.th จะไม่ว่างเสมอ ทั้งๆ ที่ จริงๆ แล้ว อาจจะว่างก็ได้ ต้องแก้ไขยังไงครับ
ขอบพระคุณล่วงหน้าครับ
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2012-08-01 16:17:06 |
By :
Black_Hawk |
View :
1893 |
Reply :
7 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ปกติพวกนี้มันใช้การตรวจสอข้อความที่ถูกส่งกลับมาครับ ลองดูว่าใช้ whois.thnic.net มัน return ค่ากลับมาเป็นอะไร ลองเช็คโดเมนที่ว่าง กับไม่ว่าง แล้วดูค่าที่ได้ครับ
|
 |
 |
 |
 |
Date :
2012-08-01 21:43:51 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทุกครั้งที่ Check อะไรที่เกี่ยวกับ whois.thnic.net จะไม่ว่างเสมอเลยครับ
|
 |
 |
 |
 |
Date :
2012-08-03 18:41:53 |
By :
Black_Hawk |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
echo $response;
มันได้ค่ากลับมาเป็นอะไรครับ
|
 |
 |
 |
 |
Date :
2012-08-03 21:50:35 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอบความคิดเห็นที่ : 3 เขียนโดย : mr.win เมื่อวันที่ 2012-08-03 21:50:35
รายละเอียดของการตอบ ::
Code (PHP)
echo $response;
มันได้ค่ากลับมาเป็นอะไรครับ
ไม่รู้ผมใส่ผิดรึเปล่านะครับ
ผมไปแทรกแบบบนี้
Code (PHP)
<table width="100%">
<?php
if (($d_com != '') || ($d_all != '') ) showDomainResult($domainbase.".com",'whois.crsnic.net','No match for');
if (($d_net != '') || ($d_all != '') ) showDomainResult($domainbase.".net",'whois.crsnic.net','No match for');
if (($d_org != '') || ($d_all != '') ) showDomainResult($domainbase.".org",'whois.publicinterestregistry.net','NOT FOUND');
if (($d_info != '') || ($d_all != '') ) showDomainResult($domainbase.".info",'whois.afilias.net','NOT FOUND');
if (($d_coth != '') || ($d_all != '') ) showDomainResult($domainbase.".co.th",'whois.thnic.net','No entries');
if (($d_inth != '') || ($d_all != '') ) showDomainResult($domainbase.".in.th",'whois.thnic.net','No entries found');
echo $response;
?>
</table>
ไม่ได้อะไรกลับมาเลยครับ
|
 |
 |
 |
 |
Date :
2012-08-06 09:02:57 |
By :
Black_Hawk |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ในที่สุดก็แก้ได้แล้วครับผม เป็นเรื่องของ ค่า response อย่างที่พี่วินบอกจริงๆ ด้วยครับ ไปอ่านจากเว็บต่างประเทศหลายๆ เว็บมาแล้ว แก้ได้เป็นแบบนี้ครับ
Code (PHP)
<?php
function checkDomain($domain,$server,$findText){
// Open a socket connection to the whois server
$con = fsockopen($server, 43);
if (!$con) return false;
// Send the requested doman name
fputs($con, $domain."\r\n");
// Read and store the server response
$response = ' :';
while(!feof($con)) {
$response .= fgets($con,128);
}
// Close the connection
fclose($con);
// Check the response stream whether the domain is available
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><span style='color:#0C3'>AVAILABLE</span></td></tr>";
}
else echo "<tr><td>$domain</td><td><span style='color:#F00'>TAKEN</span></td></tr>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>MicroWhois domain checker</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="main">
<div id="caption">DOMAIN LOOKUP</div>
<div id="icon"> </div>
<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" checked />all
<input type="checkbox"name="com"/>.com
<input type="checkbox" name="net"/>.net
<input type="checkbox" name="org"/>.org
<input type="checkbox" name="info"/>.info
<input type="checkbox" name="coth"/>.co.th
<input type="checkbox" name="inth"/>.in.th
</td></tr>
<tr><td align="center"><br/><input class="text" type="submit" name="submitBtn" value="Check domain"/></td></tr>
</table>
</form>
<?php
if (isset($_POST['submitBtn'])){
$domainbase = (isset($_POST['domainname'])) ? $_POST['domainname'] : '';
$d_all = (isset($_POST['all'])) ? 'all' : '';
$d_com = (isset($_POST['com'])) ? 'com' : '';
$d_net = (isset($_POST['net'])) ? 'net' : '';
$d_org = (isset($_POST['org'])) ? 'org' : '';
$d_info = (isset($_POST['info'])) ? 'info' : '';
$d_coth = (isset($_POST['coth'])) ? 'coth' : '';
$d_inth = (isset($_POST['inth'])) ? 'inth' : '';
$d_inth = (isset($_POST['goth'])) ? 'goth' : '';
// Check domains only if the base name is big enough
if (strlen($domainbase)>1){
?>
<div id="caption">RESULT</div>
<div id="icon2"> </div>
<div id="result">
<table width="100%">
<?php
if (($d_com != '') || ($d_all != '') ) showDomainResult($domainbase.".com",'whois.crsnic.net','No match for');
if (($d_net != '') || ($d_all != '') ) showDomainResult($domainbase.".net",'whois.crsnic.net','No match for');
if (($d_org != '') || ($d_all != '') ) showDomainResult($domainbase.".org",'whois.publicinterestregistry.net','NOT FOUND');
if (($d_info != '') || ($d_all != '') ) showDomainResult($domainbase.".info",'whois.afilias.net','NOT FOUND');
if (($d_coth != '') || ($d_all != '') ) showDomainResult($domainbase.".co.th",'whois.thnic.net','No match for');
if (($d_inth != '') || ($d_all != '') ) showDomainResult($domainbase.".in.th",'whois.thnic.net','No match for');
?>
</table>
</div>
<?php
}
}
?>
<div id="source">Micro Whois 1.1</div>
</div>
</body>
ใช้งานได้แล้วครับ ขอบคุณพี่วินอีกครั้งนะครับ
|
ประวัติการแก้ไข 2012-08-07 16:06:25 2012-08-07 16:16:41
 |
 |
 |
 |
Date :
2012-08-07 16:05:55 |
By :
Black_Hawk |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แจ่มครับ 
|
 |
 |
 |
 |
Date :
2012-08-07 16:09:53 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอนำไปใช้น่ะครับ ขอบคุณครับผม
|
 |
 |
 |
 |
Date :
2012-08-20 14:25:18 |
By :
nom_loso |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|