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>
  • 相关阅读:
    hdu 2019 数列有序!
    hdu 2023 求平均成绩
    HDU 5805 NanoApe Loves Sequence (思维题) BestCoder Round #86 1002
    51nod 1264 线段相交
    Gym 100801A Alex Origami Squares (求正方形边长)
    HDU 5512 Pagodas (gcd)
    HDU 5510 Bazinga (字符串匹配)
    UVALive 7269 Snake Carpet (构造)
    UVALive 7270 Osu! Master (阅读理解题)
    UVALive 7267 Mysterious Antiques in Sackler Museum (判断长方形)
  • 原文地址:https://www.cnblogs.com/kaiye/p/3039038.html
Copyright © 2011-2022 走看看