|
楼主 |
发表于 2014-3-18 20:16:48
|
显示全部楼层
来自 中国江西南昌
服务器之家 发表于 2014-3-18 20:14
你发的代码里没有 - <?php
- set_time_limit(0);
- $q = trim($_GET['q']); //关键词
- $page = intval($_GET['p']); //页数
- if($page==0) $page=1;
- $r_num = 0; //结果个数
- $p_num = 40; //每页结果的数据条数
- $result = "";
- $shengpy = array('B','T','H','S','N','L','J','H','S','J','Z','A','F','J','S','H','H','H','G','G','H','C','S','G','Y','X','S','G','Q','N','X','X','A','T');
- $sheng = array('北京','天津','河北','山西','内蒙古','辽宁','吉林','黑龙江','上海','江苏','浙江','安徽','福建','江西','山东','湖南','湖北','河南','广东','广西','海南','重庆','四川','贵州','云南','西藏','陕西','甘肃','青海','宁夏','新疆','香港','澳门','台湾');
- if($q){
- switch ($_GET['w']){
- case "sheng":
- case "diqu":
- case "shi":
- case "cun":
- case "youbian":
- case "quhao":
- $keydb = "cache/".$_GET['w']."/".urlencode($q).".htm";
- break;
- default:
- $keydb = "cache/all/".urlencode($q).".htm";
- break;
- }
- if (!@file_exists($keydb)){
- $dreamdb=file("y/p.dat");//读取区号文件
- $count=count($dreamdb);//计算行数
- for($i=0; $i<$count; $i++) {
- $keyword=explode(" ",$q);//拆分关键字
- $dreamcount=count($keyword);//关键字个数
- $detail=explode("\t",$dreamdb[$i]);
- for ($ai=0; $ai<$dreamcount; $ai++){
- switch ($_GET['w']){
- case "sheng":
- @e val("\$found = eregi("$keyword[$ai]","$detail[0]");");
- break;
- case "diqu":
- @e val("\$found = eregi("$keyword[$ai]","$detail[1]");");
- break;
- case "shi":
- @e val("\$found = eregi("$keyword[$ai]","$detail[2]");");
- break;
- case "cun":
- @e val("\$found = eregi("$keyword[$ai]","$detail[3]");");
- break;
- case "youbian":
- @e val("\$found = eregi("$keyword[$ai]","$detail[4]");");
- break;
- case "quhao":
- @e val("\$found = eregi("$keyword[$ai]","$detail[5]");");
- break;
- default:
- @e val("\$found = eregi("$keyword[$ai]","$dreamdb[$i]");");
- break;
- }
- if(($found)){
- $r_num++;
- if(fmod($r_num, $p_num)==0) $r .= "\n";
- $r .= '<tr height="24"><td><a href="?q='.urlencode($detail[0]).'&w=sheng">'.$detail[0].'</a></td><td><a href="?q='.urlencode($detail[1]).'&w=diqu">'.$detail[1].'</a></td><td><a href="?q='.urlencode($detail[2]).'&w=shi">'.$detail[2].'</a></td><td><a href="?q='.urlencode($detail[3]).'&w=cun">'.$detail[3].'</a></td><td><a href="?q='.$detail[4].'&w=youbian">'.$detail[4].'</a></td><td><a href="?q='.trim($detail[5],"\n\r").'&w=quhao">'.trim($detail[5],"\n\r").'</a></td></tr>';
- if($r_num>=$p_num*($page-1)+1 && $r_num<=$p_num*$page){
- $result .= '<tr height="24"><td><a href="?q='.urlencode($detail[0]).'&w=sheng">'.$detail[0].'</a></td><td><a href="?q='.urlencode($detail[1]).'&w=diqu">'.$detail[1].'</a></td><td><a href="?q='.urlencode($detail[2]).'&w=shi">'.$detail[2].'</a></td><td><a href="?q='.urlencode($detail[3]).'&w=cun">'.$detail[3].'</a></td><td><a href="?q='.$detail[4].'&w=youbian">'.$detail[4].'</a></td><td><a href="?q='.trim($detail[5],"\n\r").'&w=quhao">'.trim($detail[5],"\n\r").'</a></td></tr>';
- }
- break;
- }
- }
- $p = ceil($r_num/$p_num); //结果实际页数
- }
- //将数据缓存下来
- $fp = @fopen($keydb,"a");
- @fwrite($fp,$r_num."\n".$r);
- @fclose($fp);
- }else{
- $dreamdb=file($keydb);
- $r_num = trim($dreamdb[0],"\n\r");
- $p = ceil($r_num/$p_num); //结果实际页数
- if($page>$p) $page=$p;
- $result = $dreamdb[$page];
- }
- for($i=1; $i<=$p; $i++){
- $post_l .= '<a href="?q='.urlencode($q).'&p='.$i;
- if($_GET['w']) $post_l .= '&act='.$_GET['w'];
- if($i==$page){
- $post_l .= '"><font color="red">['.$i.']</font></a> ';
- }else{
- $post_l .= '">['.$i.']</a> ';
- }
- }
- $post_l = '<tr><td align="center" style="font-size:14px;padding:10px;" bgcolor="#EDF7FF">分页:'.$post_l.' (共计'.$r_num.'个,每页'.$p_num.'个)</td></tr>';
- $result = '<table width="730" cellpadding="2" cellspacing="0" style="border:1px solid #B2D0EA;"><tr><td style="background:#EDF7FF;padding:0 5px;color:#014198;" height="26" valign="middle"><strong>找到'.$r_num.'个与 <a href="./?q='.urlencode($q).'"><font color="#c60a00">'.$q.'</font></a> 相关的邮编区号</strong></td></tr><tr><td><table cellpadding="4" cellspacing="4" width="100%" style="text-align:center"><tr style="text-align:center;font-weight:bold;" height="26" bgcolor="#efefef"><td width="80">省</td><td>地区</td><td>市县</td><td>乡镇村</td><td width="80">邮政编码</td><td width="60">电话区号</td></tr>'.$result.'</table></td></tr>'.$post_l.'</table>';
- }
- ?>
复制代码 这里呢? |
|