{"id":552,"date":"2020-03-30T10:10:51","date_gmt":"2020-03-30T10:10:51","guid":{"rendered":"http:\/\/www.nywzjs.com\/?p=552"},"modified":"2020-03-30T10:10:51","modified_gmt":"2020-03-30T10:10:51","slug":"%e8%ae%a9phpcms%e6%94%af%e6%8c%81https","status":"publish","type":"post","link":"http:\/\/www.nywzjs.com\/?p=552","title":{"rendered":"\u8ba9phpcms\u652f\u6301https"},"content":{"rendered":"<div id=\"articleContent\" class=\"content\">\n<p>\u672c\u6587\u6574\u7406\u81eaPHPCMS\u5b98\u65b9\u8bba\u575b\u7684\u4e00\u7bc7\u6587\u7ae0\uff0c\u611f\u8c22\u4f5c\u8005\u7684\u5949\u732e\u3002<\/p>\n<p>\u5047\u8bbe\u5df2\u7ecf\u914d\u7f6e\u597dssl\u8bc1\u4e66\uff0c\u4e0d\u77e5\u5982\u4f55\u7533\u8bf7ssl\u8bc1\u4e66\u8005\u8bf7\u81ea\u884c\u767e\u5ea6\u3002<\/p>\n<p><strong>1\u3001\u5982\u679c\u5df2\u7ecf\u5b89\u88c5\u597dphpcms\uff0c\u5219\u9700\u8981\u5bf9caches\/configs\/system.php\u4e2d\u7684\u914d\u7f6e\u9009\u9879\u505a\u66ff\u6362\uff0c<\/strong>\u5c06\"http:\/\/\"\u5168\u90e8\u66ff\u6362\u4e3a\"https:\/\/\"\u3002\u5982\u6709\u5fc5\u8981\uff0c\u6570\u636e\u5e93\u4e2d\u5df2\u5b58\u5728\u7684\u94fe\u63a5\u4e5f\u8981\u5b8c\u5168\u66ff\u6362\u4e3ahttps\u5f00\u5934\u3002<\/p>\n<p><strong>2\u3001\u7a0b\u5e8f\u4fee\u6539\u90e8\u5206\uff1a<\/strong><br \/>\n<strong>\uff081\uff09<\/strong>\u4fee\u6539phpcms\/modules\/admin\/site.php \u5927\u7ea645\u884c\u548c128\u884c\u7684\u6b63\u5219<\/p>\n<pre><code class=\"hljs php\">(<span class=\"hljs-string\">'\/http:\\\/\\\/(.+)\\\/$\/i'<\/span>, $domain))<\/code><\/pre>\n<p>\u4fee\u6539\u4e3a<\/p>\n<pre><code class=\"hljs php\">(<span class=\"hljs-string\">'\/(http|https):\\\/\\\/(.+)\\\/$\/i'<\/span>, $domain))<\/code><\/pre>\n<p><strong>\uff082\uff09<\/strong>\u4fee\u6539phpcms\/modules\/admin\/templates\/setting.tpl.php \u5927\u7ea618\u884c\u4e2d\u7684\u6b63\u5219<\/p>\n<pre><code class=\"hljs\">http:\\\/\\\/(.+)[^\/]$<\/code><\/pre>\n<p>\u4fee\u6539\u4e3a<\/p>\n<pre><code class=\"hljs\">http[s]?:\\\/\\\/(.+)[^\/]$<\/code><\/pre>\n<p><strong>\uff083\uff09<\/strong>\u4fee\u6539phpcms\/modules\/admin\/templates\/site_add.tpl.php \u5927\u7ea613\u884c\u4e2d\u7684\u6b63\u5219<\/p>\n<pre><code class=\"hljs\">http:\\\/\\\/(.+)\\\/$<\/code><\/pre>\n<p>\u4fee\u6539\u4e3a<\/p>\n<pre><code class=\"hljs\">http[s]?:\\\/\\\/(.+)\\\/$<\/code><\/pre>\n<p><strong>\uff084\uff09<\/strong>\u4fee\u6539phpcms\/modules\/admin\/templates\/site_edit.tpl.php \u5927\u7ea611\u884c\u4e2d\u7684\u6b63\u5219<\/p>\n<pre><code class=\"hljs\">http:\\\/\\\/(.+)\\\/$<\/code><\/pre>\n<p>\u4fee\u6539\u4e3a<\/p>\n<pre><code class=\"hljs\">http[s]?:\\\/\\\/(.+)\\\/$<\/code><\/pre>\n<p><strong>\uff085\uff09<\/strong>\u4fee\u6539phpcms\/modules\/link\/index.php \u5927\u7ea641\u884c\u548c51\u884c\u4e2d\u7684\u6b63\u5219<\/p>\n<pre><code class=\"hljs\">\/^http:\\\/\\\/(.*)\/i<\/code><\/pre>\n<p>\u4fee\u6539\u4e3a<\/p>\n<pre><code class=\"hljs\">\/^http[s]?:\\\/\\\/(.*)\/i<\/code><\/pre>\n<p><strong>\uff086\uff09<\/strong>\u4fee\u6539phpcms\/modules\/link\/templates\/link_add.tpl.php \u5927\u7ea610\u884c\u4e2d\u7684\u6b63\u5219<\/p>\n<pre><code class=\"hljs javascript\">^http:\\\/\\\/[A-Za-z0<span class=\"hljs-number\">-9<\/span>]+\\.[A-Za-z0<span class=\"hljs-number\">-9<\/span>]+[\\\/=\\?%\\-&amp;]*([^<span class=\"xml\"><span class=\"hljs-tag\">&lt;&gt;<\/span>])*$<\/span><\/code><\/pre>\n<p>\u4fee\u6539\u4e3a<\/p>\n<pre><code class=\"hljs javascript\">^http[s]?:\\\/\\\/[A-Za-z0<span class=\"hljs-number\">-9<\/span>]+\\.[A-Za-z0<span class=\"hljs-number\">-9<\/span>]+[\\\/=\\?%\\-&amp;]*([^<span class=\"xml\"><span class=\"hljs-tag\">&lt;&gt;<\/span>])*$<\/span><\/code><\/pre>\n<p><strong>\uff087\uff09<\/strong>\u4fee\u6539phpcms\/modules\/link\/templates\/link_edit.tpl.php \u5927\u7ea611\u884c\u4e2d\u7684\u6b63\u5219<\/p>\n<pre><code class=\"hljs javascript\">^http:\\\/\\\/[A-Za-z0<span class=\"hljs-number\">-9<\/span>]+\\.[A-Za-z0<span class=\"hljs-number\">-9<\/span>]+[\\\/=\\?%\\-&amp;]*([^<span class=\"xml\"><span class=\"hljs-tag\">&lt;&gt;<\/span>])*$<\/span><\/code><\/pre>\n<p>\u4fee\u6539\u4e3a<\/p>\n<pre><code class=\"hljs javascript\">^http[s]?:\\\/\\\/[A-Za-z0<span class=\"hljs-number\">-9<\/span>]+\\.[A-Za-z0<span class=\"hljs-number\">-9<\/span>]+[\\\/=\\?%\\-&amp;]*([^<span class=\"xml\"><span class=\"hljs-tag\">&lt;&gt;<\/span>])*$<\/span><\/code><\/pre>\n<p>\u4e25\u683c\u6309\u7167\u4ee5\u4e0a\u6b65\u9aa4\u4fee\u6539\u540e\uff0c\u6ce8\u518c\u7528\u6237 \u5e10\u53f7\u767b\u5f55\u7b49\u64cd\u4f5c\u5b8c\u5168\u6b63\u5e38 \u548cPHPSSO\u901a\u4fe1\u5b8c\u5168\u6b63\u5e38\uff0c\u540e\u53f0\u6dfb\u52a0\u4fe1\u606f\u548c\u524d\u53f0\u94fe\u63a5URL\u5b8c\u5168\u6b63\u5e38<\/p>\n<p>\u6ce8\u610f\uff1a<br \/>\na.\u5982\u6ce8\u518c\u7528\u6237\u63d0\u793a\u2018\u64cd\u4f5c\u5931\u8d25\u2019\uff0c\u8bf7\u5728\u540e\u53f0\u4f1a\u5458\u6a21\u5757\u8bbe\u7f6e\u4e2d\u5173\u95ed\u2018\u6ce8\u518c\u65f6\u53ef\u9009\u4f1a\u5458\u6a21\u578b\u2019\u6216\u8005\u4fdd\u8bc1\u4f1a\u5458\u4e0d\u5c11\u4e8e\u4e24\u4e2a\u4f1a\u5458\u6a21\u578b<\/p>\n<p>b.\u5728PHP5.6\u6216\u4ee5\u4e0a\u7684PHP\u7248\u672c\u4e2d\u4f1a\u51fa\u73b0\u548cPHPSSO\u65e0\u6cd5\u6b63\u5e38\u901a\u4fe1\u7684\u60c5\u51b5\uff0c\u56e0\u4e3aPHP5.6\u53ca\u4ee5\u4e0afsockopen\u548cfile_get_contents\u7b49\u51fd\u6570openssl\u9700\u8981\u9a8c\u8bc1\u76ee\u6807\u7684SSL\u8bc1\u4e66\u662f\u5426\u53ef\u4fe1\uff0c\u9700\u8981\u5b89\u88c5openssl\u6839\u8bc1\u4e66\u624d\u53ef\u4ee5\uff0c\u5426\u5219openssl\u4f1a\u62a5\u8b66\u544a\u4fe1\u606f \u8bc1\u4e66\u9a8c\u8bc1\u5931\u8d25\uff01<br \/>\n\u5982\u9700\u5728php5.6\u6216\u4ee5\u4e0a\u7248\u672c\u4e2d\u4f7f\u7528HTTPS\u7684\u8bf7\u53c2\u9605PHP\u5b98\u65b9\u6709\u5173php5.6\u548copenssl\u7684\u8d44\u6599<a href=\"http:\/\/php.net\/manual\/en\/migration56.openssl.php\" rel=\"nofollow\">http:\/\/php.net\/manual\/en\/migration56.openssl.php<\/a><\/p>\n<p><strong>3\u3001\u7ecf\u8fc7\u4e0a\u9762\u4fee\u6539\u540e\uff0cphpcms\u4e2d\u7684\u5185\u5bb9\u53ef\u901a\u8fc7https\u8bbf\u95ee\uff0c\u4f46\u5206\u9875\u51fa\u73b0\u9519\u8bef\u3002\u89e3\u51b3\u65b9\u6cd5\u4e3a\uff1a<\/strong><br \/>\n\u6253\u5f00\u6587\u4ef6 phpcms\\libs\\functions \\global.func.php \uff0c\u627e\u5230738\u884c\u7684\u4f4d\u7f6e\uff1a<\/p>\n<pre><code class=\"hljs php\">$url = str_replace(<span class=\"hljs-keyword\">array<\/span>(<span class=\"hljs-string\">'http:\/\/'<\/span>,<span class=\"hljs-string\">'\/\/'<\/span>,<span class=\"hljs-string\">'~'<\/span>), <span class=\"hljs-keyword\">array<\/span>(<span class=\"hljs-string\">'~'<\/span>,<span class=\"hljs-string\">'\/'<\/span>,<span class=\"hljs-string\">'http:\/\/'<\/span>), $url);<\/code><\/pre>\n<p>\u4fee\u6539\u4e3a<\/p>\n<pre><code class=\"hljs php\">$url = str_replace(<span class=\"hljs-keyword\">array<\/span>(<span class=\"hljs-string\">'https:\/\/'<\/span>,<span class=\"hljs-string\">'\/\/'<\/span>,<span class=\"hljs-string\">'~'<\/span>), <span class=\"hljs-keyword\">array<\/span>(<span class=\"hljs-string\">'~'<\/span>,<span class=\"hljs-string\">'\/'<\/span>,<span class=\"hljs-string\">'https:\/\/'<\/span>), $url);<\/code><\/pre>\n<p>\u7ecf\u8fc7\u4ee5\u4e0a\u4e09\u6b65\uff0cphpcms\u5b8c\u7f8e\u652f\u6301https\uff0c\u7ed3\u5408\u9875\u9762\u9759\u6001\u5316\u548curl\u4f2a\u9759\u6001\u89c4\u5219\uff0c\u4eb2\u6d4b\u9759\u6001\u9875\u9762\u4e5f\u53ef\u7528https\u3002<br \/>\n<strong>\u6b64\u65f6\u7684\u7f51\u7ad9\u5b9e\u9645\u4e0a\u901a\u8fc7http\u548chttps\u90fd\u80fd\u8bbf\u95ee<\/strong>\uff0c\u5982\u679c\u8981\u5f3a\u5236\u5168\u7ad9\u8df3\u8f6c\u5230https\uff0c\u8bf7\u7ee7\u7eed\u770b\u53e6\u4e00\u7bc7\u535a\u5ba2\u00a0<strong><a href=\"https:\/\/my.oschina.net\/codercpf\/blog\/3082342\" rel=\"nofollow\">Apache\u73af\u5883\u4e0b\u5f3a\u5236\u8df3\u8f6c\u5230https<\/a><\/strong><\/p>\n<\/div>\n<p>\u8f6c\u8f7d\u4e8e:https:\/\/my.oschina.net\/codercpf\/blog\/3082332<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u6574\u7406\u81eaPHPCMS\u5b98\u65b9\u8bba\u575b\u7684\u4e00\u7bc7\u6587\u7ae0\uff0c\u611f\u8c22\u4f5c\u8005\u7684\u5949\u732e\u3002 \u5047\u8bbe\u5df2\u7ecf\u914d\u7f6e\u597dssl\u8bc1\u4e66\uff0c\u4e0d\u77e5\u5982\u4f55\u7533\u8bf7ssl\u8bc1\u4e66\u8005 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,13],"tags":[45,79],"_links":{"self":[{"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=\/wp\/v2\/posts\/552"}],"collection":[{"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=552"}],"version-history":[{"count":0,"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=\/wp\/v2\/posts\/552\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=552"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=552"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=552"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}