CREATE TABLE cdb_downloadlist (
uid int(8) unsigned NOT NULL default '0',
dateline int(10) unsigned NOT NULL default '0',
fid int(8) unsigned NOT NULL default '0',
tid int(8) unsigned NOT NULL default '0',
pid int(8) unsigned NOT NULL default '0',
aid int(8) unsigned NOT NULL default '0',
subject varchar(255) NOT NULL default 'None',
username varchar(255) NOT NULL default 'Guest'
) TYPE=MyISAM;
$db->query("UPDATE {$tablepre}attachments SET downloads=downloads+'1' WHERE aid='$aid'", 'UNBUFFERED');
$query = $db->query("SELECT * FROM {$tablepre}threads WHERE tid='$attach[tid]'");
$info = $db->fetch_array($query);
$db->query("INSERT INTO {$tablepre}downloadlist (uid,dateline,fid,tid,pid,aid,subject,username) Values ('$discuz_uid','$timestamp','$info[fid]','$attach[tid]','$attach[pid]','$aid','$info[subject]','$discuz_userss')");
} elseif($action == 'rate' && $pid) {
} elseif($action == 'viewlists' && $pid) {
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
require_once './forumdata/cache/cache_forums.php';
require_once './include/attachment.func.php';
$querys = $db->query("SELECT COUNT(*) FROM {$tablepre}downloadlist WHERE pid='$pid'");
$num = $db->result($querys, 0);
$multipage = multi($num, $tpp, $page, 'misc.php?action=viewlists&tid='.$thread['tid'].'&pid='.$pid);
$querya = $db->query("SELECT * FROM {$tablepre}attachments WHERE pid='$pid' ORDER BY dateline DESC");
while($atta = $db->fetch_array($querya)) {
$extension = strtolower(fileext($atta['filename']));
$attachs[$atta['aid']]['attachicon'] = attachtype($extension."\t".$atta['filetype']);
$attachs[$atta['aid']]['name']=$atta['filename'];
$attachs[$atta['aid']]['size']=sizecount($atta['filesize']);
}
$queryr = $db->query("SELECT * FROM {$tablepre}downloadlist WHERE pid='$pid' ORDER BY dateline DESC LIMIT $start_limit, $tpp");
$queryp = $db->query("SELECT * FROM {$tablepre}posts WHERE pid='$pid' AND invisible='0'");
if(!($db->num_rows($queryr)) || !($db->num_rows($queryp))) {
showmessage('对不起,指定附件在近一年内没有下载记录,请返回。');
}
$post = $db->fetch_array($queryp);
if($post['tid'] != $thread['tid']) {
showmessage('undefined_action', NULL, 'HALTED');
}
$loglist = array();
while($log = $db->fetch_array($queryr)) {
$log['dateline'] = gmdate("$dateformat $timeformat", $log['dateline'] + $timeoffset * 3600);
$loglist[] = $log;
}
include template('downloadlist_view');
{lang attachment}</div><div class="msgborder" style="padding: 0px; border-bottom: 0px;">
{lang attachment} <a href="misc.php?action=viewlists&tid=$tid&pid=$post[pid]">(下载记录)</a></div><div class="msgborder" style="padding: 0px; border-bottom: 0px;">