PHP--用萬網(wǎng)的接口實(shí)現(xiàn)域名查詢功能
更新時(shí)間:2012年12月13日 09:31:28 作者:
PHP用萬網(wǎng)的接口實(shí)現(xiàn)域名查詢功能,需要的朋友可以了解下
今天給別人做網(wǎng)站時(shí)有個(gè)需求是要有域名查詢功能,查了點(diǎn)資料寫了個(gè)簡(jiǎn)單的查詢功能
前臺(tái)頁面用的是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)絡(luò)">.網(wǎng)絡(luò)</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="中國">.中國</td>
</tr>
</tbody></table></td>
</tr>
</tbody>
</form>
PHP代碼:
<?php
//得到頂級(jí)域名
$ext=$_POST['ext'];
//得到二級(jí)域名
$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 ":恭喜您,可以注冊(cè)";
}else if($status=="211"){
echo ":已經(jīng)注冊(cè)";
}else if($status=="212"){
echo ":參數(shù)錯(cuò)誤";
}
echo '<br>';
}
?>
前臺(tái)頁面用的是checkbox,代碼如下:
復(fù)制代碼 代碼如下:
<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)絡(luò)">.網(wǎng)絡(luò)</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="中國">.中國</td>
</tr>
</tbody></table></td>
</tr>
</tbody>
</form>
PHP代碼:
復(fù)制代碼 代碼如下:
<?php
//得到頂級(jí)域名
$ext=$_POST['ext'];
//得到二級(jí)域名
$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 ":恭喜您,可以注冊(cè)";
}else if($status=="211"){
echo ":已經(jīng)注冊(cè)";
}else if($status=="212"){
echo ":參數(shù)錯(cuò)誤";
}
echo '<br>';
}
?>
相關(guān)文章
php設(shè)計(jì)模式之適配器模式實(shí)例分析【星際爭(zhēng)霸游戲案例】
這篇文章主要介紹了php設(shè)計(jì)模式之適配器模式,結(jié)合星際爭(zhēng)霸游戲案例形式分析了PHP適配器模式相關(guān)原理、用法及操作注意事項(xiàng),需要的朋友可以參考下2020-04-04ThinkPHP的截取字符串函數(shù)無法顯示省略號(hào)的解決方法
這篇文章主要介紹了ThinkPHP的截取字符串函數(shù)無法顯示省略號(hào)的解決方法,需要的朋友可以參考下2014-06-06php實(shí)現(xiàn)HTML實(shí)體編號(hào)與非ASCII字符串相互轉(zhuǎn)換類實(shí)例
本篇文章主要介紹了"php實(shí)現(xiàn)HTML實(shí)體編號(hào)與非ASCII字符串相互轉(zhuǎn)換類實(shí)例",主要涉及到HTML實(shí)體編號(hào)與非ASCII字符串相互轉(zhuǎn)換類方面的內(nèi)容,感興趣的同學(xué)可以參考一下。2016-11-11PHP根據(jù)傳入?yún)?shù)合并多個(gè)JS和CSS文件的簡(jiǎn)單實(shí)現(xiàn)
這篇文章主要介紹了PHP合并多個(gè)JS和CSS文件的簡(jiǎn)單實(shí)現(xiàn),本文使用了一種比較簡(jiǎn)單的方法,重在揭示實(shí)現(xiàn)原理,需要的朋友可以參考下2014-06-06PHP并發(fā)場(chǎng)景的三種解決方案代碼實(shí)例
這篇文章主要介紹了PHP并發(fā)場(chǎng)景的三種解決方案代碼實(shí)例,有對(duì)這方面感興趣的同學(xué)可以借鑒參考下2021-02-02