上次看到某论坛里转我的贴子把我的版权删除了..没必要吧?
原创: oytktk
测试: 小 JM (jimmyjimmyqqq) 在这里感谢一下啦.
说明一下: 这个展示的优点在于, 用JS特效使图片不停的滚动..无间隔显示.
不会对论坛服务器造成任何影响,
JS是在客户端运行的,
如果滚动速度很快,
客户端会占一部分CPU资源,如果慢则不会.
功能简介:
1. 后台设置开关;
2. 后台设定图片个数;
3. 后台设定 随机提取图片 或 最新图片
1). 选最新图片, 首页不加查询;
2). 选随机图片, 首页增加1个查询;
4. 后台设置图片滚动的速度;
图片演示:
安装方法:
1. 升级数据库
- 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');
复制代码
2. admin/settings.php
查找:
- showsetting('settings_smcols', 'settingsnew[smcols]', $settings['smcols'], 'text');
复制代码
下面加:
- showsetting('settings_attaopen', 'settingsnew[attaopen]', $settings['attaopen'], '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');
复制代码
查找:
后面加:
3.templates\default\admincp.lang.php
查找:
- 'settings_smcols_comment' => '发帖页面每行显示 Smilies 的个数',
复制代码
下面加:
- 'settings_attaopen' => '首页站内图片展示开关:',
- 'settings_attacoun' => '首页站内图片展示中图片的个数:',
- 'settings_attasehe' => '首页站内图片展示是否启用随机功能:',
- 'settings_attasehe_comment' => '注意:开启随机功能首页会增加1个查询,若关闭随机则显示最新图片,首页不增加查询',
- 'settings_attasppe' => '首页站内图片展示的滚动速度:',
- 'settings_attasppe_comment' => '默认为30,数字越大速度越慢,速度越快越占系统资源.(by oytktk)',
复制代码
4. include/cache.php
查找:
- 'censor' => array('censor'),
复制代码
下面加:
- 'attas' => array('attachs'),//首页站内图片附件展示 by oytktk
复制代码
查找:
- case ranks:
- $table = $GLOBALS['table_ranks'];
- $cols='ranktitle,postshigher,stars,color';
- $conditions = "WHERE 1 ORDER BY postshigher desc";
- break;
复制代码
上面加:
- //首页站内图片附件展示 by oytktk
- case attachs:
- global $attacoun;
- $table = $GLOBALS['table_attachments'];
- $cols='tid, attachment';
- $conditions = "WHERE filetype='image/pjpeg' ORDER BY aid DESC LIMIT 0, $attacoun";
- break;
- //首页站内图片附件展示 by oytktk
复制代码
查找:
- case 'plugins':
- $data = array();
- while($plugin = $db->fetch_array($query)) {
- $data["$plugin[plug_key]"] = $plugin;
- }
- break;
复制代码
上面加:
- //首页站内图片附件展示 by oytktk
- case 'attachs':
- while($atta = $db->fetch_array($query)) {
- $data[] = $atta;
- }
- break;
- //首页站内图片附件展示 by oytktk
复制代码
5. include/editpost.php
查找:
- $db->query("UPDATE $table_attachments set creditsrequire='$att[creditsrequire]' WHERE aid='$att[aid]'", 'UNBUFFERED');
复制代码
下面加:
- @require_once "./include/cache.php";
- updatecache("attachs");
复制代码
查找:
- $db->query("DELETE FROM $table_attachments WHERE pid='$pid' and aid in($del_aids)", 'UNBUFFERED');
复制代码
下面加:
- @require_once "./include/cache.php";
- updatecache("attachs");
复制代码
继续查找:
下面加:
- @require_once "./include/cache.php";
- updatecache("attachs");
复制代码
再查找:
- $db->query("DELETE FROM $table_attachments WHERE pid='$pid'");
- updatethread_type($tid , $thread['attachment']);
复制代码
下面加:
- @require_once "./include/cache.php";
- updatecache("attachs");
复制代码
最后查找:
- $db->query("DELETE FROM $table_posts WHERE tid='$tid'");
复制代码
下面加:
- @require_once "./include/cache.php";
- updatecache("attachs");
复制代码
6. include/newthread.php
查找:
- $db->query("UPDATE $table_attachments SET tid='$tid', pid='$pid' WHERE aid in ($aid)", 'UNBUFFERED');
复制代码
下面加:
- @require_once "./include/cache.php";
- updatecache("attachs");
复制代码
7. include/newreply.php
查找:
- $db->query("UPDATE $table_attachments SET pid='$pid' WHERE aid in ($aid)", 'UNBUFFERED');
复制代码
下面加:
- @require_once "./include/cache.php";
- updatecache("attachs");
复制代码
8. index.php
查找:
- unset($_DCACHE['announcements']);
复制代码
下面加:
- //首页站内图片附件展示 by oytktk
- if($attaopen){
- if($attasehe){
- $query = $db->query("SELECT tid, attachment FROM $table_attachments WHERE filetype='image/pjpeg' ORDER BY rand() DESC LIMIT 0, $attacoun");
- while($aids = $db->fetch_array($query)) {
- $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'>";
- }
- }else{
- require DISCUZ_ROOT.'./forumdata/cache/cache_attas.php';
- $attass=$_DCACHE['attachs'];
- 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'>";
- }
- }
- }
- //首页站内图片附件展示 by oytktk end
复制代码
9. 模板 index.htm
关于模板的修改大家可以自己爱自己的意愿来改,我提供加在HEADER.HTM下的一种方法,只要把这代加在你要想显示的位置就可以了.
查找:
下面加:
- <!--{if $attaopen}-->
- <center> <div id=demo style=overflow:hidden;height:122;width:98%>
- <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>
- <!--{/if}-->
复制代码
查找:
{template footer}
下面加:
- <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>
复制代码
完成--> 更新缓存.
如果你想在其它页面也出现这个展示的话, 重复8,9两步对你需要的页面进行修改...
bk.gif 图片上传到 images 目录下
图片用肉眼看不到, 直接点击附件名称进行下载!
反安装代码:
- DELETE FROM `cdb_settings` WHERE `variable` = 'attaopen';
- DELETE FROM `cdb_settings` WHERE `variable` = 'attacoun';
- DELETE FROM `cdb_settings` WHERE `variable` = 'attasehe';
- DELETE FROM `cdb_settings` WHERE `variable` = 'attasppe';
复制代码
[ 本帖最后由 oytktk 于 2007-8-24 08:44 编辑 ] |