当前位置: 首页 > 图文教程 > 网络编程 > PHP > 是一个设计将LinuxFreak.org新闻标题放置到你的网站的PHP脚本程序。

PHP
php4的彩蛋
正则表达式例子:获得某个网页上的所有超裢接
正则表达式例子:在一个字符串中查找另一个字符串
正则表达式例子:将MM/DD/YYYY格式的日期转换为YYYY-MM-DD格式
Pattern Modifiers - 规则表达式的修饰符
PHP4实际应用经验篇(1)
PHP4实际应用经验篇(2)
PHP4实际应用经验篇(3)
PHP4实际应用经验篇(4)
PHP4实际应用经验篇(5)
PHP4实际应用经验篇(6)
PHP中的DOM XML函数
使用php动态生成gif时遇到的问题和解决办法
用PHP连mysql和oracle数据库性能比较
浅谈Windows下 PHP4.0与oracle 8的连接设置
用PHP调用数据库的存贮过程
用php与mysql的电子贺卡程序
挑战最棒的留言本的源码(一)
挑战最棒的留言本的源码(二)
如何实现日期比较,暨实现显示5天内,显示10天内的记录

是一个设计将LinuxFreak.org新闻标题放置到你的网站的PHP脚本程序。


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 57 ::
收藏到网摘: n/a

  <?php

//  bi bolo monggole huen !
//  
// v2.0.5
// <?
// include("linuxfreak.php3");
// ?>
//    dreamphp boy = sunboy

$link_prefix    =    "&nbsp;&nbsp;o ";
$link_postfix    =    "<BR>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 == "<item>") && ($items < $max_items)) {
                    $title = ltrim(Chop(fgets($fpread, 256)));
                    $link = ltrim(Chop(fgets($fpread, 256)));

                    $title = ereg_replace( "<title>", "", $title );
                    $title = ereg_replace( "</title>", "", $title );
                    $link = ereg_replace( "<link>", "", $link );
                    $link = ereg_replace( "</link>", "", $link );

                    fputs($fpwrite, "$link_prefix<A HREF="$link" TARGET="$target">$title</A>$link_postfix");

                    $items++;
                }
            }
        }
        fclose($fpread);
    }