效果图:

方法如下:
找到emlog程序路径/include/lib/checkcode.php文件,把下面代码全部替换到checkcode.php里面即可,修改前请注意先备份数据,养成好的备份习惯。
<?php /** * Emlog验证码防干扰 * 精品资源:http://www.fqyxy.xyz */ session_start(); $randCode = ''; $chars = 'abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPRSTUVWXYZ23456789'; for ( $i = 0; $i < 5; $i++ ){ $randCode .= substr($chars, mt_rand(0, strlen($chars) - 1), 1); } $_SESSION['code'] = strtoupper($randCode); $img = imagecreate(75,25) or die("创建图像资源失败,请刷新页面"); $bgColor = isset($_GET['mode']) && $_GET['mode'] == 't' ? imagecolorallocate($img,245,245,245) : imagecolorallocate($img,255,255,255); $pixColor = imagecolorallocate($img,mt_rand(88, 245), mt_rand(55, 240), mt_rand(99, 200)); //画字符、大小 for($i = 0; $i < 5; $i++){ $x = $i * 13 + mt_rand(3, 7) - 2; $y = mt_rand(0, 3); $text_color = imagecolorallocate($img, mt_rand(100, 250), mt_rand(80, 180), mt_rand(90, 220)); imagechar($img, 5, $x + 5, $y + 3, $randCode[$i], $text_color); } //画干扰点 for($j = 0; $j < 240; $j++){ $x = mt_rand(0,500); $y = mt_rand(0,100); imagesetpixel($img,$x,$y,$pixColor); } //4条横斜线 for ($i=0; $i < 5; $i++) { $lineColor = imagecolorallocate($img, rand(50, 150), rand(50, 150), rand(50, 150)); $lineX1 = 0; $lineX2 = 90; $lineY1 = ($i + 1) * 8; $lineY2 = ($i + 1) * 15; imageline($img, $lineX1, $lineY1, $lineX2, $lineY2, $lineColor); } //4条竖斜线 for ($i=0; $i < 5; $i++) { $lineColor = imagecolorallocate($img, rand(50, 150), rand(50, 150), rand(50, 150)); $lineY1 = 0; $lineY2 = 90; $lineX1 = ($i + 1) * 8; $lineX2 = ($i + 1) * 15; imageline($img, $lineX1, $lineY1, $lineX2, $lineY2, $lineColor); } header('Content-Type: image/png'); imagepng($img); imagedestroy($img);
您阅读这篇文章共花了: 0小时00分10秒
您可以选择以下一种方式打赏本站
支付宝扫一扫打赏
生成文章海报