{"id":199330,"date":"2025-05-03T08:21:28","date_gmt":"2025-05-03T00:21:28","guid":{"rendered":"https:\/\/server.hk\/cnblog\/199330\/"},"modified":"2025-05-03T08:21:28","modified_gmt":"2025-05-03T00:21:28","slug":"%e8%ae%a9ecshop%e7%94%a8%e6%88%b7%e7%99%bb%e5%bd%95%e8%af%84%e4%bb%b7%e4%bb%a5%e5%8f%af%e6%8b%a9%e5%8c%bf%e5%90%8d%e8%af%84%e4%bb%b7","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/199330\/","title":{"rendered":"\u8ba9ecshop\u7528\u6237\u767b\u5f55\u8bc4\u4ef7\u4ee5\u53ef\u62e9\u533f\u540d\u8bc4\u4ef7"},"content":{"rendered":"<p> ECSHOP \u9ed8\u8ba4\u7684\u7a0b\u5e8f \u662f \u5f53\u7528\u6237\u767b\u5f55\u540e\uff0c\u5bf9\u5546\u54c1\u5546\u54c1\u8bc4\u4ef7\u662f\u4e0d\u662f\u80fd\u533f\u540d\u8bc4\u4ef7\u7684\u3002<\/p>\n<p> \u6709\u4e9b\u5e97\u94fa\u8bbe\u7f6e\u4e86\u53ea\u80fd\u767b\u5f55\u8bc4\u4ef7\uff0c\u4f46\u5ba2\u6237\u53c8\u4e0d\u60f3\u663e\u793a\u81ea\u5df1\u7684\u8d26\u53f7\u540d\u79f0\u3002\u8fd9\u65f6\u5019 \u8fd9\u529f\u80fd \u5c31\u53ef\u4ee5\u6d3e\u4e0a\u7528\u573a\u4e86<\/p>\n<p> <img decoding=\"async\" src=\"https:\/\/www.ldhost.cn\/helphmb\/uploads\/allimg\/140902\/14262IO7-0.jpg\" style=\"width: 700px;height: 522px\" class=\"aligncenter\"><\/p>\n<p> &nbsp;<\/p>\n<p> 1\u5728 comment.php \u7684\u5e95\u90e8 \u628a add_comment \u65b9\u6cd5\u66ff\u6362\u6210\u4ee5\u4e0b\u4ee3\u7801<\/p>\n<p> &nbsp;<\/p>\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td>   \/**   &nbsp;* \u6dfb\u52a0\u8bc4\u8bba\u5185\u5bb9   &nbsp;*   &nbsp;* @access&nbsp; public   &nbsp;* @param&nbsp;&nbsp; object&nbsp; $cmt   &nbsp;* @return&nbsp; void   &nbsp;*\/   function&nbsp;add_comment($cmt)   {   &nbsp;&nbsp;&nbsp;&nbsp;\/* \u8bc4\u8bba\u662f\u5426\u9700\u8981\u5ba1\u6838 *\/   &nbsp;&nbsp;&nbsp;&nbsp;$status&nbsp;= 1 &#8211;&nbsp;$GLOBALS[&#8216;_CFG&#8217;][&#8216;comment_check&#8217;];   &nbsp;   &nbsp;&nbsp;&nbsp;&nbsp;$user_id&nbsp;=&nbsp;empty($_SESSION[&#8216;user_id&#8217;]) ? 0 :&nbsp;$_SESSION[&#8216;user_id&#8217;];   &nbsp;&nbsp;&nbsp;&nbsp;$email&nbsp;=&nbsp;empty($cmt-&gt;email) ?&nbsp;$_SESSION[&#8217;email&#8217;] : trim($cmt-&gt;email);   &nbsp;&nbsp;&nbsp;&nbsp;$user_name&nbsp;=&nbsp;empty($cmt-&gt;username) ?&nbsp;$_SESSION[&#8216;user_name&#8217;] : trim($cmt-&gt;username);   &nbsp;&nbsp;&nbsp;&nbsp;$email&nbsp;= htmlspecialchars($email);   &nbsp;&nbsp;&nbsp;&nbsp;$user_name&nbsp;= htmlspecialchars($user_name);   &nbsp;   &nbsp;   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   &nbsp;&nbsp;&nbsp;&nbsp;\/\/file_put_contents(&#8216;test.txt&#8217;,$cmt-&gt;nimingis);   &nbsp;&nbsp;&nbsp;&nbsp;$nimingis=$cmt-&gt;nimingis;   &nbsp;&nbsp;&nbsp;&nbsp;if($nimingis){   &nbsp;&nbsp;&nbsp;&nbsp;$user_id=0;   &nbsp;&nbsp;&nbsp;&nbsp;$user_name= str_mid_replace($_SESSION[&#8216;user_name&#8217;]);   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}   &nbsp;&nbsp;&nbsp;&nbsp;   &nbsp;&nbsp;&nbsp;&nbsp;   &nbsp;&nbsp;&nbsp;&nbsp;\/* \u4fdd\u5b58\u8bc4\u8bba\u5185\u5bb9 *\/   &nbsp;&nbsp;&nbsp;&nbsp;$sql&nbsp;=&nbsp;&#8220;INSERT INTO &#8221;&nbsp;.$GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;comment&#8217;) .   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;(comment_type, id_value, email, user_name, content, comment_rank, add_time, ip_address, status, parent_id, user_id) VALUES &#8221;&nbsp;.   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;(&#8216;&#8221;&nbsp;.$cmt-&gt;type.&nbsp;&#8220;&#8216;, &#8216;&#8221;&nbsp;.$cmt-&gt;id.&nbsp;&#8220;&#8216;, &#8216;$email&#8217;, &#8216;$user_name&#8217;, &#8216;&#8221;&nbsp;.$cmt-&gt;content.&#8221;&#8216;, &#8216;&#8221;.$cmt-&gt;rank.&#8221;&#8216;, &#8220;.gmtime().&#8221;, &#8216;&#8221;.real_ip().&#8221;&#8216;, &#8216;$status&#8217;, &#8216;0&#8217;, &#8216;$user_id&#8217;)&#8221;;   &nbsp;   &nbsp;&nbsp;&nbsp;&nbsp;$result&nbsp;=&nbsp;$GLOBALS[&#8216;db&#8217;]-&gt;query($sql);   &nbsp;&nbsp;&nbsp;&nbsp;clear_cache_files(&#8216;comments_list.lbi&#8217;);   &nbsp;&nbsp;&nbsp;&nbsp;\/*if ($status &gt; 0)   &nbsp;&nbsp;&nbsp;&nbsp;{   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;add_feed($GLOBALS[&#8216;db&#8217;]-&gt;insert_id(), COMMENT_GOODS);   &nbsp;&nbsp;&nbsp;&nbsp;}*\/   &nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;$result;   }   &nbsp;   &nbsp;\/\/\u5b57\u7b26\u4e32\u622a\u53d6&nbsp;&nbsp;&nbsp;&nbsp;   function&nbsp;str_mid_replace($string) {   &nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!&nbsp;$string&nbsp;|| !isset($string[1]))&nbsp;return&nbsp;$string;   &nbsp;   &nbsp;&nbsp;&nbsp;&nbsp;$len&nbsp;=&nbsp;strlen($string);   &nbsp;&nbsp;&nbsp;&nbsp;$starNum&nbsp;=&nbsp;floor($len&nbsp;\/ 2);   &nbsp;&nbsp;&nbsp;&nbsp;$noStarNum&nbsp;=&nbsp;$len&nbsp;&#8211;&nbsp;$starNum;   &nbsp;&nbsp;&nbsp;&nbsp;$leftNum&nbsp;=&nbsp;ceil($noStarNum&nbsp;\/ 2);   &nbsp;&nbsp;&nbsp;&nbsp;$rightNum&nbsp;=&nbsp;$noStarNum&nbsp;&#8211;&nbsp;$leftNum;   &nbsp;   &nbsp;&nbsp;&nbsp;&nbsp;$result&nbsp;=&nbsp;substr($string, 0,&nbsp;$leftNum);   &nbsp;&nbsp;&nbsp;&nbsp;$result&nbsp;.=&nbsp;str_repeat(&#8216;*&#8217;,&nbsp;$starNum);   &nbsp;&nbsp;&nbsp;&nbsp;$result&nbsp;.=&nbsp;substr($string,&nbsp;$len-$rightNum);   &nbsp;   &nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;$result;   }   &nbsp;   <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p> \u30002\u3002\u5728comments.lbi \u4e2d\u7684&nbsp;submitComment \u65b9\u6cd5\u4e2d\u589e\u52a0<\/p>\n<p>    &nbsp;   <\/p>\n<table>\n<tbody>\n<tr>\n<td>   1   <\/td>\n<td>   cmt.nimingis&nbsp;=&nbsp;frm.elements[&#8216;nimingis&#8217;].checked;   <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p> 3.\u5728html\u4ee3\u7801\u4e2d\u589e\u52a0<\/p>\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td>   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;!&#8211;{if&nbsp;$smarty.session.user_name}&#8211;&gt;   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&#8221;64&#8243;&nbsp;align=&#8221;right&#8221;&gt;\u662f\u5426\u533f\u540d\uff1a&lt;\/td&gt;   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&#8221;631&#8243;&gt;{$lang.anonymous}&lt;input type=&#8221;checkbox&#8221;&nbsp;name=&#8221;nimingis&#8221;&nbsp;value=&#8221;&#8221;&nbsp;&nbsp;&gt;&lt;\/td&gt;   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/tr&gt;   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   &nbsp;&nbsp;&nbsp;&nbsp;&lt;!&#8211;{\/if}&#8211;&gt;   <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>ECSHOP \u9ed8\u8ba4\u7684\u7a0b\u5e8f \u662f \u5f53&#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-199330","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199330","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=199330"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199330\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=199330"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=199330"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=199330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}