ALTER TABLE `cdb_attachments` ADD `dl_users` TEXT NOT NULL ;
$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'");
}
<!--{if $post['attachment']}-->
<br><br><img src="images/attachicons/common.gif" alt="" /> {lang attachment}: <i>{lang attach_nopermission}</i>
<!--{elseif $hideattach && $post['attachments']}-->
<br><br><img src="images/attachicons/common.gif" alt="" /> {lang attachment}: <i>{lang attachment_reply_show}</i>
<!--{elseif $post['attachlist']}-->
<br><br>
<div class="msgbody"><div class="msgheader">
<!--{if CURSCRIPT != 'blog'}--><div class="right"><a href="member.php?action=credits&view=getattach" target="_blank"><img src="{IMGDIR}/credits_attachlist.gif" border="0" alt="{lang credits_policy_view}" /></a></div><!--{/if}-->
{lang attachment}</div><div class="msgborder" style="padding: 0px; border-bottom: 0px;">
$post[attachlist]
</div></div>
<!--{/if}-->