织梦列表页 {page}列表的页码 防采集设置

织梦列表页命名规则一般为:{typedir}/list_{tid}_{page}.html如图:

织梦列表页 {page}列表的页码 防采集设置

所以一般显示的文件名为:list_1_1.html、list_1_2.html、list_1_3.html、list_1_4.html.这种格式对于采集者来说,很容易采集到你网站文章,哪如何避免呢?

下面是修改方法(原理,对list_1_X.html中的X做MD5处理):

1、修改:include/arc.listview.class.php文件在底部 }//End Class前新增代码:

function wjwpage($wjwpage)
{
$wjwpage =  md5(md5('349ufYJGhds4yr#^ajsbLKasd'.$wjwpage));
return substr(md5($wjwpage), 8, 16);
}
上面代码把page传入做二次MD5加密,加密的同时加骚乱字符串,防止采集者破解。在返回page也就是上面中的X。

2、在322行

$makeFile = str_replace("{page}",$this->PageNo, $makeFile);

修改为$makeFile = str_replace("{page}", $this->wjwpage($this->PageNo), $makeFile);

3、修改静态函数 GetPageListST代码如下:

/**
*  获取静态的分页列表
*
* @access    public
* @param     string  $list_len  列表宽度
* @param     string  $list_len  列表样式
* @return    string
*/
function GetPageListST($list_len,$listitem="index,end,pre,next,pageno")
{
$prepage = $nextpage = '';
$prepagenum = $this->PageNo-1;
$nextpagenum = $this->PageNo+1;
if($list_len=='' || preg_match("/[^0-9]/", $list_len))
{
$list_len=3;
}
$totalpage = ceil($this->TotalResult/$this->PageSize);
if($totalpage<=1 && $this->TotalResult>0)
{
return "<li><span class="pageinfo">共 <strong>1</strong>页<strong>".$this->TotalResult."</strong>条记录</span></li>rn";
}
if($this->TotalResult == 0)
{
return "<li><span class="pageinfo">共 <strong>0</strong>页<strong>".$this->TotalResult."</strong>条记录</span></li>rn";
}
$purl = $this->GetCurUrl();
$maininfo = "<li><span class="pageinfo">共 <strong>{$totalpage}</strong>页<strong>".$this->TotalResult."</strong>条</span></li>rn";
$tnamerule = $this->GetMakeFileRule($this->Fields['id'],"list",$this->Fields['typedir'],$this->Fields['defaultname'],$this->Fields['namerule2']);
$tnamerule = preg_replace("/^(.*)//", '', $tnamerule);

//获得上一页和主页的链接
if($this->PageNo != 1)
{
$prepage.="<li><a href='".str_replace("{page}",$this->wjwpage($prepagenum),$tnamerule)."'>上一页</a></li>rn";
$indexpage="<li><a href='".str_replace("{page}",$this->wjwpage(1),$tnamerule)."'>首页</a></li>rn";
}
else
{
$indexpage="<li>首页</li>rn";
}

//下一页,未页的链接
if($this->PageNo!=$totalpage && $totalpage>1)
{
$nextpage.="<li><a href='".str_replace("{page}",$this->wjwpage($nextpagenum),$tnamerule)."'>下一页</a></li>rn";
$endpage="<li><a href='".str_replace("{page}",$this->wjwpage($totalpage),$tnamerule)."'>末页</a></li>rn";
}
else
{
$endpage="<li>末页</li>rn";
}

//option链接
$optionlist = '';
$optionlen = strlen($totalpage);
$optionlen = $optionlen*12 + 18;
if($optionlen < 36) $optionlen = 36;
if($optionlen > 100) $optionlen = 100;
$optionlist = "<li><select name='sldd' style='width:{$optionlen}px' onchange='location.href=this.options[this.selectedIndex].value;'>rn";
for($mjj=1;$mjj<=$totalpage;$mjj++)
{
if($mjj==$this->PageNo)
{
$optionlist .= "<option value='".str_replace("{page}",$this->wjwpage($mjj),$tnamerule)."' selected>$mjj</option>rn";
}
else
{
$optionlist .= "<option value='".str_replace("{page}",$this->wjwpage($mjj),$tnamerule)."'>$mjj</option>rn";
}
}
$optionlist .= "</select></li>rn";

//获得数字链接
$listdd="";
$total_list = $list_len * 2 + 1;
if($this->PageNo >= $total_list)
{
$j = $this->PageNo-$list_len;
$total_list = $this->PageNo+$list_len;
if($total_list>$totalpage)
{
$total_list=$totalpage;
}
}
else
{
$j=1;
if($total_list>$totalpage)
{
$total_list=$totalpage;
}
}
for($j;$j<=$total_list;$j++)
{
if($j==$this->PageNo)
{
$listdd.= "<li class="thisclass">".$j."</li>rn";
}
else
{
$listdd.="<li><a href='".str_replace("{page}",$this->wjwpage($j),$tnamerule)."'>".$j."</a></li>rn";
}
}
$plist = '';
if(preg_match('/index/i', $listitem)) $plist .= $indexpage;
if(preg_match('/pre/i', $listitem)) $plist .= $prepage;
if(preg_match('/pageno/i', $listitem)) $plist .= $listdd;
if(preg_match('/next/i', $listitem)) $plist .= $nextpage;
if(preg_match('/end/i', $listitem)) $plist .= $endpage;
if(preg_match('/option/i', $listitem)) $plist .= $optionlist;
if(preg_match('/info/i', $listitem)) $plist .= $maininfo;

return $plist;
}

整个函数只要是生成静态时把对应数字的链接加密成MD5。

4、清空plus/list.php文件代码。这里主要是防止采集者通过动态链接plus/list.php?tid=1获取文章列表。

最后展示结果:

织梦列表页 {page}列表的页码 防采集设置

总结

以上方法只对静态织梦网站有效,动态或者伪静态网站无效,动态站可以参考上面方法修改动态函数及plus/list.php文件。

发表评论

您的邮箱地址不会被公开。 必填项已用 * 标注