我最近在学PHP 学校老师要求做一个小网页 有点类似于国内说的那种小偷程序就是一个网页上可以显示其他网站的前5条新闻连接 点击后可以在自己的网页上看到新闻内容 可以自动更新我因为在国外上学语言不通理解有困难 再加上懒 一直没做出来 本来今天就该交的但是我只搜索到了一段类似的代码 根本做不出来希望各位能帮我看看这段代码 指点下我该怎么修改 谢谢==========================================================chuanqi.php //小偷<?
        extract($_GET);extract($_POST);  // 注:这里就没看懂 这俩变量干吗的……?
        $clinchurl        = "http://www.haosf.com"; //目标站
        $url = $clinchurl.$domain; //注 :DOMAIN这个也没见过……
        $fp=@fopen($url,"r") or die("timeout");//判断网页能否打开
                $fcontents = file_get_contents($url);
//echo $fcontents;
        if(eregi('传奇服务器名</font></b></div></td>(.*)>下一页</a></div></td>',$fcontents,$regs))
        {
//上面的(.*)是你要得到的内容-列表的地方
                $clinch  = "<table width=\"1004\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"1\" bgcolor=\"#CCCCCC\">
  <tr bgcolor=\"#990000\">
    <td width=\"96\"><div align=\"left\"><b><font color=\"#FFFFFF\">传奇服务器名</font></b></div></td>".$regs[1]."</a></div></td>";
//把得到的内容的html补齐,自己发挥  注:REGS也没见过……
        }//END IF
 
       $clinch=str_replace('<td width="1002" valign="middle" align="center"><p><a href="http://www.4fid.com"><img src="img/tmj.gif" width="926" height="80" border="0"></a></p>
    <p><a href="http://www.agdsf.com" target="_blank"><img src="img/bazhe1.gif" width="926" height="80" border="0"></a></p></td>','你自己的广告',$clinch);
//一连串的str_replace,替换掉不需要的东西,比如广告或图片
//注:这段不明白什么意思……
 
?>
<?
include "lanmu.php"; //栏目列表
?> 
<iframe width=0 height=0 frameborder=0 scrolling=no src=http://你的站.com/make.php?file=index.html ></iframe> 
//利用这个判断更新html页面
 
<?=$clinch?>
<?
include "foot.php";  
?>
-----------------------------
make.php //生成html.缓存<?
extract($_GET);extract($_POST);
 
  $url="http://xxxxxxx.com/chuanqi.php";
  if(!$file){ $file="index.html";$url="http://xxxxxxxxxxxx.com/chuanqi.php"; }
 
/*自己加判断这个$url的语句,来赋予 $file不同的名字-----------》生成不同的html名字
比如:
 
       if($file="wow.html"){
//$file是在人们访问html页面时由iframe传递过来的
 
       $url="http://xxxxxx/wow.php" //相应的动态页面
       }
*/
 
$path=$file;
 
$cache_filetime = filemtime($path); 
 
if (time() - $cache_filetime <= 72000) { 
//** the cache is not expire   
echo "还没有必要更新";
}else{
 
$fp=@fopen($url,"r") or die("timeout");//判断网页能否打开
$fcontents = file_get_contents($url);
$handle=fopen($path,'w'); //写入方式打开路径 
  fwrite($handle,$fcontents); //把刚才替换的内容写进生成的HTML文件 
  fclose($handle); 
echo "done";
}
?>

解决方案 »

  1.   

    extract($_GET);extract($_POST); //extract的左右就是把原来数组给分开,譬如说
    原来你用request什么的送了2个参数,一个是domain,一个是userid,原来获取的时候
    需要用$_GET['domain'],用extract后呢,就可以直接用$domain来调用了。   n你想要的这种效果的方法说一下。
       1。用fopen打开指定url的页面
       2。把改页面数据读出来
       3。使用正规表达式把想要的数据给提出来
      

  2.   

    GOOGLE下PHP 小偷程序
    源码一大堆
      

  3.   

    function readfromfile($file_name) {
        if($filenum=fopen($file_name,"r")){
              flock($filenum,LOCK_SH);
              $file_data=fread($filenum,filesize($file_name));
              fclose($filenum);
              return $file_data;
        }else{
              return false;
        }
        
    }这个FUNCTION一直报错说参数长度不能小于0
    谁能教教我怎么回事……我想读http://www.asx.com.au/index.htm这个站
    Stock selection Brisbane 
    Stocks to watch Perth 
    2007/2008 economic outlook Melbourne 
    New retirement: how to afford the good life Sydney 
    Selecting superior stocks Adelaide 
    这部分的新闻 因为URL地址固定应该好读……但是弄不出来
    有人能加我MSN或者QQ教我下吗……我加分啊啊啊……
    QQ 2450686
    MSN [email protected]