PHP--用萬網(wǎng)的接口實現(xiàn)域名查詢功能
更新時間:2012年12月13日 09:31:28 作者:
PHP用萬網(wǎng)的接口實現(xiàn)域名查詢功能,需要的朋友可以了解下
今天給別人做網(wǎng)站時有個需求是要有域名查詢功能,查了點資料寫了個簡單的查詢功能
前臺頁面用的是checkbox,代碼如下:
<form name="form1" method="post" action="chaxun.php">
<tbody><tr>
<td align="right" valign="middle" width="251">
<p align="center">
<img border="0" src="./templates/img/www.gif"><input name="dns" type="text" id="dns" size="20" style="background-color: #C0C0C0"></p></td>
<td style="padding-top:11px;" valign="top" width="99">
<!--
<input type="image" src="./templates/img/cx.gif" align="left" onclick="submit()" width="50" height="18">
-->
<input type="submit" value="查詢"/>
</td>
</tr>
<tr>
<td colspan="2" align="left" valign="top" style="padding-left:12px;">
<table width="96%" border="0" cellspacing="0" cellpadding="0" height="94%">
<tbody><tr>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="com" checked="">.com</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="cn" checked="">.cn</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="tel" checked="">.tel</td>
</tr>
<tr>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="mobi">.mobi</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="net" checked="">.net</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="org">.org</td>
</tr>
<tr>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="asia">.asia</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="me">.me</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="com.cn" checked="">.com.cn</td>
</tr>
<tr>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="net.cn">.net.cn</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="org.cn">.org.cn</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="gov.cn">.gov.cn</td>
</tr>
<tr>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="hk">.hk</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="tv">.tv</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="biz">.biz</td>
</tr>
<tr>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="cc">.cc</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="name">.name</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="info">.info</td>
</tr>
<tr>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="公司">.公司</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="網(wǎng)絡">.網(wǎng)絡</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="中國">.中國</td>
</tr>
</tbody></table></td>
</tr>
</tbody>
</form>
PHP代碼:
<?php
//得到頂級域名
$ext=$_POST['ext'];
//得到二級域名
$dns = $_POST['dns'];
//print_r($ext);
//$domain = $dns . "." . $ext[0];
//echo $domain;
//遍歷所有的域名
foreach ($ext as $value) {
//組合域名
$domain = $dns . "." . $value;
//查詢:
echo $domain ;
$do = "http://panda.www.net.cn/cgi-bin/check.cgi?area_domain=" . $domain;
$xml_data = file_get_contents($do);
$result_arr = (array) simplexml_load_string($xml_data);
$returncode=$result_arr['returncode'];
$key=$result_arr['key'];
$original=$result_arr['original'];
$status= substr($original,0,3);
if($status=="210"){
echo ":恭喜您,可以注冊";
}else if($status=="211"){
echo ":已經(jīng)注冊";
}else if($status=="212"){
echo ":參數(shù)錯誤";
}
echo '<br>';
}
?>
前臺頁面用的是checkbox,代碼如下:
復制代碼 代碼如下:
<form name="form1" method="post" action="chaxun.php">
<tbody><tr>
<td align="right" valign="middle" width="251">
<p align="center">
<img border="0" src="./templates/img/www.gif"><input name="dns" type="text" id="dns" size="20" style="background-color: #C0C0C0"></p></td>
<td style="padding-top:11px;" valign="top" width="99">
<!--
<input type="image" src="./templates/img/cx.gif" align="left" onclick="submit()" width="50" height="18">
-->
<input type="submit" value="查詢"/>
</td>
</tr>
<tr>
<td colspan="2" align="left" valign="top" style="padding-left:12px;">
<table width="96%" border="0" cellspacing="0" cellpadding="0" height="94%">
<tbody><tr>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="com" checked="">.com</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="cn" checked="">.cn</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="tel" checked="">.tel</td>
</tr>
<tr>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="mobi">.mobi</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="net" checked="">.net</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="org">.org</td>
</tr>
<tr>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="asia">.asia</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="me">.me</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="com.cn" checked="">.com.cn</td>
</tr>
<tr>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="net.cn">.net.cn</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="org.cn">.org.cn</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="gov.cn">.gov.cn</td>
</tr>
<tr>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="hk">.hk</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="tv">.tv</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="biz">.biz</td>
</tr>
<tr>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="cc">.cc</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="name">.name</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="info">.info</td>
</tr>
<tr>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="公司">.公司</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="網(wǎng)絡">.網(wǎng)絡</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="中國">.中國</td>
</tr>
</tbody></table></td>
</tr>
</tbody>
</form>
PHP代碼:
復制代碼 代碼如下:
<?php
//得到頂級域名
$ext=$_POST['ext'];
//得到二級域名
$dns = $_POST['dns'];
//print_r($ext);
//$domain = $dns . "." . $ext[0];
//echo $domain;
//遍歷所有的域名
foreach ($ext as $value) {
//組合域名
$domain = $dns . "." . $value;
//查詢:
echo $domain ;
$do = "http://panda.www.net.cn/cgi-bin/check.cgi?area_domain=" . $domain;
$xml_data = file_get_contents($do);
$result_arr = (array) simplexml_load_string($xml_data);
$returncode=$result_arr['returncode'];
$key=$result_arr['key'];
$original=$result_arr['original'];
$status= substr($original,0,3);
if($status=="210"){
echo ":恭喜您,可以注冊";
}else if($status=="211"){
echo ":已經(jīng)注冊";
}else if($status=="212"){
echo ":參數(shù)錯誤";
}
echo '<br>';
}
?>
相關文章
ThinkPHP的截取字符串函數(shù)無法顯示省略號的解決方法
這篇文章主要介紹了ThinkPHP的截取字符串函數(shù)無法顯示省略號的解決方法,需要的朋友可以參考下2014-06-06php實現(xiàn)HTML實體編號與非ASCII字符串相互轉(zhuǎn)換類實例
本篇文章主要介紹了"php實現(xiàn)HTML實體編號與非ASCII字符串相互轉(zhuǎn)換類實例",主要涉及到HTML實體編號與非ASCII字符串相互轉(zhuǎn)換類方面的內(nèi)容,感興趣的同學可以參考一下。2016-11-11PHP根據(jù)傳入?yún)?shù)合并多個JS和CSS文件的簡單實現(xiàn)
這篇文章主要介紹了PHP合并多個JS和CSS文件的簡單實現(xiàn),本文使用了一種比較簡單的方法,重在揭示實現(xiàn)原理,需要的朋友可以參考下2014-06-06