From 0d608ca06c21639337af2ab9cbad6a39d3b0558b Mon Sep 17 00:00:00 2001
From: Li Jianxuan
+ + +
+@@ -369,7 +373,7 @@ function todownload(ft) function ajaxpage(page){$.ajax({type:"GET",url:"/data/comment/uuid/= $md->uuid; ?>",data:'page='+page,success:function(html){$('#allcomments').html(html);}, beforeSend:function(){$('#allcomments').html('加载中');}});};ajaxpage(0); function postcomment(){ $.ajax({'type':"POST",'url':"/data/postcomment",'data':$('#postcommentform').serialize(), -'success':function(html){$('#postcomment').html('提交');setTimeout("$('#postcomment').removeAttr('disabled');",3000); $('#returninfo').html(html);ajaxpage(0);}, +'success':function(html){$('#postcomment').html('提交');setTimeout("$('#postcomment').removeAttr('disabled');",3000);$('#returninfo').html(html);}, 'beforeSend':function(){$('#postcomment').attr('disabled','disabled');$('#postcomment').html('正在提交...'); }});} $('#literature_t').click(function(){literature(1);}); diff --git a/application/default/views/scripts/heihe/view.phtml b/application/default/views/scripts/heihe/view.phtml index 5452f9c2..9e1de4c0 100755 --- a/application/default/views/scripts/heihe/view.phtml +++ b/application/default/views/scripts/heihe/view.phtml @@ -310,6 +310,10 @@ if($auth->hasIdentity())
+ + +
+@@ -371,7 +375,7 @@ function todownload(ft) function ajaxpage(page){$.ajax({type:"GET",url:"/data/comment/uuid/= $md->uuid; ?>",data:'page='+page,success:function(html){$('#allcomments').html(html);}, beforeSend:function(){$('#allcomments').html('加载中');}});};ajaxpage(0); function postcomment(){ $.ajax({'type':"POST",'url':"/data/postcomment",'data':$('#postcommentform').serialize(), -'success':function(html){$('#postcomment').html('提交');setTimeout("$('#postcomment').removeAttr('disabled');",3000); $('#returninfo').html(html);ajaxpage(0);}, +'success':function(html){$('#postcomment').html('提交');setTimeout("$('#postcomment').removeAttr('disabled');",3000);$('#returninfo').html(html);}, 'beforeSend':function(){$('#postcomment').attr('disabled','disabled');$('#postcomment').html('正在提交...'); }});} $('#literature_t').click(function(){literature(1);}); diff --git a/application/default/views/scripts/water/view.phtml b/application/default/views/scripts/water/view.phtml index 6f1abb55..ba6ce5cf 100755 --- a/application/default/views/scripts/water/view.phtml +++ b/application/default/views/scripts/water/view.phtml @@ -300,6 +300,10 @@ if($auth->hasIdentity())
+ + +
+@@ -335,7 +339,7 @@ $(document).ready(function(){$(".colorbox").colorbox({photo:"true"});}); function ajaxpage(page){$.ajax({type:"GET",url:"/data/comment/uuid/= $md->uuid; ?>",data:'page='+page,success:function(html){$('#allcomments').html(html);}, beforeSend:function(){$('#allcomments').html('加载中');}});};ajaxpage(0); function postcomment(){ $.ajax({'type':"POST",'url':"/data/postcomment",'data':$('#postcommentform').serialize(), -'success':function(html){$('#postcomment').html('提交');setTimeout("$('#postcomment').removeAttr('disabled');",3000); $('#returninfo').html(html);ajaxpage(0);}, +'success':function(html){$('#postcomment').html('提交');setTimeout("$('#postcomment').removeAttr('disabled');",3000);$('#returninfo').html(html);}, 'beforeSend':function(){$('#postcomment').attr('disabled','disabled');$('#postcomment').html('正在提交...'); }});} $('#literature_t').click(function(){literature(1);}); diff --git a/application/models/ImgCode.php b/application/models/ImgCode.php new file mode 100644 index 00000000..67bb7a77 --- /dev/null +++ b/application/models/ImgCode.php @@ -0,0 +1,176 @@ +rand_string($length,$mode);//生成随机数 + + + //$authCode = new Zend_Session_Namespace('Auth_Code'); + //$authCode->imagecode = $randval;//生成session + + $_SESSION['vdcodes'] = strtolower($randval); + + $width = ($length*9+10)>$width?$length*9+10:$width; + if ( $type!='gif' && function_exists('imagecreatetruecolor')) { + $im = @imagecreatetruecolor($width,$height); + }else { + $im = @imagecreate($width,$height); + } + $r = Array(225,255,255,223); + $g = Array(225,236,237,255); + $b = Array(225,236,166,125); + $key = mt_rand(0,3); + + $backColor = imagecolorallocate($im, $r[$key],$g[$key],$b[$key]); //背景色(随机) + $borderColor = imagecolorallocate($im, 100, 100, 100); //边框色 + $pointColor = imagecolorallocate($im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255)); //点颜色 + + @imagefilledrectangle($im, 0, 0, $width - 1, $height - 1, $backColor); + @imagerectangle($im, 0, 0, $width-1, $height-1, $borderColor); + $stringColor = imagecolorallocate($im,mt_rand(0,200),mt_rand(0,120),mt_rand(0,120)); + // 干扰 + for($i=0;$i<10;$i++){ + $fontcolor=imagecolorallocate($im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255)); + imagearc($im,mt_rand(-10,$width),mt_rand(-10,$height),mt_rand(30,300),mt_rand(20,200),55,44,$fontcolor); + } + for($i=0;$i<25;$i++){ + $fontcolor=imagecolorallocate($im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255)); + imagesetpixel($im,mt_rand(0,$width),mt_rand(0,$height),$pointColor); + } + + @imagestring($im, 5, 5, 3, $randval, $stringColor); + $this->output($im,$type); + } + + // 更复杂的验证码 + function image3($length=4,$type='png',$width=50,$height=60,$fontface='fpnf.ttf',$verifyName='verify') { + $code = $this->rand_string($length,4); + $width = ($length*25)>$width?$length*25:$width; + $authCode = new Zend_Session_Namespace('Auth_Code'); + $authCode->imagecode = $randval; + + $im=imagecreatetruecolor($width,$height); + $borderColor = imagecolorallocate($im, 100, 100, 100); //边框色 + $bkcolor=imagecolorallocate($im,250,250,250); + imagefill($im,0,0,$bkcolor); + @imagerectangle($im, 0, 0, $width-1, $height-1, $borderColor); + // 干扰 + for($i=0;$i<15;$i++){ + $fontcolor=imagecolorallocate($im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255)); + imagearc($im,mt_rand(-10,$width),mt_rand(-10,$height),mt_rand(30,300),mt_rand(20,200),55,44,$fontcolor); + } + for($i=0;$i<255;$i++){ + $fontcolor=imagecolorallocate($im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255)); + imagesetpixel($im,mt_rand(0,$width),mt_rand(0,$height),$fontcolor); + } + if(!is_file($fontface)) { + $fontface = dirname(__FILE__)."/".$fontface; + } + for($i=0;$i<$length;$i++){ + $fontcolor=imagecolorallocate($im,mt_rand(0,120),mt_rand(0,120),mt_rand(0,120)); //这样保证随机出来的颜色较深。 + $codex= substr($code,$i,1); + imagettftext($im,mt_rand(16,20),mt_rand(-60,60),40*$i+20,mt_rand(30,35),$fontcolor,$fontface,$codex); + } + $this->output($im,$type); + } + + function output($im,$type='png') + { + header("Content-type: image/".$type); + $ImageFun='Image'.$type; + $ImageFun($im); + imagedestroy($im); + } + + /** + +---------------------------------------------------------- + * 产生随机字串,可用来自动生成密码 默认长度6位 字母和数字混合 + +---------------------------------------------------------- + * @param string $len 长度 + * @param string $type 字串类型 + * 0 字母 1 数字 其它 混合 + * @param string $addChars 额外字符 + +---------------------------------------------------------- + * @return string + +---------------------------------------------------------- + */ + function rand_string($len=6,$type='',$addChars='') { + $str =''; + switch($type) { + case 0: + $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.$addChars; + break; + case 1: + $chars= str_repeat('0123456789',3); + break; + case 2: + $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ'.$addChars; + break; + case 3: + $chars='abcdefghijklmnopqrstuvwxyz'.$addChars; + break; + default : + // 默认去掉了容易混淆的字符oOLl和数字01,要添加请使用addChars参数 + $chars='ABCDEFGHIJKMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789'.$addChars; + break; + } + if($len>10 ) {//位数过长重复字符串一定次数 + $chars= $type==1? str_repeat($chars,$len) : str_repeat($chars,5); + } + if($type!=4) { + $chars = str_shuffle($chars); + $str = substr($chars,0,$len); + }else{ + // 中文随机字 + for($i=0;$i<$len;$i++){ + $str.= substr($chars, floor(mt_rand(0,mb_strlen($chars,'utf-8')-1)),1); + } + } + return $str; + } + +} \ No newline at end of file