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

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

Authnum.class.php 下載
復制代碼 代碼如下:
<?php
session_start();
class Authnum {
//圖片對象、寬度、高度、驗證碼長度
private $im;
private $im_width;
private $im_height;
private $len;
//隨機字符串、y軸坐標值、隨機顏色
private $randnum;
private $y;
private $randcolor;
//背景色的紅綠藍,默認是淺灰色
public $red=238;
public $green=238;
public $blue=238;
/**
* 可選設置:驗證碼類型、干擾點、干擾線、Y軸隨機
* 設為 false 表示不啟用
**/
//默認是大小寫數字混合型,1 2 3 分別表示 小寫、大寫、數字型
public $ext_num_type='';
public $ext_pixel = false; //干擾點
public $ext_line = false; //干擾線
public $ext_rand_y= true; //Y軸隨機
function __construct ($len=4,$im_width='',$im_height=25) {
// 驗證碼長度、圖片寬度、高度是實例化類時必需的數據
$this->len = $len; $im_width = $len * 15;
$this->im_width = $im_width;
$this->im_height= $im_height;
$this->im = imagecreate($im_width,$im_height);
}
// 設置圖片背景顏色,默認是淺灰色背景
function set_bgcolor () {
imagecolorallocate($this->im,$this->red,$this->green,$this->blue);
}
// 獲得任意位數的隨機碼
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軸
function get_y () {
if ($this->ext_rand_y) $this->y = rand(5, $this->im_height/5);
else $this->y = $this->im_height / 4 ;
}
// 獲得隨機色
function get_randcolor () {
$this->randcolor = imagecolorallocate($this->im,rand(0,100),rand(0,150),rand(0,200));
}
// 添加干擾點
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);
}
}
}
/**創建驗證碼圖像:
* 建立畫布(__construct函數)
* 設置畫布背景($this->set_bgcolor();)
* 獲取隨機字符串($this->get_randnum ();)
* 文字寫到圖片上(imagestring函數)
* 添加干擾點/線($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
/**使用驗證碼類的方法:
* $an = new Authnum(驗證碼長度,圖片寬度,圖片高度);
* 實例化時不帶參數則默認是四位的60*25尺寸的常規驗證碼圖片
* 表單頁面檢測驗證碼的方法,對比 $_SESSION[an] 是否等于 $_POST[驗證碼文本框ID]
* 可選配置:
* 1.驗證碼類型:$an->ext_num_type=1; 值為1是小寫類型,2是大寫類型,3是數字類型
* 2.干擾點:$an->ext_pixel = false; 值為false表示不添加干擾點
* 3.干擾線:$an->ext_line = false; 值為false表示不添加干擾線
* 4.Y軸隨機:$an->ext_rand_y = false; 值為false表示不支持圖片Y軸隨機
* 5.圖片背景:改變 $red $green $blue 三個成員變量的值即可
**/
$an = new Authnum();
$an->ext_num_type='';
$an->ext_pixel = true; //干擾點
$an->ext_line = false; //干擾線
$an->ext_rand_y= true; //Y軸隨機
$an->green = 238;
$an->create();
?>

php技術PHP驗證碼類代碼( 最新修改,完全定制化! ),轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 亚洲精品AV中文字幕在线 | 中国二级毛片 | 星空无限传媒视频在线观看视频 | 国产婷婷综合在线视频中文 | 亚洲国产区中文在线观看 | 色戒无删减流畅完整版 | 久久精品无码人妻无码AV蜜臀 | 欧美精品专区第1页 | 成人国产在线看不卡 | 母狗黄淑珍 | 母狗黄淑珍 | 久久成人永久免费播放 | 97在线精品视频免费 | 一品道门在线视频高清完整版 | 羞羞影院男女爽爽影院尤物 | 露露的性战k8经典 | 亚洲成人免费观看 | 迅雷成人论坛 | 美女激清床上戏大全 | adc影院欢迎您大驾光临入口 | 伊人国产在线视频 | 亚洲黄色录像片 | 久久电影院久久国产 | 亚洲黄色免费在线观看 | 丝瓜影院观看免费高清国际观察 | 蜜臀AV久久国产午夜福利软件 | 国产一卡 二卡三卡四卡无卡乱码视频 | 国产超嫩一线天在线播放 | 成电影人免费网站 | 99久久做夜夜爱天天做精品 | 99精品成人无码A片观看金桔 | 欧美精品高清在线观看 | 亚洲精品午睡沙发系列 | 三级貂蝉艳史 在线观看 | 俄罗斯美女z0z0z0在线 | 吉吉影音先锋av资源网 | 亚洲乱亚洲乱妇在线观看 | 任你躁国语自产二区在线播放 | 欧洲亚洲精品A片久久99果冻 | 伸进同桌奶罩里摸她胸作文 | 久久精品美女久久 |