{"id":61027,"date":"2025-04-26T08:51:10","date_gmt":"2025-04-26T00:51:10","guid":{"rendered":"https:\/\/fwq.ai\/blog\/61027\/"},"modified":"2025-04-26T08:51:10","modified_gmt":"2025-04-26T00:51:10","slug":"zen-cart%e6%95%b0%e6%8d%ae%e5%ba%93%e5%b0%81%e8%a3%85%e7%b1%bb%e8%a7%a3%e8%af%bb","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/61027\/","title":{"rendered":"Zen-cart\u6570\u636e\u5e93\u5c01\u88c5\u7c7b\u89e3\u8bfb"},"content":{"rendered":"<p>\u8981\u64cd\u4f5cZen-cart\u6570\u636e\u5e93\uff0c\u4e00\u822c\u6b65\u9aa4\u57fa\u672c\u5982\u6b64\uff0c\u9996\u5148\u5efa\u7acb\u5230\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u7684\u8fde\u63a5\uff0c\u7136\u540e\u9009\u62e9\u6570\u636e\uff0c\u63a5\u7740\u5c31\u662f\u64cd\u4f5c\u6570\u636e\u5e93\u3002\u9996\u5148\u770b\u770bqueryFactory\u7c7b\uff0c\u770b\u770b1.3.9\u7248\u672c\u8fde\u63a5\u6570\u636e\u5e93\u7cfb\u7edf\u7684\u6539\u8fdb\uff1a   &nbsp;   01<br \/>\n<span> <\/span>$connectionRetry = 10;   02<br \/>\n<span> <\/span>while (!isset($this-&gt;link) || ($this-&gt;link == FALSE &amp;&amp; $connectionRetry !=0) )   03<br \/>\n<span> <\/span>{   04<br \/>\n<span> <\/span> &nbsp;$this-&gt;link = @mysql_connect($zf_host, $zf_user, $zf_password, true);   05<br \/>\n<span> <\/span> &nbsp;$connectionRetry&#8211;;   06<br \/>\n<span> <\/span>}   07<br \/>\n<span> <\/span>if ($this-&gt;link) {   08<br \/>\n<span> <\/span> &nbsp;if (@mysql_select_db($zf_database, $this-&gt;link)) {   09<br \/>\n<span> <\/span> &nbsp; &nbsp;if (defined(&#8216;DB_CHARSET&#8217;) &amp;&amp; version_compare(@mysql_get_server_info(), &#8216;4.1.0&#8217;, &#8216;&gt;=&#8217;)) {   10<br \/>\n<span> <\/span> &nbsp; &nbsp; &nbsp;@mysql_query(&#8220;SET NAMES &#8216;&#8221; . DB_CHARSET . &#8220;&#8216;&#8221;, $this-&gt;link);   11<br \/>\n<span> <\/span> &nbsp; &nbsp; &nbsp;if (function_exists(&#8216;mysql_set_charset&#8217;)) {   12<br \/>\n<span> <\/span> &nbsp; &nbsp; &nbsp; &nbsp;@mysql_set_charset(DB_CHARSET, $this-&gt;link);   13<br \/>\n<span> <\/span> &nbsp; &nbsp; &nbsp;} else {   14<br \/>\n<span> <\/span> &nbsp; &nbsp; &nbsp; &nbsp;@mysql_query(&#8220;SET CHARACTER SET &#8216;&#8221; . DB_CHARSET . &#8220;&#8216;&#8221;, $this-&gt;link);   15<br \/>\n<span> <\/span> &nbsp; &nbsp; &nbsp;}   16<br \/>\n<span> <\/span> &nbsp; &nbsp;}   17<br \/>\n<span> <\/span> &nbsp; &nbsp;$this-&gt;db_connected = true;   18<br \/>\n<span> <\/span> &nbsp; &nbsp;return true;   19<br \/>\n<span> <\/span> &nbsp;} else {   20<br \/>\n<span> <\/span> &nbsp; &nbsp;$this-&gt;set_error(mysql_errno(),mysql_error(), $zp_real);   21<br \/>\n<span> <\/span> &nbsp; &nbsp;return false;   22<br \/>\n<span> <\/span> &nbsp;}   23<br \/>\n<span> <\/span>} else {   24<br \/>\n<span> <\/span> &nbsp;$this-&gt;set_error(mysql_errno(),mysql_error(), $zp_real);   25<br \/>\n<span> <\/span> &nbsp;return false;   26<br \/>\n<span> <\/span>}   \u8fd9\u6bb5\u4ee3\u7801\u6bd41.3.8\u7684\u8fde\u63a5\u903b\u8f91\u66f4\u52a0\u7684\u7f1c\u5bc6\u4e86\uff0c\u9996\u5148\u5c1d\u8bd510\u6b21\u8fde\u63a5\u6570\u636e\u7cfb\u7edf\uff0c1.3.8\u4e2d\u53ea\u8981\u8fde\u63a5\u4e00\u6b21\u8fde\u63a5\u4e0d\u4e0a\u5c31\u56de\u663e\u9519\u8bef\uff0c\u4e0d\u7ba1\u600e\u6837\uff0c\u5c1d\u8bd5\u591a\u6b21\u8fde\u63a5\uff0c\u5e94\u8be5\u662f\u5408\u7406\u7684\u3002\u53e6\u5916\u65b0\u7248\u672c\u4e2d\u5f15\u8fdb\u4e86DB_CHARSET\u5e38\u91cf\uff0c\u8ba9\u6211\u4eec\u53ef\u4ee5\u81ea\u5df1\u6307\u5b9a\u6570\u636e\u7684\u5b57\u7b26\u7f16\u7801\uff0c\u57281.3.8\u4e2d\uff0c\u9ed8\u8ba4\u5e76\u6ca1\u6709\u8fd9\u4e2a\u8003\u8651\uff0c\u8fd9\u4e5f\u5c31\u662f\u4e00\u4e9b\u4e71\u7801\u4ea7\u751f\u7684\u672c\u8d28\u539f\u56e0\uff0c\u4f46\u662fZen-cart\u4e2d\u6587\u7248\u4e2d\u4e3a\u4e86\u5bf9\u4ed8\u8fd9\u4e2a\u95ee\u9898\uff0c\u52a0\u5165\u4e86mysql_query(\u2018SET NAMES \u201cutf8\u2033\u2018, $this-&gt;link)\u8fd9\u4e2a\u8bed\u53e5\uff0c\u76f8\u6bd4\u4e4b\u4e0b\uff0c\u539f\u4f5c\u8005\u7684\u6c34\u5e73\u8fd8\u662f\u6280\u9ad8\u4e00\u7b79\u554a\u2026\u2026   &nbsp;   \u63a5\u4e0b\u6765\u518d\u770b\u770b\u8fd9\u4e2a\u65b9\u6cd5\uff1a   &nbsp;   1<br \/>\n<span> <\/span>function prepare_input($zp_string) {   2<br \/>\n<span> <\/span> &nbsp;if (function_exists(&#8216;mysql_real_escape_string&#8217;)) {   3<br \/>\n<span> <\/span> &nbsp; &nbsp;return mysql_real_escape_string($zp_string, $this-&gt;link);   4<br \/>\n<span> <\/span> &nbsp;} elseif (function_exists(&#8216;mysql_escape_string&#8217;)) {   5<br \/>\n<span> <\/span> &nbsp; &nbsp;return mysql_escape_string($zp_string, $this-&gt;link);   6<br \/>\n<span> <\/span> &nbsp;} else {   7<br \/>\n<span> <\/span> &nbsp; &nbsp;return addslashes($zp_string);   8<br \/>\n<span> <\/span> &nbsp;}   9<br \/>\n<span> <\/span>}   \u8fd9\u4e2a\u51fd\u6570\u7528\u4e8e\u5bf9\u6570\u636e\u8fdb\u884c\u8f6c\u4e49\uff0c\u4fdd\u8bc1\u6570\u636e\u5b89\u5168\u3002\u8fd9\u53ef\u6b63\u6240\u8c13\u662f\u69a8\u5e72\u4e86\u6cb9\u7684\u987e\u8651\u554a\uff0c\u540c\u65f6\u4e5f\u77e5\u9053\u5e94\u8be5\u5148\u7528mysql_real_escape_string()\u518d\u7528mysql_escape_string()\u5b9e\u5728\u4e0d\u884c\u518d\u7528addslashes()\u3002   &nbsp;   \u53ef\u4ee5\u8bf4\uff0c\u8fd9\u4e2a\u7c7b\u4e2d\u7684Execute\u51fd\u6570\u662f\u6700\u6838\u5fc3\u7684\uff0c\u5148\u770b\u8fd9\u4e2a\u51fd\u6570\u5f00\u59cb\u7684\u8fd9\u6bb5\u4ee3\u7801\uff1a   &nbsp;   01<br \/>\n<span> <\/span>\/\/ bof: collect database queries   02<br \/>\n<span> <\/span>if (defined(&#8216;STORE_DB_TRANSACTIONS&#8217;) &amp;&amp; STORE_DB_TRANSACTIONS==&#8217;true&#8217;) {   03<br \/>\n<span> <\/span> &nbsp;global $PHP_SELF, $box_id, $current_page_base;   04<br \/>\n<span> <\/span> &nbsp;if (strtoupper(substr($zf_sql,0,6))==&#8217;SELECT&#8217; \/*&amp;&amp; strstr($zf_sql,&#8217;products_id&#8217;)*\/) {   05<br \/>\n<span> <\/span> &nbsp; &nbsp;$f=@fopen(DIR_FS_SQL_CACHE.&#8217;\/query_selects_&#8217; . $current_page_base . &#8216;_&#8217; . time() . &#8216;.txt&#8217;,&#8217;a&#8217;);   06<br \/>\n<span> <\/span> &nbsp; &nbsp;if ($f) {   07<br \/>\n<span> <\/span> &nbsp; &nbsp; &nbsp;fwrite($f, &nbsp;&#8220;\\n\\n&#8221; . &#8216;I AM HERE &#8216; . $current_page_base . \/*zen_get_all_get_params() .*\/ &#8220;\\n&#8221; . &#8216;sidebox: &#8216; . $box_id . &#8220;\\n\\n&#8221; . &#8220;Explain \\n&#8221; . $zf_sql.&#8221;;\\n\\n&#8221;);   08<br \/>\n<span> <\/span> &nbsp; &nbsp; &nbsp;fclose($f);   09<br \/>\n<span> <\/span> &nbsp; &nbsp;}   10<br \/>\n<span> <\/span> &nbsp; &nbsp;unset($f);   11<br \/>\n<span> <\/span> &nbsp;}   12<br \/>\n<span> <\/span>}   13<br \/>\n<span> <\/span>\/\/ eof: collect products_id queries   \u521a\u5f00\u59cb\u771f\u8ba9\u4eba\u6478\u4e0d\u7740\u5317\uff0c\u5176\u5b9e\u8fd9\u6bb5\u4ee3\u7801\u5c31\u662f\u8bb0\u5f55\u6570\u636e\u5e93\u67e5\u8be2\uff0c\u5bf9\u5e94\u540e\u53f0 \u65e5\u5fd7\u9009\u9879-&gt;\u4fdd\u5b58\u6570\u636e\u5e93\u67e5\u8be2\uff0c\u7cfb\u7edf\u9ed8\u8ba4\u662ffalse\uff0c\u4e5f\u6ca1\u6709\u5fc5\u8981\u6253\u5f00\uff0c\u5426\u5219\u6bcf\u6b21\u67e5\u8be2\u5c06\u88ab\u4fdd\u5b58\u4e00\u6761\u65e5\u5fd7\u4fe1\u606f\uff0c\u5e94\u8be5\u6765\u8bf4\uff0c\u8fd9\u4e9b\u4fe1\u606f\u6ca1\u6709\u592a\u591a\u7528\u5904\u3002   &nbsp;   \u63a5\u4e0b\u6765\u8fd9\u4e2a\u51fd\u6570\u9996\u5148\u6839\u636e\u4f20\u9012\u8fdb\u6765\u7684\u53c2\u6570$zf_cache\u5224\u65ad\u8fd9\u4e2a\u67e5\u8be2\u662f\u5426\u9700\u8981\u7f13\u5b58\uff0c\u5982\u679c\u5982\u679c\u9700\u8981\u7f13\u5b58\u548c\u67e5\u8be2\u5df2\u7ecf\u88ab\u7f13\u5b58\u5e76\u4e14\u7f13\u5b58\u8fd8\u6ca1\u6709\u8fc7\u671f\uff0c\u5c31\u628a\u7f13\u5b58\u5185\u5bb9\u5438\u6536\u56de\u6765\u586b\u5145\uff0c\u5426\u5219\u5982\u679c\u6ca1\u6709\u7f13\u5b58\u6587\u4ef6\u6216\u8005\u7f13\u5b58\u6587\u4ef6\u8fc7\u671f\uff0c\u4f46\u662f\u6307\u5b9a\u67e5\u8be2\u9700\u8981\u7f13\u5b58\uff0c\u90a3\u4e48\u5148\u5220\u9664\u5df2\u7ecf\u7f13\u5b58\u7684\u6587\u4ef6(\u5982\u679c\u6709)\uff0c\u7136\u540e\u83b7\u53d6\u67e5\u8be2\u6570\u636e\uff0c\u63a5\u7740\u7f13\u5b58\u8fd9\u4e2a\u7ed3\u679c\u96c6\uff0c\u518d\u5426\u5219\u7684\u8bdd\u5c31\u76f4\u63a5\u8fd4\u56de\u67e5\u8be2\u6570\u636e\u3002\u4ece\u8fd9\u4e2a\u6e90\u7801\u53ef\u4ee5\u770b\u5230\uff0cExecut\u51fd\u6570\u6700\u540e\u662f\u7528\u6765\u67e5\u8be2\uff0c\u7531\u4e8e\u5176\u91cc\u9762\u4e5f\u662f\u4f7f\u7528mysql_query\u6267\u884cSQL\u8bed\u53e5\uff0c\u5982\u679c\u662fINSERT\u8fd9\u6837\u7684\u64cd\u4f5c\uff0c\u540c\u6837\u4e5f\u662f\u53ef\u4ee5\u88ab\u6267\u884c\u7684\uff0c\u53ea\u662f\u5728$obj-&gt;RecordCount() &gt; 0\u8fd9\u4e2a\u6761\u4ef6\u65f6\uff0c\u8fd4\u56de\u4e86false\uff0c\u6240\u4ee5\u5e76\u6ca1\u6709\u4ec0\u4e48\u5f71\u54cd\uff0c\u4e8b\u5b9e\u4e0a\uff0c\u8fd9\u4e2a\u7c7b\u4e2d\u4e5f\u5b9e\u73b0\u4e86\u53e6\u4e00\u4e2a\u65b9\u6cd5\u53ebperform()\uff0c\u4e13\u95e8\u7528\u6765\u5bf9\u4ed8insert\u548cupdate\uff0c\u8fd9\u4e2a\u51fd\u6570\u53ea\u662fexecute\u51fd\u6570\u7684\u5c01\u88c5\uff0c\u53ea\u662f\u5b83\u6dfb\u52a0\u4e86\u8c03\u8bd5\u8ddf\u8e2a\u7684\u673a\u5236\uff0c\u770b\u8d77\u6765\uff0c\u5b83\u4f3c\u4e4e\u66f4\u597d\uff0c\u4f46\u662f\u5bf9\u6211\u4e60\u60ef\u4e86SQL\u8bed\u53e5\uff0c\u5e76\u4e14\u5bf9SQL\u8bed\u53e5\u6709\u5341\u8db3\u628a\u63e1\u80fd\u529b\u7684\u6765\u8bf4\uff0c\u6211\u66f4\u559c\u6b22\u76f4\u63a5\u63a7\u5236SQL\u8bed\u53e5\uff0c\u6211\u5e76\u4e0d\u60f3\u53d8\u5f97\u66f4\u52a0\u50bb\u74dc\u2026..   &nbsp;   \u73b0\u5728\u6765\u770b\u770bqueryFactoryResult\u7c7b\uff0c\u8fd9\u4e2a\u662f\u4e00\u4e2a\u67e5\u8be2\u7ed3\u679c\u96c6\uff0c\u4e3b\u8981\u4e24\u4e2a\u51fd\u6570\uff0cRecordCount\u8fd4\u56de\u8bb0\u5f55\u6570\uff0cMoveNext\u79fb\u52a8\u5230\u4e0b\u4e00\u6761\u8bb0\u5f55\uff0c\u8fd9\u4e2a\u7c7b\u7684\u5bf9\u8c61\u6570\u636e\u5728\u67e5\u8be2\u65f6\u88ab\u586b\u5145\u3002\u4ece\u8fd9\u4e2a\u5c42\u6b21\u6765\u8bf4\uff0cZen-cart\u91cc\u9762\u7684\u7c7b\uff0c\u53ea\u662f\u4e3a\u4e86\u66f4\u52a0\u65b9\u4fbf\u7684\u96c6\u4e2d\u51fd\u6570\uff0c\u7c7b\u4e4b\u95f4\u7684\u5173\u7cfb\u6bd4\u8f83\u677e\u5f1b\uff0c\u6ca1\u6709\u771f\u6b63\u6309\u7167\u9762\u5411\u5bf9\u8c61\u7684\u601d\u7ef4\u6765\u7ec4\u7ec7\u7c7b\uff0c\u603b\u4e4b\uff0cZen-cart\u672c\u8eab\u5c31\u662f\u4e00\u4e2a\u9762\u5411\u8fc7\u7a0b\u8bbe\u8ba1\u601d\u7ef4\u8bbe\u8ba1\u51fa\u6765\u7684\u7cfb\u7edf\uff0c\u867d\u7136\u4e2d\u95f4\u7528\u4e86\u5f88\u591a\u7c7b\uff0c\u4e0d\u8fc7\u5b83\u53ea\u4e0d\u8fc7\u662f\u4e3a\u4e86\u66f4\u52a0\u65b9\u4fbf\u7684\u96c6\u4e2d\u51fd\u6570\uff0c\u5982\u6b64\u800c\u5df2\u3002  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8981\u64cd\u4f5cZen-cart\u6570\u636e\u5e93\uff0c\u4e00\u822c\u6b65\u9aa4\u57fa\u672c\u5982\u6b64\uff0c\u9996\u5148\u5efa\u7acb\u5230\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u7684\u8fde\u63a5\uff0c\u7136\u540e\u9009\u62e9\u6570\u636e\uff0c\u63a5\u7740\u5c31\u662f\u64cd\u4f5c\u6570\u636e\u5e93\u3002\u9996\u5148\u770b\u770bqueryFactory\u7c7b\uff0c\u770b\u770b1.3.9\u7248\u672c\u8fde\u63a5\u6570\u636e\u5e93\u7cfb\u7edf\u7684\u6539\u8fdb\uff1a &nbsp; 01 $connectionRetry = 10; 02 while (!isset($this-&gt;link) || ($this-&gt;link == FALSE &amp;&amp; $connectionRetry !=0) ) 03 { 04 &nbsp;$this-&gt;link = @mysql_connect($zf_host, $zf_user, $zf_password, true); 05 &nbsp;$connectionRetry&#8211;; 06 } 07 if ($this-&gt;link) { 08 &nbsp;if (@mysql_select_db($zf_database, $this-&gt;link)) { 09 &nbsp; &nbsp;if (defined(&#8216;DB_CHARSET&#8217;) &amp;&amp; version_compare(@mysql_get_server_info(), &#8216;4.1.0&#8217;, &#8216;&gt;=&#8217;)) { 10 &nbsp; &nbsp; &nbsp;@mysql_query(&#8220;SET NAMES &#8216;&#8221; . [&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-61027","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/61027","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=61027"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/61027\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=61027"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=61027"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=61027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}