Discuz! 插件: 网盘链接可见性控制 - 隐藏百度网盘、115网盘、阿里网盘链接
这是一个 Discuz! 插件,用于隐藏论坛帖子中来自百度网盘、115网盘和阿里网盘的分享链接,仅允许帖子作者和回复者查看。
插件代码如下:
<?php
if (!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class plugin_wangpancheck {
}
class plugin_wangpancheck_forum extends plugin_wangpancheck {
var $thread_author_id;
function viewthread_postbottom_output() {
global $_G, $postlist, $bestpost;
$bestpost['message'] = '';
foreach ($postlist as &$post) {
// 如果是主题的第一篇帖子,保存楼主的ID
if ($post['first']) {
$this->thread_author_id = $post['authorid'];
}
// 判断当前用户是否是帖子回复者或者楼主
$isAuthorOrThreadAuthor = ($_G['uid'] == $post['authorid']) || ($_G['uid'] == $this->thread_author_id);
// 如果不是作者或主题作者,则替换含有 'baidu.com', '115.com' 或 'aliyundrive.com' 的整个链接
if (!$isAuthorOrThreadAuthor) {
if (strpos($post['message'], 'baidu.com') !== false) {
$post['message'] = preg_replace('/http[s]?://[^ ]*baidu.com[^ ]*/i', '***百度网盘分享链接仅楼主和回帖人可见***', $post['message']);
}
if (strpos($post['message'], '115.com') !== false) {
$post['message'] = preg_replace('/http[s]?://[^ ]*115.com[^ ]*/i', '***115网盘分享链接仅楼主和回帖人可见***', $post['message']);
}
if (strpos($post['message'], 'aliyundrive.com') !== false) {
$post['message'] = preg_replace('/http[s]?://[^ ]*aliyundrive.com[^ ]*/i', '***阿里网盘分享链接仅楼主和回帖人可见***', $post['message']);
}
// 移除所有的 a 标签以确保替换后的文本不再是超链接
$post['message'] = preg_replace('/<a[^>]*>|</a>/i', '', $post['message']);
}
}
}
}
该插件可以有效地保护网盘分享链接的隐私,避免恶意复制和传播。请尊重开发者的知识产权,不要恶意抄袭和篡改代码。
原文地址: https://www.cveoy.top/t/topic/oYiw 著作权归作者所有。请勿转载和采集!