zoukankan      html  css  js  c++  java
  • 叶落花开博客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>
  • 相关阅读:
    [Objective-C语言教程]决策结构(10)
    [Objective-C语言教程]循环语句(9)
    [Objective-C语言教程]关系运算符(8)
    [Objective-C语言教程]常量(7)
    [Objective-C语言教程]变量(6)
    [Objective-C语言教程]数据类型(5)
    转 Apache Ant 实现自动化部署
    转 智能化运维最佳实践-自动化
    ANT 操控 ORACLE数据库实践
    转: Ant 脚本的结构化设计
  • 原文地址:https://www.cnblogs.com/kaiye/p/3039038.html
Copyright © 2011-2022 走看看