{"id":60738,"date":"2025-04-26T12:20:41","date_gmt":"2025-04-26T04:20:41","guid":{"rendered":"https:\/\/fwq.ai\/blog\/60738\/"},"modified":"2025-04-26T12:20:41","modified_gmt":"2025-04-26T04:20:41","slug":"zencart%e5%90%8e%e5%8f%b0ckeditor%e7%bc%96%e8%be%91%e5%99%a8%e5%a2%9e%e5%8a%a0%e5%9b%be%e7%89%87%e4%b8%8a%e4%bc%a0%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/60738\/","title":{"rendered":"zencart\u540e\u53f0CKeditor\u7f16\u8f91\u5668\u589e\u52a0\u56fe\u7247\u4e0a\u4f20\u529f\u80fd"},"content":{"rendered":"<p> 1.\u4fee\u6539\u7f51\u7ad9\u6839\u76ee\u5f55\u6587\u4ef6\u5939editors\\ckeditor\\config.js \u6587\u4ef6\uff0c\u5728CKEDITOR.editorConfig&nbsp;=&nbsp;function(&nbsp;config&nbsp;) &nbsp;&nbsp;{ &nbsp;&nbsp;}; \u4e2d\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p> config.filebrowserImageUploadUrl&nbsp;=&nbsp;&#8216;.\/upload.php?type=img&#8217;;<\/p>\n<p> config.filebrowserFlashUploadUrl&nbsp;=&nbsp;&#8216;.\/upload.php?type=flash&#8217;;<\/p>\n<p> 2.\u5728admin\u6587\u4ef6\u5939\u4e2d\u65b0\u5efaupload.php\u6587\u4ef6\uff0c\u5728\u5176\u4e2d\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p> &lt;?php<br \/> \/*<br \/> CKEditor_upload.php<br \/> monkee<br \/> 2009-11-15 16:47<br \/> *\/<br \/> $config=array();<\/p>\n<p> $config[&#8216;type&#8217;]=array(&#8220;flash&#8221;,&#8221;img&#8221;); \/\/\u4e0a\u4f20\u5141\u8bb8type\u503c<\/p>\n<p> $config[&#8216;img&#8217;]=array(&#8220;jpg&#8221;,&#8221;bmp&#8221;,&#8221;gif&#8221;); \/\/img\u5141\u8bb8\u540e\u7f00<br \/> $config[&#8216;flash&#8217;]=array(&#8220;flv&#8221;,&#8221;swf&#8221;); \/\/flash\u5141\u8bb8\u540e\u7f00<\/p>\n<p> $config[&#8216;flash_size&#8217;]=200; \/\/\u4e0a\u4f20flash\u5927\u5c0f\u4e0a\u9650 \u5355\u4f4d\uff1aKB<br \/> $config[&#8216;img_size&#8217;]=500; \/\/\u4e0a\u4f20img\u5927\u5c0f\u4e0a\u9650 \u5355\u4f4d\uff1aKB<\/p>\n<p> $config[&#8216;message&#8217;]=&#8221;\u4e0a\u4f20\u6210\u529f,upload success!&#8221;; \/\/\u4e0a\u4f20\u6210\u529f\u540e\u663e\u793a\u7684\u6d88\u606f\uff0c\u82e5\u4e3a\u7a7a\u5219\u4e0d\u663e\u793a<\/p>\n<p> $config[&#8216;name&#8217;]=mktime(); \/\/\u4e0a\u4f20\u540e\u7684\u6587\u4ef6\u547d\u540d\u89c4\u5219 \u8fd9\u91cc\u4ee5unix\u65f6\u95f4\u6233\u6765\u547d\u540d<\/p>\n<p> $config[&#8216;flash_dir&#8217;]=&#8221;\/editors\/ckeditor\/upload\/flash&#8221;; \/\/\u4e0a\u4f20flash\u6587\u4ef6\u5730\u5740 \u91c7\u7528\u7edd\u5bf9\u5730\u5740 \u65b9\u4fbfupload.php\u6587\u4ef6\u653e\u5728\u7ad9\u5185\u7684\u4efb\u4f55\u4f4d\u7f6e \u540e\u9762\u4e0d\u52a0&#8221;\/&#8221;<br \/> $config[&#8216;img_dir&#8217;]=&#8221;\/editors\/ckeditor\/upload\/img&#8221;; \/\/\u4e0a\u4f20img\u6587\u4ef6\u5730\u5740 \u91c7\u7528\u7edd\u5bf9\u5730\u5740 \u91c7\u7528\u7edd\u5bf9\u5730\u5740 \u65b9\u4fbfupload.php\u6587\u4ef6\u653e\u5728\u7ad9\u5185\u7684\u4efb\u4f55\u4f4d\u7f6e \u540e\u9762\u4e0d\u52a0&#8221;\/&#8221;<\/p>\n<p> $config[&#8216;site_url&#8217;]=&#8221;&#8221;; \/\/\u7f51\u7ad9\u7684\u7f51\u5740 \u8fd9\u4e0e\u56fe\u7247\u4e0a\u4f20\u540e\u7684\u5730\u5740\u6709\u5173 \u6700\u540e\u4e0d\u52a0&#8221;\/&#8221; \u53ef\u7559\u7a7a<\/p>\n<p> \/\/\u6587\u4ef6\u4e0a\u4f20<br \/> uploadfile();<\/p>\n<p> function uploadfile()<br \/> {<br \/> global $config;<br \/> \/\/\u5224\u65ad\u662f\u5426\u662f\u975e\u6cd5\u8c03\u7528<br \/> if(empty($_GET[&#8216;CKEditorFuncNum&#8217;]))<br \/> mkhtml(1,&#8221;&#8221;,&#8221;\u9519\u8bef\u7684\u529f\u80fd\u8c03\u7528\u8bf7\u6c42&#8221;);<br \/> $fn=$_GET[&#8216;CKEditorFuncNum&#8217;];<br \/> if(!in_array($_GET[&#8216;type&#8217;],$config[&#8216;type&#8217;]))<br \/> mkhtml(1,&#8221;&#8221;,&#8221;\u9519\u8bef\u7684\u6587\u4ef6\u8c03\u7528\u8bf7\u6c42&#8221;);<br \/> $type=$_GET[&#8216;type&#8217;];<br \/> if(is_uploaded_file($_FILES[&#8216;upload&#8217;][&#8216;tmp_name&#8217;]))<br \/> {<br \/> \/\/\u5224\u65ad\u4e0a\u4f20\u6587\u4ef6\u662f\u5426\u5141\u8bb8<br \/> $filearr=pathinfo($_FILES[&#8216;upload&#8217;][&#8216;name&#8217;]);<br \/> $filetype=$filearr[&#8220;extension&#8221;];<br \/> if(!in_array($filetype,$config[$type]))<br \/> mkhtml($fn,&#8221;&#8221;,&#8221;\u9519\u8bef\u7684\u6587\u4ef6\u7c7b\u578b\uff01Incorrect file type&#8221;);<br \/> \/\/\u5224\u65ad\u6587\u4ef6\u5927\u5c0f\u662f\u5426\u7b26\u5408\u8981\u6c42<br \/> if($_FILES[&#8216;upload&#8217;][&#8216;size&#8217;]&gt;$config[$type.&#8221;_size&#8221;]*1024)<br \/> mkhtml($fn,&#8221;&#8221;,&#8221;\u4e0a\u4f20\u7684\u6587\u4ef6\u4e0d\u80fd\u8d85\u8fc7&#8221;.$config[$type.&#8221;_size&#8221;].&#8221;KB\uff01&#8221;);<br \/> \/\/$filearr=explode(&#8220;.&#8221;,$_FILES[&#8216;upload&#8217;][&#8216;name&#8217;]);<br \/> \/\/$filetype=$filearr[count($filearr)-1];<br \/> $file_abso=$config[$type.&#8221;_dir&#8221;].&#8221;\/&#8221;.$config[&#8216;name&#8217;].&#8221;.&#8221;.$filetype;<br \/> $file_host=$_SERVER[&#8216;DOCUMENT_ROOT&#8217;].$file_abso;<\/p>\n<p> if(move_uploaded_file($_FILES[&#8216;upload&#8217;][&#8216;tmp_name&#8217;],$file_host))<br \/> {<br \/> mkhtml($fn,$config[&#8216;site_url&#8217;].$file_abso,$config[&#8216;message&#8217;]);<br \/> }<br \/> else<br \/> {<br \/> mkhtml($fn,&#8221;&#8221;,&#8221;\u6587\u4ef6\u4e0a\u4f20\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u4e0a\u4f20\u76ee\u5f55\u8bbe\u7f6e\u548c\u76ee\u5f55\u8bfb\u5199\u6743\u9650,upload fail!&#8221;);<br \/> }<br \/> }<br \/> }<br \/> \/\/\u8f93\u51fajs\u8c03\u7528<br \/> function mkhtml($fn,$fileurl,$message)<br \/> {<br \/> $str='&lt;script type=&#8221;text\/javascript&#8221;&gt;window.parent.CKEDITOR.tools.callFunction(&#8216;.$fn.&#8217;, \\&#8221;.$fileurl.&#8217;\\&#8217;, \\&#8221;.$message.&#8217;\\&#8217;);&lt;\/script&gt;&#8217;;<br \/> exit($str);<br \/> }<br \/> ?&gt;<\/p>\n<p> 3.\u4fdd\u8bc1\/editors\/ckeditor\/upload\/img\u8fd9\u4e9b\u4e2a\u6587\u4ef6\u5939\u90fd\u5b58\u5728\uff0c\u7136\u540e\u7f16\u8f91\u5668\u5c31\u53ef\u4ee5\u4e0a\u4f20\u56fe\u7247\u4e86\uff0c\u4e0a\u4f20\u7684\u56fe\u7247\u90fd\u4f1a\u4fdd\u5b58\u5728\/editors\/ckeditor\/upload\/img\u6587\u4ef6\u5939\u4e2d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.\u4fee\u6539\u7f51\u7ad9\u6839\u76ee\u5f55\u6587\u4ef6\u5939editors\\ckeditor\\config.js \u6587\u4ef6\uff0c\u5728CKEDITOR.editorConfig&nbsp;=&nbsp;function(&nbsp;config&nbsp;) &nbsp;&nbsp;{ &nbsp;&nbsp;}; \u4e2d\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\uff1a config.filebrowserImageUploadUrl&nbsp;=&nbsp;&#8216;.\/upload.php?type=img&#8217;; config.filebrowserFlashUploadUrl&nbsp;=&nbsp;&#8216;.\/upload.php?type=flash&#8217;; 2.\u5728admin\u6587\u4ef6\u5939\u4e2d\u65b0\u5efaupload.php\u6587\u4ef6\uff0c\u5728\u5176\u4e2d\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\uff1a &lt;?php \/* CKEditor_upload.php monkee 2009-11-15 16:47 *\/ $config=array(); $config[&#8216;type&#8217;]=array(&#8220;flash&#8221;,&#8221;img&#8221;); \/\/\u4e0a\u4f20\u5141\u8bb8type\u503c $config[&#8216;img&#8217;]=array(&#8220;jpg&#8221;,&#8221;bmp&#8221;,&#8221;gif&#8221;); \/\/img\u5141\u8bb8\u540e\u7f00 $config[&#8216;flash&#8217;]=array(&#8220;flv&#8221;,&#8221;swf&#8221;); \/\/flash\u5141\u8bb8\u540e\u7f00 $config[&#8216;flash_size&#8217;]=200; \/\/\u4e0a\u4f20flash\u5927\u5c0f\u4e0a\u9650 \u5355\u4f4d\uff1aKB $config[&#8216;img_size&#8217;]=500; \/\/\u4e0a\u4f20img\u5927\u5c0f\u4e0a\u9650 \u5355\u4f4d\uff1aKB $config[&#8216;message&#8217;]=&#8221;\u4e0a\u4f20\u6210\u529f,upload success!&#8221;; \/\/\u4e0a\u4f20\u6210\u529f\u540e\u663e\u793a\u7684\u6d88\u606f\uff0c\u82e5\u4e3a\u7a7a\u5219\u4e0d\u663e\u793a $config[&#8216;name&#8217;]=mktime(); \/\/\u4e0a\u4f20\u540e\u7684\u6587\u4ef6\u547d\u540d\u89c4\u5219 \u8fd9\u91cc\u4ee5unix\u65f6\u95f4\u6233\u6765\u547d\u540d $config[&#8216;flash_dir&#8217;]=&#8221;\/editors\/ckeditor\/upload\/flash&#8221;; \/\/\u4e0a\u4f20flash\u6587\u4ef6\u5730\u5740 \u91c7\u7528\u7edd\u5bf9\u5730\u5740 \u65b9\u4fbfupload.php\u6587\u4ef6\u653e\u5728\u7ad9\u5185\u7684\u4efb\u4f55\u4f4d\u7f6e \u540e\u9762\u4e0d\u52a0&#8221;\/&#8221; $config[&#8216;img_dir&#8217;]=&#8221;\/editors\/ckeditor\/upload\/img&#8221;; \/\/\u4e0a\u4f20img\u6587\u4ef6\u5730\u5740 \u91c7\u7528\u7edd\u5bf9\u5730\u5740 \u91c7\u7528\u7edd\u5bf9\u5730\u5740 \u65b9\u4fbfupload.php\u6587\u4ef6\u653e\u5728\u7ad9\u5185\u7684\u4efb\u4f55\u4f4d\u7f6e \u540e\u9762\u4e0d\u52a0&#8221;\/&#8221; $config[&#8216;site_url&#8217;]=&#8221;&#8221;; \/\/\u7f51\u7ad9\u7684\u7f51\u5740 \u8fd9\u4e0e\u56fe\u7247\u4e0a\u4f20\u540e\u7684\u5730\u5740\u6709\u5173 \u6700\u540e\u4e0d\u52a0&#8221;\/&#8221; \u53ef\u7559\u7a7a \/\/\u6587\u4ef6\u4e0a\u4f20 uploadfile(); function uploadfile() { [&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-60738","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/60738","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=60738"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/60738\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=60738"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=60738"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=60738"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}