php滑動拼圖驗證碼的圖片是怎樣生成的

1 如果放在項目中用,驗證碼圖片希望可以是介面返回。ImageView以及其子類支持花式載入圖片。
2 繼承自ImageView,繪制圖片本身不用我們干預,也不用我們操心scaleType,節省很多工作。
* 在onSizeChanged()方法中生成 和 控制項寬高相關的屬性值:
1 初始化時隨機生成驗證碼區域起點
2 生成驗證碼區域Path
3 生成滑塊Bitmap
* onDraw()時,依次繪制:
1 驗證碼陰影
2 滑塊

② 滑動驗證碼怎麼實現gd2、php滑動驗證碼怎麼弄

$XSVerification=newXSVerification();//載入類XSVerification.class.php
$data=$XSVerification->getOkPng();
$temp=array_chunk($data['data'],20);
$this->assign('left_pic',$temp[0]);
$this->assign('right_pic',$temp[1]);
$this->assign('pg_bg',$data['bg_pic']);
$this->assign('ico_pic',$data['ico_pic']);
$this->assign('y_point',$data['y_point']);

源碼下載:http://www.thinkphp.cn/topic/45662.html

③ 實現php中圖形驗證碼刷新的問題

tm沒有具體意義。兩個代碼都是為了讓每次打開的圖片是不同的SRC地址。

因為瀏覽器在打開圖片時,如果發現圖片的SRC地址是緩存中存在的,就可能讀取上一次的緩存,導致圖片刷新失敗。

在地址後加?和隨機值,就是為了讓SRC地址每次不同,瀏覽器也就每次請求伺服器,而不是顯示緩存

④ php圖片驗證碼實現

可以用php的GD庫做

//隨機生成驗證碼
class randomString
{

function createRandomStr($strLen)
{
list($usec, $sec) = explode(' ', microtime());
(float) $sec + ((float) $usec * 100000);

$number = '';
$number_len = $strLen;
$stuff = '';//附加碼顯示範圍ABCDEFGHIJKLMNOPQRSTUVWXYZ
$stuff_len = strlen($stuff) - 1;
for ($i = 0; $i < $number_len; $i++) {
$number .= substr($stuff, mt_rand(0, $stuff_len), 1);
}
return $number;
}
}
通過ZD庫將驗證碼變成圖片
$number = $createStr->createRandomStr('4');//驗證碼的位數
$number_len = strlen($number);
$_SESSION["VERIFY_CODE"] = $number;

// 生成驗證碼圖片
$img_width = 60;
$img_height = 20;

$img = imageCreate($img_width, $img_height);
ImageColorAllocate($img, 0x6C, 0x74, 0x70);
$white = ImageColorAllocate($img, 0xff, 0xff, 0xff);

$ix = 6;
$iy = 2;
for ($i = 0; $i < $number_len; $i++) {
imageString($img, 5, $ix, $iy, $number[$i], $white);
$ix += 14;
}
for($i=0;$i<200;$i++) //加入干擾象素
{
$randcolor = ImageColorallocate($img,rand(0,255),rand(0,255),rand(0,255));
imagesetpixel($img, rand()%100 , rand()%50 , $randcolor);
}

// 輸出圖片
header("Content-type: " . image_type_to_mime_type(IMAGETYPE_PNG));

imagepng($img);
imagedestroy($img);

⑤ 我的php代碼中登陸界面加一個驗證碼,如何實現

php登陸頁面+驗證碼的實現,參考如下:

1、首先新建一個php站點;

⑥ 求完整的PHP驗證碼驗證代碼

<?php
header("content-Type:image/gif");function getRandStr($len=4,$type=0){
mt_srand(microtime(true)*10000);
$num='';
//獲取數字
for($n=48;$n<58;$n++){
$num.=chr($n);
} $xiaoie='';
//獲取小寫
for($m=97;$m<123;$m++){
$xiaoxie.=chr($m);
} $daie='';
//獲取大寫
for($n=65;$n<91;$n++){
$daxie.=chr($n);
}
switch($type){
case 0:
$allstr=$num.$daxie.$xiaoxie;
break;
case 1:
$allstr=$num;
break;
case 2:
$allstr=$daxie.$xiaoxie;
break;
default:
$allstr=$num.$daxie.$xiaoxie;
break;
}
$strlen=strlen($allstr);
if($len>$strlen)
return '';
$rand='';
for($l=0;$l<$len;$l++){
$rand.=$allstr{mt_rand(0,$strlen-1)};
}
return $rand;
}
$w=80;
$h=30;//創建畫布
$im=imagecreate($w,$h);//創建真彩畫布,跟上面效果一樣
//$im=imagecreatetruecolor($w,$h);//設置背景顏色
$bg_color=imagecolorallocate($im,rand(100,150),rand(200,255),rand(100,150));//設置模糊點的顏色
$mohu_color=imagecolorallocate($im,mt_rand(20,50),mt_rand(20,50),mt_rand(100,200));
//為背景加模糊點
for($i=0;$i<100;$i++){
imagesetpixel($im,rand(1,$w-1),rand(1,$h-1),$mohu_color);
} //設置線條顏色
$line_color=imagecolorallocate($im,mt_rand(20,50),mt_rand(20,50),mt_rand(100,200));
for($j=0;$j<5;$j++){
//畫線條
imageline($im,mt_rand(0,$w),mt_rand(0,$h),mt_rand(0,$w),mt_rand(0,$w),$line_color);
} $randstr=getrandStr();
$_SESSION['randcode']=$randstr;$font_color=imagecolorallocate($im,mt_rand(20,50),mt_rand(20,50),mt_rand(100,200));
$font="./Fonts/ARIALNI.TTF";
//王圖片加字元串
imagettftext($im,14,rand(0,6),15,20,$font_color,$font,$randstr);//生成GIF圖片
imagegif($im);//銷毀圖片
imagedestroy;
?>

⑦ php實現驗證碼,能給具體的代碼嗎 在這謝謝過各位高手了

index.php:
<?php
/* index.php start*/
if(!empty($_POST)) {
session_start();
if($_POST['seccode'] == $_SESSION['seccode']) {
echo '<script>alert("驗證成功")</script>';
} else {
echo '<script>alert("驗證失敗")</script>';
}
session_destroy();
}
?>
<form action="" method="post" />
<img id="seccode" src="seccode.php?rand=".<?=rand()?> /> <input type="text" name="seccode" /> <input type="submit" value="submit" />
<input type="button" onclick="document.getElementById('seccode').src = 'seccode.php?reload=1&' + Math.random()" value="change one"/>
</form>

<?php
/* index.php end*/
?>

******************************
seccode.php:
<?php
/*seccode.php start*/
session_start();
if(isset($_SESSION['seccode']) && empty($_GET['reload'])) {
$arr = $_SESSION['seccode'];
} else {
for($i=0; $i<4; $i++) {
$arr[] = rand(0, 9);
}
$_SESSION['seccode'] = implode($arr);
}
$im = imagecreate(90, 25);
$backgroundcolor = imagecolorallocate ($im, 255, 255, 255);

for($i = 0; $i < 4; $i++) {
$s = iconv('GBK', 'UTF-8', $arr[$i]);
$x = $i * 20 + mt_rand(0, 4) - 2;// 隨機X
$y = mt_rand(0, 4); // 隨機Y
$angle = mt_rand(0,4);// 隨機角度
$text_color = imagecolorallocate($im, mt_rand(50, 255), mt_rand(50, 128), mt_rand(50, 255)); // 隨機顏色
imagettftext($im,20, $angle,$x,20+$y,$text_color,"C:\\Windows\\Fonts\\SIMSUN.TTC",$s);
}

// 線條
$linenums = mt_rand(10, 32);
for($i=0; $i <= $linenums; $i++) {
$linecolor = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
$linex = mt_rand(0, 62);
$liney = mt_rand(0, 25);
imageline($im, $linex, $liney, $linex + mt_rand(0, 4) - 2, $liney + mt_rand(0, 4) - 2, $linecolor);
}

// 雜點
for($i=0; $i <= 64; $i++) {
$pointcolor = imagecolorallocate($im, mt_rand(50, 255), mt_rand(50, 255), mt_rand(50, 255));
imagesetpixel($im, mt_rand(0, 62), mt_rand(0, 25), $pointcolor);
}

// 邊框
$bordercolor = imagecolorallocate($im , 150, 150, 150);
imagerectangle($im, 0, 0, 89, 24, $bordercolor);

header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
/*seccode.php end*/
?>

⑧ 我想在我的PHP網站里加一個驗證碼,滑動那種

你也真敢想。
網頁驗證碼一般是在後台生成一個驗證碼在後台生成好圖片返回給網頁內顯示,用戶輸入的信息與後端保容存的信息再進行驗證。
如果後端的信息返回到前端是已文字的形式,就起不到安全的作用了。
你的這個功能可以這樣設計,但作用不大。我來說說我的思路吧
首先後端返回一個數字類型的驗證碼,前端獲取數字行的驗證用js+css組織實現特效。你在上圖的黑色部分設定一個擋扳的html元素(這個元素距離左邊的三角形滑動塊的距離就是後端返回的數字),左邊滑塊滑動多少距離達這個隱藏區塊,獲取這個數值,保存下來。

⑨ 怎麼用lua語言來實現滑塊驗證的代碼

這個驗證一般都是由PHP和js配合完成的