[fwxx]歸屬地[/fwxx]
fwxx段名
<?php
/**
sooden
2007-10-2
**/
header("Content-type: text/html;charset=gbk");
/*
構(gòu)建函數(shù)
*/
//讀取電話號碼文件
function readfiletext ($file, $id)
{
$myaddress='';
$fp = @file("$file");
//循環(huán)比對
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);
}
//匹配函數(shù)
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 "";
}
}
/*
函數(shù)構(gòu)建結(jié)束
*/
$id=$_GET['id']; //ID
$file = 'phone.txt'; //設(shè)定電話文件地址
//如果ID為空退出
if(empty($id))
{
exit();
}
else
{
//查詢文件內(nèi)是否有地址
$myaddress=readfiletext($file,$id);
if ($myaddress) { $showadd=$myaddress; }
else {
//獲得號碼地址頁面
$show=file_get_contents("http://www.123cha.com/ip/?q=$id"); //手機號碼段
//寫入文件
@$dh=Cut($show,'您的查詢: ',"n</li><li>",0);
if(!$dh) {
@$dh=Cut($show,'您的查詢: ',' </li><li>',0); }
$dh = trim(ereg_replace("rn","",$dh));
$dh =nl2br(preg_replace('/[ ]+/',' ',$dh));
$showadd=$dh;
$dh=$id.'||'.$dh.'||'."rn";
writefiletext ($file,$dh); }
}
?>
<span><a href="#clos" onclick="ShowTel();" />X關(guān)閉</a></span> <font color=red>查詢結(jié)果</font>
<div id=cresult>
<ul>
<?php
if ($showadd) {
print_r(str_replace("查詢太頻繁,暫時禁用", "無", "$showadd")); //$showadd);
}
else {
echo "<li>服務(wù)器忙,請稍后再試……"; }
?>
</li>
</ul>
</div>
版權(quán)聲明: 本站資源均來自互聯(lián)網(wǎng)或會員發(fā)布,如果侵犯了您的權(quán)益請與我們聯(lián)系,我們將在24小時內(nèi)刪除!謝謝!
轉(zhuǎn)載請注明: 帝國cms分類信息電話號碼查詢