Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

经典-不同附件显示不同图标

[复制链接]
xulian 发表于 2006-6-28 14:09:24 | 显示全部楼层 |阅读模式

转载自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 编辑 ]
 楼主| xulian 发表于 2006-6-28 14:31:55 | 显示全部楼层
难道没有人需要吗
回复

使用道具 举报

tryer 发表于 2006-6-28 14:33:49 | 显示全部楼层
Clement
FreeDiscuz! VIP
Freediscuz Supporter

请勿转载或修改后发布到非本站.谢谢合作.
回复

使用道具 举报

 楼主| xulian 发表于 2006-6-28 15:07:52 | 显示全部楼层
我找了很久了呀呀
实在很牛
没有想违背作者的意愿
回复

使用道具 举报

诚信的松子茶 发表于 2006-6-28 15:29:35 | 显示全部楼层
不错
回复

使用道具 举报

 楼主| xulian 发表于 2006-6-28 21:22:05 | 显示全部楼层
:)
回复

使用道具 举报

泡海椒 发表于 2006-6-28 22:47:06 | 显示全部楼层


LZ 应该使用CODE代码
回复

使用道具 举报

 楼主| xulian 发表于 2006-6-28 23:39:58 | 显示全部楼层
code ???
回复

使用道具 举报

 楼主| xulian 发表于 2006-6-29 11:06:41 | 显示全部楼层
??
回复

使用道具 举报

 楼主| xulian 发表于 2006-6-29 21:16:10 | 显示全部楼层
没人要吗
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2025-2-24 06:50 , Processed in 0.036722 second(s), 3 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表