天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

PHP驗(yàn)證碼類代碼( 最新修改,完全定制化! )

Authnum.class.php 下載
復(fù)制代碼 代碼如下:
<?php
session_start();
class Authnum {
//圖片對(duì)象、寬度、高度、驗(yàn)證碼長(zhǎng)度
private $im;
private $im_width;
private $im_height;
private $len;
//隨機(jī)字符串、y軸坐標(biāo)值、隨機(jī)顏色
private $randnum;
private $y;
private $randcolor;
//背景色的紅綠藍(lán),默認(rèn)是淺灰色
public $red=238;
public $green=238;
public $blue=238;
/**
* 可選設(shè)置:驗(yàn)證碼類型、干擾點(diǎn)、干擾線、Y軸隨機(jī)
* 設(shè)為 false 表示不啟用
**/
//默認(rèn)是大小寫數(shù)字混合型,1 2 3 分別表示 小寫、大寫、數(shù)字型
public $ext_num_type='';
public $ext_pixel = false; //干擾點(diǎn)
public $ext_line = false; //干擾線
public $ext_rand_y= true; //Y軸隨機(jī)
function __construct ($len=4,$im_width='',$im_height=25) {
// 驗(yàn)證碼長(zhǎng)度、圖片寬度、高度是實(shí)例化類時(shí)必需的數(shù)據(jù)
$this->len = $len; $im_width = $len * 15;
$this->im_width = $im_width;
$this->im_height= $im_height;
$this->im = imagecreate($im_width,$im_height);
}
// 設(shè)置圖片背景顏色,默認(rèn)是淺灰色背景
function set_bgcolor () {
imagecolorallocate($this->im,$this->red,$this->green,$this->blue);
}
// 獲得任意位數(shù)的隨機(jī)碼
function get_randnum () {
$an1 = 'abcdefghijklmnopqrstuvwxyz';
$an2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$an3 = '0123456789';
if ($this->ext_num_type == '') $str = $an1.$an2.$an3;
if ($this->ext_num_type == 1) $str = $an1;
if ($this->ext_num_type == 2) $str = $an2;
if ($this->ext_num_type == 3) $str = $an3;
for ($i = 0; $i < $this->len; $i++) {
$start = rand(1,strlen($str) - 1);
$randnum .= substr($str,$start,1);
}
$this->randnum = $randnum;
$_SESSION[an] = $this->randnum;
}
// 獲得驗(yàn)證碼圖片Y軸
function get_y () {
if ($this->ext_rand_y) $this->y = rand(5, $this->im_height/5);
else $this->y = $this->im_height / 4 ;
}
// 獲得隨機(jī)色
function get_randcolor () {
$this->randcolor = imagecolorallocate($this->im,rand(0,100),rand(0,150),rand(0,200));
}
// 添加干擾點(diǎn)
function set_ext_pixel () {
if ($this->ext_pixel) {
for($i = 0; $i < 100; $i++){
$this->get_randcolor();
imagesetpixel($this->im, rand()%100, rand()%100, $this->randcolor);
}
}
}
// 添加干擾線
function set_ext_line () {
if ($this->ext_line) {
for($j = 0; $j < 2; $j++){
$rand_x = rand(2, $this->im_width);
$rand_y = rand(2, $this->im_height);
$rand_x2 = rand(2, $this->im_width);
$rand_y2 = rand(2, $this->im_height);
$this->get_randcolor();
imageline($this->im, $rand_x, $rand_y, $rand_x2, $rand_y2, $this->randcolor);
}
}
}
/**創(chuàng)建驗(yàn)證碼圖像:
* 建立畫布(__construct函數(shù))
* 設(shè)置畫布背景($this->set_bgcolor();)
* 獲取隨機(jī)字符串($this->get_randnum ();)
* 文字寫到圖片上(imagestring函數(shù))
* 添加干擾點(diǎn)/線($this->set_ext_line(); $this->set_ext_pixel();)
* 輸出圖片
**/
function create () {
$this->set_bgcolor();
$this->get_randnum ();
for($i = 0; $i < $this->len; $i++){
$font = rand(4,6);
$x = $i/$this->len * $this->im_width + rand(1, $this->len);
$this->get_y();
$this->get_randcolor();
imagestring($this->im, $font, $x, $this->y, substr($this->randnum, $i ,1), $this->randcolor);
}
$this->set_ext_line();
$this->set_ext_pixel();
header("content-type:image/png");
imagepng($this->im);
imagedestroy($this->im); //釋放圖像資源
}
}//end class
/**使用驗(yàn)證碼類的方法:
* $an = new Authnum(驗(yàn)證碼長(zhǎng)度,圖片寬度,圖片高度);
* 實(shí)例化時(shí)不帶參數(shù)則默認(rèn)是四位的60*25尺寸的常規(guī)驗(yàn)證碼圖片
* 表單頁(yè)面檢測(cè)驗(yàn)證碼的方法,對(duì)比 $_SESSION[an] 是否等于 $_POST[驗(yàn)證碼文本框ID]
* 可選配置:
* 1.驗(yàn)證碼類型:$an->ext_num_type=1; 值為1是小寫類型,2是大寫類型,3是數(shù)字類型
* 2.干擾點(diǎn):$an->ext_pixel = false; 值為false表示不添加干擾點(diǎn)
* 3.干擾線:$an->ext_line = false; 值為false表示不添加干擾線
* 4.Y軸隨機(jī):$an->ext_rand_y = false; 值為false表示不支持圖片Y軸隨機(jī)
* 5.圖片背景:改變 $red $green $blue 三個(gè)成員變量的值即可
**/
$an = new Authnum();
$an->ext_num_type='';
$an->ext_pixel = true; //干擾點(diǎn)
$an->ext_line = false; //干擾線
$an->ext_rand_y= true; //Y軸隨機(jī)
$an->green = 238;
$an->create();
?>

php技術(shù)PHP驗(yàn)證碼類代碼( 最新修改,完全定制化! ),轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 正在播放一区二区 | 国产精品久久人妻互换毛片 | 在线高清电影理论片4399 | AV天堂AV亚洲啪啪久久无码 | 男男高H啪肉Np文多攻多一受 | 成人网视频在线观看免费 | 国产精品一久久香蕉国产线看 | 精品麻豆一卡2卡三卡4卡乱码 | jlzz中国jizz日本老师水多 | 国产精品观看视频免费完整版 | 久久99国产精品自在自在 | 亚洲欧美中文字幕高清在线 | 日本XXXXZZX片免费观看 | 久久久精品3d动漫一区二区三区 | 在线亚洲中文精品第1页 | 成人国产亚洲精品A区天堂蜜臀 | 2021扫黑风暴在线观看免费完整版 | 青青久久久 | 亚洲国产日韩欧美高清片a 亚洲国产日韩a精品乱码 | 久久亚洲精品AV成人无 | 艳照门在线观看 | 伦理片 a在线线版韩国 | 蜜臀AV中文字幕熟女人妻 | 国产成人h在线视频 | 色欲精品久久人妻AV中文字幕 | 中文字幕在线视频在线看 | 久久兔费黄A级毛片高清 | 青草久久精品亚洲综合专区 | 亚洲 日韩 自拍 视频一区 | 亚洲视频一区在线 | 亚洲色欲色欲无码AV | 国产精品VIDEOS麻豆TUBE | lesbabes性欧美| 一本之道高清视频在线观看 | 迈开腿让我看下你的小草莓声音 | BT7086福利二区最新 | 美美哒免费影视8 | 俄罗斯女人与马Z00Z视频 | 观看免费做视频 | 久久婷婷色香五月综合激情 | 日本邪恶少女漫画大全 |