zoukankan      html  css  js  c++  java
  • 2014-05-14 总结

    PHP 验证码(补充)

    1、改变验证码背景颜色:imagefill(图片,填充的宽,填充的高,颜色)

           $back = imagecolorallocate($img,194,219,255);        imagefill($img,0,0,$back);

    2、字体颜色随机改变:rand(0,255)

          $color = imagecolorallocate($img,rand(0,255),rand(0,255),rand(0,255));

    3、生成文字的位置不同:    

        $fwx=rand(6,30);   

        for($i=0;$i<4;$i++){   

        $fwy=rand(2,15);   

        imagestring($img,rand(2,5),$fwx,$fwy,substr($rand,$i,1),$color);   

        $fwx+=rand(8,20);

        }

    4、生成干扰线: imageline(图片,起始x位置,起始y位置,结束x位置,结束y位置,颜色);

         $ganraox1=rand(6,30);     

         $ganraox2=rand(30,60);     

         for($i=0;$i<4;$i++){          

         $ganraoy1=rand(2,20);          

         $ganraoy2=rand(8,30);        

          imageline       ($img,$ganraox1,$ganraoy1,$ganraox2,$ganraoy2,$color);          

          $ganraox1+=rand(30,60);          

          $ganraox2+=rand(61,98);    

         }

    5、生成干扰点:

            for($i=0;$i<100;$i++){            imagesetpixel($img,rand(2,100),rand(2,30),$color);        }

    PHP 函数封装

    6、连接数据库

          define("HOST","127.0.0.1");
          define("USER","root");
          define("PWD","");
          $conn = "";
          function get_conn(){
             global $conn;
             $conn = mysql_connect(HOST,USER,PWD) or die(mysql_error());
             mysql_select_db("test",$conn);
             mysql_query("set names 'utf8'");
    }

          

  • 相关阅读:
    织梦删除不需要的文件及文件安全设置
    织梦安全设置
    阿里云一个虚拟主机安装多个织梦系统
    显示织梦模板不存在的解决方法
    织梦安装
    织梦修改数据库密码
    CSS实现兼容性的渐变背景(gradient)效果
    css边框样式、边框配色、边框阴影、边框圆角、图片边框
    织梦后台编辑器添加中文字体
    织梦安装百度编辑器
  • 原文地址:https://www.cnblogs.com/zouyajun/p/3728727.html
Copyright © 2011-2022 走看看