## 解析dedecms使用关键词关联文章无效的解决方法

Copy to ClipboardLiehuo.Net Codes引用的内容：[] if(\$arr['type']=='htmltext' && \$GLOBALS['cfg_keyword_replace']=='Y' && !empty(\$this->Fields['keywords'])) { \$this->Fields[\$nk] = \$this->ReplaceKeyword(\$this->Fields['keywords'],\$this->Fields[\$nk]); }

Copy to ClipboardLiehuo.Net Codes引用的内容：[] function ReplaceKeyword(\$kw,&\$body) { global \$cfg_cmspath; \$maxkey = 5; \$kws = explode(",",trim(\$kw)); //以分好为间隔符 \$i=0; \$karr = \$kaarr = \$GLOBALS['replaced'] = array(); //暂时屏蔽超链接 \$body = preg_replace("/(<a(.*))(>)(.*)(<)(\/a>)/isU", '\\1-]-\\4-[-\\6', \$body); foreach(\$kws as \$k) { \$k = trim(\$k); if(\$k!="") { if(\$i > \$maxkey) { break; } \$myrow = \$this->dsql->GetOne("select * from [url=mailto:dede_keywords]dede_keywords[/url] where keyword='\$k' And rpurl<>'' "); if(is_array(\$myrow)) { \$karr[] = \$k; \$GLOBALS['replaced'][\$k] = 0; \$kaarr[] = "<a href='{\$myrow['rpurl']}'><u>\$k</u></a>"; } \$i++; } } \$body = preg_replace("/(^|>)([^<]+)(?=<|\$)/sUe", "_highlight('\\2', \\$karr, \\$kaarr, '\\1')", \$body); //恢复超链接 \$body = preg_replace("/(<a(.*))-\]-(.*)-\[-(\/a>)/isU", '\\1>\\3<[url=file://\\4]\\4'[/url], \$body); return \$body; }

Copy to ClipboardLiehuo.Net Codes引用的内容：[] if(\$arr['type']=='htmltext' && \$GLOBALS['cfg_keyword_replace']=='Y') { \$this->Fields[\$nk] = \$this->ReplaceKeyword(\$this->Fields['keywords'],\$this->Fields[\$nk]); }

Copy to ClipboardLiehuo.Net Codes引用的内容：[] function ReplaceKeyword(\$kw,&\$body) { global \$cfg_cmspath; \$maxkey = 5; \$kws = explode(",",trim(\$kw)); //以分好为间隔符 \$i=0; \$karr = \$kaarr = \$GLOBALS['replaced'] = array(); //暂时屏蔽超链接 \$body = preg_replace("/(<a(.*))(>)(.*)(<)(\/a>)/isU", '\\1-]-\\4-[-\\6', \$body); global \$dsql; \$query="SELECT * FROM [url=mailto:dede_keywords]dede_keywords[/url] WHERE rpurl<>'' ORDER BY rank DESC"; \$dsql->SetQuery(\$query); \$dsql->Execute(); while(\$row = \$dsql->GetArray()) { \$key = trim(\$row['keyword']); \$key_url=trim(\$row['rpurl']); \$karr[] = \$key; \$kaarr[] = "<a href='\$key_url' target='_blank'><u>\$key</u></a>"; } \$body = preg_replace("/(^|>)([^<]+)(?=<|\$)/sUe", "_highlight('\\2', \\$karr, \\$kaarr, '\\1')", \$body); //恢复超链接 \$body = preg_replace("/(<a(.*))-\]-(.*)-\[-(\/a>)/isU", '\\1>\\3<[url=file://\\4]\\4'[/url], \$body); return \$body; }

cfg_keyword_replace是指关键字替换(是/否)使用本功能会影响HTML生成速度： 这项 而cfg_keyword_like 是指使用关键词关连文章： • 全部评论（0
还没有评论，快来抢沙发吧！
{"ft_lang_label":"__label__zh","ft_lang_prob":0.65388244,"math_prob":0.9783889,"size":3563,"snap":"2019-35-2019-39","text_gpt3_token_len":1992,"char_repetition_ratio":0.12138241,"word_repetition_ratio":0.37068966,"special_character_ratio":0.33398822,"punctuation_ratio":0.18548387,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9770034,"pos_list":[0,1,2],"im_url_duplicate_count":[null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-09-20T01:29:23Z\",\"WARC-Record-ID\":\"<urn:uuid:63568044-5fed-4780-a770-fc2b0aeb2b41>\",\"Content-Length\":\"23240\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:0bcafb72-6bbd-47a0-8f30-ffc700f4aa5c>\",\"WARC-Concurrent-To\":\"<urn:uuid:c562b7d8-b744-4192-ae30-7ada7d3f1e3d>\",\"WARC-IP-Address\":\"39.96.41.128\",\"WARC-Target-URI\":\"https://wjwblog.com/jc/1203.html\",\"WARC-Payload-Digest\":\"sha1:KI7MYCK2TLIWXDMBH4OLDI4K65WNWTXO\",\"WARC-Block-Digest\":\"sha1:TOIC2ZDWH7QCR5UOFJM4QPYKZ2PFLV76\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-39/CC-MAIN-2019-39_segments_1568514573801.14_warc_CC-MAIN-20190920005656-20190920031656-00069.warc.gz\"}"}