c#写的ajax接口测试工具

作者: Admin | 分类 c# | 2014-7-30 8:38:00

0

如图,安装地址http://www.aghost.cn/ajaxtest/

php5 fpm chroot之后的问题以及解决

作者: Admin | 分类 | 2014-6-10 22:29:00

0

这几天尝试了一下用nginx+php-fpm使用chroot保证安全性,结果发现各种无法使用,最后发现可能是因为chroot之后php找不到运行库,所以决定编译安装,然后将php文件放置在网站根目录的上层目录

以下是编译的congfig

 

./configure --prefix=/var/www/  --enable-fpm --with-fpm-user=www-data \
 --with-fpm-group=www-data --with-config-file-path=/etc/php5/ \ 
--with-config-file-scan-dir=/etc/php5/ --with-regex=php --with-openssl=/var/www/lib/openssl \ 
--with-pcre-regex --with-zlib --enable-bcmath --with-bz2 --enable-calendar \ 
--with-curl=/var/www/lib/curl/ --enable-exif --enable-ftp --with-gd --with-gettext \ 
--with-mhash --with-imap --with-imap-ssl  --with-kerberos --enable-mbstring \ 
--with-mcrypt  --with-mysql --with-mysqli --enable-opcache --with-pdo-mysql  \
--with-libedit --with-readline --with-mm --enable-zip --with-xsl --with-pear \
--with-zend-vm=GOTO

c#验证码输出代码

作者: Admin | 分类 c# | 2014-6-3 6:56:00

0

定义一个字符集,去掉一些容易混淆的字符,比如说O与0,1与l

 

//验证码的字符集,去掉了一些容易混淆的字符
        private static char[] character = { '2', '3', '4', '5', '6', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 
                                              'H', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'W', 'X', 'Y' };

 

 

生成验证码的字符串

 

            String capStr = String.Empty;
            Random rnd = new Random();
            for (int tmp = 0; tmp < 4; tmp++)
            {
                capStr += character[rnd.Next(character.Length)];
            }

 

 

将验证码以及生成时间保存到session

 

            Session["yzm"] = capStr;
            Session["yzmTime"] = Models.Captcha.getNowTimeStamp();

 

保存生成时间之后就可以对验证码进行过期判断了

 

生成一个新的内存流用于缓存验证码图片

 

MemoryStream ms = new MemoryStream();

optCaptcha(capStr,ms);

 

 

通过Response将图片内容直接输出

 

            //使用缓存
            Response.Buffer = true;
            Response.ExpiresAbsolute = System.DateTime.Now.AddMilliseconds(0);
            Response.Expires = 0;
            Response.CacheControl = "no-cache";
            //通知浏览器不缓存此图片
           Response.AppendHeader("Pragma", "No-Cache");
            Response.ClearContent();
            Response.ContentType = "image/Png";
            Response.BinaryWrite(ms.ToArray());

 

接下来就是生成验证码图片的方法了

 

        public static void optCaptcha(String capCode,MemoryStream ms)
        {
            Random rnd = new Random();
           //画布大小为150*30,如果需要修改必须将对应的数值一起修改
            Bitmap bmp = new Bitmap(150, 30);
            Graphics g = Graphics.FromImage(bmp);
            g.Clear(Color.White);
            
            //i为噪线的个数,可以自行修改
            for (int i = 0; i < 4; i++) 
            {
                //获取噪线的两个坐标点
                int x1 = rnd.Next(150);
                int y1 = rnd.Next(30);
                int x2 = rnd.Next(150);
                int y2 = rnd.Next(30);
                //随机噪线颜色
                Color clr = color[rnd.Next(color.Length)];
                g.DrawLine(new Pen(clr), x1, y1, x2, y2);
            }
            //将文字画到画布上
            for (int i = 0; i < capCode.Length; i++)
            {
                string fnt = font[rnd.Next(font.Length)];
                Font ft = new Font(fnt, 16);
                Color clr = color[rnd.Next(color.Length)];
                g.DrawString(capCode[i].ToString(), ft, new SolidBrush(clr), (float)i * 30 + 25, (float)5);
            }

            //随机躁点
            var pointNum = rnd.Next(50);
            for (int i = 0; i < pointNum; i++) 
            {
                int x = rnd.Next(bmp.Width);
                int y = rnd.Next(bmp.Height);
                Color clr = color[rnd.Next(color.Length)];
                bmp.SetPixel(x, y, clr);
            }

            bmp.Save(ms, ImageFormat.Png);

        }

 

iis8.5 + php 报500错误 解决办法

作者: Admin | 分类 iis | 2014-6-2 6:25:00

0

-, -搞了半天原来是只能用nts的。。。。。

大家用iis8搭建php环境的时候切记要用nts。。。。。

吐槽下微软系统管的越来越多了

windows/ubuntu多系统grub引导重建

作者: Admin | 分类 Linux | 2014-5-30 15:07:00

0

重装windows后有可能会破坏引导扇区里的grub引导(本人每次重装的时候都会习惯性重建mbr ORZ),所以把步骤写下来

1、使用ubuntu livecd引导系统

2、打开命令行界面

3、将root分区挂载到/mnt/ (可以随便挂载,挂mnt比较方便)

mount /dev/sdxx /mnt/

4、执行grub-install

grub-install --root-directory=/mnt /dev/sdx

将sdx与sdxx替换成你对应的分区,然后就ok拉~~~

 

ubuntu之apt-mirror的配置文件

作者: Admin | 分类 Linux | 2014-5-30 14:48:00

0

 

#8.04
deb http://mirrors.ustc.edu.cn/ubuntu/ lucid main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ lucid-backports main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ lucid-proposed main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ lucid-security main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ lucid-updates main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ lucid main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ lucid-backports main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ lucid-proposed main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ lucid-security main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ lucid-updates main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ lucid main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ lucid-backports main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ lucid-proposed main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ lucid-security main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ lucid-updates main multiverse restricted universe

#12.04
deb http://mirrors.ustc.edu.cn/ubuntu/ precise main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ precise-backports main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ precise-security main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ precise-updates main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise-backports main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise-security main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ precise-updates main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ precise main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ precise-backports main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ precise-security main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ precise-updates main multiverse restricted universe

#12.10
deb http://mirrors.ustc.edu.cn/ubuntu/ quantal main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ quantal-backports main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ quantal-proposed main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ quantal-security main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ quantal-updates main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ quantal main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ quantal-backports main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ quantal-proposed main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ quantal-security main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ quantal-updates main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ quantal main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ quantal-backports main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ quantal-proposed main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ quantal-security main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ quantal-updates main multiverse restricted universe

#13.04
deb http://mirrors.ustc.edu.cn/ubuntu/ raring main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ raring-backports main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ raring-proposed main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ raring-security main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ raring-updates main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ raring main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ raring-backports main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ raring-proposed main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ raring-security main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ raring-updates main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ raring main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ raring-backports main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ raring-proposed main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ raring-security main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ raring-updates main multiverse restricted universe

#13.10
deb http://mirrors.ustc.edu.cn/ubuntu/ saucy main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ saucy-backports main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ saucy-proposed main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ saucy-security main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ saucy-updates main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ saucy main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ saucy-backports main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ saucy-proposed main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ saucy-security main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ saucy-updates main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ saucy main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ saucy-backports main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ saucy-proposed main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ saucy-security main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ saucy-updates main multiverse restricted universe

#14.04
deb http://mirrors.ustc.edu.cn/ubuntu/ trusty main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ trusty-backports main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ trusty-proposed main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ trusty-security main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu/ trusty-updates main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty-backports main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty-proposed main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty-security main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty-updates main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ trusty main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ trusty-backports main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ trusty-proposed main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ trusty-security main multiverse restricted universe
deb-i386 http://mirrors.ustc.edu.cn/ubuntu/ trusty-updates main multiverse restricted universe

 

 

  注:按照这个配置文件最后同步出来的数据有约600GB,请确保硬盘空间够用

 

Linux指向本目录的软链接

作者: Admin | 分类 Linux | 2014-5-30 6:04:00

0

最近在搭建一个ubuntu的本地更新源,想在目录下做一个指向本目录的软链接,想到了两种方法

(我在/下新建了一个目录test用于测试)

1、使用绝对路径

命令:

/test# ln -s /test/ /test/test

 

 

2、使用相对路径(我记得 . 和 .. 其实是预定义的符号链接)

 

/test# ln -s ./ test