from:
http://www.alan888.com/Discuz/thread-126446-1-1.html
AL8 附件下載名單 For 6.0
適用版本: Discuz 6.0
作者: alan888
演示:
http://www.alan888.com/D6/thread-1-1-2.html
附注:
1. 此
插件部份修改源自下帖, 作者: AndyGod
http://www.alan888.com/Discuz/viewthread.php?tid=1413
2. 從其他版本
升級不用執行下面步驟 (1) 的資料庫
升級
3. 下載名單只能顯示於安裝此插件後的下載者, 同時下載次數與顯示下載名單的數量也會有差異
修改辦法
1. 資料庫升級
複製內容到剪貼簿
代碼:
ALTER TABLE `cdb_attachments` ADD `dl_users` TEXT NOT NULL ;2. attachment.php
找
複製內容到剪貼簿
代碼:
$db->query("UPDATE {$tablepre}attachments SET downloads=downloads+'1' 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'");
}2. 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)-1;
$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 = '<a href="space.php?action=viewpro&username='.rawurlencode(trim($dlid)).'" target="_blank">'.$dlid.'</a>';
$dllist[] = $dlid;
}
}
include template('dluserlist');3. 修改 discuzcode 模版
找
複製內容到剪貼簿
代碼:
<dl 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>找
複製內容到剪貼簿
代碼:
$attach[dateline], {lang downloads}: $attach[downloads]在下面加上
複製內容到剪貼簿
代碼:
<!--{if $attach[downloads] > 0}-->
<a href="###" onclick="showdllist($attach[aid])"><span style="color:{LIGHTTEXT}; font-weight:normal">[下載名單]</span></a>
<!--{/if}-->找
複製內容到剪貼簿
代碼:
<!--{if $attach['description']}--><p>{$attach[description]}</p><!--{/if}-->
</dd>
<!--{/if}-->
</dl>在下面加上
複製內容到剪貼簿
代碼:
<div id="viewdluserframe$attach[aid]" style="width:100%;clear:both;display:none; margin-top:5;"></div>4. 下載附件 dluserlist
模板解壓後上載至 templates/default 目錄下
5. 往後台 "更新快取"
~完成~