叶落花开博客DEMO页列表整理

kamal的建议下,整理了博客中用到的一些DEMO页:

工具类:

http://yekai.net/demo/?q=tool

游戏类:

http://yekai.net/demo/?q=game

将以下PHP代码,丢入DEMO根目录即可自动生成列表:

复制代码
<!doctype html>
<title>叶落花开:DEMO列表</title>
<style>
body{line-height:1.8;font-size:14px;}
.xxxxx{color:#666;font-size:12px;}
</style>
<h1>叶落花开:DEMO列表</h1>
<ul>
<?php

//是否为UTF8编码
function is_utf8 ( $string ) {
     // From http://w3.org/International/questions/qa-forms-utf-8.html
     return preg_match ( '%^(?:
          [\x09\x0A\x0D\x20-\x7E]             # ASCII
        | [\xC2-\xDF][\x80-\xBF]              # non-overlong 2-byte
        |   \xE0[\xA0-\xBF][\x80-\xBF]         # excluding overlongs
        | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}   # straight 3-byte
        |   \xED[\x80-\x9F][\x80-\xBF]         # excluding surrogates
        |   \xF0[\x90-\xBF][\x80-\xBF]{2}      # planes 1-3
        | [\xF1-\xF3][\x80-\xBF]{3}           # planes 4-15
        |   \xF4[\x80-\x8F][\x80-\xBF]{2}      # plane 16
    )*$%xs' , $string );
}

function showDemo( $filedir ) {
    //打开目录
    $dir = dir($filedir);
    //列出目录中的文件
    while (($file = $dir->read())!==false){
        //列出除首页以外的其他文件
        if(is_file($file) && $file !== 'index.php'){
            //只列html和php后缀的
            if(pathinfo($file, PATHINFO_EXTENSION) == 'php' || pathinfo($file, PATHINFO_EXTENSION) == 'html'){
                preg_match("/<title>(.+)<\/title>/i", file_get_descriptions($file), $matches);
                
                $metaTags = get_meta_tags($file);
                $xxxxx = array_key_exists('xxxxx',$metaTags) ? (is_utf8($metaTags['xxxxx']) ? $metaTags['xxxxx'] : iconv("GBK", "UTF-8", $metaTags['xxxxx']) ) : $file ;
                //只列包含有title的DEMO
                if(count($matches)){
                    //有些DEMO是GBK的,转码一下
                    $title = (is_utf8($matches[1]) ? $matches[1] : iconv("GBK", "UTF-8", $matches[1]));
                    //查询关键词
                    if(!empty($_GET["q"]) && (stripos($title, $_GET["q"]) === FALSE)){
                        continue;
                    }
                    echo "<li><a href=". $file .">". $title ."</a> | <span class='xxxxx'>". $xxxxx ."</span></li>";
                }
            }
        }
    }
    $dir->close();
}

showDemo(".");

?>
</ul>
复制代码

 

posted @   猫哥_kaiye  阅读(295)  评论(0编辑  收藏  举报
编辑推荐:
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
点击右上角即可分享
微信分享提示