【适用版本】: Discuz 5.5
【作者】: alan888
附注:
1. 此插件部份修改源自下帖, 作者: AndyGod
http://www.alan888.com/Discuz...php?tid=14132. 从其他版本升级不用执行下面步骤 (1) 的数据库升级
3. 下载名单只能显示于安装此插件后的下载者, 同时下载次数与显示下载名单的数量也会有差异
修改办法1. 数据库升级
复制程式
ALTER TABLE `cdb_attachments` ADD `dl_users` TEXT NOT NULL ;
2. 修改 attachment.php
找
复制程式
$db->query("UPDATE {$tablepre}attachments SET downloads=downloads+Ƈ' WHERE aid='$aid'", 'UNBUFFERED');
更换为
复制程式
$query2 = $db->query("SELECT dl_users FROM{$tablepre}attachments WHERE aid='$aid' AND dl_users like'%$discuz_user,%'");
if($db->result($query2, 0)) {
} else {
$db->query("UPDATE {$tablepre}attachments SET downloads=downloads+1 WHERE aid='$aid'", 'UNBUFFERED');
$dl_user = $attach[dl_users].''.$discuz_user.', '
$dl_user = addslashes($dl_user);
$db->query("UPDATE {$tablepre}attachments SET dl_users='$dl_user' WHERE aid='$aid'");
}
3. 修改 misc.php
找
复制程式
} elseif($action == 'customtopics') {
在
上面加上
复制程式
} elseif($action == 'viewdluser') {
if(empty($forum['allowview'])) {
if(!$forum['viewperm'] && !$readaccess) {
showmessage('group_nopermission', NULL, 'NOPERM');
} elseif($forum['viewperm'] && !forumperm($forum['viewperm'])) {
showmessage('forum_nopermission', NULL, 'NOPERM');
}
}
if($thread['readperm'] && $thread['readperm'] >$readaccess && !$forum['ismoderator'] &&$thread['authorid'] != $discuz_uid) {
showmessage('thread_nopermission', NULL, 'NOPERM');
}
if($forum['password'] && $forum['password'] != $_DCOOKIE['fidpw'.$fid]) {
dheader("Location: {$boardurl}forumdisplay.php?fid=$fid&sid=$sid");
}
$dllistpp = 180; //每页显示名单数量
$page = $_GET['page'];
$dl_user = ''
$query = $db->query("SELECT dl_users FROM {$tablepre}attachments WHERE tid=$tid AND aid='$aid'");
$dl_user = $db->result($query, 0);
$dlusername = explode(",", trim($dl_user));
$num = count($dlusername);
$page = max(1, intval($page));
$start_limit = ($page - 1) * $dllistpp;
$multipage = multi($num, $dllistpp, $page, "misc.php?action=viewdluser&tid=$tid&aid=$aid");
$dlusername = @array_slice($dlusername, $start_limit, $dllistpp);
if($dlusername) {
$dllist = $dlid = array();
foreach($dlusername as $dlid) {
$dlid = '<ahref="viewpro.php?username='.rawurlencode(trim($dlid)).'"target="_blank">'.$dlid.'</a>'
$dllist[] = $dlid;
}
}
include template('dluserlist');
4. 修改 viewthread_attachlist 模板
找
复制程式
<div class="t_attachlist">
在
上面加上
复制程式
<script type="text/javascript">
function showdllist(aid) {
var obj = document.getElementById('viewdluserframe'+aid);
var url = 'misc.php?action=viewdluser&tid=$attach[tid]&aid='+aid;
showframe(obj, url);
}
function showframe(obj, url) {
if(!obj.innerHTML) {
obj.innerHTML = '<iframe width="100%"align="center" height="30" onload="setframeheight(this)"frameborder="0" scrolling="no" src="'+url+'"></iframe>'
}
if(obj.innerHTML) {
obj.style.display = obj.style.display == '' ? 'none' : ''
}
}
function setframeheight(obj) {
obj.height = obj.contentDocument ? obj.contentDocument.body.scrollHeight + 14 : obj.Document.body.scrollHeight;
}
</script>
找
复制程式
{lang downloads}: $attach[downloads]
在
下面加上
复制程式
<!--{if $attach[downloads] > 0}-->
<a href="###" onclick="showdllist($attach[aid])">[下载名单]</a>
<!--{/if}-->
找
复制程式
在
上面加上
复制程式
<div id="viewdluserframe$attach[aid]" style="width:100%;clear:both;display:none; margin-top:5;"></div>
5. 下载附件解压后上载至 templates/default 目录下
~完成~