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

PHP
网站开发者参考:开源PHP网站源码
PHP教程:PHP开发网站代码编写规范
PHP教程:WebService最常用的两种方法
PHP通过SQL语句将数据写入MySQL数据库指定的表
PHP教程:修改discuz兼容自己开发的通行证
PHP教程:strlen与mb_strlen字符串长度函数
Apache的mod_rewrite模块拒绝盗链
windows 2003虚拟主机用httpd.ini控制盗链
PHP6的核心是对Unicode的内置支持
提高系统性能用eAccelerator优化PHP
10个开源的PHP网站内容管理系统
php中3des加密(完全与.net中的兼容)
PHP教程:时间函数
PHP教程:UCenter的MVC架构
PHP教程:PHP解析HTML字符串的问题
PHP教程:PHP截取HTML代码串问题
PhpSecInfo列出PHP环境设定中存在的安全问题
PHP教程:preg_replace_callback()函数
Google网站管理员工具的验证问题
解决PHP相对目录问题最有效的办法

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 110 ::
收藏到网摘: 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);
    }