打开:在148行左右找到:\source\include\portalcp\portalcp_article.php- $content = getstr($_POST['content'], 0, 0, 0, 0, 1);
复制代码 在下面插入代码:- require_once DISCUZ_ROOT.'/keywords.php';
- foreach ($keywordsmeishiq as $values){
- $content=str_replace_once($values['key'],$values['ok'],$content);
- }
复制代码 新建一个文件保存为:keywords.php放到网址的根目录;文内容如下:- <?php
- function str_replace_once($needle, $replace, $haystack) {
- $needle2='>'.$needle;
- $needle3='/'.$needle;
- $pos2 = strpos($haystack, $needle2);
- $pos2 =$pos2?$pos2:strpos($haystack, $needle3);
- $pos = strpos($haystack, $needle);
- if ($pos2) {
- return $haystack;
- }elseif($pos === false){
- return $haystack;
- }else{
- return substr_replace($haystack, $replace, $pos, strlen($needle));
- }
- }
- $keywordsmeishiq=array();
- $keywordsmeishiq[] = array('key'=>'美食','ok'=>'<a href="http://www.meishiq.com/">美食</a>');
- $keywordsmeishiq[] = array('key'=>'牛肉','ok'=>'<a href="<a href="http://www.meishiq.com/做法/牛肉/">牛肉</a>');
- $keywordsmeishiq[] = array('key'=>'茄子','ok'=>'<a href="<a href="http://www.meishiq.com/做法/茄子/">茄子</a>');
- $keywordsmeishiq[] = array('key'=>'羊肉','ok'=>'<a href="<a href="http://www.meishiq.com/做法/羊肉/">羊肉</a>');
- $keywordsmeishiq[] = array('key'=>'鸡肉','ok'=>'<a href="<a href="http://www.meishiq.com/做法/鸡肉/">鸡肉</a>');
- $keywordsmeishiq[] = array('key'=>'猪','ok'=>'<a href="<a href="http://www.meishiq.com/做法/猪肉/">猪</a>');
- $keywordsmeishiq[] = array('key'=>'鱼','ok'=>'<a href="<a href="http://www.meishiq.com/做法/鱼肉/">鱼</a>');
- $keywordsmeishiq[] = array('key'=>'家常菜','ok'=>'<a href="http://www.meishiq.com/jiangchangcai/">家常菜</a>');
- $keywordsmeishiq[] = array('key'=>'私房菜','ok'=>'<a href="http://www.meishiq.com/jiangchangcai/sifangcai/">私房菜</a>');
- ?>
复制代码 能看懂代码吧。就是把上面的改成你的地址和关键字就好了。很简单的斯密达。
|