<?php
/**
* description:ZMAX验证码 主文件
* author:min.zhang
* Email:zhang19min88@163.com
* Url:http://www.zmax99.com
* copyright:南宁市程序人软件科技有限责任公司保留所有权利
* date:2014-12-08
*/
/**
* @description validatecode class file
*
* @copyright
*/
class CValidateCode
{
/**
* @description random seed
* @type string
*/
private $_charset = 'abcdefghkmnprstuvwxyzABCDEFGHKMNPRSTUVWXYZ23456789';
/**
* @description captchar
* @type string
*/
private $_code;
/**
* @description the length of captchar
* @type int
*/
private $_codelen = 4;
/**
* @description the width(height) of captchar
* @type int
*/
private $_width = 130;
private $_height = 50;
/**
* @description the handle of image
* @type object
*/
private $_img;
private $_font;
private $_fontsize = 20;
private $_fontcolor;
/**
* @description the path of this file
* @type string00
*/
private $_path;
public function __construct($path_root)
{
$this->_path = $path_root;
$this->_font = $path_root.'/elephant.ttf';
}
/**
* @description create code form rand number
* @param none
* @return none
*/
private function _createCode()
{
$_len = strlen($this->_charset)-1;
for ($i=0;$i<$this->_codelen;$i++) {
$this->_code .= $this->_charset[mt_rand(0,$_len)];
}
}
private function _createBg()
{
$this->_img = imagecreatetruecolor($this->_width, $this->_height);
$color = imagecolorallocate($this->_img, mt_rand(157,255), mt_rand(157,255), mt_rand(157,255));
imagefilledrectangle($this->_img,0,$this->_height,$this->_width,0,$color);
}
private function _createFont()
{
$_x = $this->_width / $this->_codelen;
for ($i=0;$i<$this->_codelen;$i++) {
$this->_fontcolor = imagecolorallocate($this->_img,mt_rand(0,156),mt_rand(0,156),mt_rand(0,156));
imagettftext($this->_img,$this->_fontsize,mt_rand(-30,30),$_x*$i+mt_rand(1,5),$this->_height / 1.4,$this->_fontcolor,$this->_font,$this->_code[$i]);
}
}
private function _createLine()
{
for ($i=0;$i<6;$i++) {
$color = imagecolorallocate($this->_img,mt_rand(0,156),mt_rand(0,156),mt_rand(0,156));
imageline($this->_img,mt_rand(0,$this->_width),mt_rand(0,$this->_height),mt_rand(0,$this->_width),mt_rand(0,$this->_height),$color);
}
for ($i=0;$i<100;$i++) {
$color = imagecolorallocate($this->_img,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255));
imagestring($this->_img,mt_rand(1,5),mt_rand(0,$this->_width),mt_rand(0,$this->_height),'*',$color);
}
}
private function _outPut($strFileName, $strPath="")
{
$path = $strPath;
if($path=="")
{
$path = $this->_path;
}
$filePath = $path .'/'.$strFileName;
header('Content-type:image/png');
imagepng($this->_img,$filePath);
//在这里已经释放了图片资源
imagedestroy($this->_img);
}
/**
* @description get the captcha image
* @param string $strFileName the name of the image
* @param string $strPath the path of the image .default is the root path
* @return none
*/
public function createImage($strFileName, $strPath="") {
$this->_createBg();
$this->_createCode();
$this->_createLine();
$this->_createFont();
$this->_outPut($strFileName ,$strPath);
unset($this->_font);
}
/**
* @description get the image code
* @param none
* @return string the code on the image
*/
public function getCode() {
return strtolower($this->_code);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
joomla 图形验证码
共45个文件
html:23个
php:10个
sql:3个
需积分: 19 10 下载量 30 浏览量
2015-11-24
12:16:27
上传
评论
收藏 76KB ZIP 举报
温馨提示
针对joomla网站,ZMAX团队开发的joomla图形验证码,只需要一键安装本扩展,Joomla网站可以轻松实现图形验证码。ZMAX程序人团队倾力打造的免费Joomla图形验证码。
资源推荐
资源详情
资源评论
收起资源包目录
com_zmaxcaptchav_image_1.0.0_2015-05-28_for_j3x.zip (45个子文件)
com_zmaxcaptcha
index.html 0B
admin
sql
index.html 0B
uninstall.mysql.utf8.sql 43B
updates
index.html 0B
mysql
index.html 0B
1.0.0.sql 569B
install.mysql.utf8.sql 606B
index.html 0B
views
index.html 0B
main
tmpl
index.html 0B
default.php 1KB
index.html 0B
view.html.php 1KB
models
index.html 0B
controllers
index.html 0B
images
index.html 0B
zmax_logo.png 5KB
controller.php 450B
extensions
index.html 0B
phonecaptcha.zip 9KB
imagecaptcha.zip 7KB
language
index.html 0B
zh-CN
index.html 0B
zh-CN.com_zmaxcaptcha.ini 159B
zh-CN.com_zmaxcaptcha.sys.ini 69B
libs
index.html 0B
captcha
index.html 0B
elephant.ttf 44KB
zmax.png 5KB
captcha.php 4KB
sms
sms.lib.php 505B
zmaxcaptcha.php 551B
config.xml 936B
tables
index.html 0B
script.php 3KB
site
index.html 0B
models
index.html 0B
forms
index.html 0B
controller.php 2KB
helpers
zmaxcaptcha.php 3KB
language
index.html 0B
zh-CN
index.html 0B
en-GB
index.html 0B
zmaxcaptcha.php 740B
zmaxcaptcha.xml 3KB
共 45 条
- 1
资源评论
zhangmin19
- 粉丝: 0
- 资源: 51
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功