转载自http://www.freediscuz.net/dev/viewthread.php?tid=13900
实在是比较经典不能不转望作者见谅
主题列表前加上附件图标(06.05.28)
请勿转载或修改后发布到非本站.谢谢合作.
1.
include/newthread.inc.php
找到
if($attachment) {
foreach($attachments as $attach) {
$db->query("INSERT INTO {$tablepre}attachments (tid, pid, dateline, readperm, filename, description, filetype, filesize, attachment, downloads)
VALUES ('$tid', '$pid', '$timestamp', '$attach[perm]', '$attach[name]', '$attach[description]', '$attach[type]', '$attach[size]', '$attach[attachment]', '0')");
}
updatecredits($discuz_uid, $creditspolicy['postattach'], count($attachments));
}
改成
if($attachment) {
foreach($attachments as $attach) {
$db->query("INSERT INTO {$tablepre}attachments (tid, pid, dateline, readperm, filename, description, filetype, filesize, attachment, downloads)
VALUES ('$tid', '$pid', '$timestamp', '$attach[perm]', '$attach[name]', '$attach[description]', '$attach[type]', '$attach[size]', '$attach[attachment]', '0')");
$last_attach_type = strtolower(fileext($attach['name']))."\t".$attach['type'];
}
updatecredits($discuz_uid, $creditspolicy['postattach'], count($attachments));
require_once DISCUZ_ROOT.'./include/attachment.func.php';
$db->query("UPDATE {$tablepre}threads SET attachment='".attachtype($last_attach_type, 'id')."' WHERE tid='$tid'", 'UNBUFFERED');
}
include/newreply.inc.php 内找到
if($attachment) {
foreach($attachments as $attach) {
$db->query("INSERT INTO {$tablepre}attachments (tid, pid, dateline, readperm, filename, description, filetype, filesize, attachment, downloads)
VALUES ('$tid', '$pid', '$timestamp', '$attach[perm]', '$attach[name]', '$attach[description]', '$attach[type]', '$attach[size]', '$attach[attachment]', '0')");
}
updatecredits($discuz_uid, $creditspolicy['postattach'], count($attachments));
}
改成
if($attachment) {
foreach($attachments as $attach) {
$db->query("INSERT INTO {$tablepre}attachments (tid, pid, dateline, readperm, filename, description, filetype, filesize, attachment, downloads)
VALUES ('$tid', '$pid', '$timestamp', '$attach[perm]', '$attach[name]', '$attach[description]', '$attach[type]', '$attach[size]', '$attach[attachment]', '0')");
$last_attach_type = strtolower(fileext($attach['name']))."\t".$attach['type'];
}
updatecredits($discuz_uid, $creditspolicy['postattach'], count($attachments));
require_once DISCUZ_ROOT.'./include/attachment.func.php';
}
$attachtype = $last_attach_type ? attachtype($last_attach_type, 'id') : '';
找到
$db->query("UPDATE {$tablepre}threads SET lastposter='$author', lastpost='$timestamp', replies=replies+1 ".($attachment ? ', attachment=\'1\'' : '').", subscribed='".($subscribed || $newsubscribed ? 1 : 0)."' WHERE tid='$tid'", 'UNBUFFERED');
改为
$db->query("UPDATE {$tablepre}threads SET lastposter='$author', lastpost='$timestamp', replies=replies+1 ".($attachtype ? ', attachment=\''.$attachtype.'\'' : '').", subscribed='".($subscribed || $newsubscribed ? 1 : 0)."' WHERE tid='$tid'", 'UNBUFFERED');
forumdisplay.php内找到
while(($querysticky && $thread = $db->fetch_array($querysticky)) || ($query && $thread = $db->fetch_array($query))) {
下面1行加
if($thread['attachment']) {
require_once DISCUZ_ROOT.'./include/attachment.func.php';
$thread['attachment'] = attachtype($thread['attachment']).' ';
} else {
$thread['attachment'] = '';
}
templates/default/forumdisplay.htm内
找到
<!--{if $thread['attachment']}--><img src="images/attachicons/common.gif"><!--{/if}-->
改为
<!--{if $thread['attachment']}-->$thread[attachment]<!--{/if}-->
5.17更新内容.
include/editpost.inc.php
找
if($pattachment) {
foreach($attachments as $attach) {
$db->query("INSERT INTO {$tablepre}attachments (tid, pid, dateline, readperm, filename, description, filetype, filesize, attachment, downloads)
VALUES ('$tid', '$pid', '$timestamp', '$attach[perm]', '$attach[name]', '$attach[description]', '$attach[type]', '$attach[size]', '$attach[attachment]', '0')");
}
updatecredits($orig['authorid'], $creditspolicy['postattach'], count($attachments));
} else {
$query = $db->query("SELECT aid FROM {$tablepre}attachments WHERE pid='$pid' LIMIT 1");
$pattachment = $db->result($query, 0) ? 1 : 0;
}
if($pattachment) {
$tattachment = 1;
} else {
$query = $db->query("SELECT a.aid FROM {$tablepre}posts p, {$tablepre}attachments a WHERE a.tid='$tid' AND a.pid=p.pid AND p.invisible='0' LIMIT 1");
$tattachment = $db->result($query, 0) ? 1 : 0;
}
$db->query("UPDATE {$tablepre}threads SET attachment='$tattachment' WHERE tid='$tid'");
替换为
if($pattachment) {
foreach($attachments as $attach) {
$db->query("INSERT INTO {$tablepre}attachments (tid, pid, dateline, readperm, filename, description, filetype, filesize, attachment, downloads)
VALUES ('$tid', '$pid', '$timestamp', '$attach[perm]', '$attach[name]', '$attach[description]', '$attach[type]', '$attach[size]', '$attach[attachment]', '0')");
$last_attach_type = strtolower(fileext($attach['name']))."\t".$attach['type'];
}
updatecredits($orig['authorid'], $creditspolicy['postattach'], count($attachments));
} else {
$query = $db->query("SELECT a.aid, a.filename, a.filetype FROM {$tablepre}posts p, {$tablepre}attachments a WHERE a.tid='$tid' AND a.pid=p.pid AND p.invisible='0' ORDER BY a.dateline DESC LIMIT 1");
$lasttype = $db->fetch_array($query);
$lasttype && $last_attach_type = strtolower(fileext($lasttype['filename']))."\t".$lasttype['filetype'];
}
if($last_attach_type) {
require_once DISCUZ_ROOT.'./include/attachment.func.php';
$attachmentnew = attachtype($last_attach_type, 'id');
}
$db->query("UPDATE {$tablepre}threads SET attachment='$attachmentnew' WHERE tid='$tid'");
5.19更新内容.
include/editpost.inc.php
找
$query = $db->query("SELECT pid, attachment FROM {$tablepre}attachments WHERE tid='$tid'");
while($attach = $db->fetch_array($query)) {
if($attach['pid'] == $pid) {
$post_attachment = 1;
@unlink($attachdir.'/'.$attach['attachment']);
} else {
$thread_attachment = 1;
}
}
改为
$query = $db->query("SELECT pid, attachment, filename, filetype FROM {$tablepre}attachments WHERE tid='$tid'");
while($attach = $db->fetch_array($query)) {
if($attach['pid'] == $pid) {
$post_attachment = 1;
@unlink($attachdir.'/'.$attach['attachment']);
} else {
$thread_attachment = strtolower(fileext($attach['filename']))."\t".$attach['filetype'];
}
}
if($thread_attachment) {
require_once DISCUZ_ROOT.'./include/attachment.func.php';
$thread_attachment = attachtype($thread_attachment, 'id');
}
感谢madly协助测试完善插件.
06.05.28更新内容.
1.修正删除帖子会显示别针.(今后安装用户亦须改此项.)
include/post.func.php内
找到
$query = $db->query("SELECT attachment FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0' AND attachment>0 LIMIT 1");
$attachadd = ', attachment=\''.($db->num_rows($query)).'\'';
改为
$query = $db->query("SELECT a.aid, a.filename, a.filetype FROM {$tablepre}posts p, {$tablepre}attachments a WHERE a.tid='$tid' AND a.pid=p.pid AND p.invisible='0' ORDER BY a.dateline DESC LIMIT 1");
$lasttype = $db->fetch_array($query);
if($lasttype) {
$last_attach_type = strtolower(fileext($lasttype['filename']))."\t".$lasttype['filetype'];
require_once DISCUZ_ROOT.'./include/attachment.func.php';
$attachadd = ', attachment=\''.attachtype($last_attach_type, 'id').'\'';;
}
2.修正回复不带附件帖子时帖子图标消失.(今后安装用户无须修改此项)
include/newreply.inc.php内找到
$db->query("UPDATE {$tablepre}threads SET lastposter='$author', lastpost='$timestamp', replies=replies+1, attachment='$attachtype', subscribed='".($subscribed || $newsubscribed ? 1 : 0)."' WHERE tid='$tid'", 'UNBUFFERED');
改为
$db->query("UPDATE {$tablepre}threads SET lastposter='$author', lastpost='$timestamp', replies=replies+1 ".($attachtype ? ', attachment=\''.$attachtype.'\'' : '').", subscribed='".($subscribed || $newsubscribed ? 1 : 0)."' WHERE tid='$tid'", 'UNBUFFERED');
感谢yoursb协助完善此插件.
[ 本帖最后由 xulian 于 2006-6-28 14:14 编辑 ]
[ 本帖最后由 xulian 于 2006-6-28 14:18 编辑 ]
[ 本帖最后由 xulian 于 2006-6-28 15:18 编辑 ] |