兼容GD字体无函数

This commit is contained in:
Anyon 2019-11-25 09:54:34 +08:00
parent bea693c868
commit 967644b339
4 changed files with 14 additions and 10 deletions

8
composer.lock generated
View File

@ -783,12 +783,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git", "url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "a01d99bd039989a587fdc0c9d38e300b86a71045" "reference": "d59b40f099926275e5ecec372624ab7212c27bc0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/a01d99bd039989a587fdc0c9d38e300b86a71045", "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/d59b40f099926275e5ecec372624ab7212c27bc0",
"reference": "a01d99bd039989a587fdc0c9d38e300b86a71045", "reference": "d59b40f099926275e5ecec372624ab7212c27bc0",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -832,7 +832,7 @@
], ],
"description": "ThinkPHP v6.0 Development Library", "description": "ThinkPHP v6.0 Development Library",
"homepage": "http://framework.thinkadmin.top", "homepage": "http://framework.thinkadmin.top",
"time": "2019-11-23T10:28:22+00:00" "time": "2019-11-23T12:12:24+00:00"
} }
], ],
"packages-dev": [], "packages-dev": [],

View File

@ -805,12 +805,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git", "url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "a01d99bd039989a587fdc0c9d38e300b86a71045" "reference": "d59b40f099926275e5ecec372624ab7212c27bc0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/a01d99bd039989a587fdc0c9d38e300b86a71045", "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/d59b40f099926275e5ecec372624ab7212c27bc0",
"reference": "a01d99bd039989a587fdc0c9d38e300b86a71045", "reference": "d59b40f099926275e5ecec372624ab7212c27bc0",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -826,7 +826,7 @@
"ext-json": "*", "ext-json": "*",
"topthink/framework": "^6.0" "topthink/framework": "^6.0"
}, },
"time": "2019-11-23T10:28:22+00:00", "time": "2019-11-23T12:12:24+00:00",
"type": "library", "type": "library",
"extra": { "extra": {
"think": { "think": {

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php <?php
// This file is automatically generated at:2019-11-23 18:32:47 // This file is automatically generated at:2019-11-25 09:53:56
declare (strict_types = 1); declare (strict_types = 1);
return array ( return array (
0 => 'think\\app\\Service', 0 => 'think\\app\\Service',

View File

@ -146,7 +146,11 @@ class CaptchaService extends Service
$_x = $this->width / $this->codelen; $_x = $this->width / $this->codelen;
for ($i = 0; $i < $this->codelen; $i++) { for ($i = 0; $i < $this->codelen; $i++) {
$this->fontcolor = imagecolorallocate($this->img, mt_rand(0, 156), mt_rand(0, 156), mt_rand(0, 156)); $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]); if (function_exists('imagettftext')) {
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]);
} else {
imagestring($this->img, 15, $_x * $i + mt_rand(10, 15), mt_rand(10, 30), $this->code[$i], $this->fontcolor);
}
} }
ob_start(); ob_start();
imagepng($this->img); imagepng($this->img);