仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1123|回复: 19
打印 上一主题 下一主题

[学习教程] PHP编程:是一个设计将LinuxFreak.org旧事题目放...

[复制链接]
小女巫 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-2-4 00:04:38 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
聪明的你,显然已经逐渐的开悟了,慢慢的理解了编程的概念,那么祝贺你,你已经迈出了成功的第一步。   <?php

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

$link_prefix    =    "  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);
    }
    fclose($fpwrite);
}
if (file_exists($cache_file)) {
    include($cache_file);
}
?>  
你的留言本应该加入注册以及分页功能了,而如果你更强的话,UI(用户界面)也可以加强,完成之后,感觉是不是特有成就感?不管怎么样,咱好歹是写了一个动态网站程序了,放在自己的网站上耍耍吧。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-15 11:31

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表