列印

AL8 附件下載名單 For 6.0

AL8 附件下載名單 For 6.0

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&amp;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}-->
                  &nbsp;&nbsp;<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. 往後台 "更新快取"

~完成~
附件: 您所在的用戶組無法下載或查看附件
Hack 安裝錯誤, 80% 來自粗心, 請專心安裝
Linux0911 打造您的個性論壇

本人現在忙於研究所, 沒多的時間管論壇, 有問題別發 pm 給我, 謝謝~
Linux0911 Forum © 2004-2009 All Rights Reserved.

TOP

我是用UTF-8, 要怎麼做??
Linux0911 Forum © 2004-2009 All Rights Reserved.

TOP



論壇聲明
  • 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
    如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
    請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!
最佳瀏覽解析度:不低於 1024 (最佳 1280 以上).(支援 IE 7, Mozilla Firefox, Safari, Chrome)
The Best Surfing Resolution: No Lower than 1024 (Best: above 1280).(IE 7, Mozilla Firefox, Safari, Chrome Supported)