{"id":1586,"date":"2018-04-19T13:50:45","date_gmt":"2018-04-19T05:50:45","guid":{"rendered":"http:\/\/www.baishitou.cn\/?p=1586"},"modified":"2018-04-21T13:25:08","modified_gmt":"2018-04-21T05:25:08","slug":"%e7%bb%87%e6%a2%a6dedecms%e5%9c%a8php%e7%89%88%e6%9c%ac%e9%ab%98%e4%ba%8e5-5%e7%9a%84%e6%83%85%e5%86%b5%e4%b8%8b%e6%97%a0%e6%b3%95%e4%bd%bf%e7%94%a8%e5%85%b3%e9%94%ae%e8%af%8d%e5%85%a7%e9%93%be","status":"publish","type":"post","link":"https:\/\/www.baishitou.cn\/1586.html","title":{"rendered":"\u7ec7\u68a6DEDECMS\u5728PHP\u7248\u672c\u9ad8\u4e8e5.5\u7684\u60c5\u51b5\u4e0b\u65e0\u6cd5\u4f7f\u7528\u5173\u952e\u8bcd\u5167\u94fe\u7684\u89e3\u51b3\u65b9\u6cd5"},"content":{"rendered":"
\u7ec7\u68a6DEDECMS\u5728PHP\u7248\u672c\u9ad8\u4e8e5.5\u7684\u60c5\u51b5\u4e0b\u65e0\u6cd5\u4f7f\u7528\u5173\u952e\u8bcd\u5167\u94fe\u7684\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n
\u6253\u5f00\/include\/arc.archives.class.php \u627e\u5230 \u627e\u5230\uff1a<\/p>\n
$body<\/span> = @preg_replace_callback<\/span>(\"#(^|>)([^<]+)(?=<|$)#sU\"<\/span>, \"_highlight('\\\\2', \\$karr, \\$kaarr, '\\\\1')\"<\/span>, $body<\/span>);<\/code><\/pre>\n\u66ff\u6362\u6210\uff1a<\/p>\n
global $cfg_replace_num;\r\nif($cfg_replace_num > 0)\r\n{\r\n $query = \"SELECT * FROM #@__keywords WHERE rpurl<>'' ORDER BY rank DESC\";\r\n $this->dsql->SetQuery($query);\r\n $this->dsql->Execute();\r\n while($row = $this->dsql->GetArray())\r\n {\r\n $key = trim($row['keyword']);\r\n $key_url=trim($row['rpurl']);\r\n $body = str_replace_limit($key, \"<a href='$key_url' target='_blank'><u>$key<\/u><\/a>\", $body, $cfg_replace_num);\r\n }\r\n\r\n}\r\nelse\r\n{\r\n $query = \"SELECT * FROM #@__keywords WHERE rpurl<>'' ORDER BY rank DESC\";\r\n $this->dsql->SetQuery($query);\r\n $this->dsql->Execute();\r\n while($row = $this->dsql->GetArray())\r\n {\r\n $key = trim($row['keyword']);\r\n $key_url=trim($row['rpurl']);\r\n $body = str_replace($key, \"<a href='$key_url' target='_blank'><u>$key<\/u><\/a>\", $body);\r\n }\r\n}<\/code><\/pre>\n\u641c\u7d22<\/p>\n
\/\/\u9ad8\u4eae\u4e13\u7528<\/code><\/pre>\n\u5728\u5b83\u4e0a\u9762\u6dfb\u52a0<\/p>\n
\/\/\u6307\u5b9a\u66ff\u6362\u6b21\u6570\u529f\u80fd\r\nfunction str_replace_limit($search, $replace, $subject, $limit)\r\n{\r\n if(is_array($search))\r\n {\r\n foreach($search as $k=>$v)\r\n {\r\n $search[$k] = '`'. preg_quote($search[$k], '`'). '`';\r\n }\r\n }\r\n else\r\n {\r\n $search = '`'. preg_quote($search, '`'). '`';\r\n }\r\n return preg_replace($search, $replace, $subject, $limit);\r\n}<\/code><\/pre>\n <\/p>\n","protected":false},"excerpt":{"rendered":"
\u7ec7\u68a6DEDECMS\u5728PHP\u7248\u672c\u9ad8\u4e8e5.5\u7684\u60c5\u51b5\u4e0b\u65e0\u6cd5\u4f7f\u7528\u5173\u952e\u8bcd\u5167\u94fe\u7684\u89e3\u51b3\u65b9\u6cd5\uff1a \u6253\u5f00\/include\/arc. […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[43,180],"class_list":["post-1586","post","type-post","status-publish","format-standard","hentry","category-web","tag-dedecms","tag-180"],"_links":{"self":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/posts\/1586","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/comments?post=1586"}],"version-history":[{"count":0,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/posts\/1586\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/media?parent=1586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/categories?post=1586"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/tags?post=1586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}