{"id":30933,"date":"2024-11-25T17:21:20","date_gmt":"2024-11-25T09:21:20","guid":{"rendered":"https:\/\/fwq.ai\/blog\/30933\/"},"modified":"2024-11-25T17:21:20","modified_gmt":"2024-11-25T09:21:20","slug":"phpcms%e4%b8%8d%e8%83%bd%e5%8a%a0%e6%b0%b4%e5%8d%b0%e6%80%8e%e4%b9%88%e5%8a%9e","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/30933\/","title":{"rendered":"phpcms\u4e0d\u80fd\u52a0\u6c34\u5370\u600e\u4e48\u529e"},"content":{"rendered":"<p style=\"text-align: center\"><strong><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/020\/5e13ed870d5fb607.jpg\" class=\"aligncenter\" title=\"phpcms\u4e0d\u80fd\u52a0\u6c34\u5370\u600e\u4e48\u529e\u63d2\u56fe\" alt=\"phpcms\u4e0d\u80fd\u52a0\u6c34\u5370\u600e\u4e48\u529e\u63d2\u56fe\" \/><\/strong><\/p>\n<p><strong>\u4e0d\u80fd\u52a0\u6c34\u5370\u600e\u4e48\u529e\uff1f<\/strong><\/p>\n<p>phpcms\u8fdc\u7a0b\u56fe\u7247\u672c\u5730\u5316\u4e0d\u6210\u529f\u53ca\u52a0\u6c34\u5370\u529f\u80fd\u5931\u6548\u7684\u89e3\u51b3\u6559\u7a0b<\/p>\n<p>\u5177\u4f53\u4fee\u6539\u5982\u4e0b\uff1a include\/attachment.class.php \u6dfb\u52a0\u4e86\u4e00\u4e2a\u51fd\u6570<\/p>\n<p>\u4ee3\u7801\u5982\u4e0b:<\/p>\n<pre>function&nbsp;ycimg($file,$newfile)\n{\n\/\/&nbsp;\u521d\u59cb\u5316\u4e00\u4e2a&nbsp;cURL&nbsp;\u5bf9\u8c61\n$curl&nbsp;=&nbsp;curl_init();\n\/\/&nbsp;\u8bbe\u7f6e\u4f60\u9700\u8981\u6293\u53d6\u7684URL\ncurl_setopt($curl,&nbsp;CURLOPT_URL,&nbsp;$file);\n\/\/&nbsp;\u8bbe\u7f6eheader\ncurl_setopt($curl,&nbsp;CURLOPT_HEADER,&nbsp;0);\n\/\/&nbsp;\u8bbe\u7f6ecURL&nbsp;\u53c2\u6570\uff0c\u8981\u6c42\u7ed3\u679c\u4fdd\u5b58\u5230\u5b57\u7b26\u4e32\u4e2d\u8fd8\u662f\u8f93\u51fa\u5230\u5c4f\u5e55\u4e0a\u3002\ncurl_setopt($curl,&nbsp;CURLOPT_RETURNTRANSFER,&nbsp;1);\n\/\/&nbsp;\u8fd0\u884ccURL\uff0c\u8bf7\u6c42\u7f51\u9875\n$data&nbsp;=&nbsp;curl_exec($curl);\n\/\/&nbsp;\u5173\u95edURL\u8bf7\u6c42\ncurl_close($curl);\n\/\/\u5199\u5165\u83b7\u5f97\u7684\u6570\u636e\n$write&nbsp;=&nbsp;@fopen($newfile,\"w\");\nfwrite($write,$data);\nfclose($write);\nreturn&nbsp;TRUE;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u91cc\u53ef\u80fd\u6709\u70b9\u5c0f\u95ee\u9898.\u4e0d\u8fc7\u6d4b\u8bd5\u7684\u65f6\u5019\u90fd\u53ef\u4ee5\u6210\u529f\u6293\u53d6.\u6240\u4ee5\u76f4\u63a5\u8ba9\u4ed6\u8fd4\u56de\u4e86 TRUE .\u6709\u5174\u8da3\u7684\u670b\u53cb\u53ef\u4ee5\u7ee7\u7eed\u5b8c\u5584\u4e0b\u8fd9\u4e2a\u51fd\u6570.<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u7136\u540e\u5728\u8fd9\u6587\u4ef6\u91cc\u627e\u5230<\/p>\n<pre>if(@$upload_func($file,&nbsp;$newfile))<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4fee\u6539\u4e3a\uff1a<\/p>\n<pre>if($this-&amp;gt;ycimg($file,$newfile))<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6700\u540e\u53bb\u6389\uff1a<\/p>\n<pre>@chmod($newfile,&nbsp;0777);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u4e00\u6bb5\u4ee3\u7801.<\/p>\n<p>\u8fd9\u6837\u8fdc\u7a0b\u6293\u53d6\u7684\u65f6\u5019\u6210\u529f\u7387\u5c31\u5f88\u9ad8\u4e86.\u672c\u5730\u6d4b\u8bd5\u7684\u65f6\u5019\u6210\u529f\u7387100%,\u800ccopy\u51fd\u6570\u6210\u529f\u7387\u4e0d\u523070% \u2026\u2026<\/p>\n<p>\u4e0a\u9762\u8bf4\u8fc7,\u7f51\u7edc\u56e0\u7d20\u5f71\u54cd\u6bd4\u8f83\u5927.<\/p>\n<p>\u518d\u5c31\u662f\u8fdc\u7a0b\u4fdd\u5b58\u7684\u56fe\u7247\u52a0\u6c34\u5370\u7684\u529f\u80fd.<\/p>\n<p>\u540c\u6837\u8fd8\u662f\u8fd9\u4e2a\u6587\u4ef6.\u627e\u5230\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre>$this-&amp;gt;downloadedfiles[$aid]&nbsp;=&nbsp;$filepath;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u4e0b\u9762\u52a0\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p>\u4ee3\u7801\u5982\u4e0b:<\/p>\n<pre>$waterpath&nbsp;=&nbsp;UPLOAD_URL.$filepath;\nrequire_once&nbsp;'image.class.php';\n$image&nbsp;=&nbsp;new&nbsp;image();\n$image-&amp;gt;watermark($waterpath,&nbsp;'',&nbsp;'9',&nbsp;'images\/watermark.gif',&nbsp;'',&nbsp;'5',&nbsp;'#ff0000',&nbsp;'80','100');<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6c34\u5370\u53c2\u6570\u53ea\u80fd\u8fd9\u91cc\u8c03\u6574,\u7cfb\u7edf\u91cc\u7684\u8bbe\u7f6e\u65e0\u6548\u2026\u2026<\/p>\n<p>PHP\u4e2d\u6587\u7f51\uff0c\u5927\u91cf\u7684\u514d\u8d39\uff0c\u6b22\u8fce\u5728\u7ebf\u5b66\u4e60\uff01<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4e0d\u80fd\u52a0\u6c34\u5370\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>\u4e0d\u80fd\u52a0\u6c34\u5370\u600e\u4e48\u529e\uff1f phpcms\u8fdc\u7a0b\u56fe\u7247\u672c\u5730\u5316\u4e0d\u6210\u529f\u53ca\u52a0\u6c34\u5370\u529f\u80fd\u5931\u6548\u7684\u89e3\u51b3\u6559\u7a0b \u5177\u4f53\u4fee\u6539\u5982\u4e0b\uff1a include\/attachment.class.php \u6dfb\u52a0\u4e86\u4e00\u4e2a\u51fd\u6570 \u4ee3\u7801\u5982\u4e0b: function&nbsp;ycimg($file,$newfile) { \/\/&nbsp;\u521d\u59cb\u5316\u4e00\u4e2a&nbsp;cURL&nbsp;\u5bf9\u8c61 $curl&nbsp;=&nbsp;curl_init(); \/\/&nbsp;\u8bbe\u7f6e\u4f60\u9700\u8981\u6293\u53d6\u7684URL curl_setopt($curl,&nbsp;CURLOPT_URL,&nbsp;$file); \/\/&nbsp;\u8bbe\u7f6eheader curl_setopt($curl,&nbsp;CURLOPT_HEADER,&nbsp;0); \/\/&nbsp;\u8bbe\u7f6ecURL&nbsp;\u53c2\u6570\uff0c\u8981\u6c42\u7ed3\u679c\u4fdd\u5b58\u5230\u5b57\u7b26\u4e32\u4e2d\u8fd8\u662f\u8f93\u51fa\u5230\u5c4f\u5e55\u4e0a\u3002 curl_setopt($curl,&nbsp;CURLOPT_RETURNTRANSFER,&nbsp;1); \/\/&nbsp;\u8fd0\u884ccURL\uff0c\u8bf7\u6c42\u7f51\u9875 $data&nbsp;=&nbsp;curl_exec($curl); \/\/&nbsp;\u5173\u95edURL\u8bf7\u6c42 curl_close($curl); \/\/\u5199\u5165\u83b7\u5f97\u7684\u6570\u636e $write&nbsp;=&nbsp;@fopen($newfile,&#8221;w&#8221;); fwrite($write,$data); fclose($write); return&nbsp;TRUE; } \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u91cc\u53ef\u80fd\u6709\u70b9\u5c0f\u95ee\u9898.\u4e0d\u8fc7\u6d4b\u8bd5\u7684\u65f6\u5019\u90fd\u53ef\u4ee5\u6210\u529f\u6293\u53d6.\u6240\u4ee5\u76f4\u63a5\u8ba9\u4ed6\u8fd4\u56de\u4e86 TRUE .\u6709\u5174\u8da3\u7684\u670b\u53cb\u53ef\u4ee5\u7ee7\u7eed\u5b8c\u5584\u4e0b\u8fd9\u4e2a\u51fd\u6570. \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u7136\u540e\u5728\u8fd9\u6587\u4ef6\u91cc\u627e\u5230 if(@$upload_func($file,&nbsp;$newfile)) \u767b\u5f55\u540e\u590d\u5236 \u4fee\u6539\u4e3a\uff1a if($this-&amp;gt;ycimg($file,$newfile)) \u767b\u5f55\u540e\u590d\u5236 \u6700\u540e\u53bb\u6389\uff1a @chmod($newfile,&nbsp;0777); \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u4e00\u6bb5\u4ee3\u7801. \u8fd9\u6837\u8fdc\u7a0b\u6293\u53d6\u7684\u65f6\u5019\u6210\u529f\u7387\u5c31\u5f88\u9ad8\u4e86.\u672c\u5730\u6d4b\u8bd5\u7684\u65f6\u5019\u6210\u529f\u7387100%,\u800ccopy\u51fd\u6570\u6210\u529f\u7387\u4e0d\u523070% \u2026\u2026 \u4e0a\u9762\u8bf4\u8fc7,\u7f51\u7edc\u56e0\u7d20\u5f71\u54cd\u6bd4\u8f83\u5927. \u518d\u5c31\u662f\u8fdc\u7a0b\u4fdd\u5b58\u7684\u56fe\u7247\u52a0\u6c34\u5370\u7684\u529f\u80fd. \u540c\u6837\u8fd8\u662f\u8fd9\u4e2a\u6587\u4ef6.\u627e\u5230\u4ee5\u4e0b\u4ee3\u7801\uff1a $this-&amp;gt;downloadedfiles[$aid]&nbsp;=&nbsp;$filepath; \u767b\u5f55\u540e\u590d\u5236 \u5728\u4e0b\u9762\u52a0\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a \u4ee3\u7801\u5982\u4e0b: $waterpath&nbsp;=&nbsp;UPLOAD_URL.$filepath; require_once&nbsp;&#8216;image.class.php&#8217;; $image&nbsp;=&nbsp;new&nbsp;image(); $image-&amp;gt;watermark($waterpath,&nbsp;&#8221;,&nbsp;&#8216;9&#8217;,&nbsp;&#8216;images\/watermark.gif&#8217;,&nbsp;&#8221;,&nbsp;&#8216;5&#8217;,&nbsp;&#8216;#ff0000&#8242;,&nbsp;&#8217;80&#8217;,&#8217;100&#8242;); \u767b\u5f55\u540e\u590d\u5236 [&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-30933","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30933","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=30933"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30933\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=30933"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=30933"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=30933"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}