校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 網(wǎng)站建設(shè) > 建站知識(shí) > 織夢(mèng) dedecms 5.7 中文驗(yàn)證碼下載

織夢(mèng) dedecms 5.7 中文驗(yàn)證碼下載

POST TIME:2020-04-13 22:48

幫客戶用織夢(mèng)5.7做了一個(gè)中國林果網(wǎng),后來有機(jī)器注冊(cè)垃圾會(huì)員,嘗試了很多種辦法防止無效后,就從網(wǎng)上找了個(gè)中文驗(yàn)證碼,運(yùn)行時(shí)不對(duì),我作了修改了后可以運(yùn)行,垃圾會(huì)員也明顯的少了些,現(xiàn)在分享出來。

把文件vdimgck.php和simhei.ttf(字體文件)放在/下,vdimgck.php文件源碼如下:

代碼如下  

<?php
/**
* 驗(yàn)證圖片
* 在網(wǎng)上下的,經(jīng)過阿亮修改
* 834114969@qq.com
* http://liuzhiliang.com/
*/
require_once(dirname(__FILE__)."/common.inc.php");
//Session保存路徑
$sessSavePath = DEDEDATA."/sessions/";

if(is_writeable($sessSavePath) && is_readable($sessSavePath)){ session_save_path($sessSavePath); }
if(!empty($cfg_domain_cookie)) session_set_cookie_params(0,'/',$cfg_domain_cookie);

session_start();

//獲取隨機(jī)字符
$rndstring = '';
//$ch_h = chr(($num,0,2)+160);
// $ch_l = chr(substr($num,2,2)+160);
function c2ch($num){
$ch_h = chr(substr($num,0,2)+160);
$ch_l = chr(substr($num,2,2)+160);
return $ch_h.$ch_l;
}
function num_rand(){
mt_srand((double)microtime() * 1000000);
$d= mt_rand(16,36);
$n= mt_rand(1,19);
return c2ch($d*100+$n);
}

for($i=0; $i<4; $i++) $rndstring .= gb2utf8(num_rand());
//如果支持GD,則繪圖
if(function_exists("imagecreate"))
{
//Firefox部份情況會(huì)多次請(qǐng)求的問題,5秒內(nèi)刷新頁面將不改變session
$ntime = time();
if(empty($_SESSION['securimage_code_value_last']) || empty($_SESSION['securimage_code_value']) || ($ntime - $_SESSION['securimage_code_value_last'] > 1))
{
$_SESSION['securimage_code_value'] = strtolower($rndstring);
$_SESSION['securimage_code_value_last'] = $ntime;
}
$rndstring = $_SESSION['securimage_code_value'];
//創(chuàng)建圖片,并設(shè)置背景色
$x_size=80;
$y_size=25;
$font='simhei.ttf';
$im=imagecreate($x_size,$y_size);
$background_color = imagecolorallocate ($im, 255, 255, 255);

// 隨機(jī)顏色
$fontColor[] = imagecolorallocate($im, 0x15, 0x15, 0x15);
$fontColor[] = imagecolorallocate($im, 0x95, 0x1e, 0x04);
$fontColor[] = imagecolorallocate($im, 0x93, 0x14, 0xa9);
$fontColor[] = imagecolorallocate($im, 0x12, 0x81, 0x0a);
$fontColor[] = imagecolorallocate($im, 0x06, 0x3a, 0xd5);
$c_fontColor = $fontColor[mt_rand(0,4)];

imagettftext($im,15,mt_rand(-8,8),6,mt_rand(19,22),$c_fontColor,$font,substr($rndstring,0,3));
imagettftext($im,15,mt_rand(-8,8),37,20,$c_fontColor,$font,substr($rndstring,6,3));
imagettftext($im,mt_rand(15,17),mt_rand(-8,8),22,20,$c_fontColor,$font,substr($rndstring,3,3));
imagettftext($im,mt_rand(15,17),mt_rand(-8,8),54,mt_rand(19,22),$c_fontColor,$font,substr($rndstring,9,3));
imagerectangle($im, 0, 0, $x_size - 1, $y_size - 1,$black);

header("Pragma:no-cachern");
header("Cache-Control:no-cachern");
header("Expires:0rn");

//輸出特定類型的圖片格式,優(yōu)先級(jí)為 gif -> jpg ->png
if(function_exists("imagejpeg"))
{
header("content-type:image/jpegrn");
imagejpeg($im);
}
else
{
header("content-type:image/pngrn");
imagepng($im);
}
ImageDestroy($im);
exit();
}
else
{
//不支持GD,只輸出字母 ABCD
$_SESSION['securimage_code_value'] = "abcd";
$_SESSION['securimage_code_value_last'] = '';
header("content-type:image/jpegrn");
header("Pragma:no-cachern");
header("Cache-Control:no-cachern");
header("Expires:0rn");
$fp = ("data/vdcode.jpg","r");
echo fread($fp,filesize("data/vdcode.jpg"));
fclose($fp);
exit();
}

?>




收縮
  • 微信客服
  • 微信二維碼
  • 電話咨詢

  • 400-1100-266
主站蜘蛛池模板: 新建县| 龙江县| 潼南县| 弥渡县| 茌平县| 黔西县| 会宁县| 肥乡县| 长垣县| 襄城县| 涿鹿县| 肇庆市| 蒙自县| 吴川市| 额济纳旗| 北流市| 竹山县| 全椒县| 文安县| 密山市| 景宁| 东阳市| 璧山县| 马鞍山市| 沙洋县| 新晃| 肇庆市| 城口县| 遂溪县| 崇左市| 肃北| 台中县| 特克斯县| 青海省| 奉新县| 光泽县| 洛阳市| 维西| 大埔县| 军事| 延安市|