[转帖]应众多朋友要求,现放出手机归属地查询方法
申明:本程序来源于网络..简单易懂.解释权归原作者所有....................... //---------------------------用户自定义标签文件 /e/class/userfun.php
//手机归属地查询 function user_belonging($id) { global $empire,$dbtbpre,$navinfor; $id=$navinfor['id']; $r=$empire->fetch1("select phone from {$dbtbpre}ecms_info where id=$id"); $number=trim($r['phone']); if ($number) { $expr="^1[35][0-9]{9}$"; $Results=ereg($expr,$number); //验证号码是否正确 if ($Results==1) { $lent = sub ($number, 0, 7, false); $return=' <img src="/images/mobile.gif" alt="手机归属地查询" width="15" height="16" /><a href="#mobi" onclick="MyOnchange(\'/e/key/mobile_search.php?id='.$lent.'\',document.getElementById(\'ShowTel\'));"><span class="px10">手机归属地查询</span></a>'; } else { $return=''; } } else { $return=''; } echo $return; }
//---------------------------------------------------------------------------------------------------------------- 新建标签 标签名:显示手机归属地查询(随便你写什么) 标签符号:belonging 函数名:user_belonging] 标签格式:[belonging]归属地[/belonging] 标签说明:[belonging]phone[/belonging] //------------------------------------------------------------------------------------------------------------------ 内容页中放上[belonging]phone[/belonging] //------------------------------------------------------------------------------------------------------------------ mobile_search.php <?php header("Content-type: text/html;charset=gbk"); /* 构建函数 */ //读取电话号码文件 function readfiletext ($file, $id) { $myaddress=''; $fp = @file("$file"); //循环比对 for ($i=0; $i<count($fp); $i++) { $readfile=explode('||',$fp[$i]); $file1=$readfile['0']; $file2=$readfile['1']; $id==$file1?$myaddress=$file2:''; } return $myaddress; } //写文件 function writefiletext ($file, $string) { $string = stripslashes ($string); $fp = @fopen ($file, 'a+'); @fwrite ($fp, $string); @fclose ($fp); } //匹配函数 function Cut($FileStr,$StartStr,$EndStr,$Type) { if(ereg($StartStr,$FileStr)&&ereg($EndStr,$FileStr)) { if($Type==0){ $GetContent = substr($FileStr,0-(strlen($FileStr)-(strpos($FileStr,$StartStr)+strlen($StartStr)))); $GetContent = substr($GetContent,0,strpos($GetContent,$EndStr)); return $GetContent; }else{ $GetContent = substr($FileStr,0-(strlen($FileStr)-(strpos($FileStr,$StartStr)))); $GetContent = substr($GetContent,0,strpos($GetContent,$EndStr)+strlen($EndStr)); return $GetContent; } }else{ return ""; } } /* 函数构建结束 */ $id=$_GET['id']; //ID $file = 'phone.txt'; //设定电话文件地址 //如果ID为空退出 if(empty($id)) { exit(); } else { //查询文件内是否有地址 $myaddress=readfiletext($file,$id);
if ($myaddress) { $showadd=$myaddress; } else { //获得号码地址页面 $show=file_get_contents("http://www.123cha.com/ip/?q=$id"); //手机号码段 //写入文件 @$phone=Cut($show,'您的查询: ',"\n</li><li>",0); if(!$phone) { @$phone=Cut($show,'您的查询: ',' </li><li>',0); } $phone = trim(ereg_replace("\r\n","",$phone)); $phone =nl2br(preg_replace('/[ ]+/',' ',$phone)); $showadd=$phone; $phone=$id.'||'.$phone.'||'."\r\n"; writefiletext ($file,$phone); } }
?> <span><a href="#clos" onclick="ShowTel();" />X关闭</a></span> <font color=red>查询结果</font> <div id=cresult> <ul> <?php if ($showadd) { print_r(str_replace("查询太频繁,暂时禁用", "无", "$showadd")); //$showadd); } else { echo "<li>服务器忙,请稍后再试……"; } ?> </li> </ul> </div> //---------------------------------------------------------------------------------------------------------------------------------------------------------- mobile.gif
上传以下图片:
|
[该贴被修改 1 次,最后修改时间 2008-12-22 13:04:56 ]
|