// bi bolo monggole huen !
//
// v2.0.5
//
http://www.gaodaima.com/47356.html是一个设计将linuxFreak.org新闻标题放_php
// include("linuxfreak.php3");
// ?>
// dreamphp boy = sunboy
$link_prefix = " o ";
$link_postfix = "
n";
$cache_file = "/tmp/linuxfreak2.cache";
$cache_time = 1200;
$max_items = 8;
$target = "_top";
// End of customizations
$backend = "http://www.linuxfreak.org/backend/linuxfreak.rdf";
$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))) ) {
$fpread = fopen($backend, 'r');
if(!$fpread) {
} else {
$fpwrite = fopen($cache_file, 'w');
if(!$fpwrite) {
} else {
while(! feof($fpread) ) {
$buffer = ltrim(Chop(fgets($fpread, 256)));
if (($buffer == "") && ($items < $max_items)) {
$title = ltrim(Chop(fgets($fpread, 256)));
$link = ltrim(Chop(fgets($fpread, 256)));
$title = ereg_replace( "
", "", $title );$title = ereg_replace( "
", "", $title );$link = ereg_replace( "", "", $link );
$link = ereg_replace( "", "", $link );
fputs($fpwrite, "$link_prefix$title$link_postfix");
$items++;
}
}
}
fclose($fpread);
}
fclose($fpwrite);
}
if (file_exists($cache_file)) {
include($cache_file);
}
?>
欢迎大家阅读《是一个设计将LinuxFreak.org新闻标题放_php》,跪求各位点评,若觉得好的话请收藏本文,by 搞代码

微信 赏一包辣条吧~

支付宝 赏一听可乐吧~
这段代码展示了如何利用PHP从LinuxFreak.org获取新闻标题,并存储到本地缓存文件中,以减少对源站的频繁请求。通过检查缓存文件是否存在、更新时间以及大小,实现了一种简单的缓存机制。最后,从缓存文件中读取并显示新闻标题。

被折叠的 条评论
为什么被折叠?



