{"id":199347,"date":"2025-05-03T13:30:26","date_gmt":"2025-05-03T05:30:26","guid":{"rendered":"https:\/\/server.hk\/cnblog\/199347\/"},"modified":"2025-05-03T13:30:26","modified_gmt":"2025-05-03T05:30:26","slug":"%e6%8e%92%e6%9f%a5ecshop2-7-3%e4%b8%8ediscuz-x3-1%e5%90%8c%e6%ad%a5%e7%99%bb%e5%bd%95%e6%97%b6%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/199347\/","title":{"rendered":"\u6392\u67e5ecshop2.7.3\u4e0ediscuz X3.1\u540c\u6b65\u767b\u5f55\u65f6\u95ee\u9898"},"content":{"rendered":"<p>\u73af\u5883\uff1aApache\/2.2.21 + PHP\/5.3.10 + winXP<br \/>\n<br \/> \u80cc\u666f\uff1aecshop2.7.3&nbsp;\u6253\u4e0a\u8865\u4e01\u3001discuz X3.1\u3001ucenter1.6&nbsp;\u5168\u90e8utf-8\u7f16\u7801\u5b9e\u73b0\u540c\u6b65\u767b\u5f55\u3001\u9000\u51fa\u3001\u7528\u6237\u521b\u5efa<\/p>\n<p> &nbsp;1\u3001\u5728ucenter\u4e2d\u770b\u5230\u7684\u662f\u5168\u90e8\u901a\u4fe1\u6210\u529f\uff0c\u4f46\u5c31\u662f\u65e0\u6cd5\u540c\u6b65\u767b\u5f55\uff0c\u6ce8\u518c\u65b0\u7528\u6237\u4e5f\u53ef\u4ee5\u540c\u6b65\u3002\u800c\u4e14\u5728ecshop\u767b\u5f55\u7684\u65f6\u5019\u8fd8\u4f1a\u51fa\u73b0400 Bad Request\u9519\u8bef<br \/>\n<br \/> <br \/>\n<img decoding=\"async\" src=\"https:\/\/www.ldhost.cn\/helphmb\/uploads\/allimg\/141210\/102252J63-0.png\" class=\"aligncenter\"><br \/>\n<br \/> \u8ba9\u597d\u6a21\u677f\u6781\u5ea6\u90c1\u95f7\uff0c\u4e8e\u662f\u6328\u4e2a\u7684\u8ffd\u8e2a\uff0c\u4e00\u76f4\u8ffd\u8e2a\u5230ecshop\/uc_client\/client.php\u4e2d\u7684uc_fopen\u51fd\u6570\uff0c\u5927\u81f4\u4f4d\u4e8e178\u884c\u3002\u770b\u4e86\u4e0b\uff0c\u4e5f\u6ca1\u6709\u4ec0\u4e48\u95ee\u9898\u3002\u5230\u7f51\u4e0a\u5230\u5904\u641c\u7d22\uff0c\u4f17\u8bf4\u7eb7\u4e91\uff0c\u6709\u4e9b\u597d\u6a21\u677f\u8fd8\u662f\u4f1a\u76f4\u63a5\u5426\u5b9a\u6389\u7684\u3002\u7531\u4e8e\u7f51\u7edc\u6587\u7ae0\u4e00\u5806\u6284\u3002\u7b97\u4e86\u3002\u5230\u8fd9\u4e2a\u51fd\u6570\u8fd9\u91cc\uff0c\u597d\u6a21\u677f\u51c6\u5907\u8bb0\u5f55\u4e0b\uff0c\u5b83\u5230\u5e95\u53d1\u4ec0\u4e48\u6570\u636e\u51fa\u53bb\uff0c\u53c8\u63a5\u6536\u5230\u4ec0\u4e48\u600e\u6837\u7684\u6570\u636e\u624d\u663e\u793a\u51fa400\u7ed9\u597d\u6a21\u677f\u3002<br \/>\n<br \/> \u4e8e\u662f\u53c8\u518d\u6b21\u6293\u5305\uff1a<br \/>\n<br \/> <br \/>\n<img decoding=\"async\" src=\"https:\/\/www.ldhost.cn\/helphmb\/uploads\/allimg\/141210\/1022524355-1.png\" style=\"width: 700px;height: 499px\" class=\"aligncenter\"><\/p>\n<p> \u7ed3\u679c\u771f\u8ba9\u4eba\u6c57\u989c\uff0c\u8fd4\u56de\u662f\u6b63\u786e\u7684\u7ed3\u679c\uff0c\u4e3a\u4ec0\u4e48\u7528\u6d4f\u89c8\u5668\u767b\u5f55\u8fd4\u56de\u5374\u662f\u4e0d\u6b63\u5e38\u7684\u3002\u628a\u8fd9\u4e9b\u5730\u5740\u590d\u5236\u5230\u540c\u4e00\u6d4f\u89c8\u5668\u91cc\uff0c\u7ed3\u679c\u53ef\u4ee5\u540c\u6b65\u767b\u5f55\u4e86\u3002\u6655\u5012\u4e86\u3002\u95ee\u9898\u786e\u5b9a\u4e86\uff0c\u662fsocket\u51fa\u7684\u95ee\u9898\u3002\u4e8e\u662f\u5c31\u7528curl\u8bd5\u4e86\u4e00\u4e0b\uff0c\u5475\u5475\uff0c\u767b\u5f55\u540c\u6b65\u6210\u529f\u3002<\/p>\n<p> if(stripos($return, &#8216;400 Bad Request&#8217;) != false &nbsp;|| empty($return)) {<br \/>\n<br \/> $return = &#8221;;<br \/>\n<br \/> $curl = curl_init();&nbsp;<br \/>\n<br \/> curl_setopt($curl, CURLOPT_URL, $url);&nbsp;<br \/>\n<br \/> curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER[&#8216;HTTP_USER_AGENT&#8217;]);&nbsp;<br \/>\n<br \/> if($post) {&nbsp;<br \/>\n<br \/> curl_setopt($curl, CURLOPT_POST, 1);&nbsp;<br \/>\n<br \/> curl_setopt($curl, CURLOPT_POSTFIELDS, $post);&nbsp;<br \/>\n<br \/> }&nbsp;<br \/>\n<br \/> if($cookie) {&nbsp;<br \/>\n<br \/> curl_setopt($curl, CURLOPT_COOKIE, $cookie);&nbsp;<br \/>\n<br \/> }&nbsp;<br \/>\n<br \/> curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);&nbsp;<br \/>\n<br \/> curl_setopt($curl, CURLOPT_HEADER, 0);&nbsp;<br \/>\n<br \/> curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);&nbsp;<br \/>\n<br \/> $return = curl_exec($curl);&nbsp;<br \/>\n<br \/> if (curl_errno($curl)) {&nbsp;<br \/>\n<br \/> \/\/echo &#8216;&lt;pre&gt;&lt;b&gt;\u9519\u8bef:&lt;\/b&gt;&lt;br \/&gt;&#8217;.curl_error($curl);&nbsp;<br \/>\n<br \/> }&nbsp;<br \/>\n<br \/> curl_close($curl);&nbsp;<br \/>\n<br \/> }<br \/>\n<br \/> \u53e6\u5916\uff0c\u518d\u4fee\u6b63\u4e0b\u5b98\u65b9\u7684host\uff0c\u56e0\u4e3a\u597d\u6a21\u677f\u8fd9\u91cc\u8bb0\u5f55\u4e0bheader\u7684\u65f6\u5019\uff0chost\u5c45\u7136\u4e3a\u7a7a\u7684\uff0c\u4e0d\u77e5\u9053\u662f\u4e0d\u662f\u597d\u6a21\u677fucenter\u914d\u7f6e\u7684\u95ee\u9898\u3002<br \/>\n<br \/> $path = $matches[&#8216;path&#8217;] ? $matches[&#8216;path&#8217;].($matches[&#8216;query&#8217;] ? &#8216;?&#8217;.$matches[&#8216;query&#8217;] : &#8221;) : &#8216;\/&#8217;;<br \/>\n<br \/> $host = empty($matches[&#8216;host&#8217;]) ? dirname($path) : $matches[&#8216;host&#8217;];<br \/>\n<br \/> \u5927\u7ea6\u4f4d\u4e8e184\u884c\u3002<\/p>\n<p> 2\u3001\u4e0a\u9762\u53ef\u4ee5\u89e3\u51b3ecshop\u767b\u5f55\uff0cdiscuz\u4e5f\u767b\u5f55\uff0c\u4f46ecshop\u9000\u51fa\uff0cdiscuz\u5374\u4fdd\u6301\u767b\u5f55\u72b6\u6001<br \/>\n<br \/> \u4fee\u6539ecshop\/includes\/lib_common.php<br \/>\n<br \/> $res = call_user_func_array($func, empty($params) ? array(&#8216;0&#8217;) : $params); &nbsp;&nbsp; \u5b8c\u6210\u4e0a\u97622\u6b65\u4ee5\u540e\uff0c\u53ef\u4ee5\u5b9e\u73b0ecshop\u767b\u5f55\u3001\u9000\u51fa\u540e\uff0cdiscuz\u4e5f\u8ddf\u7740\u505a\u540c\u6837\u7684\u52a8\u4f5c\u3002<\/p>\n<p> 3\u3001\u4e00\u5b9a\u8981\u5c06ecshop\/uc_client\u4e0ediscuzX\/uc_client\u4fdd\u6301\u4e00\u81f4<br \/>\n<br \/> \u5c06ecshop\/uc_client\/data\/cache\/apps.php\u4e0ediscuzX\/uc_client\/data\/cache\/apps.php\u5185\u5bb9\u4fdd\u6301\u4e00\u81f4<br \/>\n<br \/> \u5c06ecshop\/uc_client\/client.php\u4e0ediscuzX\/uc_client\/client.php \u5185\u5bb9\u4fdd\u6301\u4e00\u81f4&nbsp;<\/p>\n<p> 4\u3001\u4eceecshop\u767b\u5f55\uff0cdiscuz\u9000\u51fa\uff0c\u4f1a\u51fa\u73b0ecshop\u6ca1\u6709\u9000\u51fa\u7684\u73b0\u8c61\u3002\u7531\u4e8ecookie\u503c\u57df\u7684\u95ee\u9898\u3002\u56e0\u4e3adiscuz\u5728\u9000\u51fa\u7684\u65f6\u5019\u4f1a\u7528JS\u8c03\u7528\u5230\u8fd9\u4e2aapi\u6765\u540c\u6b65\u9000\u51fa\u3002<br \/>\n<br \/> \u4fee\u6539ecshop\/api\/uc.php\u4e2d\u7684set_cookie\u51fd\u6570\uff0c\u7ea6408\u884c<\/p>\n<p> setcookie(&#8216;ECS[user_id]&#8217;, &#8221;, $time, $GLOBALS[&#8216;cookie_path&#8217;], $GLOBALS[&#8216;cookie_domain&#8217;]);<br \/>\n<br \/> setcookie(&#8216;ECS[username]&#8217;, &#8221;, $time, $GLOBALS[&#8216;cookie_path&#8217;], $GLOBALS[&#8216;cookie_domain&#8217;]);<br \/>\n<br \/> setcookie(&#8216;ECS[email]&#8217;, &#8221;, $time, $GLOBALS[&#8216;cookie_path&#8217;], $GLOBALS[&#8216;cookie_domain&#8217;]);<\/p>\n<p> 5\u3001ecshop\/includes\/modules\/integrates\/ucenter.php<br \/>\n<br \/> ucenter($cfg)\u51fd\u6570\uff08\u7ea675\u884c\uff09$this-&gt;is_ecshop = 1;\u540e\u9762\u52a0\u5165\uff1a<br \/>\n<br \/> $this-&gt;cookie_path = $cfg[&#8216;cookie_path&#8217;];<br \/>\n<br \/> $this-&gt;cookie_domain = $cfg[&#8216;cookie_domain&#8217;];<\/p>\n<p> \u7b2c463\u884cset_cookie($username=&#8221;)\u51fd\u6570\u52a0\u5165\u57df\u8303\u56f4<br \/>\n<br \/> \/* \u6467\u6bc1cookie *\/<br \/>\n<br \/> $time = time() &#8211; 3600;<br \/>\n<br \/> setcookie(&#8220;ECS[user_id]&#8221;, &#8221;, $time, $this-&gt;cookie_path, $this-&gt;cookie_domain);&nbsp;<br \/>\n<br \/> setcookie(&#8220;ECS[password]&#8221;, &#8221;, $time, $this-&gt;cookie_path, $this-&gt;cookie_domain);<\/p>\n<p> OK\uff0c\u81f3\u6b64ecshop\u548cdiscuz\u5c31\u53ef\u4ee5\u5b8c\u5168\u6ce8\u518c\u767b\u5f55\u9000\u51fa\u540c\u6b65\u4e86\u3002<\/p>\n<p> PS\uff1a\u5982\u679cdiscuz X3.1\u5728\u9000\u51fa\u65f6\u63d0\u793a\uff1aDiscuz!&nbsp; System Error&nbsp;\u60a8\u5f53\u524d\u7684\u8bbf\u95ee\u8bf7\u6c42\u5f53\u4e2d\u542b\u6709\u975e\u6cd5\u5b57\u7b26\uff0c\u5df2\u7ecf\u88ab\u7cfb\u7edf\u62d2\u7edd<br \/>\n<br \/> &nbsp;\u53ef\u4ee5\u4e0b\u8f7d\u5b98\u65b9\u7684\u8bed\u8a00\u5305\u8986\u76d6\u5c31\u884c\u4e86l \u6ce8\u610f\u6b64\u8bed\u8a00\u5305\u4e3aGBK\u7248<\/p>\n<p> \u76ee\u524d\uff0c\u53ea\u6709\u6ce8\u518c\u5e76\u540c\u6b65\u767b\u5f55\u672a\u5b9e\u73b0\uff1a\u53c2\u8003\u4e86\u4e00\u4e0b\u7f51\u4e0a\u7684\u4ee3\u7801\uff0c\u4f46\u597d\u6a21\u677f\u8fd9\u91cc\u5e76\u6ca1\u6709\u6210\u529f<br \/>\n<br \/> discuz\/api\/uc.php\u4e2dsynlogin\u51fd\u6570\u7b2c191\u884c<br \/>\n<br \/> if(($member = getuserbyuid($uid, 1))) {<br \/>\n<br \/> dsetcookie(&#8216;auth&#8217;, authcode(&#8220;$member[password]\\t$member[uid]&#8221;, &#8216;ENCODE&#8217;), $cookietime);<br \/>\n<br \/> }else{<br \/>\n<br \/> \/\/\u4e0b\u9762\u4e3a\u589e\u52a0\u90e8\u5206<br \/>\n<br \/> $username = $get[&#8216;username&#8217;];&nbsp;<br \/>\n<br \/> $password = md5(time().rand(100000, 999999));<br \/>\n<br \/> $email = $get[&#8217;email&#8217;];<br \/>\n<br \/> $ip = $_SERVER[&#8216;REMOTE_ADDR&#8217;];<br \/>\n<br \/> $time = time();&nbsp;<\/p>\n<p> $userdata = array(<br \/>\n<br \/> &#8216;uid&#8217; =&gt; $uid,<br \/>\n<br \/> &#8216;username&#8217; =&gt; $username,<br \/>\n<br \/> &#8216;password&#8217; =&gt; $password,<br \/>\n<br \/> &#8217;email&#8217; =&gt; $email,<br \/>\n<br \/> &#8216;adminid&#8217; =&gt; 0,<br \/>\n<br \/> &#8216;groupid&#8217; =&gt; 10,<br \/>\n<br \/> &#8216;regdate&#8217; =&gt; $time,<br \/>\n<br \/> &#8216;credits&#8217; =&gt; 0,<br \/>\n<br \/> &#8216;timeoffset&#8217; =&gt; 9999<br \/>\n<br \/> );<br \/>\n<br \/> DB::insert(&#8216;common_member&#8217;, $userdata);<\/p>\n<p> $status_data = array(<br \/>\n<br \/> &#8216;uid&#8217; =&gt; $uid,<br \/>\n<br \/> &#8216;regip&#8217; =&gt; $ip,<br \/>\n<br \/> &#8216;lastip&#8217; =&gt; $ip,<br \/>\n<br \/> &#8216;lastvisit&#8217; =&gt; $time,<br \/>\n<br \/> &#8216;lastactivity&#8217; =&gt; $time,<br \/>\n<br \/> &#8216;lastpost&#8217; =&gt; 0,<br \/>\n<br \/> &#8216;lastsendmail&#8217; =&gt; 0,<br \/>\n<br \/> );<br \/>\n<br \/> DB::insert(&#8216;common_member_status&#8217;, $status_data);<br \/>\n<br \/> DB::insert(&#8216;common_member_profile&#8217;, array(&#8216;uid&#8217; =&gt; $uid));<br \/>\n<br \/> DB::insert(&#8216;common_member_field_forum&#8217;, array(&#8216;uid&#8217; =&gt; $uid));<br \/>\n<br \/> DB::insert(&#8216;common_member_field_home&#8217;, array(&#8216;uid&#8217; =&gt; $uid));<br \/>\n<br \/> DB::insert(&#8216;common_member_count&#8217;, array(&#8216;uid&#8217; =&gt; $uid));&nbsp;<br \/>\n<br \/> $query = DB::query(&#8220;SELECT uid, username, password FROM &#8220;.DB::table(&#8216;common_member&#8217;).&#8221; WHERE uid=&#8217;$uid'&#8221;);<br \/>\n<br \/> if($member = DB::fetch($query)) {<br \/>\n<br \/> dsetcookie(&#8216;auth&#8217;, authcode(&#8220;$member[password]\\t$member[uid]&#8221;, &#8216;ENCODE&#8217;), $cookietime);<br \/>\n<br \/> }<br \/>\n<br \/> }<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u73af\u5883\uff1aApache\/2.2.21&#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-199347","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199347","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=199347"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199347\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=199347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=199347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=199347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}