织梦重复文档检测结果增加导出到文档的方法

时间:2021-11-25
类别:教程 - CMS教程

织梦DEDE后台重复文档检测功能,增加结果显示文档id和文档url链接,此功能方便记录查看和删除后提交到百度删除死链,增加网站SEO功能。

效果图如下:

最终效果图

实现方法如下:

1、打开 /dede/templets/article_result_same.htm 找到,大概在114行

  1. <?php echo $row['title']; ?> 

在它下面加入

  1. ( <?php echo $row['id']; ?> ) ( <?php $arcrow=GetOneArchive($row['id']);echo $arcrow['arcurl']; ?> ) <input name="arcIds" type="checkbox" id="arcId" value="<?php echo $row['id'];?>" style="display:none;" checked /> 

继续找到129行左右的

  1. (共有 <?php echo $allarc; ?> 篇重复标题的文档!) 

在它上面加入

  1. <input type='button' name='bt4' value='导出全部链接' onclick='expArc()' />&nbsp; 
  2.  
  3. <script> 
  4.  
  5. function expArc(){ 
  6.  
  7.     var qstr=""
  8.  
  9.     if(document.form2.arcId.value) return document.form2.arcId.value; 
  10.  
  11.     for(i=0;i<document.form2.arcId.length;i++) 
  12.  
  13.     { 
  14.  
  15.         if(document.form2.arcId[i].checked) 
  16.  
  17.         { 
  18.  
  19.             if(qstr==""
  20.  
  21.                 qstr=document.form2.arcId[i].value; 
  22.  
  23.             else 
  24.  
  25.                 qstr=qstr+"`"+document.form2.arcId[i].value; 
  26.  
  27.         } 
  28.  
  29.     } 
  30.  
  31.     document.form2.titles.value = qstr; 
  32.  
  33.     document.form2.dopost.value = 'export'
  34.  
  35.     document.form2.submit(); 
  36.  
  37.  
  38. </script> 

2、打开 /dede/article_test_same.php 找到

  1. COUNT(title) AS dd,title 

改成

  1. COUNT(title) AS dd,title,id 

继续找到大概在30行

  1. //删除选中的内容(只保留一条) 

在它上面加入

  1. else if($dopost=='export'
  2.  
  3.  
  4.     if(emptyempty($titles)) 
  5.  
  6.     { 
  7.  
  8.         header("Content-Type: text/html; charset={$cfg_ver_lang}"); 
  9.  
  10.         echo "<meta http-equiv="Content-Type" content="text/html; charset={$cfg_ver_lang}"> "
  11.  
  12.         echo "没有指定导出的文档!"
  13.  
  14.         exit(); 
  15.  
  16.     } 
  17.  
  18.     if(isset($cfg_basehost) && $cfg_basehost != '/'
  19.  
  20.     { 
  21.  
  22.         $domain = $cfg_basehost
  23.  
  24.     } 
  25.  
  26.     else 
  27.  
  28.     { 
  29.  
  30.         if(isset($_SERVER['HTTPS']) && ('1' == $_SERVER['HTTPS'] || 'on' == strtolower($_SERVER['HTTPS']))){ 
  31.  
  32.             $SERVER_PORT = 'https://'
  33.  
  34.         }elseif(isset($_SERVER['SERVER_PORT']) && ('443' == $_SERVER['SERVER_PORT'] )) { 
  35.  
  36.             $SERVER_PORT = 'https://'
  37.  
  38.         }else
  39.  
  40.             $SERVER_PORT = 'http://'
  41.  
  42.         } 
  43.  
  44.         $domain = $SERVER_PORT . $_SERVER['HTTP_HOST']; 
  45.  
  46.     } 
  47.  
  48.     $content = ""
  49.  
  50.     $ids = split('`',$titles); 
  51.  
  52.     foreach($ids as $id
  53.  
  54.     { 
  55.  
  56.         $arcrow = GetOneArchive($id); 
  57.  
  58.         $content .= $domain . str_replace($domain''$arcrow['arcurl']) . " "
  59.  
  60.     } 
  61.  
  62.     Header("Content-type:application/octet-stream"); 
  63.  
  64.     Header("Accept-Ranges:bytes"); 
  65.  
  66.     header("Content-Disposition:attachment;filename=badlink.txt"); 
  67.  
  68.     header("Expires:0"); 
  69.  
  70.     header("Cache-Control:must-revalidate,post-check=0,pre-check=0 "); 
  71.  
  72.     header("Pragma:public"); 
  73.  
  74.     echo $content
  75.  
  76.     exit(); 
  77.  

修改保存后即可完成。

    收藏