织梦如何禁止会员发布文章内容带超链接

织梦会员中心发布文章自动过滤外部外部链接,保留本站站内链接。这个织梦默认后台本身带有这样的功能的,只是会员模块里没有而已。

我们可以把功能嫁接到会员模块里去使用,实现自动过滤外部链接

实现教程

打开 /member/inc/inc_archives_functions.php 在文件的最下面插入

/**
 *  删除非站内链接
 *
 * @access    public
 * @param     string  $body  内容
 * @param     array  $allow_urls  允许的超链接
 * @return    string
 */
function Replace_Links( &$body, $allow_urls=array()  )
{
    $host_rule = join('|', $allow_urls);
    $host_rule = preg_replace("#[\n\r]#", '', $host_rule);
    $host_rule = str_replace('.', "\\.", $host_rule);
    $host_rule = str_replace('/', "\\/", $host_rule);
    $arr = '';
    preg_match_all("#<a([^>]*)>(.*)<\/a>#iU", $body, $arr);
    if( is_array($arr[0]) )
    {
        $rparr = array();
        $tgarr = array();
        foreach($arr[0] as $i=>$v)
        {
            if( $host_rule != '' && preg_match('#'.$host_rule.'#i', $arr[1][$i]) )
            {
                continue;
            } else {
                $rparr[] = $v;
                $tgarr[] = $arr[2][$i];
            }
        }
        if( !empty($rparr) )
        {
            $body = str_replace($rparr, $tgarr, $body);
        }
    }
    $arr = $rparr = $tgarr = '';
    return $body;
}

继续在这个文件中找到,大概在329行

//自动摘要

在它上面加入

//删除非站内链接
$allow_urls = array($_SERVER['HTTP_HOST']);
// 读取允许的超链接设置
if(file_exists(DEDEDATA."/admin/allowurl.txt"))
{
	$allow_urls = array_merge($allow_urls, file(DEDEDATA."/admin/allowurl.txt"));
}
$body = Replace_Links($body, $allow_urls);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你可以使用 Apache POI 库来生成超链接的 Word 目录。下面是一个使用 Java 生成超链接的 Word 目录的示例代码: ```java import org.apache.poi.xwpf.usermodel.*; import java.io.FileOutputStream; import java.io.IOException; public class WordTableOfContentsExample { public static void main(String[] args) { try { // 创建一个新的文档 XWPFDocument document = new XWPFDocument(); // 添加一个标题 XWPFParagraph title = document.createParagraph(); XWPFRun run = title.createRun(); run.setText("Table of Contents"); run.setBold(true); run.setFontSize(14); // 添加目录 XWPFParagraph toc = document.createParagraph(); CTSimpleField tocField = toc.getCTP().addNewFldSimple(); tocField.setInstr("TOC \\o \"1-3\" \\h \\z \\u"); // 添加章节标题 XWPFParagraph chapter1Title = document.createParagraph(); XWPFHyperlink hyperlink = chapter1Title.createHyperlink(); hyperlink.setAnchor("chapter1"); XWPFRun chapter1Run = hyperlink.createRun(); chapter1Run.setText("Chapter 1: Introduction"); // 添加章节内容 XWPFParagraph chapter1Content = document.createParagraph(); XWPFRun chapter1ContentRun = chapter1Content.createRun(); chapter1ContentRun.setText("This is the content of chapter 1."); // 保存文档 FileOutputStream out = new FileOutputStream("TableOfContents.docx"); document.write(out); out.close(); System.out.println("Table of Contents generated successfully!"); } catch (IOException e) { e.printStackTrace(); } } } ``` 这个示例代码创建了一个有目录的 Word 文档。你可以根据需要添加更多的章节标题和内容。在目录中,使用 `XWPFHyperlink` 创建超链接,并设置 `setAnchor` 方法来指定目标位置。在章节标题和内容中,使用 `XWPFRun` 来添加文本内容。 运行代码后,会生成一个名为 "TableOfContents.docx" 的 Word 文档,其中包含了超链接的目录。 请注意,为了运行此示例代码,你需要在你的项目中添加 Apache POI 库的依赖。你可以通过 Maven 或 Gradle 来添加依赖。 希望这可以帮助到你!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值