ecshop自动内链插件seo优化插件
ecshop自动内链插件seo优化插件安装教程:
1.打开admin\includes里面的inc_menu.php文件:
添加:
$modules['11_system']['auto_neilian'] = 'auto_neilian.php?act=list_edit'; // ecshop自动内链插件
如图:
2.languages\zh_cn\admin\common.php 增加语言项
/* 系统设置 */
$_LANG['01_shop_config'] = '商店设置';
$_LANG['auto_neilian'] = '自动添加内链设置';
3 修改跟目录article.php
搜索: ./* 获得文章的信息 *
找到:$row['author'] = $GLOBALS['_CFG']['shop_name'];
在: {
$row['author'] = $GLOBALS['_CFG']['shop_name'];
}
下方增加:
//seo内链插件 start
function str_replace_once($needle, $replace, $haystack) {
//函数作用,只替换一次字符
//$needle --- 需要替换的字符
//$replace --- 替换成什么字符
//$haystack --- 需要操作的字符串
$pos = strpos($haystack, $needle);
if ($pos === false) {
return $haystack;
}
return substr_replace($haystack, $replace, $pos, strlen($needle));
}
$content = file_get_contents("data/auto_neilian.php");
$array = explode("\r\n",$content);
foreach ($array AS $value){
$tmp = explode("---",$value);
if ($tmp !== false){
if($tmp[1]){
$str = "<a target='_blank' href='".$tmp[1]."'>".$tmp[0]."</a>";
}
else{
$str = "<a target='_blank' href='search.php?keywords=".rawurlencode($tmp[0])."'>".$tmp[0]."</a>";
}
$str_1 = $tmp[0];
$str_2 = $str;
$tmp1 = explode("<",$row['content']);
foreach ($tmp1 as $key=>$item){
$tmp2 = explode(">",$item);
if (sizeof($tmp2)>1) {
if(substr($tmp2[0],0,1)!="a" && substr($tmp2[0],0,1)!="A"){
if(strpos($tmp2[1],$str_1)!==false){
$tmp2[1] = str_replace_once($str_1,$str_2,$tmp2[1]);
$tmp1[$key] = implode(">",$tmp2);
break;
}
}
}
}
$row['content'] = implode("<",$tmp1);
}
}
//seo内链插件 end
4. 修改跟目录goods.php
/* 如果没有找到任何记录则跳回到首页 */
ecs_header("Location: ./\n");
exit;
}
else
{
下方增加:
//seo内链插件 start
//$content = iconv("GB2312","UTF-8",file_get_contents("data/auto_neilian.php"));
function str_replace_once($needle, $replace, $haystack) {
//函数作用,只替换一次字符
//$needle --- 需要替换的字符
//$replace --- 替换成什么字符
//$haystack --- 需要操作的字符串
$pos = strpos($haystack, $needle);
if ($pos === false) {
return $haystack;
}
return substr_replace($haystack, $replace, $pos, strlen($needle));
}
$content = file_get_contents("data/auto_neilian.php");
$array = explode("\r\n",$content);
foreach ($array AS $value){
$tmp = explode("---",$value);
if ($tmp !== false){
if($tmp[1]){
$str = "<a target='_blank' href='".$tmp[1]."'>".$tmp[0]."</a>";
}
else{
$str = "<a target='_blank' href='search.php?keywords=".rawurlencode($tmp[0])."'>".$tmp[0]."</a>";
}
$str_1 = $tmp[0];
$str_2 = $str;
$tmp1 = explode("<",$goods['goods_desc']);
foreach ($tmp1 as $key=>$item){
$tmp2 = explode(">",$item);
if (sizeof($tmp2)>1) {
if(substr($tmp2[0],0,1)!="a" && substr($tmp2[0],0,1)!="A"){
if(strpos($tmp2[1],$str_1)!==false){
$tmp2[1] = str_replace_once($str_1,$str_2,$tmp2[1]);
$tmp1[$key] = implode(">",$tmp2);
break;
}
}
}
}
$goods['goods_desc'] = implode("<",$tmp1);
}
}
//seo内链插件 end
5. 剩下全部覆盖就可以了 !