{"id":199420,"date":"2025-05-03T08:43:44","date_gmt":"2025-05-03T00:43:44","guid":{"rendered":"https:\/\/server.hk\/cnblog\/199420\/"},"modified":"2025-05-03T08:43:44","modified_gmt":"2025-05-03T00:43:44","slug":"%e4%bc%98%e5%8c%96ecshop%e8%87%aa%e5%8a%a8%e7%94%9f%e6%88%90%e7%b1%bb%e7%9b%ae%e9%a1%b5keywords%e3%80%81desciption-meta","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/199420\/","title":{"rendered":"\u4f18\u5316ecshop\u81ea\u52a8\u751f\u6210\u7c7b\u76ee\u9875Keywords\u3001Desciption Meta"},"content":{"rendered":"<p>ECshop\u652f\u6491\u5bf9\u4e8e\u6bcf\u4e2a\u65b0\u5efa\u7684\u7c7b\u76ee\u81ea\u5b9a\u4e49Keywords\u3001Description Meta\u4fe1\u606f\uff0c\u597d\u5904\u5c31\u4e0d\u7528\u8bf4\u4e86\uff0c\u534f\u52a9SEO\u6216\u8bb8\u8ba9\u9605\u8bfb\u8005\u4e86\u89e3\u8fd9\u662f\u5565\u9875\u9762\uff0c\u4f46\u5982\u679c\u6709\u51e0\u767e\u4e2a\u7c7b\u76ee\u7684\u65f6\u5206\uff0c\u4eba\u5de5\u53bb\u5199\u8fd9\u4e9b\u7c7b\u76ee\u53c8\u6709\u70b9\u7d2f\u4eba\uff08\u54b1\u4e0d\u5e72\u4f53\u529b\u52b3\u52a8\u7684 \u6d3b\uff09\uff0c\u82b1\u4e86\u70b9\u65f6\u523b\uff0c\u5199\u4e86\u4e2a\u4e3b\u52a8\u751f\u6210Keywords\u3001Description\u7684PHP\u811a\u672c\uff0c\u652f\u6491\u56db\u7ea7\u5206\u7c7b\uff0c\u539f\u7406\u662f\u5b50\u7c7b\u76ee\u5305\u62ec\u7236\u4eb2\u7c7b\u76ee\u3001\u7237\u7237\u7c7b\u76ee\u3002\u3002\u3002\u5230\u9876 \u7ea7\u7c7b\u76ee\u540d\u4f5c\u4e3a\u5173\u952e\u5b57\uff0c\u7136\u540e\u4e00\u53e5\u63cf\u8ff0\u7684\u8bdd\uff0c\u5305\u62ec\u8fd9\u4e9b\u7c7b\u76ee\u7684\u79f0\u53f7\u3002\u6211\u4eec\u80fd\u591f\u4f9d\u636e\u81ea\u4e2a\u9700\u6c42\u7b80\u7565\u7684\u4fee\u6539\u3002   &nbsp;   \u7528\u6cd5\uff0c\u5728\u4f60\u7684\u540e\u53f0\u7c7b\u76ee\uff0c\u9ed8\u8bb8\u662fAdmin\u91cc\u9762\u521b\u7acb\u4e00\u4e2a\u65b0\u7684PHP\u6587\u4ef6\uff0c\u6587\u4ef6\u540d\u81ea\u5b9a\u4e49\uff0c\u5c06\u4e0b\u9762\u7684\u4ee3\u7801\u4eff\u5236\u8fdb\u5165\u5c31\u80fd\u591f\u4e86\uff0c\u9700\u6c42\u751f\u6210\u7684\u65f6\u5206\uff0c\u8bbf\u95ee\u4e00\u4e0b\u8fd9\u4e2a\u6587\u4ef6\u5c31\u4e3b\u52a8\u751f\u6210\u4e86\u3002   &nbsp;   &nbsp;   &lt;?php   set_time_limit(600);   &nbsp;   &nbsp;   define(&#8216;IN_ECS&#8217;, true);   &nbsp;   require(dirname(__FILE__) . &#8216;\/includes\/init.php&#8217;);   &nbsp;   $sql_1 = &#8220;SELECT cat_id,cat_name FROM &#8221; .$ecs-&gt;table(&#8216;category&#8217;). &#8221; where parent_id = 0 ORDER BY cat_id asc&#8221;;   $res_1 = $db-&gt;query($sql_1);   &nbsp;   \/\/\u4e00\u7ea7\u7c7b\u76ee\u5faa\u73af   while ($row_1 = $db-&gt;fetchRow($res_1))   {   &nbsp;   \/\/\u53d6\u5f97\u4e00\u7ea7\u7c7b\u76ee\u5b50\u7c7b\u76ee   $sql_2 = &#8220;SELECT cat_id,cat_name FROM &#8221; .$ecs-&gt;table(&#8216;category&#8217;). &#8221; where parent_id = &#8220;. $row_1[&#8216;cat_id&#8217;] .&#8221; ORDER BY cat_id asc&#8221;;   $res_2 = $db-&gt;query($sql_2);   print &#8220;*** \u4e00\u7ea7\u5206\u7c7b\uff1a&#8221; . $row_1[&#8216;cat_name&#8217;] .&#8221;&lt;br&gt;&#8221;;   &nbsp;   \/\/\u4e00\u7ea7\u7c7b\u76ee\u5b50\u7c7b\u76ee\u5faa\u73af   $keyword_1 = &#8221;;   $c2 = 0;   while ($row_2 = $db-&gt;fetchRow($res_2))   {   $c2 = $c2 + 1;   if ($c2 &lt; 7)   {   \/\/\u751f\u6210\u4e00\u7ea7\u7c7b\u76ee\u7684\u5173\u952e\u8bcd\u548c\u63cf\u8ff0\uff0c\u53d6\u524dX\u4e2a   $keyword_1 = $keyword_1 . replace_cat_name($row_2[&#8216;cat_name&#8217;]) . &#8220;, &#8220;;   }   &nbsp;   \/\/=====================================================================   \/\/\u53d6\u5f97\u4e8c\u7ea7\u7c7b\u76ee\u5b50\u7c7b\u76ee   $sql_3 = &#8220;SELECT cat_id,cat_name FROM &#8221; .$ecs-&gt;table(&#8216;category&#8217;). &#8221; where parent_id = &#8220;. $row_2[&#8216;cat_id&#8217;] .&#8221; ORDER BY cat_id asc&#8221;;   $res_3 = $db-&gt;query($sql_3);   print &#8220;****** \u4e8c\u7ea7\u5206\u7c7b\uff1a&#8221; . $row_2[&#8216;cat_name&#8217;] .&#8221;&lt;br&gt;&#8221;;   &nbsp;   \/\/\u4e8c\u7ea7\u7c7b\u76ee\u5b50\u7c7b\u76ee\u5faa\u73af   $keyword_2 = &#8221;;   $c3 = 0;   while ($row_3 = $db-&gt;fetchRow($res_3))   {   &nbsp;   $c3 = $c3 + 1;   if ($c3 &lt; 7)   {   \/\/\u751f\u6210\u4e8c\u7ea7\u7c7b\u76ee\u7684\u5173\u952e\u8bcd\u548c\u63cf\u8ff0   $keyword_2 = $keyword_2 . replace_cat_name($row_3[&#8216;cat_name&#8217;]) . &#8220;, &#8220;;   }   &nbsp;   \/\/=====================================================================   \/\/\u53d6\u5f97\u4e09\u7ea7\u7c7b\u76ee\u5b50\u7c7b\u76ee   $sql_4 = &#8220;SELECT cat_id,cat_name FROM &#8221; .$ecs-&gt;table(&#8216;category&#8217;). &#8221; where parent_id = &#8220;. $row_3[&#8216;cat_id&#8217;] .&#8221; ORDER BY cat_id asc&#8221;;   $res_4 = $db-&gt;query($sql_4);   print &#8220;********* \u4e09\u7ea7\u5206\u7c7b\uff1a&#8221; . $row_3[&#8216;cat_name&#8217;] .&#8221;&lt;br&gt;&#8221;;   &nbsp;   \/\/\u4e09\u7ea7\u7c7b\u76ee\u5b50\u7c7b\u76ee\u5faa\u73af   $keyword_3 = &#8221;;   $c4 = 0;   while ($row_4 = $db-&gt;fetchRow($res_4))   {   &nbsp;   $c4 = $c4 + 1;   if ($c4 &lt; 7)   {   \/\/\u751f\u6210\u4e09\u7ea7\u7c7b\u76ee\u7684\u5173\u952e\u8bcd\u548c\u63cf\u8ff0   $keyword_3 = $keyword_3 . replace_cat_name($row_4[&#8216;cat_name&#8217;]) . &#8220;, &#8220;;   }   &nbsp;   \/\/\u76f4\u63a5\u5199\u4e09\u7ea7\u7c7b\u76ee\u7684\u503c   print &#8220;************ \u56db\u7ea7\u5206\u7c7b\uff1a&#8221; . $row_4[&#8216;cat_name&#8217;] .&#8221;&lt;br&gt;&#8221;;   $cat_name_4_str = replace_cat_name($row_4[&#8216;cat_name&#8217;]);   $keyword_4_str = $cat_name_4_str . &#8221; Products, Online Shopping, Taobao Agent, Taobao Dropship&#8221;;   $desc_4_str = &#8220;Online shopping &#8220;. $cat_name_4_str .&#8221; Products from &#8220;. $GLOBALS[&#8216;_CFG&#8217;][&#8216;shop_name&#8217;] .&#8221;, Factory Price, Worldwide Shipping!&#8221;;   &nbsp;   $db-&gt;query(&#8220;UPDATE &#8221; .$ecs-&gt;table(&#8216;category&#8217;). &#8221; SET keywords ='&#8221;. $keyword_4_str .&#8221;&#8216;, cat_desc ='&#8221;. $desc_4_str .&#8221;&#8216; WHERE cat_id =&#8221;. $row_4[&#8216;cat_id&#8217;] .&#8221;&#8221;);   &nbsp;   }   &nbsp;   \/\/\u5bf9\u4e09\u7ea7\u7c7b\u76ee\u5b57\u7b26\u4e32\u8fdb\u884c\u5904\u7406\u66f4\u65b0   $cat_name_3_str = replace_cat_name($row_3[&#8216;cat_name&#8217;]);   &nbsp;   if (substr($keyword_3,-2) == &#8216;, &#8216;)   {   $keyword_3 = substr($keyword_3,0,strlen($keyword_3)-2);   }   &nbsp;   if ($keyword_3 == &#8221;)   {   $keyword_3_str = $cat_name_3_str . &#8221; Products&#8221;;   $desc_3_str = &#8220;Online shopping &#8220;. $cat_name_3_str .&#8221; Products, Browse Through Our Category of &#8220;. $cat_name_3_str . &#8221; Products and more from &#8220;. $GLOBALS[&#8216;_CFG&#8217;][&#8216;shop_name&#8217;] .&#8221;, Factory Price, Worldwide Shipping!&#8221;;   }   else   {   $keyword_3_str = $cat_name_3_str . &#8220;, &#8220;. $keyword_3 . &#8221; Products&#8221;;   $desc_3_str = &#8220;Online shopping &#8220;. $cat_name_3_str .&#8221; Products, Browse Through Our Categories of &#8220;. $keyword_3 . &#8221; Products and more from &#8220;. $GLOBALS[&#8216;_CFG&#8217;][&#8216;shop_name&#8217;] .&#8221;, Factory Price, Worldwide Shipping!&#8221;;   }   &nbsp;   $db-&gt;query(&#8220;UPDATE &#8221; .$ecs-&gt;table(&#8216;category&#8217;). &#8221; SET keywords ='&#8221;. $keyword_3_str .&#8221;&#8216;, cat_desc ='&#8221;. $desc_3_str .&#8221;&#8216; WHERE cat_id =&#8221;. $row_3[&#8216;cat_id&#8217;] .&#8221;&#8221;);   &nbsp;   }   \/\/\u5bf9\u4e8c\u7ea7\u7c7b\u76ee\u5b57\u7b26\u4e32\u8fdb\u884c\u5904\u7406\u66f4\u65b0   $cat_name_2_str = replace_cat_name($row_2[&#8216;cat_name&#8217;]);   &nbsp;   if (substr($keyword_2,-2) == &#8216;, &#8216;)   {   $keyword_2 = substr($keyword_2,0,strlen($keyword_2)-2);   }   &nbsp;   if ($keyword_2 == &#8221;)   {   $keyword_2_str = $cat_name_2_str . &#8221; Products&#8221;;   $desc_2_str = &#8220;Online shopping &#8220;. $cat_name_2_str .&#8221; Products, Browse Through Our Category of &#8220;. $cat_name_2_str . &#8221; Products and more from &#8220;. $GLOBALS[&#8216;_CFG&#8217;][&#8216;shop_name&#8217;] .&#8221;, Factory Price, Worldwide Shipping!&#8221;;   }   else   {   $keyword_2_str = $cat_name_2_str . &#8220;, &#8220;. $keyword_2 . &#8221; Products&#8221;;   $desc_2_str = &#8220;Online shopping &#8220;. $cat_name_2_str .&#8221; Products, Browse Through Our Categories of &#8220;. $keyword_2 . &#8221; Products and more from &#8220;. $GLOBALS[&#8216;_CFG&#8217;][&#8216;shop_name&#8217;] .&#8221;, Factory Price, Worldwide Shipping!&#8221;;   }   &nbsp;   $db-&gt;query(&#8220;UPDATE &#8221; .$ecs-&gt;table(&#8216;category&#8217;). &#8221; SET keywords ='&#8221;. $keyword_2_str .&#8221;&#8216;, cat_desc ='&#8221;. $desc_2_str .&#8221;&#8216; WHERE cat_id =&#8221;. $row_2[&#8216;cat_id&#8217;] .&#8221;&#8221;);   &nbsp;   \/\/=====================================================================   }   &nbsp;   \/\/\u5bf9\u4e00\u7ea7\u7c7b\u76ee\u5b57\u7b26\u4e32\u8fdb\u884c\u5904\u7406\u66f4\u65b0   $cat_name_1_str = replace_cat_name($row_1[&#8216;cat_name&#8217;]);   if (substr($keyword_1,-2) == &#8216;, &#8216;)   {   $keyword_1 = substr($keyword_1,0,strlen($keyword_1)-2);   }   &nbsp;   $keyword_1_str = $cat_name_1_str . &#8220;, &#8220;. $keyword_1 . &#8221; Products&#8221;;   $desc_1_str = &#8220;Online shopping &#8220;. $cat_name_1_str .&#8221; Products, Browse Through Our Categories of &#8220;. $keyword_1 . &#8221; Products and more from &#8220;. $GLOBALS[&#8216;_CFG&#8217;][&#8216;shop_name&#8217;] .&#8221;, Factory Price, Worldwide Shipping!&#8221;;   &nbsp;   $db-&gt;query(&#8220;UPDATE &#8221; .$ecs-&gt;table(&#8216;category&#8217;). &#8221; SET keywords ='&#8221;. $keyword_1_str .&#8221;&#8216;, cat_desc ='&#8221;. $desc_1_str .&#8221;&#8216; WHERE cat_id =&#8221;. $row_1[&#8216;cat_id&#8217;] .&#8221;&#8221;);   }   &nbsp;   function replace_cat_name($cate_name)   {   $str = str_replace(&#8216; ,&#8217;,&#8217;,&#8217;,str_replace(&#8216; &#8216;,&#8217; &#8216;,str_replace(&#8216; &amp;&#8217;,&#8217;, &#8216;,str_replace(&#8216;&amp;&#8217;,&#8217;, &#8216;,str_replace(&#8216; \/&#8217;,&#8217;\/&#8217;,str_replace(&#8216;\/&#8217;,&#8217;, &#8216;,addslashes($cate_name)))))));   return $str;   }   ?&gt;   &nbsp;  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>ECshop\u652f\u6491\u5bf9\u4e8e\u6bcf\u4e2a\u65b0\u5efa\u7684\u7c7b&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-199420","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199420","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=199420"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199420\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=199420"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=199420"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=199420"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}