频道栏目
首页 > 资讯 > php > 正文

一个很简单的PHP的后端脚本,能够从(某个网中)得到最新新闻。

08-04-21        来源:[db:作者]  
收藏   我要投稿
<?
// sunboys data
// bi balo aruhan domdadu o los in wuber mongglo in huen egun i wuzhe  
// zhu tuhe re hu humen tai ban nai zha bolu ya !

$link_prefix    =     "&nbsp;&nbsp;o";
$link_postfix    =     "<BR>n";
$cache_file    =     "tmp/heise.cache";
$cache_time    =    3600;


$items        =    0;
$time        =    split( " ", microtime());

srand((double)microtime()*1000000);
$cache_time_rnd    =    300 - rand(0, 600);

if ((!(file_exists($cache_file))) || ((filectime($cache_file) + $cache_time - $time[1]) + $cache_time_rnd < 0) || (!(filesize($cache_file))) ) {
$fp1=fopen("http://www.ourjia.net/index.shtml", "r");
$string=fread($fp1,20000);

ereg("<!-- MITTE (NEWS) -->(.*)<!-- MITTE (NEWS-UEBERBLICK) -->",
$string, $matches);
$match=str_replace("HREF="/newsticker/","href="http://www.ourjia.net/",$matches[1]);

$exp="#newsticker/data/(.*)/">(.*</FONT></B>)#i";
preg_match_all($exp, $matches[1], $matchin);

for($i=0;$i<count($matchin[1]);$i++)
   {
$body.= "$link_prefix <a href="http://www.ourjia.net/data/".$matchin[1][$i]."/">" . $matchin[2][$i]. "</a><br>n";
   }
$body = eregi_replace( "</A></FONT></B>", "", $body);
fclose($fp1);

$fpwrite = fopen($cache_file,w);
fputs($fpwrite,  "$body");
fclose($fpwrite);
}
include($cache_file);
?>

注意:1:这里的www.ourjia.net该为为有新闻更新系统的网站列如:
        http://www.heise.de/newsticker。  

【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】    
相关TAG标签
上一篇:PHP用户认证及管理完全源码
下一篇:如何用php作线形图的函数
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站