{"id":22265,"date":"2024-11-21T08:36:50","date_gmt":"2024-11-21T00:36:50","guid":{"rendered":"https:\/\/fwq.ai\/blog\/22265\/"},"modified":"2024-11-21T08:36:50","modified_gmt":"2024-11-21T00:36:50","slug":"thinkphp%e9%aa%8c%e8%af%81%e7%a0%81%e9%94%99%e8%af%af%e4%b8%8d%e5%88%b7%e6%96%b0%e6%80%8e%e4%b9%88%e5%8a%9e","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/22265\/","title":{"rendered":"thinkphp\u9a8c\u8bc1\u7801\u9519\u8bef\u4e0d\u5237\u65b0\u600e\u4e48\u529e"},"content":{"rendered":"<p>thinkphp\u662f\u4e00\u6b3e\u57fa\u4e8emvc\u6a21\u5f0f\u7684\u5f00\u6e90web\u5e94\u7528\u6846\u67b6\uff0c\u5b83\u63d0\u4f9b\u4e86\u8bf8\u591a\u4f18\u79c0\u7684\u529f\u80fd\u548c\u7279\u6027\uff0c\u8ba9\u5f00\u53d1\u8005\u80fd\u591f\u66f4\u52a0\u9ad8\u6548\u5730\u5f00\u53d1web\u5e94\u7528\u3002\u5176\u4e2d\u4e4b\u4e00\u4fbf\u662f\u9a8c\u8bc1\u7801\u529f\u80fd\u3002\u9a8c\u8bc1\u7801\uff0c\u5168\u79f0\u4e3a\u201c\u56fe\u5f62\u9a8c\u8bc1\u7801\u201d\uff0c\u662f\u4e00\u79cd\u7528\u4e8e\u9632\u6b62\u6076\u610f\u673a\u5668\u4eba\u6ce8\u518c\u6216\u767b\u5f55\u7684\u6280\u672f\u624b\u6bb5\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u5f53\u7528\u6237\u8f93\u5165\u9519\u8bef\u7684\u9a8c\u8bc1\u7801\u65f6\uff0c\u7f51\u7ad9\u4f1a\u5237\u65b0\u6216\u91cd\u65b0\u751f\u6210\u4e00\u5f20\u9a8c\u8bc1\u7801\u56fe\u7247\u3002\u4f46\u662f\u6709\u4e00\u4e9b\u7528\u6237\u9047\u5230\u4e86thinkphp\u9a8c\u8bc1\u7801\u9519\u8bef\u5374\u4e0d\u5237\u65b0\u7684\u95ee\u9898\uff0c\u8fd9\u662f\u600e\u4e48\u56de\u4e8b\u5462\uff1f<\/p>\n<p>\u4e00\u3001\u95ee\u9898\u63cf\u8ff0<\/p>\n<p>Thinkphp\u4e2d\uff0c\u9a8c\u8bc1\u7801\u7684\u751f\u6210\u548c\u6821\u9a8c\u4f7f\u7528\u7684\u662fThinkphp\u81ea\u5e26\u7684\u9a8c\u8bc1\u7801\u7c7b\u5e93\u3002\u5728\u4f7f\u7528\u8be5\u7c7b\u5e93\u65f6\uff0c\u7528\u6237\u4f1a\u53d1\u73b0\u51fa\u73b0\u4e86\u4e00\u79cd\u60c5\u51b5\uff0c\u5373\u5f53\u9a8c\u8bc1\u7801\u8f93\u5165\u9519\u8bef\u65f6\uff0c\u7f51\u7ad9\u4e0d\u4f1a\u7acb\u5373\u5237\u65b0\u9a8c\u8bc1\u7801\u3002\u5982\u679c\u7528\u6237\u8fde\u7eed\u591a\u6b21\u8f93\u5165\u9519\u8bef\u7684\u9a8c\u8bc1\u7801\uff0c\u7f51\u7ad9\u5e76\u6ca1\u6709\u66f4\u65b0\u9a8c\u8bc1\u7801\uff0c\u8fd9\u8ba9\u7528\u6237\u611f\u5230\u975e\u5e38\u4e0d\u4fbf\u3002<\/p>\n<p>\u4e8c\u3001\u95ee\u9898\u5206\u6790<\/p>\n<p>\u8be5\u95ee\u9898\u7684\u51fa\u73b0\u539f\u56e0\u662f\u56e0\u4e3a\u5728Thinkphp\u7684\u9a8c\u8bc1\u7801\u7c7b\u5e93\u4e2d\uff0c\u5b58\u5728\u4e00\u4e2a\u5c5e\u6027$reset\u4e3afalse\u7684\u65b9\u6cd5\u3002\u5f53\u8be5\u5c5e\u6027\u503c\u4e3afalse\u65f6\uff0c\u5373\u4e0d\u5237\u65b0\u9a8c\u8bc1\u7801\uff0c\u76f4\u81f3\u8fc7\u671f\u4e3a\u6b62\u3002\u6240\u4ee5\u5f53\u7528\u6237\u591a\u6b21\u8f93\u5165\u9519\u8bef\u7684\u9a8c\u8bc1\u7801\u65f6\uff0c\u7f51\u7ad9\u4e0d\u4f1a\u66f4\u65b0\u9a8c\u8bc1\u7801\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u4e09\u3001\u89e3\u51b3\u65b9\u6cd5<\/p>\n<p>\u9488\u5bf9\u8be5\u95ee\u9898\uff0c\u89e3\u51b3\u65b9\u6cd5\u4e5f\u5f88\u7b80\u5355\uff0c\u53ea\u9700\u8981\u628a$reset\u5c5e\u6027\u503c\u4fee\u6539\u4e3atrue\u5373\u53ef\u3002\u4fee\u6539\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<p>\u5728ThinkPHP\/Library\/Think\/Verify.class.php\u4e2d\u627e\u5230\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre>   \/\/\u662f\u5426\u753b\u6df7\u6dc6\u66f2\u7ebf\n   public $useCurve     = true;\n   \/\/\u662f\u5426\u6dfb\u52a0\u6742\u70b9\n   public $useNoise     = true;\n   \/\/\u9a8c\u8bc1\u7801\u56fe\u7247\u5bbd\u5ea6\n   public $imageW       = 130;\n   \/\/\u9a8c\u8bc1\u7801\u56fe\u7247\u9ad8\u5ea6\n   public $imageH       = 50;\n   \/\/\u9a8c\u8bc1\u7801\u4f4d\u6570\n   public $length       = 4;\n   \/\/\u9a8c\u8bc1\u7801\u5b57\u4f53\u5927\u5c0f(px)\n   public $fontSize     = 25;\n   \/\/\u662f\u5426\u753b\u989c\u8272\u80cc\u666f\n   public $useZh        = false;\n   \/\/\u9a8c\u8bc1\u7801\u79cd\u5b50\n   protected $seed     = '123456789QWERTYUIOPASDFGHJKLZXCVBNM';\n   \/\/\u751f\u6210\u9a8c\u8bc1\u7801\n   public function entry(){\n       \/\/\u9a8c\u8bc1\u7801\u5b57\u7b26\n       $this-&gt;code = $this-&gt;makeCode();\n       session($this-&gt;seKey,$this-&gt;code);\/\/\u9a8c\u8bc1\u7801\u4fdd\u5b58\u5230SESSION\u4e2d\n       $width       = ($this-&gt;length* $this-&gt;fontSize*0.9 + $this-&gt;fontSize*1.5);\n       $height      = $this-&gt;fontSize*2;\n       if( $this-&gt;useZh ){\n           $width  = 230;\n           $height = 50;\n       }\n       \/\/\u521b\u5efa\u56fe\u50cf\n       $this-&gt;image = imagecreate($width,$height);\n       \/\/\u8bbe\u7f6e\u80cc\u666f\n       if($this-&gt;useZh)\n           imagecolorallocate($this-&gt;image,244, 220, 215);\n       else{\n           $this-&gt;bkcolor = imagecolorallocate($this-&gt;image, 255, 255, 255);\n           imagefill($this-&gt;image,0,0,$this-&gt;bkcolor);\n       }\n       \/\/\u6df7\u6dc6\u66f2\u7ebf\n       if ($this-&gt;useCurve) {\n           $this-&gt;writeCurve();\n       }\n       \/\/\u6742\u70b9\n       if ($this-&gt;useNoise) {\n           $this-&gt;writeNoise();\n       }\n       \/\/\u9a8c\u8bc1\u7801\n       $this-&gt;writeCode();\n       header(\"Cache-Control: max-age=1, s-maxage=1, no-cache, must-revalidate\");\n       header(\"Content-type: image\/png;charset=utf8\");\n       imagepng($this-&gt;image);\n       imagedestroy($this-&gt;image);\n   }<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5c06\u5176\u4e2d\u7684$reset\u5c5e\u6027\u503c\u4fee\u6539\u4e3atrue\uff0c\u4fee\u6539\u540e\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>   \/\/\u662f\u5426\u753b\u6df7\u6dc6\u66f2\u7ebf\n   public $useCurve     = true;\n   \/\/\u662f\u5426\u6dfb\u52a0\u6742\u70b9\n   public $useNoise     = true;\n   \/\/\u9a8c\u8bc1\u7801\u56fe\u7247\u5bbd\u5ea6\n   public $imageW       = 130;\n   \/\/\u9a8c\u8bc1\u7801\u56fe\u7247\u9ad8\u5ea6\n   public $imageH       = 50;\n   \/\/\u9a8c\u8bc1\u7801\u4f4d\u6570\n   public $length       = 4;\n   \/\/\u9a8c\u8bc1\u7801\u5b57\u4f53\u5927\u5c0f(px)\n   public $fontSize     = 25;\n   \/\/\u662f\u5426\u753b\u989c\u8272\u80cc\u666f\n   public $useZh        = false;\n   \/\/\u9a8c\u8bc1\u7801\u79cd\u5b50\n   protected $seed     = '123456789QWERTYUIOPASDFGHJKLZXCVBNM';\n   \/\/\u751f\u6210\u9a8c\u8bc1\u7801\n   public function entry(){\n       \/\/\u9a8c\u8bc1\u7801\u5b57\u7b26\n       $this-&gt;code = $this-&gt;makeCode();\n       session($this-&gt;seKey,$this-&gt;code);\/\/\u9a8c\u8bc1\u7801\u4fdd\u5b58\u5230SESSION\u4e2d\n       $width       = ($this-&gt;length* $this-&gt;fontSize*0.9 + $this-&gt;fontSize*1.5);\n       $height      = $this-&gt;fontSize*2;\n       if( $this-&gt;useZh ){\n           $width  = 230;\n           $height = 50;\n       }\n       \/\/\u521b\u5efa\u56fe\u50cf\n       $this-&gt;image = imagecreate($width,$height);\n       \/\/\u8bbe\u7f6e\u80cc\u666f\n       if($this-&gt;useZh)\n           imagecolorallocate($this-&gt;image,244, 220, 215);\n       else{\n           $this-&gt;bkcolor = imagecolorallocate($this-&gt;image, 255, 255, 255);\n           imagefill($this-&gt;image,0,0,$this-&gt;bkcolor);\n       }\n       \/\/\u6df7\u6dc6\u66f2\u7ebf\n       if ($this-&gt;useCurve) {\n           $this-&gt;writeCurve();\n       }\n       \/\/\u6742\u70b9\n       if ($this-&gt;useNoise) {\n           $this-&gt;writeNoise();\n       }\n       \/\/\u9a8c\u8bc1\u7801\n       $this-&gt;writeCode();\n       \/\/ \u4ee5\u4e0b\u4e3a\u4ee3\u7801\u4fee\u6539\n       $this-&gt;reset = true;\n       header(\"Cache-Control: max-age=1, s-maxage=1, no-cache, must-revalidate\");\n       header(\"Content-type: image\/png;charset=utf8\");\n       imagepng($this-&gt;image);\n       imagedestroy($this-&gt;image);\n   }<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4fee\u6539\u5b8c\u540e\uff0c\u4fdd\u5b58\u5e76\u91cd\u65b0\u63d0\u4ea4\u5373\u53ef\u3002<\/p>\n<p>\u56db\u3001\u7ed3\u8bba<\/p>\n<p>\u672c\u6587\u4ecb\u7ecd\u4e86Thinkphp\u9a8c\u8bc1\u7801\u9519\u8bef\u4e0d\u5237\u65b0\u7684\u95ee\u9898\u51fa\u73b0\u539f\u56e0\u548c\u89e3\u51b3\u65b9\u6cd5\u3002\u53ea\u9700\u4fee\u6539\u4e00\u884c\u4ee3\u7801\uff0c\u5373\u53ef\u89e3\u51b3\u8be5\u95ee\u9898\u3002\u5b9e\u9645\u4e0a\uff0c\u5728\u4f7f\u7528\u4efb\u4f55\u6846\u67b6\u65f6\uff0c\u51fa\u73b0\u95ee\u9898\u7684\u60c5\u51b5\u90fd\u662f\u4e0d\u53ef\u907f\u514d\u7684\u3002\u4e0d\u8fc7\u53ea\u8981\u6211\u4eec\u79ef\u6781\u5730\u53bb\u5bfb\u627e\u89e3\u51b3\u65b9\u6cd5\uff0c\u95ee\u9898\u603b\u4f1a\u88ab\u89e3\u51b3\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fthinkphp\u9a8c\u8bc1\u7801\u9519\u8bef\u4e0d\u5237\u65b0\u600e\u4e48\u529e\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>thinkphp\u662f\u4e00\u6b3e\u57fa\u4e8emvc\u6a21\u5f0f\u7684\u5f00\u6e90web\u5e94\u7528\u6846\u67b6\uff0c\u5b83\u63d0\u4f9b\u4e86\u8bf8\u591a\u4f18\u79c0\u7684\u529f\u80fd\u548c\u7279\u6027\uff0c\u8ba9\u5f00\u53d1\u8005\u80fd\u591f\u66f4\u52a0\u9ad8\u6548\u5730\u5f00\u53d1web\u5e94\u7528\u3002\u5176\u4e2d\u4e4b\u4e00\u4fbf\u662f\u9a8c\u8bc1\u7801\u529f\u80fd\u3002\u9a8c\u8bc1\u7801\uff0c\u5168\u79f0\u4e3a\u201c\u56fe\u5f62\u9a8c\u8bc1\u7801\u201d\uff0c\u662f\u4e00\u79cd\u7528\u4e8e\u9632\u6b62\u6076\u610f\u673a\u5668\u4eba\u6ce8\u518c\u6216\u767b\u5f55\u7684\u6280\u672f\u624b\u6bb5\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u5f53\u7528\u6237\u8f93\u5165\u9519\u8bef\u7684\u9a8c\u8bc1\u7801\u65f6\uff0c\u7f51\u7ad9\u4f1a\u5237\u65b0\u6216\u91cd\u65b0\u751f\u6210\u4e00\u5f20\u9a8c\u8bc1\u7801\u56fe\u7247\u3002\u4f46\u662f\u6709\u4e00\u4e9b\u7528\u6237\u9047\u5230\u4e86thinkphp\u9a8c\u8bc1\u7801\u9519\u8bef\u5374\u4e0d\u5237\u65b0\u7684\u95ee\u9898\uff0c\u8fd9\u662f\u600e\u4e48\u56de\u4e8b\u5462\uff1f \u4e00\u3001\u95ee\u9898\u63cf\u8ff0 Thinkphp\u4e2d\uff0c\u9a8c\u8bc1\u7801\u7684\u751f\u6210\u548c\u6821\u9a8c\u4f7f\u7528\u7684\u662fThinkphp\u81ea\u5e26\u7684\u9a8c\u8bc1\u7801\u7c7b\u5e93\u3002\u5728\u4f7f\u7528\u8be5\u7c7b\u5e93\u65f6\uff0c\u7528\u6237\u4f1a\u53d1\u73b0\u51fa\u73b0\u4e86\u4e00\u79cd\u60c5\u51b5\uff0c\u5373\u5f53\u9a8c\u8bc1\u7801\u8f93\u5165\u9519\u8bef\u65f6\uff0c\u7f51\u7ad9\u4e0d\u4f1a\u7acb\u5373\u5237\u65b0\u9a8c\u8bc1\u7801\u3002\u5982\u679c\u7528\u6237\u8fde\u7eed\u591a\u6b21\u8f93\u5165\u9519\u8bef\u7684\u9a8c\u8bc1\u7801\uff0c\u7f51\u7ad9\u5e76\u6ca1\u6709\u66f4\u65b0\u9a8c\u8bc1\u7801\uff0c\u8fd9\u8ba9\u7528\u6237\u611f\u5230\u975e\u5e38\u4e0d\u4fbf\u3002 \u4e8c\u3001\u95ee\u9898\u5206\u6790 \u8be5\u95ee\u9898\u7684\u51fa\u73b0\u539f\u56e0\u662f\u56e0\u4e3a\u5728Thinkphp\u7684\u9a8c\u8bc1\u7801\u7c7b\u5e93\u4e2d\uff0c\u5b58\u5728\u4e00\u4e2a\u5c5e\u6027$reset\u4e3afalse\u7684\u65b9\u6cd5\u3002\u5f53\u8be5\u5c5e\u6027\u503c\u4e3afalse\u65f6\uff0c\u5373\u4e0d\u5237\u65b0\u9a8c\u8bc1\u7801\uff0c\u76f4\u81f3\u8fc7\u671f\u4e3a\u6b62\u3002\u6240\u4ee5\u5f53\u7528\u6237\u591a\u6b21\u8f93\u5165\u9519\u8bef\u7684\u9a8c\u8bc1\u7801\u65f6\uff0c\u7f51\u7ad9\u4e0d\u4f1a\u66f4\u65b0\u9a8c\u8bc1\u7801\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u4e09\u3001\u89e3\u51b3\u65b9\u6cd5 \u9488\u5bf9\u8be5\u95ee\u9898\uff0c\u89e3\u51b3\u65b9\u6cd5\u4e5f\u5f88\u7b80\u5355\uff0c\u53ea\u9700\u8981\u628a$reset\u5c5e\u6027\u503c\u4fee\u6539\u4e3atrue\u5373\u53ef\u3002\u4fee\u6539\u65b9\u6cd5\u5982\u4e0b\uff1a \u5728ThinkPHP\/Library\/Think\/Verify.class.php\u4e2d\u627e\u5230\u4ee5\u4e0b\u4ee3\u7801\uff1a \/\/\u662f\u5426\u753b\u6df7\u6dc6\u66f2\u7ebf public $useCurve = true; \/\/\u662f\u5426\u6dfb\u52a0\u6742\u70b9 public $useNoise = true; \/\/\u9a8c\u8bc1\u7801\u56fe\u7247\u5bbd\u5ea6 public $imageW = 130; \/\/\u9a8c\u8bc1\u7801\u56fe\u7247\u9ad8\u5ea6 public $imageH = 50; \/\/\u9a8c\u8bc1\u7801\u4f4d\u6570 public $length = 4; \/\/\u9a8c\u8bc1\u7801\u5b57\u4f53\u5927\u5c0f(px) public $fontSize = 25; \/\/\u662f\u5426\u753b\u989c\u8272\u80cc\u666f public $useZh = false; \/\/\u9a8c\u8bc1\u7801\u79cd\u5b50 protected $seed = &#8216;123456789QWERTYUIOPASDFGHJKLZXCVBNM&#8217;; \/\/\u751f\u6210\u9a8c\u8bc1\u7801 public function entry(){ \/\/\u9a8c\u8bc1\u7801\u5b57\u7b26 $this-&gt;code [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-22265","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/22265","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=22265"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/22265\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=22265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=22265"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=22265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}