 |
|
ทำไมส่งภาษาไทยไปแล้วเช็คค่าผิดพลาดครับ (domain check)
จากโค๊ดด้านล่าง ตอนที่ทำการทดสอบให้เรียกเพจ
Code (PHP)
http://www.example.com/index.php?domain=ก.com
ซึ่ง ก.com จะเป็นโดเมนที่ไม่ว่าง แต่พอทดสอบปุ๊บ จากที่เป็น ก.com กลายเป็น \u0e01.com เฉยเลยครับ ไม่ทราบว่าจะต้องแก้ตรงส่วนใดครับ
index.php
Code (PHP)
<?php
function checkDomain($domain_check,$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_check."\r\n");
// Read and store the server response
$response = ' :';
while(!feof($con))
{
$response .= fgets($con,128);
}
//echo $response;
// 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_check,$server,$findText)
{
if (checkDomain($domain_check,$server,$findText))
{
class Emp {
public $domain = "";
public $availability = "";
}
$e = new Emp();
$e->domain = $domain_check;
$e->availability = "available";
echo json_encode($e);
}
else
{
class Emp {
public $domain = "";
public $availability = "";
}
$e = new Emp();
$e->domain = $domain_check;
$e->availability = "TAKEN";
echo json_encode($e);
}
}
?>
<?php
if ($_GET['domain'] != '')
{
list($domain_name, $tld) = explode(".", urldecode($_GET[domain]));
$tld_all = $tld;
$tld_main = $tld;
$server = "whois.verisign-grs.com";
$response = "No match for";
showDomainResult($domain_name.".".$tld_all,$server,$response);
}
?>
Tag : PHP
|
|
 |
 |
 |
 |
Date :
2015-05-19 23:13:31 |
By :
peap |
View :
820 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |