Discuz!NT 2.5 正式版 下载
beta、RC版升级补丁
中秋模板发布
首届Discuz!NT 模板大赛圆满结束
著名音乐网站SoGua网、分贝网
采用Discuz!NT搭建社区
FIFA Online2官网论坛使用Discuz!NT
游戏城寨论坛使用Discuz!NT搭建
Discuz!NT 2.5正式开源 Discuz!NT文档中心
用户整合说明文档
Discuz!NT亮相微软Tech-Ed 2007
Discuz!NT情景搞笑短片抢先看
 
1/2页12 跳转到查看:9120
发新话题 回复该主题

[下载] 全内存缓存版首页四格for DNT .net2.0 sqlserver版

全内存缓存版首页四格for DNT .net2.0 sqlserver版

找了好久都没发现有性能比较好的DNT首页四格,于是自己动手写了个。
演示地址:http://www.dushuhu.com.cn
全内存缓存版,提高性能。

附件: 首页四格全内存缓存版.rar (2007-8-21 0:39:36, 15.40 K)
该附件被下载次数 364


安装方法:
1、上传Discuz.Plugin.TopShow.dll到论坛的bin文件夹下
2、上传pixviewer.swf至论坛的根目录
3、后台-〉界面风格-〉模版管理,打开index
4、在开头<%template _header%>上如没有<%namespace Discuz.Plugin%>,则加上。
5、找到<%template _pagewordadlist%>,在他上边添加以下代码

<!--四格开始-->
<div class="maintable">
<div class="spaceborder" style="WIDTH: 100%">
  <table cellspacing="0" cellpadding="4" width="100%" align="center">
  <tbody>
    <tr>
    <td width="25%" class="header"><span class="bold">图片推荐</span></td>
    <td width="25%" class="header"><span class="bold">最新主题</span></td>
    <td width="25%" class="header"><span class="bold">最新回复</span></td>
    <td width="25%" class="header"><span class="bold">本周热点</span></td>
    </tr>
  </tbody>
  <tbody id="forumtopshow">
  <tr>
  <td class="altbg1" width="25%">
  <script language="JavaScript">
  var focus_width=250
            var focus_height=220
            var text_height=20
            var swf_height = focus_height+text_height
  {TopShow.GetNewPic()}
  document.write('<object classid="clsid27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">');
            document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="pixviewer.swf"><param name="quality" value="high"><param name="bgcolor" value="#FFFFFF">');
            document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
            document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
            document.write('<embed src="pixviewer.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#FFFFFF" quality="high" width="'+ focus_width +'" height="'+ focus_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');document.write('</object>');
            </script>
  </td>
  <td class="altbg1" width="25%" style="line-height:23px" valign="top">{TopShow.GetNewTopic()}</td>
  <td class="altbg1" width="25%" style="line-height:23px" valign="top">{TopShow.GetNewReply()}</td>
  <td class="altbg1" width="25%" style="line-height:23px" valign="top">{TopShow.GetHotTopic()}</td>
  </tr>
  </tbody>
  </table>
</div>
</div>
<br />
<!--四格结束-->

6、生成index.aspx,刷新首页即可!

本插件为DNT .net2.0 sqlserver版。。。未测试其他版本。。。
页面数据均缓存在内存,以提高加载速度!
如需改变缓存参数,请在上边插入字段的<!--四格开始-->后加上
{TopShow.SetTopShow(10,6,10)}
其中10,6,10分别表示每格调用帖子数:10,图片调用张数:6,和缓存10分钟(默认)。可根据具体需要修改!
如有不清楚的请跟贴。。。。
为自己的论坛做个广告。http://www.dushuhu.com.cn

把源代码发上来,有需要的朋友自己改吧.
本帖被评分 1 次
最后编辑gongxiaohu 最后编辑于 2007-08-21 00:40:13

TOP

 

回复:全内存缓存版首页四格for DNT .net2.0 server版

这个只适合官方Table模板
对于Div+Css可以不合适

我之前也修改过一个,是使用在Div+Css模板的,大家也可以参考一下

最新四格调用插件  已经有22页的回复了
地址:http://nt.discuz.net/showtopic-16958.html

TOP

 

回复: 全内存缓存版首页四格for DNT .net2.0 sqlserver版

关于样式可以自己修改模版阿。我这个不是通过调用官方的接口来实现的,而是自己写的查询,然后存储在Cache中。应该和你那个不一样。。。

TOP

 

回复:全内存缓存版首页四格for DNT .net2.0 sqlserver版

晕死,超过今天最大附件了,源码项目明天再发吧。
using System;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Discuz.Common;
using Discuz.Forum;
using System.Web;
using System.Web.Caching;

namespace Discuz.Plugin
{
    public class TopShow
    {
        private static int topiccount = 10;
        private static int piccount = 6;
        private static int minutes = 10;

        private const string NEWTOPIC_KEY = "newtopic";
        private const string NEWREPLY_KEY = "newreply";
        private const string HOTTOPIC_KEY = "hottopic";
        private const string NEWPIC_KEY = "newpic";

        public static string SetTopShow(int topic,int pic,int min)
        {
            if (topic != topiccount || pic != piccount || min != minutes)
            {
                RemoveCache();
                topiccount = topic;
                piccount = pic;
                minutes = min;
            }
            return "<!--当前显示帖子数为" + topiccount + ",显示图片数为" + piccount + ",缓存时间为" + minutes + "分钟-->";
        }
        public static string GetNewTopic()
        {
            if (HttpContext.Current.Cache[NEWTOPIC_KEY] == null)
            {
                string SQL_NEWTOPIC = "SELECT TOP " + topiccount + " tid, title FROM " + BaseConfigFactory.GetTablePrefix + "topics ORDER BY postdatetime DESC";
                TopicCache(SQL_NEWTOPIC, NEWTOPIC_KEY);
            }
            return (string)HttpContext.Current.Cache[NEWTOPIC_KEY];
        }
        public static string GetNewReply()
        {
            if (HttpContext.Current.Cache[NEWREPLY_KEY] == null)
            {
                string SQL_NEWREPLY = "SELECT TOP " + topiccount + " tid, title FROM " + BaseConfigFactory.GetTablePrefix + "topics WHERE (postdatetime<>lastpost) ORDER BY lastpost DESC";
                TopicCache(SQL_NEWREPLY, NEWREPLY_KEY);
            }
            return (string)HttpContext.Current.Cache[NEWREPLY_KEY];
        }
        public static string GetHotTopic()
        {
            if (HttpContext.Current.Cache[HOTTOPIC_KEY] == null)
            {
                string SQL_HOTTOPIC = "SELECT TOP " + topiccount + " tid, title FROM " + BaseConfigFactory.GetTablePrefix + "topics ORDER BY views DESC";
                TopicCache(SQL_HOTTOPIC, HOTTOPIC_KEY);
            }
            return (string)HttpContext.Current.Cache[HOTTOPIC_KEY];
        }
        public static void TopicCache(string sql,string cachekey)
        {
            StringBuilder stb = new StringBuilder();
            SqlDataReader reader = Database.ExecuteReader(CommandType.Text, sql);
            if (reader != null)
            {
                while (reader.Read())
                {
                    stb.Append("<div style='width:200px; text-overflow:ellipsis;overflow:hidden'><nobr><a href=\"showtopic-");
                    stb.Append(reader[0].ToString().Trim());
                    stb.Append(".aspx\" target=\"_blank\">");
                    stb.Append(reader[1].ToString().Trim());
                    stb.Append("</a></nobr></div>");
                }
            }
            HttpContext.Current.Cache.Insert(cachekey, stb.ToString(), null, DateTime.Now.AddMinutes(minutes), Cache.NoSlidingExpiration);
        }
        public static string GetNewPic()
        {
            if (HttpContext.Current.Cache[NEWPIC_KEY] == null)
            {
                StringBuilder spics = new StringBuilder();
                StringBuilder stexts = new StringBuilder();
                StringBuilder slinks = new StringBuilder();
                SqlDataReader reader = Database.ExecuteReader(CommandType.Text, "SELECT TOP " + piccount + " " + BaseConfigFactory.GetTablePrefix + "attachments.filename, " + BaseConfigFactory.GetTablePrefix + "topics.title, " + BaseConfigFactory.GetTablePrefix + "attachments.tid FROM " + BaseConfigFactory.GetTablePrefix + "attachments INNER JOIN " + BaseConfigFactory.GetTablePrefix + "topics ON " + BaseConfigFactory.GetTablePrefix + "attachments.tid = " + BaseConfigFactory.GetTablePrefix + "topics.tid WHERE (" + BaseConfigFactory.GetTablePrefix + "attachments.attachment LIKE '%.jpg%') ORDER BY " + BaseConfigFactory.GetTablePrefix + "attachments.postdatetime DESC");
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        spics.Append("|upload/" + reader[0].ToString().Trim().Replace("\\", "/"));
                        stexts.Append("|" + reader[1].ToString().Trim());
                        slinks.Append("|showtopic-" + reader[2].ToString().Trim() + ".aspx");
                    }
                }
                string pics = "var pics ='" + spics.ToString().Remove(0, 1) + "';";
                string texts = "var texts ='" + stexts.ToString().Remove(0, 1) + "';";
                string links = "var links ='" + slinks.ToString().Remove(0, 1) + "';";
                HttpContext.Current.Cache.Insert(NEWPIC_KEY, pics + texts + links, null, DateTime.Now.AddMinutes(minutes), Cache.NoSlidingExpiration);
            }
            return (string)HttpContext.Current.Cache[NEWPIC_KEY];
        }
        public static void RemoveCache()
        {
            if (HttpContext.Current.Cache[NEWTOPIC_KEY] != null)
                HttpContext.Current.Cache.Remove(NEWTOPIC_KEY);
            if (HttpContext.Current.Cache[NEWREPLY_KEY] != null)
                HttpContext.Current.Cache.Remove(NEWREPLY_KEY);
            if (HttpContext.Current.Cache[HOTTOPIC_KEY] != null)
                HttpContext.Current.Cache.Remove(HOTTOPIC_KEY);
            if (HttpContext.Current.Cache[NEWPIC_KEY] != null)
                HttpContext.Current.Cache.Remove(NEWPIC_KEY);
        }
    }
}
最后编辑gongxiaohu 最后编辑于 2007-08-21 00:41:21

TOP

 

回复:全内存缓存版首页四格for DNT .net2.0 sqlserver版

:tuzki3: :tuzki3: :tuzki3:

TOP

 

回复:全内存缓存版首页四格for DNT .net2.0 sqlserver版

:lol 好东西要支持

TOP

 

回复:全内存缓存版首页四格for DNT .net2.0 sqlserver版

又一个好东东

TOP

 

回复:全内存缓存版首页四格for DNT .net2.0 sqlserver版

nion9: nion9: NT越来越美好

TOP

 

回复:全内存缓存版首页四格for DNT .net2.0 sqlserver版

楼主可不可发一下各版块的主题调用代码,也是用内存缓存机制,好人做到底嘛!
欢迎访问中国高考论坛:http://www.gkbbs.net.cn

TOP

 

回复:全内存缓存版首页四格for DNT .net2.0 sqlserver版

为什么我的用不了?????????????
http://www.yi-show.com[亿秀官方社区]

TOP

 
1/2页12 跳转到
发表新主题 回复该主题