积累、 沉淀、 历程,一步一个脚印
  • 防御PHP木马攻击的技巧

    2012-03-20

    1、防止跳出web目录

    首先修改httpd.conf,如果你只允许你的php脚本程序在web目录里操作,还可以修改httpd.conf文件限制php的操作路径。比如你的web目录是/usr/local/apache/htdocs,那么在httpd.conf里加上这么几行:

    Read More »

    作者:admin | 分类目录:PHP | 标签:
  • 从 max_connections 的实验带来的思考

    2012-03-20

    php没有数据库连接池的概念,一般情况下程序中使用mysql_connect()连接数据库,在php脚本执行完毕之后进程会释放掉连接资源所占的内存。访问每个php网页都会出现一个解析脚本的进程,那么数据库服务端也会出现一个connect连接。当然前提是只有一个数据库设计的系统。在高并发高流量的情况下,基于数据库驱动的应用系统很容易出现瓶颈,这个瓶颈首先就是max_connections,即数据库的同时最大连接数,在MySQL安装的时候默认只有100个。增大这个连接数能马上起到效果。但是并不是能无限量增加,我在window服务器下和linux服务器下分别做了实验。

    Read More »

    作者:admin | 分类目录:Mysql | 标签:
  • mysql压力测试之mybench

    2012-03-20

    mybench是用PERL写的简单压力测试工具。官方:http://jeremy.zawodny.com/mysql/mybench/
    下载地址:http://jeremy.zawodny.com/mysql/mybench/mybench-1.0.tar.gz
    本站地址:mybench-1.0.tar

    Read More »

    作者:admin | 分类目录:Mysql | 标签:
  • 基于OpenCV的PHP图像人脸检测识别技术

    2012-03-20

    本文所介绍的技术不是原创,而是从一个叫Robert Eisele的德国人那里学习来的。他写了一个PHP扩展openCV,只封装了两个函数,叫face_detect和face_count。openCV是一个开源的用C/C++开发的计算机图形图像库,非常强大,研究资料很齐全。本文重点是介绍如何使用php来调用其中的局部的功能。人脸侦查技术只是openCV一个应用分支。

    Read More »

    作者:admin | 分类目录:PHP | 标签:
  • 利用imagick生成GIF动态图片

    2012-03-20

    /* This object will hold the animation */
    $animation = new Imagick();

    /* Set the format to gif. All created images will be gifs*/
    $animation->setFormat( “gif” );

    /* Create a pixel to handle colors */
    $color = new ImagickPixel( “white” );

    /* The first frame */
    $color->setColor( “white” );

    /* This is the string we print on the image
    Character by character */
    $string = “HELLO WORLD!”;

    /* Create a new ImagickDraw object and set the font
    Text color defaults to black */
    $draw = new ImagickDraw();

    /* You can get configured fonts with $im->queryFonts
    or use /path/to/file.ttf */
    $draw->setFont( “Arial” );

    /* Loop trough the string.. */
    for ( $i = 0; $i <= strlen( $string ); $i++ )
    {
    /* Take some characters for this frame */
    $part = substr( $string, 0, $i );

    /* Create a new frame */
    $animation->newImage( 100, 50, $color );

    /* Annotate the characters on the image */
    $animation->annotateImage( $draw, 10, 10, 0, $part );

    /* Set a little higher delay for the frame*/
    $animation->setImageDelay( 30 );
    }

    /* The last frame contains the same text with bold */
    $draw->setFont( “Arial” );

    /* One more frame */
    $animation->newImage( 100, 50, $color );

    /* Annotate the bold text on the image */
    $animation->annotateImage( $draw, 10, 10, 0, $string );

    /* The bold can be visible a little longer time */
    $animation->setImageDelay( 60 );

    /* Display the output as an animation.
    Use getImagesBlob to get all images combined */
    header( “Content-Type: image/gif” );
    echo $animation->getImagesBlob();

    ?>

    作者:admin | 分类目录:PHP | 标签:
  • imagick生成透明gif动画

    2012-03-20

    $new_im = new Imagick();
    $new_im->setFormat(’gif’);
    $pics = glob(”nv01/*.png”);
    foreach($pics as $k => $v)
    {
    $im = new Imagick($v);
    $im->trimImage(0);
    $new_im->addImage($im);
    $new_im->setImageDelay(15);
    //设置每一帧图片是独立的,屏蔽上一帧(关键)
    $new_im->setImageDispose(imagick::DISPOSE_PREVIOUS);
    }
    $new_im->coalesceImages();
    $new_im->writeImages(’ani.gif’,1);
    ?>

    作者:admin | 分类目录:PHP | 标签:
  • MySQL: #2013 – Lost connection to MySQL server at ‘reading initial communication packet

    2012-03-20

    [总结] MySQL: #2013 – Lost connection to MySQL server at ‘reading initial communication packet

    连接 MySQL 报错
    #2013 – Lost connection to MySQL server at ‘reading initial communication packet’, system error: 111

    解决Lost connection to MySQL server at ‘reading initial communication packet’的方法

    当通过 TCP/IP 连接 MySQL 远程主机时,出现 ERROR 2013 (HY000): Lost connection to MySQL server at ‘reading initial communication packet’, system error: 104 。

    如果是在linux shell命令行中直接打 mysql 命令,能够顺利连上 MySQL,执行查询语句也比较正常,但如果执行 STOP SLAVE; 命令时就随机出现 ERROR 2013 (HY000): Lost connection to MySQL server during query 问题。而如果把操作命令写到脚本文件再去执行该脚本文件的话,则必然出现 Lost connection to MySQL server at ‘reading initial communication packet’, system error: 111

    要是无论通过什么途径远程访问都出现错误可以认为是系统有防火墙之类的限制,但现在这种奇怪的抽筋现象让人百思不得其解。最后找到的解决方法是在 my.cnf 里面的 [mysqld] 段增加一个启动参数

    skip-name-resolve

    问题消失。

    PS: 设置安全远程连接也可.

    作者:admin | 分类目录:Mysql | 标签:
  • mysql主从同步错误:max_allowed_packet

    2012-03-20

    mysql主从同步错误:max_allowed_packet

    服务器使用master-slave模式,突然发现slave上不同步master上的数据了。于是在slave上mysql>show slave status\G;结果为:

    mysql> show slave status\G;

    Read More »

    作者:admin | 分类目录:Mysql | 标签:
  • IP地址查询接口API

    2012-03-13

    腾讯的IP地址API接口地址:http://fw.qq.com/ipaddress (似乎已经无法访问)
    新浪的IP地址查询接口:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js
    新浪多地域测试方法:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=218.192.3.42
    搜狐IP地址查询接口(默认GBK):http://pv.sohu.com/cityjson
    搜狐IP地址查询接口(可设置编码):http://pv.sohu.com/cityjson?ie=utf-8
    搜狐另外的IP地址查询接口:http://txt.go.sohu.com/ip/soip

    作者:admin | 分类目录:JqueryPHP | 标签:
  • rsync 客户端命令详解

    2012-03-08

    rsync客户端参数的具体解释如下:

    -v, –verbose 详细模式输出
    -q, –quiet 精简输出模式
    -c, –checksum 打开校验开关,强制对文件传输进行校验
    -a, –archive 归档模式,表示以递归方式传输文件,并保持所有文件属性,等于-rlptgoD
    -r, –recursive 对子目录以递归模式处理
    -R, –relative 使用相对路径信息

    Read More »

    作者:admin | 分类目录:Linux | 标签: