php 遍历目录以及子目录

源码如下:
<?php 
$dir = "c:/wamp/www/test/";  //目录名称必须是这种格式
$space="";
function fun1($dir,$space="") {
    if(is_dir($dir) && $handle = opendir($dir)){
        $space .= "&nbsp;&nbsp;&nbsp;&nbsp;";
        while(false!== ($file = readdir($handle))){
            if($file=="." || $file=="..") continue;
            if(is_dir($dir.$file.'/')){
                echo "$space|-$file<br>";
                fun1($dir.$file.'/',$space);
            }else
            echo "$space|-$file<br>";
        }
        closedir($handle);
    }else{
        echo "This have a error!";
    }
}
fun1($dir);
?>
遍历效果如下:
 |-1.php
    |-2.php
    |-2010-05-22_101859.jpg
    |-321.html
    |-ci
        |-.htaccess
        |-index.php
        |-system
27
Feb 2008
AUTHOR WiFeng
CATEGORY Web
COMMENTS No Comments

本地apache虚拟主机的配置

第一步:在 C:\WINDOWS\system32\drivers\etc 下找到 hosts  文件 ,打开并且在最后加上
127.0.0.1          localhost
127.0.0.1          uc.521-wf.com
127.0.0.1          uch.521-wf.com
第二步:在apache 的配置文件 httpd.conf 的最后加上如下的代码:
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1:80>
    ServerAdmin admin@521-wf.com
    DocumentRoot c:/wamp/www/
    ServerName localhost
</VirtualHost>

<VirtualHost 127.0.0.1:80>
    ServerAdmin admin@521-wf.com
    DocumentRoot c:/wamp/www/uc/
    ServerName uc.521-wf.com
</VirtualHost>

<VirtualHost 127.0.0.1:80>
    ServerAdmin admin@521-wf.com
    DocumentRoot c:/wamp/www/uch/
    ServerName uch.521-wf.com
</VirtualHost>
但是这是核心的代码,不是固定的写法:
     ServerAdmin   你的邮件地址(不过可以随便写,这也只不过是虚拟环境而已)
      DocumentRoot  这是你项目的路径
      ServerName    这是你的虚拟域名
有时候你把上面的127.0.0.1 换为 * 也可以。但是有时候不行。我建议还是加上。
我习惯于使用 wamp  所以我并没有加在配置文件的最后面,而是加在了以下两行代码之前:
Include "c:/wamp/apache2/conf/alias/phpmyadmin.conf"
Include "c:/wamp/apache2/conf/alias/sqlitemanager.conf"
当然如果你的操作系统装在了d盘,或者是其他盘,那就看着办吧! 这个配置我在学校里面配置我好多次,不能说倒背如流,但是可以说是滚光烂熟了吧。但是到了公司,两个多月不用了,突然想装一下uchome ,配置了半天,老是出错 。所以 还是写在这儿,以防以后再忘了。  <<<<<<<<<<<<<<<<<<<<<<<<<<补充,还可以使用以下这种方式,更安全
<VirtualHost *:80>
    DocumentRoot "D:/wamp/www/framework/webroot"
    ServerName star
    #ServerAlias *.shop.com.cn
    ErrorLog "logs/starland.ifensi-error.log"
    CustomLog "logs/make.openqee.com.cn.log" common  
    <Directory "D:/wamp/www/framework">
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    allow from all
    DirectoryIndex index.html index.php
    </Directory>
</VirtualHost>
24
Feb 2008
AUTHOR WiFeng
CATEGORY Web
COMMENTS 2 Comments

PHP Content-type 的说明

<?php
$mimetypes = array(
'ez' => 'application/andrew-inset',
'hqx' => 'application/mac-binhex40',
'cpt' => 'application/mac-compactpro',
'doc' => 'application/msword',
'bin' => 'application/octet-stream',
'dms' => 'application/octet-stream',
'lha' => 'application/octet-stream',
'lzh' => 'application/octet-stream',
'exe' => 'application/octet-stream',
'class' => 'application/octet-stream',
'so' => 'application/octet-stream',
'dll' => 'application/octet-stream',
'oda' => 'application/oda',
'pdf' => 'application/pdf',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
'smi' => 'application/smil',
'smil' => 'application/smil',
'mif' => 'application/vnd.mif',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
'wbxml' => 'application/vnd.wap.wbxml',
'wmlc' => 'application/vnd.wap.wmlc',
'wmlsc' => 'application/vnd.wap.wmlscriptc',
'bcpio' => 'application/x-bcpio',
'vcd' => 'application/x-cdlink',
'pgn' => 'application/x-chess-pgn',
'cpio' => 'application/x-cpio',
'csh' => 'application/x-csh',
'dcr' => 'application/x-director',
'dir' => 'application/x-director',
'dxr' => 'application/x-director',
'dvi' => 'application/x-dvi',
'spl' => 'application/x-futuresplash',
'gtar' => 'application/x-gtar',
'hdf' => 'application/x-hdf',
'js' => 'application/x-javascript',
'skp' => 'application/x-koan',
'skd' => 'application/x-koan',
'skt' => 'application/x-koan',
'skm' => 'application/x-koan',
'latex' => 'application/x-latex',
'nc' => 'application/x-netcdf',
'cdf' => 'application/x-netcdf',
'sh' => 'application/x-sh',
'shar' => 'application/x-shar',
'swf' => 'application/x-shockwave-flash',
'sit' => 'application/x-stuffit',
'sv4cpio' => 'application/x-sv4cpio',
'sv4crc' => 'application/x-sv4crc',
'tar' => 'application/x-tar',
'tcl' => 'application/x-tcl',
'tex' => 'application/x-tex',
'texinfo' => 'application/x-texinfo',
'texi' => 'application/x-texinfo',
't' => 'application/x-troff',
'tr' => 'application/x-troff',
'roff' => 'application/x-troff',
'man' => 'application/x-troff-man',
'me' => 'application/x-troff-me',
'ms' => 'application/x-troff-ms',
'ustar' => 'application/x-ustar',
'src' => 'application/x-wais-source',
'xhtml' => 'application/xhtml+xml',
'xht' => 'application/xhtml+xml',
'zip' => 'application/zip',
'au' => 'audio/basic',
'snd' => 'audio/basic',
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'kar' => 'audio/midi',
'mpga' => 'audio/mpeg',
'mp2' => 'audio/mpeg',
'mp3' => 'audio/mpeg',
'aif' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'aifc' => 'audio/x-aiff',
'm3u' => 'audio/x-mpegurl',
'ram' => 'audio/x-pn-realaudio',
'rm' => 'audio/x-pn-realaudio',
'rpm' => 'audio/x-pn-realaudio-plugin',
'ra' => 'audio/x-realaudio',
'wav' => 'audio/x-wav',
'pdb' => 'chemical/x-pdb',
'xyz' => 'chemical/x-xyz',
'bmp' => 'image/bmp',
'gif' => 'image/gif',
'ief' => 'image/ief',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'jpe' => 'image/jpeg',
'png' => 'image/png',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'djvu' => 'image/vnd.djvu',
'djv' => 'image/vnd.djvu',
'wbmp' => 'image/vnd.wap.wbmp',
'ras' => 'image/x-cmu-raster',
'pnm' => 'image/x-portable-anymap',
'pbm' => 'image/x-portable-bitmap',
'pgm' => 'image/x-portable-graymap',
'ppm' => 'image/x-portable-pixmap',
'rgb' => 'image/x-rgb',
'xbm' => 'image/x-xbitmap',
'xpm' => 'image/x-xpixmap',
'xwd' => 'image/x-xwindowdump',
'igs' => 'model/iges',
'iges' => 'model/iges',
'msh' => 'model/mesh',
'mesh' => 'model/mesh',
'silo' => 'model/mesh',
'wrl' => 'model/vrml',
'vrml' => 'model/vrml',
'css' => 'text/css',
'html' => 'text/html',
'htm' => 'text/html',
'asc' => 'text/plain',
'txt' => 'text/plain',
'rtx' => 'text/richtext',
'rtf' => 'text/rtf',
'sgml' => 'text/sgml',
'sgm' => 'text/sgml',
'tsv' => 'text/tab-separated-values',
'wml' => 'text/vnd.wap.wml',
'wmls' => 'text/vnd.wap.wmlscript',
'etx' => 'text/x-setext',
'xsl' => 'text/xml',
'xml' => 'text/xml',
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mpe' => 'video/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
'mxu' => 'video/vnd.mpegurl',
'avi' => 'video/x-msvideo',
'movie' => 'video/x-sgi-movie',
'ice' => 'x-conference/x-cooltalk',
);

?> 

24
Feb 2008
AUTHOR WiFeng
CATEGORY Web
COMMENTS No Comments

Linux whois命令寻找未注册域名

域名一直在被注册,好域名已经很少了,几乎没有了,只能高价购买了。一个程序帮助快速批量检测域名注册情况还是有必要的。

#!/bin/sh

NO_DOMAIN_MATCH="No match for domain"
TMP_FILE="domain_tmp"

#declare -i argsnums
#argsnums= $#

if [ $# -gt 0 ]
then
        whois $1 > $TMP_FILE
        echo -e "$1 \c"
        grep -q "$NO_DOMAIN_MATCH"  $TMP_FILE && echo "is not registered!!!" || echo "is registered........"
else
        declare -a abc=(a b c d e f g h i j k l m n o p q r s t u v w x y z)
        i=1000
        j=1005

        while [ $i -lt $j ]
        do
                domain="$i.com"
                whois $domain > $TMP_FILE
                echo -e "$domain \c"
                grep -q "$NO_DOMAIN_MATCH"  $TMP_FILE && echo "is not registered!!!" || echo "is registered."
                let "i=$i+1"
        done
fi

保存以上文件为 whois.sh 然后执行

[root@localhost ~]# sh whois.sh 521-wf.com

运行结果很友好,更加强大的功能正在加工中..........

14
Jul 2007
AUTHOR WiFeng
CATEGORY Web,Asset
COMMENTS No Comments