Automating the doc protection using FCI integration with RMS bulk protection tool
2010-02-10 09:18
267 查看
自动生成验证码
Image.php
<?php
session_start(); //启动session
header('content-type:image/gif'); //输出头信息
$image_w=100; //验证码图形的高
$image_h=25; //验证码图形的宽
$number=range(0,9); //定义一个成员为数字的数组
$character=range("Z","A"); 定义一个成员为大写字母的数组
$result=array_merge($number,$character); //合并两个数组
$string=""; //初始化
$len=count($result); //新数组的长
for ($i=0;$i<4;$i++)
{
$new_number[$i]=$result[rand(0, $len-1)]; //在$result数组中随机取出4个字符
$string=$string.$new_number[$i]; //生成验证码字符串
}
$_SESSION['string']=$string; //使用$_SESSION变量传值
$check_image=imagecreatetruecolor($image_w, $image_h); //创建图片对象
$white=imagecolorallocate($check_image,255,255,255);
$black=imagecolorallocate($check_image, 0, 0, 0);
imagefill($check_image,0,0,$white); //设置背景颜色为白色
for ($i;$i<100;$i++) //加入100个干扰的黑点
{
imagesetpixel($check_image, rand(0, $image_w), rand(0, $image_h), $black);
}
for ($i=0;$i<count($new_number);$i++)
{
$x=mt_rand(1, 8)+$image_w*$i/4; //设定字符所在位置X坐标
$y=mt_rand(1, $image_h/4); //设定字符所在位置Y坐标
//随机设定字符颜色
$color=imagecolorallocate($check_image,mt_rand(0,200),mt_rand(0,200),mt_rand(0,200));
//输入字符到图片中
imagestring($check_image,5,$x,$y,$new_number[$i],$color);
}
imagepng($check_image);
imagedestroy($check_image);
?>本文出自 “想你所想,没有不可以” 博客,请务必保留此出处http://joket.blog.51cto.com/3504252/1045163
Image.php
<?php
session_start(); //启动session
header('content-type:image/gif'); //输出头信息
$image_w=100; //验证码图形的高
$image_h=25; //验证码图形的宽
$number=range(0,9); //定义一个成员为数字的数组
$character=range("Z","A"); 定义一个成员为大写字母的数组
$result=array_merge($number,$character); //合并两个数组
$string=""; //初始化
$len=count($result); //新数组的长
for ($i=0;$i<4;$i++)
{
$new_number[$i]=$result[rand(0, $len-1)]; //在$result数组中随机取出4个字符
$string=$string.$new_number[$i]; //生成验证码字符串
}
$_SESSION['string']=$string; //使用$_SESSION变量传值
$check_image=imagecreatetruecolor($image_w, $image_h); //创建图片对象
$white=imagecolorallocate($check_image,255,255,255);
$black=imagecolorallocate($check_image, 0, 0, 0);
imagefill($check_image,0,0,$white); //设置背景颜色为白色
for ($i;$i<100;$i++) //加入100个干扰的黑点
{
imagesetpixel($check_image, rand(0, $image_w), rand(0, $image_h), $black);
}
for ($i=0;$i<count($new_number);$i++)
{
$x=mt_rand(1, 8)+$image_w*$i/4; //设定字符所在位置X坐标
$y=mt_rand(1, $image_h/4); //设定字符所在位置Y坐标
//随机设定字符颜色
$color=imagecolorallocate($check_image,mt_rand(0,200),mt_rand(0,200),mt_rand(0,200));
//输入字符到图片中
imagestring($check_image,5,$x,$y,$new_number[$i],$color);
}
imagepng($check_image);
imagedestroy($check_image);
?>本文出自 “想你所想,没有不可以” 博客,请务必保留此出处http://joket.blog.51cto.com/3504252/1045163
相关文章推荐
- AD RMS Bulk Protection Tool 批量加密解密office文档
- Using Mimikatz Alpha or Getting Clear Text Passwords with a Microsoft Tool
- Using the latest Jython with a WebSphere Application Server wsadmin thin client
- Using UTF-8 as the internal representation for strings in C and C++ with Visual Studio
- How do I import a new Java CA cert without using the keytool command line utility?
- [Javascript + rxjs] Using the map method with Observable
- call different method with the same name, parameters and return value, select which one is called using const symbol
- Along with all the above benefits, you cannot overlook the space efficiency and performance gains in using DataFrames and Dataset APIs for two reasons.
- Communicating with the Database (Using ADO)
- Setting up and using the Rational Data Architect - Rational ClearCase integration
- Using the ASP.Net Runtime for extending desktop applications with dynamic HTML Scripts
- Placeholder for AMDU binaries and using with ASM 10g (Doc ID 553639.1)
- VC编译时,提示no compile tool is associated with the file extension错误 .
- Unable to Drop a Datafile From the Tablespace Using Alter Tablespace Command (Doc ID 1050261.1)
- Doctest: The Easiest Testing Tool(Chapter 2 of Python Testing Beginner's Guide)
- Creating New DB Using DBCA on 10.2.0.3 Fails With ORA-1092 While Upgrading To The 10.2.0.3 Works Fine
- Using the SDRAM on Altera’s DE1-SoC Board with Verilog Designs
- Using Visual C++ 2005 Express Edition with the Microsoft Platform SDK
- [转]how to split the ng-repeat data with three columns using bootstrap
- Using ASP.NET 3.5's ListView and DataPager Controls: Displaying Data with the ListView (翻译)