站内附件图片展示 FOR D4.1 全缓存强化版 Edit By 温馨阁
══════════════════════════════════════
# 原创 oytktk(靖飒)
#
# Edit By 温馨阁
#
# 版权 归 oytktk(靖飒) 所有
#
# 技术支持+演示 http://bbs.wxhome.cn
#
#
══════════════════════════════════════
■ 演示站点: http://bbs.wxhome.cn
══════════════════════════════════════
══════════════════════════════════════
■ 以下是我的小站的友情连接信息
══════════════════════════════════════
1). 论坛名称: 温馨社区
2). 论坛 URL: http://bbs.wxhome.cn
3). logo 地址: http://bbs.wxhome.cn/images/logo.gif
══════════════════════════════════════
■ 已经做好连接的朋友PM我个,我立即交换连接
══════════════════════════════════════
原创: oytktk(靖飒)
现在的功能有下面这些:
后台:
1.首页站内图片展示开关及选项:
输入 1 为显示在主页上方, 2 为显示在主页下方, 0 或其它为关闭
2.是否对游客开放此功能?
如果想让游客看到, 就选择 是 ,否则就选择 否!
3.首页站内图片展示中图片的个数:
4.首页站内图片展示是否启用随机功能(缓存):
5.首页站内图片展示的滚动速度:
默认为30,数字越大速度越慢,速度越快越占系统资源
6.首页站内图片展示中图片来源版块的FID列表(0=全部版块):
想让哪些版块的图片在展示中显示出来, 请输入版块FID列表, 多个用逗号隔开
7.首页站内图片展示中随机图片的更新时间(分):
想让随机展示的图片多少分钟更新一次?
前台:
加入表格以及COOKIE记录的折叠.
支持主页上方及下方显示的选择.
══════════════════════════════════════
■ 安装方法:
══════════════════════════════════════
SQL:
- INSERT INTO `cdb_settings` (`variable`, `value`) VALUES ('attaopen', '1');
- INSERT INTO `cdb_settings` (`variable`, `value`) VALUES ('attacoun', '15');
- INSERT INTO `cdb_settings` (`variable`, `value`) VALUES ('attasehe', '1');
- INSERT INTO `cdb_settings` (`variable`, `value`) VALUES ('attasppe', '30');
- INSERT INTO `cdb_settings` (`variable`, `value`) VALUES ('guestope', '0');
- INSERT INTO `cdb_settings` (`variable`, `value`) VALUES ('attafids', '0');
- INSERT INTO `cdb_settings` (`variable`, `value`) VALUES ('attatime', '10');
复制代码
1. 升级数据库
2. admin/settings.php
查找:
- showsetting('settings_smcols', 'settingsnew[smcols]', $settings['smcols'], 'text');
复制代码
下面加:
- showsetting('settings_attaopen', 'settingsnew[attaopen]', $settings['attaopen'], 'text');
- showsetting('settings_guestope', 'settingsnew[guestope]', $settings['guestope'], 'radio');
- showsetting('settings_attacoun', 'settingsnew[attacoun]', $settings['attacoun'], 'text');
- showsetting('settings_attasehe', 'settingsnew[attasehe]', $settings['attasehe'], 'radio');
- showsetting('settings_attasppe', 'settingsnew[attasppe]', $settings['attasppe'], 'text');
- showsetting('settings_attafids', 'settingsnew[attafids]', $settings['attafids'], 'text');
- showsetting('settings_attatime', 'settingsnew[attatime]', $settings['attatime'], 'text');
复制代码
查找:
后面加:
- , 'attacoun', 'attasppe', 'guestope', 'attatime'
复制代码
3.templates\default\admincp.lang.php
查找:
- 'settings_smcols_comment' => '发帖页面每行显示 Smilies 的个数',
复制代码
下面加:
- 'settings_attaopen' => '首页站内图片展示开关及选项:',
- 'settings_attaopen_comment' => '输入 1 为显示在主页上方, 2 为显示在主页下方, 0 或其它为关闭',
- 'settings_guestope' => '是否对游客开放此功能?',
- 'settings_guestope_comment' => '如果想让游客看到, 就选择 是 ,否则就选择 否!',
- 'settings_attacoun' => '首页站内图片展示中图片的个数:',
- 'settings_attasehe' => '首页站内图片展示是否启用随机功能:',
- 'settings_attasehe_comment' => '随机功能是指从指定的版块内所上传的图片中随机抽出图片展示,可以设置缓存更新时间',
- 'settings_attasppe' => '首页站内图片展示的滚动速度:',
- 'settings_attasppe_comment' => '默认为30,数字越大速度越慢,速度越快越占系统资源.(by oytktk)',
- 'settings_attafids' => '首页站内图片展示中图片来源版块的FID列表:',
- 'settings_attafids_comment' => '想让哪些版块的图片在展示中显示出来, 请输入版块FID列表, 多个用逗号隔开',
- 'settings_attatime' => '首页站内图片展示中随机图片的更新时间(分):',
- 'settings_attatime_comment' => '想让随机展示的图片多少分钟更新一次?',
复制代码
4. include/cache.php
查找:
- 'bbcodes' => array('bbcodes', 'smilies'),
复制代码
下面加:
- 'attasnew' => array('attachs_new'),//首页站内图片附件展示 by oytktk
- 'attasrand' => array('attachs_rand'),//首页站内图片附件展示 by oytktk, 分开是为了优化缓存程序的
复制代码
查询
查找第一个:
在上面加:
- //首页站内图片附件展示 by oytktk
- case 'attachs_new':
- global $attacoun, $attacoun, $attafids;
- $table = 'attachments a';
- $cols= 'a.tid, a.attachment, p.subject';
- $conditions = "LEFT JOIN {$tablepre}posts p USING(pid) WHERE p.fid IN($attafids) and a.filetype='image/pjpeg' ORDER BY aid DESC LIMIT 0, $attacoun";
- break;
- case 'attachs_rand':
- global $attacoun, $attacoun, $attafids;
- $table = 'attachments a';
- $cols = 'a.tid, a.attachment, p.subject';
- $conditions = "LEFT JOIN {$tablepre}posts p USING(pid) WHERE a.filetype='image/pjpeg' and p.fid IN($attafids) ORDER BY rand() LIMIT 0, $attacoun";
- break;
- //首页站内图片附件展示 by oytktk
复制代码
再找第二个:
下面加:
- //首页站内图片附件展示 by oytktk
- case 'attachs_rand':
- while($attarand=$db->fetch_array($query))$data[]=$attarand;
- $data['time']=time();
- break;
- //首页站内图片附件展示 by oytktk
复制代码
5. include/newreply.inc.php
查找:
- updatecredits($discuz_uid, $creditspolicy['postattach'], count($attachments));
复制代码
上面加:
- require_once DISCUZ_ROOT.'./include/cache.func.php';
- updatecache('attachs_new');
复制代码
6. include/newthread.inc.php
查找:
- updatecredits($discuz_uid, $creditspolicy['postattach'], count($attachments));
复制代码
下面加:
- require_once DISCUZ_ROOT.'./include/cache.func.php';
- updatecache('attachs_new');
复制代码
7. include/editpost.inc.php
查找:
- updatecredits($discuz_uid, $creditspolicy['postattach'], -($db->affected_rows()));
复制代码
下面加:
- require_once DISCUZ_ROOT.'./include/cache.func.php';
- updatecache('attachs_new');
复制代码
再找:
- updatecredits($discuz_uid, $creditspolicy['postattach'], count($attachments));
复制代码
下面加:
- require_once DISCUZ_ROOT.'./include/cache.func.php';
- updatecache('attachs_new');
复制代码
8. index.php
查找:
- $forumlist = $catforumlist = $forums = $catforums = $categories = $collapse = array();
复制代码
下面加:
- //首页站内图片附件展示 by oytktk
- if($attaopen && ( $guestope || (!$guestope && $discuz_user))){
- if(!isset($_COOKIE['discuz_collapse']) || strpos($_COOKIE['discuz_collapse'], 'category_hk1 ') === FALSE) {
- $categorys_hk1 = 'collapsed_no.gif';
- $collapse['category_hk1'] = '';
- } else {
- $categorys_hk1 = 'collapsed_yes.gif';
- $collapse['category_hk1'] = 'display: none';
- }
- if($attasehe){
- require DISCUZ_ROOT.'./forumdata/cache/cache_attasrand.php';
- $attass=$_DCACHE['attachs_rand'];
- $i=0;
- foreach($attass as $aids){
- $scoll.="<a href='viewthread.php?tid=".$aids['tid']."'><img border='0' width='120' height='120' src='attachments/".$aids['attachment']."'></a><img border=0 src='images/bk.gif' title=$aids[subject]>";
- if(($i++) == $attacoun-1) break;
- }
- $thistime=time();
- if($thistime - $attass['time'] > $attatime*60 ){
- require_once DISCUZ_ROOT.'./include/cache.func.php';
- updatecache('attachs_rand');
- }
- }else{
- require DISCUZ_ROOT.'./forumdata/cache/cache_attasnew.php';
- $attass=$_DCACHE['attachs_new'];
- foreach($attass as $aids){
- $scoll.="<a href='viewthread.php?tid=".$aids['tid']."'><img border='0' width='120' height='120' src='attachments/".$aids['attachment']."'></a><img border=0 src='images/bk.gif' title=$aids[subject]>";
- }
- }
- }else{
- $attaopen = 0;
- }
- //首页站内图片附件展示 by oytktk end
复制代码
9. 模板 index.htm
查找:
- <!--{if !empty($newpmexists)}-->
复制代码
上面加:
- <!--{if $attaopen == 1}-->
- <div class="maintable"><table cellspacing="{INNERBORDERWIDTH}" cellpadding="{TABLESPACE}" width="{TABLEWIDTH}" align="center" class="tableborder">
- <tr class="header"><td>
- <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%">
- <tr>
- <td width="50%" class="header">站内附件图片展示</td>
- <td width="50%">
- <p align="right">
- <a href="###" onclick="toggle_collapse('category_hk1')"><img id="category_hk1_img" src="{IMGDIR}/$categorys_hk1" align="right" border="0"></a></td>
- </tr>
- </table>
- </td></tr>
- <tr class="altbg2" id="category_hk1" style="$collapse['category_hk1']"><td><center> <div id=demo style=overflow:hidden;height:122;width:100%>
- <table height="100%" border=0 align=left cellpadding=2 cellspace=0>
- <tr><td height="120" valign=top id=demo1>$scoll</td><td id=demo2 valign=top>
- </td></tr>
- </tbody>
- </table>
- </div></center></td></tr>
- </table><br></div>
- <!--{/if}-->
复制代码
继续找:
- <!--{if empty($gid) && ($_DCACHE['forumlinks'] || $whosonlinestatus || $bdaystatus == 1 || $bdaystatus == 3)}-->
复制代码
下面加:
- <!--{if $attaopen == 2}-->
- </td></tr></table><br>
- <table cellspacing="{INNERBORDERWIDTH}" cellpadding="{TABLESPACE}" width="{TABLEWIDTH}" align="center" class="tableborder">
- <tr class="header"><td>
- <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%">
- <tr>
- <td width="50%" class="header">站内附件图片展示</td>
- <td width="50%">
- <p align="right">
- <a href="###" onclick="toggle_collapse('category_hk1')"><img id="category_hk1_img" src="{IMGDIR}/$categorys_hk1" align="right" border="0"></a></td>
- </tr>
- </table>
- </td></tr>
- <tr class="altbg2" id="category_hk1" style="$collapse['category_hk1']"><td><center> <div id=demo style=overflow:hidden;height:122;width:100%>
- <table height="100%" border=0 align=left cellpadding=2 cellspace=0>
- <tr><td height="120" valign=top id=demo1>$scoll</td><td id=demo2 valign=top>
- </td></tr>
- </table>
- </div></center></td></tr></table><table cellspacing="{INNERBORDERWIDTH}" cellpadding="{TABLESPACE}" width="{TABLEWIDTH}" align="center" class="tableborder">
- <!--{/if}-->
复制代码
最后找:
下面加:
- <script>
- var speed=$attasppe;
- demo2.innerHTML=demo1.innerHTML;
- function Marquee(){
- if(demo2.offsetWidth-demo.scrollLeft<=0)
- demo.scrollLeft-=demo1.offsetWidth
- else{
- demo.scrollLeft++
- }
- }
- var MyMar=setInterval(Marquee,speed)
- demo.onmouseover=function() {clearInterval(MyMar)}
- demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
- </script>
复制代码
完工..后台设置参数去.然后更新缓存.
[ 本帖最后由 温馨阁 于 2006-3-24 21:25 编辑 ] |