<?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='#(.*)#iUs'; preg_match_all($pattern,$contents,$matches); $xml=$matches[1]; $xml_num=count($xml); function get_info($xml){ //$xml为内容 //获取域名的名字 $pattern02='#(.*)#iUs'; preg_match_all($pattern02,$xml,$matches02); $xml_name=($matches02[1][0]); //获取返回的编码 $pattern01='#(.*)#iUs'; preg_match_all($pattern01,$xml,$matches01); $xml_code=($matches01[1][0]); if($xml_code==-1){ return "验证超时"; }else if($xml_code==0){ return "".$xml_name."对不起,已注册
"; }else if($xml_code==1){ // 可根据session确定用户是否登录 return "".$xml_name."恭喜,可注册立即注册
"; } } for($i=0;$i //保护隐私 略作修改 灵感来自:http://www.5idev.com/p-php_domain_ajax.shtml
12-17
12-17