Linux 常用小命令

1. find(在指定目录下搜索指定文件名的文件)

##在bin目录下查找名为insmanyou的文件##
[liuweifeng@mydev ~]$ find ./bin/  -name insmanyou 

2. groups (查看当前用户的用户组)

[liuweifeng@mydev ~]$ groups

3. su (切换当前登录用户)

[liuweifeng@mydev ~]$ su root

4. sudo(执行root有权限执行的命令)

[liuweifeng@mydev ~]$ sudo svn info

阅读剩余部分...

18
Feb 2010
AUTHOR WiFeng
CATEGORY Web
COMMENTS No Comments

抓取数据出现MySQL server has gone away

在抓取数据的时候总是提示:MySQL server has gone away, 在这样的情况下正是由于某两条SQL查询之间隔离的时间过长,导致该连接自动断开。 解决方案:在打开链接的时候如下多加一个参数

mysql_connect($dbhost, $dbuser, $dbpw, false, MYSQL_CLIENT_INTERACTIVE)

然后接着执行这样的query:

mysql_query("set interactive_timeout=24*3600");

这样的话,就不会出现mysql server has gone away 了。
为什么呢? 看看官方手册里的说明
MYSQL_CLIENT_COMPRESS 使用压缩的通讯协议
MYSQL_CLIENT_IGNORE_SPACE 允许在函数名后留空格位
MYSQL_CLIENT_INTERACTIVE 允许设置断开连接之前所空闲等候的 interactive_timeout 时间(代替 wait_timeout)。
MYSQL_CLIENT_SSL 使用 SSL 加密。本标志仅在 MySQL 客户端库版本为 4.x 或更高版本时可用。在 PHP 4 和 Windows 版的 PHP 5 安装包中绑定的都是 3.23.x。

16
Mar 2008
AUTHOR WiFeng
CATEGORY Web
COMMENTS No Comments

PHP 连接 Access 数据库

PHP连接好多数据库哦,access也可以的

原文地址:http://superstar888.wf.blog.163.com.......

27
Feb 2008
AUTHOR WiFeng
CATEGORY Web
COMMENTS No Comments

无限极分类中最经典的代码(函数)

第一种形式(最新版本)推荐使用:
<?php
function d($arr,$pid,$s) {
  static $r_arr=array();
  static $n = 0;
        $s=$s."&nbsp;&nbsp;&nbsp;";
        for($i=0;$i<count($arr);$i++){
            if($arr[$i]['parentid']==$pid){
                $r_arr[$n]['catname'] = $s.'|-'.$arr[$i]['catname'];
                $r_arr[$n]['catid'] = $arr[$i]['catid'];
    $n++;
                for($j=0;$j<count($arr);$j++){
                    if($arr[$i]['catid']==$arr[$j]['parentid']){
                        $r_arr[$n]['catname'] = $s."&nbsp;&nbsp;&nbsp;|-".$arr[$j]['catname'];
      $r_arr[$n]['catid'] = $arr[$j]['catid'];
      $n++;
                        d($arr,$arr[$j]['catid'],$s."&nbsp;&nbsp;&nbsp;");
                    }
                }
            }


        }
  return $r_arr;
    }
?>
第二种形式(原始版本):
<?php
header("Content-Type:text/html;charset=utf-8");
function d($arr,$pid,$s) {
        $s=$s."&nbsp;&nbsp;&nbsp;";
        for($i=0;$i<count($arr);$i++){
            if($arr[$i][2]==$pid){
                echo $s.$arr[$i][1]."<br>";


                for($j=0;$j<count($arr);$j++){
                    if($arr[$i][0]==$arr[$j][2]){
                        echo $s."&nbsp;&nbsp;&nbsp;".$arr[$j][1]."<br>";
                        d($arr,$arr[$j][0],$s."&nbsp;&nbsp;&nbsp;");
                    }
                }
            }
        }
    }
    $arr1=array('a1','根目录1','0','1');
    $arr2=array('b1','根目录2','0','1');
    $arr3=array('a2','一级目录','a1','2');
    $arr4=array('b2','一级目录','b1','2');
    $arr5=array('a3','二级目录','a2','3');
    $arr6=array('b3','二级目录','b2','3');
    $arr7=array('a4','三级目录','a3','4');
    $arr=array($arr1,$arr2,$arr3,$arr4,$arr5,$arr6,$arr7);
    d($arr,'0'," ");
?>
27
Feb 2008
AUTHOR WiFeng
CATEGORY Web
COMMENTS No Comments

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