日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php 验证码字体居中,自定义验证码图片的宽高后文本垂直水平居中[帝国cms ShowKey.php]-网站程序网...

發布時間:2025/3/8 php 97 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php 验证码字体居中,自定义验证码图片的宽高后文本垂直水平居中[帝国cms ShowKey.php]-网站程序网... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

define('EmpireCMSAdmin','1');

define('EmpireCMSAPage','login');

define('EmpireCMSNFPage','1');

require('../class/connect.php');

//繪制居中文本, 對于GD的內置字體

function pc_ImageStringCenter($image,$text,$font){

//字體大小

$width = array(1=>5,6,7,8,9);

$height = array(1=>6,8,13,15,15);

//計算圖像大小

$xi = imagesx($image);

$yi = imagesy($image);

//計算文本大小

$xr = $width[$font] * strlen($text);

$yr = $height[$font];

//計算中心點的位置

$x=intval(($xi-$xr)/2);

$y=intval(($yi-$yr)/2);

return array($x,$y);

}

//取得隨機數

function domake_password($pw_length){

global $public_r;

//驗證碼字符組成,0數字,1字母,2數字+字母

if($public_r["keytog"]==1)

{

$low_ascii_bound=65;

$upper_ascii_bound=90;

$notuse=array(73,79);

}

elseif($public_r["keytog"]==2)

{

$low_ascii_bound=50;

$upper_ascii_bound=90;

//過濾一些特殊符號和容易看錯的字母

//58(:) 59(;) 60() 63(?) 64(@) 73(I) 76(L) 79(O)

$notuse=array(58,59,60,61,62,63,64,73,76,79);

}

else

{

$low_ascii_bound=48;

$upper_ascii_bound=57;

$notuse=array(48,49);

}

while($i

if(PHP_VERSION

{

mt_srand((double)microtime()*1000000);

}

$randnum=mt_rand($low_ascii_bound,$upper_ascii_bound);

if(!in_array($randnum,$notuse))

{

$password1=$password1.chr($randnum);

$i++;

}

}

return $password1;

}

//返回顏色

function ReturnShowKeyColor($img){

global $public_r;

//背景色

if($public_r["keybgcolor"])

{

$bgcr=ToReturnRGB($public_r["keybgcolor"]);

$r["bgcolor"]=imagecolorallocate($img,$bgcr[0],$bgcr[1],$bgcr[2]);

}

else

{

$r["bgcolor"]=imagecolorallocate($img,7,27,63);

}

//文字色

if($public_r["keyfontcolor"])

{

$fcr=ToReturnRGB($public_r["keyfontcolor"]);

$r["fontcolor"]=ImageColorAllocate($img,$fcr[0],$fcr[1],$fcr[2]);

}

else

{

$r["fontcolor"]=ImageColorAllocate($img,255,255,255);

}

//干擾色

if($public_r["keydistcolor"])

{

$dcr=ToReturnRGB($public_r["keydistcolor"]);

$r["distcolor"]=ImageColorAllocate($img,$dcr[0],$dcr[1],$dcr[2]);

}

else

{

$r["distcolor"]=ImageColorAllocate($img,255,255,255);

}

return $r;

}

//顯示驗證碼

function ShowKey($v){

$vname=ecmsReturnKeyVarname($v);

//取得四位隨機驗證碼

$key=strtolower(domake_password(4));

//設置驗證碼

ecmsSetShowKey($vname,$key,0);

//是否支持gd庫

if(function_exists("imagegif"))

{

header("Content-type:image/gif");

$img=imagecreate(60,32);

$colorr=ReturnShowKeyColor($img);

$bgcolor=$colorr["bgcolor"];

$fontcolor=$colorr["fontcolor"];

$distcolor=$colorr["distcolor"];

imagefill($img,0,0,$bgcolor);

list($x,$y)=pc_ImageStringCenter($img,$key,5);

imagestring($img,5,$x,$y,$key,$fontcolor);

//for($i=0;$i<90;$i++)

//{

//imagesetpixel($img,rand()%70,rand()%30,$distcolor);

//}

imagegif($img);

imagedestroy($img);

}

elseif(function_exists("imagepng"))

{

header("Content-type:image/png");

$img=imagecreate(50,26);

$colorr=ReturnShowKeyColor($img);

$bgcolor=$colorr["bgcolor"];

$fontcolor=$colorr["fontcolor"];

$distcolor=$colorr["distcolor"];

imagefill($img,0,0,$bgcolor);

imagestring($img,5,6,3,$key,$fontcolor);

for($i=0;$i<90;$i++)

{

imagesetpixel($img,rand()%70,rand()%30,$distcolor);

}

imagepng($img);

imagedestroy($img);

}

elseif(function_exists("imagejpeg"))

{

header("Content-type:image/jpeg");

$img=imagecreate(50,26);

$colorr=ReturnShowKeyColor($img);

$bgcolor=$colorr["bgcolor"];

$fontcolor=$colorr["fontcolor"];

$distcolor=$colorr["distcolor"];

imagefill($img,0,0,$bgcolor);

imagestring($img,5,6,3,$key,$fontcolor);

for($i=0;$i<90;$i++)

{

imagesetpixel($img,rand()%70,rand()%30,$distcolor);

}

imagejpeg($img);

imagedestroy($img);

}

elseif(function_exists("imagewbmp"))

{

header("Content-type:image/vnd.wap.wbmp");

$img=imagecreate(50,26);

$colorr=ReturnShowKeyColor($img);

$bgcolor=$colorr["bgcolor"];

$fontcolor=$colorr["fontcolor"];

$distcolor=$colorr["distcolor"];

imagefill($img,0,0,$bgcolor);

imagestring($img,5,6,3,$key,$fontcolor);

for($i=0;$i<90;$i++)

{

imagesetpixel($img,rand()%70,rand()%30,$distcolor);

}

imagewbmp($img);

imagedestroy($img);

}

else

{

ecmsSetShowKey($vname,"ecms",0);

echo ReadFiletext("../data/images/ecms.jpg");

}

}

//返回變量名

function ecmsReturnKeyVarname($v){

$name="checkkey";

return $name;

}

$v=$_GET["v"];

ShowKey($v);

?>

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的php 验证码字体居中,自定义验证码图片的宽高后文本垂直水平居中[帝国cms ShowKey.php]-网站程序网...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。