<?php /** * 这个页面用于生成验证码图像 * * @author ♂bingo↗ [coolhpy@163.com] * @since 2006-6-17 */ session_start(); header("Cache-Control: no-cache, must-revalidate"); require "./AuthCode.class.php"; $auth_code = new AuthCode(); // 定义验证码信息 $arr['code'] = array('characters' => 'A-Z,1-9', 'length' => 4, 'deflect' => true, 'multicolor' => false); $auth_code->setCode($arr['code']); // 定义干扰信息 $arr['molestation'] = array('type' => 'both', 'density' => 'normal'); $auth_code->setMolestation($arr['molestation']); // 定义图像信息 $arr['image'] = array('type' => 'gif', 'width' => 70, 'height' => 20); $auth_code->setImage($arr['image']); // 定义字体信息 $arr['font'] = array('space' => 5, 'size' => 12, 'left' => 5, 'top' => 15, 'file' => 'arial.ttf'); $auth_code->setFont($arr['font']); // 定义背景色 $arr['bg'] = array('r' => 255, 'g' => 255, 'b' => 255); $auth_code->setBgColor($arr['bg']); // 输出到浏览器 $auth_code->paint(); // 输出到文件, 文件名中不需要扩展名 //$auth_code->paint('./test');
/** * 这个页面用于生成验证码图像 * * @author coolhpy <*****@*****.**> * @create 2006-6-17 * * 2006-7-9 增加 PHP5 的支持 */ session_start(); header("Cache-Control: no-cache, must-revalidate"); include "./include/authcode.class.php"; $auth_code_obj = new AuthCode(); // 定义验证码信息 $arr['code'] = array('characters' => 'A-H,J-N,P-Z,1-9', 'length' => 4, 'deflect' => true, 'multicolor' => false); $auth_code_obj->setCode($arr['code']); // 定义干扰信息 $arr['molestation'] = array('type' => 'both', 'density' => 'muchness'); $auth_code_obj->setMolestation($arr['molestation']); // 定义图像信息. 设置图象类型请确认您的服务器是否支持您需要的类型 $arr['image'] = array('type' => 'png', 'width' => 70, 'height' => 25); $auth_code_obj->setImage($arr['image']); // 定义字体信息 $arr['font'] = array('space' => 2, 'size' => 13, 'file' => './include/fonts/arial.ttf'); $auth_code_obj->setFont($arr['font']); // 定义背景色 $arr['bg'] = array('r' => 255, 'g' => 255, 'b' => 255); $auth_code_obj->setBgColor($arr['bg']); // 输出到浏览器 $auth_code_obj->paint(); // 输出到文件, 文件名中不需要扩展名