{"id":31745,"date":"2024-11-25T13:10:32","date_gmt":"2024-11-25T05:10:32","guid":{"rendered":"https:\/\/fwq.ai\/blog\/31745\/"},"modified":"2024-11-25T13:10:32","modified_gmt":"2024-11-25T05:10:32","slug":"phpcms-%e4%b8%8d%e6%94%af%e6%8c%81-fsockopen-%e5%87%bd%e6%95%b0%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/31745\/","title":{"rendered":"PHPCMS \u4e0d\u652f\u6301 fsockopen \u51fd\u6570\u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/046\/5f152cc06a2d6373.jpg\" class=\"aligncenter\" title=\"PHPCMS \u4e0d\u652f\u6301 fsockopen \u51fd\u6570\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"PHPCMS \u4e0d\u652f\u6301 fsockopen \u51fd\u6570\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>PHPCMS \u4e0d\u652f\u6301 fsockopen \u51fd\u6570\u5982\u4f55\u89e3\u51b3\uff1f<\/strong><\/p>\n<p>1\u3001\u5b89\u88c5\u7684\u65f6\u5019\uff0c\u5728\u5730\u5740\u680f\u76f4\u63a5\u6539\u201cstep=3\u201d\uff0c\u8df3\u8fc7\u8fd9\u4e00\u6b65\u5373\u53ef\uff1b<\/p>\n<p>2\u3001\u5c06fsockopen\u51fd\u6570\u66ff\u6362\u4e3apfsockopen\u51fd\u6570\uff1b<\/p>\n<p>3\u3001\u4fee\u6539\u201cclient.class.php\u201d\u4e2d\u7684\u4ee3\u7801\u3002<strong><br \/><\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p><strong>PHP fsockopen\u51fd\u6570\u8bf4\u660e<\/strong><\/p>\n<p>\u8bed\u6cd5\uff1a<\/p>\n<pre>resource&nbsp;fsockopen&nbsp;(&nbsp;string&nbsp;$hostname&nbsp;[,&nbsp;int&nbsp;KaTeX&nbsp;parse&nbsp;error:&nbsp;Expected&nbsp;'EOF',&nbsp;got&nbsp;'&amp;amp;'&nbsp;at&nbsp;position&nbsp;20:&nbsp;\u2026&nbsp;=&nbsp;-1&nbsp;[,&nbsp;int&nbsp;&amp;amp;\u0332errno&nbsp;[,&nbsp;string&nbsp;&amp;amp;$errstr&nbsp;[,&nbsp;float&nbsp;$timeout&nbsp;=&nbsp;ini_get(\u201cdefault_socket_timeout\u201d)&nbsp;]]]]&nbsp;)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5f00\u542fPHP fsockopen\u8fd9\u4e2a\u51fd\u6570<\/p>\n<p>PHP fsockopen\u9700\u8981 PHP.ini \u4e2d allow_url_fopen \u9009\u9879\u5f00\u542f\u3002<\/p>\n<pre>allow_url_fopen&nbsp;=&nbsp;On<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u53c2\u6570\uff1a<\/p>\n<ul>\n<li>\n<p>hostname \u5982\u679c\u5b89\u88c5\u4e86OpenSSL\uff0c\u90a3\u4e48\u4f60\u4e5f\u8bb8\u5e94\u8be5\u5728\u4f60\u7684\u4e3b\u673a\u540d\u5730\u5740\u524d\u9762\u6dfb\u52a0\u8bbf\u95ee\u534f\u8baessl:\/\/\u6216\u8005\u662ftls:\/\/\uff0c\u4ece\u800c\u53ef\u4ee5\u4f7f\u7528\u57fa\u4e8eTCP\/IP\u534f\u8bae\u7684SSL\u6216\u8005TLS\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u5230\u8fdc\u7a0b\u4e3b\u673a\u3002<\/p>\n<\/li>\n<li>\n<p>port \u7aef\u53e3\u53f7\u3002\u5982\u679c\u5bf9\u8be5\u53c2\u6570\u4f20\u4e00\u4e2a-1\uff0c\u5219\u8868\u793a\u4e0d\u4f7f\u7528\u7aef\u53e3\uff0c\u4f8b\u5982unix:\/\/\u3002<\/p>\n<\/li>\n<li>\n<p>errno \u5982\u679cerrno\u7684\u8fd4\u56de\u503c\u4e3a0\uff0c\u800c\u4e14\u8fd9\u4e2a\u51fd\u6570\u7684\u8fd4\u56de\u503c\u4e3a FALSE \uff0c\u90a3\u4e48\u8fd9\u8868\u660e\u8be5\u9519\u8bef\u53d1\u751f\u5728\u5957\u63a5\u5b57\u8fde\u63a5\uff08connect()\uff09\u8c03\u7528\u4e4b\u524d\uff0c\u5bfc\u81f4\u8fde\u63a5\u5931\u8d25\u7684\u539f\u56e0\u6700\u5927\u7684\u53ef\u80fd\u662f\u521d\u59cb\u5316\u5957\u63a5\u5b57\u7684\u65f6\u5019\u53d1\u751f\u4e86\u9519\u8bef\u3002<\/p>\n<\/li>\n<li>\n<p>errstr \u9519\u8bef\u4fe1\u606f\u5c06\u4ee5\u5b57\u7b26\u4e32\u7684\u4fe1\u606f\u8fd4\u56de\u3002<\/p>\n<\/li>\n<li>\n<p>timeout \u8bbe\u7f6e\u8fde\u63a5\u7684\u65f6\u9650\uff0c\u5355\u4f4d\u4e3a\u79d2\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u8fd4\u56de\u503c\uff1a<\/p>\n<p>fsockopen() \u5c06\u8fd4\u56de\u4e00\u4e2a\u6587\u4ef6\u53e5\u67c4\uff0c\u4e4b\u540e\u53ef\u4ee5\u88ab\u5176\u4ed6\u6587\u4ef6\u7c7b\u51fd\u6570\u8c03\u7528\uff08\u4f8b\u5982\uff1a fgets() \uff0c fgetss() \uff0c fwrite() \uff0c fclose() \u8fd8\u6709 feof() \uff09\u3002\u5982\u679c\u8c03\u7528\u5931\u8d25\uff0c\u5c06\u8fd4\u56de FALSE \u3002<\/p>\n<p>\u63a8\u8350\u6559\u7a0b\uff1a\u300a\u300b\u300a\/&#8221; target=&#8221;_blank&#8221;&gt;PHPCMS\u6559\u7a0b\u300b<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fPHPCMS \u4e0d\u652f\u6301 fsockopen \u51fd\u6570\u5982\u4f55\u89e3\u51b3\uff1f\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>PHPCMS \u4e0d\u652f\u6301 fsockopen \u51fd\u6570\u5982\u4f55\u89e3\u51b3\uff1f 1\u3001\u5b89\u88c5\u7684\u65f6\u5019\uff0c\u5728\u5730\u5740\u680f\u76f4\u63a5\u6539\u201cstep=3\u201d\uff0c\u8df3\u8fc7\u8fd9\u4e00\u6b65\u5373\u53ef\uff1b 2\u3001\u5c06fsockopen\u51fd\u6570\u66ff\u6362\u4e3apfsockopen\u51fd\u6570\uff1b 3\u3001\u4fee\u6539\u201cclient.class.php\u201d\u4e2d\u7684\u4ee3\u7801\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b PHP fsockopen\u51fd\u6570\u8bf4\u660e \u8bed\u6cd5\uff1a resource&nbsp;fsockopen&nbsp;(&nbsp;string&nbsp;$hostname&nbsp;[,&nbsp;int&nbsp;KaTeX&nbsp;parse&nbsp;error:&nbsp;Expected&nbsp;&#8216;EOF&#8217;,&nbsp;got&nbsp;&#8216;&amp;amp;&#8217;&nbsp;at&nbsp;position&nbsp;20:&nbsp;\u2026&nbsp;=&nbsp;-1&nbsp;[,&nbsp;int&nbsp;&amp;amp;\u0332errno&nbsp;[,&nbsp;string&nbsp;&amp;amp;$errstr&nbsp;[,&nbsp;float&nbsp;$timeout&nbsp;=&nbsp;ini_get(\u201cdefault_socket_timeout\u201d)&nbsp;]]]]&nbsp;) \u767b\u5f55\u540e\u590d\u5236 \u5f00\u542fPHP fsockopen\u8fd9\u4e2a\u51fd\u6570 PHP fsockopen\u9700\u8981 PHP.ini \u4e2d allow_url_fopen \u9009\u9879\u5f00\u542f\u3002 allow_url_fopen&nbsp;=&nbsp;On \u767b\u5f55\u540e\u590d\u5236 \u53c2\u6570\uff1a hostname \u5982\u679c\u5b89\u88c5\u4e86OpenSSL\uff0c\u90a3\u4e48\u4f60\u4e5f\u8bb8\u5e94\u8be5\u5728\u4f60\u7684\u4e3b\u673a\u540d\u5730\u5740\u524d\u9762\u6dfb\u52a0\u8bbf\u95ee\u534f\u8baessl:\/\/\u6216\u8005\u662ftls:\/\/\uff0c\u4ece\u800c\u53ef\u4ee5\u4f7f\u7528\u57fa\u4e8eTCP\/IP\u534f\u8bae\u7684SSL\u6216\u8005TLS\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u5230\u8fdc\u7a0b\u4e3b\u673a\u3002 port \u7aef\u53e3\u53f7\u3002\u5982\u679c\u5bf9\u8be5\u53c2\u6570\u4f20\u4e00\u4e2a-1\uff0c\u5219\u8868\u793a\u4e0d\u4f7f\u7528\u7aef\u53e3\uff0c\u4f8b\u5982unix:\/\/\u3002 errno \u5982\u679cerrno\u7684\u8fd4\u56de\u503c\u4e3a0\uff0c\u800c\u4e14\u8fd9\u4e2a\u51fd\u6570\u7684\u8fd4\u56de\u503c\u4e3a FALSE \uff0c\u90a3\u4e48\u8fd9\u8868\u660e\u8be5\u9519\u8bef\u53d1\u751f\u5728\u5957\u63a5\u5b57\u8fde\u63a5\uff08connect()\uff09\u8c03\u7528\u4e4b\u524d\uff0c\u5bfc\u81f4\u8fde\u63a5\u5931\u8d25\u7684\u539f\u56e0\u6700\u5927\u7684\u53ef\u80fd\u662f\u521d\u59cb\u5316\u5957\u63a5\u5b57\u7684\u65f6\u5019\u53d1\u751f\u4e86\u9519\u8bef\u3002 errstr \u9519\u8bef\u4fe1\u606f\u5c06\u4ee5\u5b57\u7b26\u4e32\u7684\u4fe1\u606f\u8fd4\u56de\u3002 timeout \u8bbe\u7f6e\u8fde\u63a5\u7684\u65f6\u9650\uff0c\u5355\u4f4d\u4e3a\u79d2\u3002 \u8fd4\u56de\u503c\uff1a fsockopen() \u5c06\u8fd4\u56de\u4e00\u4e2a\u6587\u4ef6\u53e5\u67c4\uff0c\u4e4b\u540e\u53ef\u4ee5\u88ab\u5176\u4ed6\u6587\u4ef6\u7c7b\u51fd\u6570\u8c03\u7528\uff08\u4f8b\u5982\uff1a fgets() \uff0c fgetss() \uff0c fwrite() \uff0c fclose() \u8fd8\u6709 feof() \uff09\u3002\u5982\u679c\u8c03\u7528\u5931\u8d25\uff0c\u5c06\u8fd4\u56de FALSE \u3002 \u63a8\u8350\u6559\u7a0b\uff1a\u300a\u300b\u300a\/&#8221; target=&#8221;_blank&#8221;&gt;PHPCMS\u6559\u7a0b\u300b \u4ee5\u4e0a\u5c31\u662fPHPCMS \u4e0d\u652f\u6301 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-31745","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31745","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=31745"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31745\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=31745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=31745"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=31745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}