<?php
header("content-type:text/html;charset=utf-8");
header("cache-control:no-cache");
$domain = htmlspecialchars(trim($_REQUEST['domain'])); //取出不能识别的字符
$str= $_REQUEST['str']; //后缀信息
if( !$domain ){
echo '请输入要查询的域名,如:tjtty';
exit;
}
if( !$str ){
echo '请输入域名后缀,如.com';
exit;
}
$arr=explode(':',$str); //将获得的数据分割成数组
$num=count($arr); //获取数组的数目
for($i=0;$i<$num;$i++){ $hou.=$arr[$i].","; } //循环获得数组
$info=substr($hou,0,-2); // .com,.net,.cn,.com.cn,.net.cn
$info1=str_replace(",.",",",$info); //用,替换,.
$info2=substr($info1,1); //字符串的提取 com,cn,net 格式
$dtime=date("YmdHi",time()); //传给接口的时间
$pwd= md5('******'.'*******'. date("YmdHi",time())); //传给接口的加密数据
$domain_api = "http://api.dmctr.cn/trans_api/api.php?command=Dmcheck&vtime=".$dtime."&checksum=".$pwd."&charset=utf-8&sld=".$domain."&tld=".$info2;
$contents= file_get_contents($domain_api);
//$xml = simplexml_load_string(trim($contents)); //使用该方法出错 应该是xml文档加载出错
$pattern='#<domain>(.*)</domain>#iUs';
preg_match_all($pattern,$contents,$matches);
$xml=$matches[1];
$xml_num=count($xml);
function get_info($xml){ //$xml为内容
//获取域名的名字
$pattern02='#<domainname>(.*)</domainname>#iUs';
preg_match_all($pattern02,$xml,$matches02);
$xml_name=($matches02[1][0]);
//获取返回的编码
$pattern01='#<RRPCode>(.*)</RRPCode>#iUs';
preg_match_all($pattern01,$xml,$matches01);
$xml_code=($matches01[1][0]);
if($xml_code==-1){
return "验证超时";
}else if($xml_code==0){
return "<font color='red'>".$xml_name."对不起,已注册</font><br/>";
}else if($xml_code==1){ // 可根据session确定用户是否登录
return "<font color='BLACK'>".$xml_name."恭喜,可注册</font><a href='/tj_login.html'><font color='green'>立即注册</font></a><br/>";
}
}
for($i=0;$i<$xml_num;$i++){
$xml_info=$xml[$i];
$result=get_info($xml_info);
echo $result;
}
?>
//保护隐私 略作修改 灵感来自:http://www.5idev.com/p-php_domain_ajax.shtml
header("content-type:text/html;charset=utf-8");
header("cache-control:no-cache");
$domain = htmlspecialchars(trim($_REQUEST['domain'])); //取出不能识别的字符
$str= $_REQUEST['str']; //后缀信息
if( !$domain ){
echo '请输入要查询的域名,如:tjtty';
exit;
}
if( !$str ){
echo '请输入域名后缀,如.com';
exit;
}
$arr=explode(':',$str); //将获得的数据分割成数组
$num=count($arr); //获取数组的数目
for($i=0;$i<$num;$i++){ $hou.=$arr[$i].","; } //循环获得数组
$info=substr($hou,0,-2); // .com,.net,.cn,.com.cn,.net.cn
$info1=str_replace(",.",",",$info); //用,替换,.
$info2=substr($info1,1); //字符串的提取 com,cn,net 格式
$dtime=date("YmdHi",time()); //传给接口的时间
$pwd= md5('******'.'*******'. date("YmdHi",time())); //传给接口的加密数据
$domain_api = "http://api.dmctr.cn/trans_api/api.php?command=Dmcheck&vtime=".$dtime."&checksum=".$pwd."&charset=utf-8&sld=".$domain."&tld=".$info2;
$contents= file_get_contents($domain_api);
//$xml = simplexml_load_string(trim($contents)); //使用该方法出错 应该是xml文档加载出错
$pattern='#<domain>(.*)</domain>#iUs';
preg_match_all($pattern,$contents,$matches);
$xml=$matches[1];
$xml_num=count($xml);
function get_info($xml){ //$xml为内容
//获取域名的名字
$pattern02='#<domainname>(.*)</domainname>#iUs';
preg_match_all($pattern02,$xml,$matches02);
$xml_name=($matches02[1][0]);
//获取返回的编码
$pattern01='#<RRPCode>(.*)</RRPCode>#iUs';
preg_match_all($pattern01,$xml,$matches01);
$xml_code=($matches01[1][0]);
if($xml_code==-1){
return "验证超时";
}else if($xml_code==0){
return "<font color='red'>".$xml_name."对不起,已注册</font><br/>";
}else if($xml_code==1){ // 可根据session确定用户是否登录
return "<font color='BLACK'>".$xml_name."恭喜,可注册</font><a href='/tj_login.html'><font color='green'>立即注册</font></a><br/>";
}
}
for($i=0;$i<$xml_num;$i++){
$xml_info=$xml[$i];
$result=get_info($xml_info);
echo $result;
}
?>
//保护隐私 略作修改 灵感来自:http://www.5idev.com/p-php_domain_ajax.shtml