ECMALL网站验证码不显示

来源:互联网 发布:淘宝评论看不见 编辑:程序博客网 时间:2024/05/01 06:56
一、确认问题:

输入下面这个地址:http://你的网址/index.php?app=captcha&4153

打开后出现:mt_rand(): max(0) is smaller than min(1) 或者 mt_rand(): max(24) is smaller than min(26) 等类型的错误,则可以采取我们下面给出的解决方法。

 

二、问题原因:

在PHP 5.3.3版本以前,mt_rand($a, $b)传入的参数$a和$b二者没有数字大小比较的限制,但是自5.3.4版本PHP开始,传入的参数必须满足$a <= $b,即第一个参数必须小于等于第二次参数。但根据目前ECMall的代码,会出现$a>$b 的情况,所以,我们要避免出现这一情况。

 

三、解决问题:

1)打开(注意:不要用记事本打开,要用DW等网页编辑器打开修改) app/captcha.app.php

$this->_captcha(80, 24);
改为
$this->_captcha(80, 26);

2)打开 admin/app/captcha.app.php 

$this->_captcha(70, 20);
修改为:
$this->_captcha(70, 26);

3)打开 includes/libraries/captcha.lib.php

把274行中的
$x = mt_rand($font[0]['angle'] > 0 ? cos(deg2rad(90 - $font[0]['angle'])) * $font[0]['zheight'] : 1, $this->width - $widthtotal);
改为:
$x = mt_rand($font[0]['angle'] > 0 ? cos(deg2rad(90 - $font[0]['angle'])) * $font[0]['zheight'] : 0, $this->width - $widthtotal);

 

总结:由此可以看出,此种情况,一般只是在PHP5.3以上的版本才会出现,如果你的是PHP5.2.*的版本,不用考虑此解决方法。

1 0