百度了 好多东西 都试过了还是不显示 求助
解决方案 »
- imagecreatefromjpeg和imagepng问题
- 字符串的截取
- 关于mysql倒入乱码的问题,求救
- php权限问题
- 怎么得到百度或者google.com搜索后点击过来的关健字?
- PHP 表单计算
- Linux 下 gd 库的安装问题?
- 框架中左右两个页面,在左页面中有一个select,怎么将select选中的值同时传给本页面和右边的页面?
- 怎样用adodb这套组件不用limit 10,40之类的sql语句来达到分页的目的?以及,如何象在asp里面调用ado这种com对象的时候设置CursorType和Lo
- PHP是什么,和JSP,,,ASP是同一类吗
- 这个错误是什么意思呀各位大侠们。
- PHP多维数组多字段排序分组,处理的数据比较多,望高手解决
<?php
/*
* $img=new CImage(72,22,15);
* $img->printimg('png');
*/
@session_start();
class CImage{
public $width;
public $heigth;
public $sessionName='_jms_vcode';
public $type='png';
public $charlen=4;
public $fontSize=15;
public $ttf;
private $img;
private $chars="0123456789";
function __construct($width=48,$heigth=18,$fontSize=15){
$this->width=$width;
$this->heigth=$heigth;
$this->fontSize=$fontSize;
$this->img=imagecreate($this->width,$this->heigth);
$this->ttf=dirname(__FILE__).'/fonts/F2FOCRBczykLTStd-Regular.otf';
imagefill($this->img,0,0,imagecolorallocate($this->img,230,235,255));
}
function writeChar($code){
$charlen=strlen($this->chars);
$fontLeft=-12;
for($i=0;$i<strlen($code);$i++){
$fontSize=mt_rand(-1,1)+$this->fontSize;
$fontLeft+=$fontSize+mt_rand(0,2);
$fontTop=$this->heigth-mt_rand(1,5);
$col=imagecolorallocate($this->img,rand(0,150),rand(0,150),rand(0,150));
imagettftext($this->img, $fontSize, mt_rand(-20,20), $fontLeft, $fontTop, $col, $this->ttf, $code{$i});
}
}
function writeArc($i){
while($i--){
ImageArc($this->img,rand(1,$this->width),rand(10,$this->heigth),rand(20,$this->width),rand(1,$this->heigth),rand(1,360),300, imagecolorallocate($this->img,rand(0,120),rand(0,120),rand(0,120)));
}
}
function writePix($i){
while($i--){
imagesetpixel($this->img,rand(0,$this->width),rand(0,$this->heigth),imagecolorallocate($this->img,rand(0,200),rand(0,200),rand(0,200)));
}
}
function printimg($type){
header("content-type:image/$type");
$len=strlen($this->chars);
$code='';
for($i=0;$i<$this->charlen;$i++) $code.=$this->chars{mt_rand(0,$len-1)};
$_SESSION[$this->sessionName]=strtolower($code);
$this->writeChar($code);
//$this->writeArc(3);
$this->writePix(20);
$fun='image'.$type;
$fun($this->img);
}
}
/**
* 验证码产生器
*/
public final function vcode($rmt=null){
$lib_path=$_SERVER['DOCUMENT_ROOT'].'/lib/';
include_once $lib_path .'classes/CImage.class';
$width=72;
$height=24;
$img=new CImage($width, $height);
$img->sessionName=$this->vcodeSessionName;
$img->printimg('png');
}
//{{{ 登录相关
function userBeforLogin(){
}function userLogin(err, data){
if(err){
alert(err);
$('input[name=vcode]')
.val('')
.closest('div')
.find('.yzmNum img')
.click();
}else{
location='/';
}
}//}}}