【適用版本】: 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 目錄下
~完成~