Jelajahi Sumber

6-5安装验证码拓展

Home 5 tahun lalu
induk
melakukan
678bc7af16
3 mengubah file dengan 97 tambahan dan 2 penghapusan
  1. 2 1
      composer.json
  2. 56 1
      composer.lock
  3. 39 0
      config/captcha.php

+ 2 - 1
composer.json

@@ -20,7 +20,8 @@
         "topthink/framework": "^6.0.0",
         "topthink/think-orm": "^2.0",
         "topthink/think-multi-app": "^1.0",
-        "topthink/think-view": "^1.0"
+        "topthink/think-view": "^1.0",
+        "topthink/think-captcha": "^3.0"
     },
     "require-dev": {
         "symfony/var-dumper": "^4.2",

+ 56 - 1
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "af4c1d3fa817eb8c58caa9a7ec0362b0",
+    "content-hash": "e042aa44f0428c2c539731651ec0e8bd",
     "packages": [
         {
             "name": "league/flysystem",
@@ -498,6 +498,61 @@
             ],
             "time": "2019-12-24T07:57:03+00:00"
         },
+        {
+            "name": "topthink/think-captcha",
+            "version": "v3.0.2",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/top-think/think-captcha.git",
+                "reference": "0b4305da19e118cefd934007875a8112f9352f01"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/top-think/think-captcha/zipball/0b4305da19e118cefd934007875a8112f9352f01",
+                "reference": "0b4305da19e118cefd934007875a8112f9352f01",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "topthink/framework": "^6.0.0"
+            },
+            "type": "library",
+            "extra": {
+                "think": {
+                    "services": [
+                        "think\\captcha\\CaptchaService"
+                    ],
+                    "config": {
+                        "captcha": "src/config.php"
+                    }
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "think\\captcha\\": "src/"
+                },
+                "files": [
+                    "src/helper.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "yunwuxin",
+                    "email": "[email protected]"
+                }
+            ],
+            "description": "captcha package for thinkphp",
+            "time": "2019-10-03T07:45:11+00:00"
+        },
         {
             "name": "topthink/think-helper",
             "version": "v3.1.3",

+ 39 - 0
config/captcha.php

@@ -0,0 +1,39 @@
+<?php
+// +----------------------------------------------------------------------
+// | Captcha配置文件
+// +----------------------------------------------------------------------
+
+return [
+    //验证码位数
+    'length'   => 5,
+    // 验证码字符集合
+    'codeSet'  => '2345678abcdefhijkmnpqrstuvwxyzABCDEFGHJKLMNPQRTUVWXY',
+    // 验证码过期时间
+    'expire'   => 1800,
+    // 是否使用中文验证码
+    'useZh'    => false,
+    // 是否使用算术验证码
+    'math'     => false,
+    // 是否使用背景图
+    'useImgBg' => false,
+    //验证码字符大小
+    'fontSize' => 25,
+    // 是否使用混淆曲线
+    'useCurve' => true,
+    //是否添加杂点
+    'useNoise' => true,
+    // 验证码字体 不设置则随机
+    'fontttf'  => '',
+    //背景颜色
+    'bg'       => [243, 251, 254],
+    // 验证码图片高度
+    'imageH'   => 0,
+    // 验证码图片宽度
+    'imageW'   => 0,
+
+    // 添加额外的验证码设置
+    // verify => [
+    //     'length'=>4,
+    //    ...
+    //],
+];