楼主不妨参考下2.5的这个,改改今日发贴数昨日发贴数
今日发贴数昨日发贴数Cache版 For D25!
插件名称: 今日发贴数昨日发贴数Cache版 For D25
适用版本: D25
作 者: happy0429
数据升级: 无
修改文件: include/cache.php,index.php
修改模板: index.htm
最后发表日期:05.2.2
插件功能简介: 看到很多人在问这个,所以就做了一个,功能是在首页显示今日发贴数,昨日发贴数,由于采用缓存技术,只是在更新的时候增加两个查询,基本不影响效率,今日发贴数的更新时间可以任意设定
演示或技术支持网站: 演示看http://www.ak521.com/bbs,有问题请尽快联系我
1.修改include/cache.php
找到
CODE: [Copy to clipboard]
--------------------------------------------------------------------------------
'plugins' => array('plugins', 'plugins_settings')
在后面加入
--------------------------------------------------------------------------------
,
下面加入
--------------------------------------------------------------------------------
'indexpost' => array('todaypost','yestodaypost')
找到
--------------------------------------------------------------------------------
case ranks:
$table = $GLOBALS['table_ranks'];
$cols='ranktitle,postshigher,stars';
$conditions = "WHERE 1 ORDER BY postshigher desc";
break;
在下面加入
--------------------------------------------------------------------------------
///////////////今日贴昨日贴//////////
case todaypost:
$timestamp=time();
$tday=gmdate("y-m-d",$timestamp);
$tday=strtotime($tday);
$table = $GLOBALS['table_posts'];
$cols='count(*)';
$conditions = "WHERE dateline > $tday";
break;
case yestodaypost:
$timestamp=time();
$tday=gmdate("y-m-d",$timestamp);
$tday=strtotime($tday);
$timestamp0=$timestamp-3600*24;
$ytday=gmdate("y-m-d",$timestamp0);
$ytday=strtotime($ytday);
$table = $GLOBALS['table_posts'];
$cols='count(*)';
$conditions = "WHERE dateline > $ytday and dateline < $tday";
break;
///////////////今日贴昨日贴//////////
找到
--------------------------------------------------------------------------------
$query = $db->query("SELECT $cols FROM $table $conditions");
switch($cachename) {
下面加入
--------------------------------------------------------------------------------
///////////////今日贴昨日贴//////////
case 'todaypost':
$data[]=$timestamp;
$data[]=$db->result($query, 0);
break;
case 'yestodaypost':
$data[]=$timestamp;
$data[]=$db->result($query, 0);
break;
///////////////今日贴昨日贴//////////
2.先更新下缓存,然后修改index.php
找到
--------------------------------------------------------------------------------
require DISCUZ_ROOT.'./include/forum.php';
下面加
--------------------------------------------------------------------------------
@require DISCUZ_ROOT.'./forumdata/cache/cache_indexpost.php';
找到
--------------------------------------------------------------------------------
$newthreads = round(($timestamp - $lastvisit + 600) / 1000) * 1000;
下面加入
--------------------------------------------------------------------------------
////////////////今日贴昨日贴//////////
$cachetime = 600;///600是更新时间,单位为秒,请根据需要修改
if(($timestamp - $_DCACHE['todaypost']['0']) > $cachetime){ @require_once DISCUZ_ROOT.'./include/cache.php';
updatecache('todaypost');}
////////////////今日贴昨日贴//////////
3.修改摸板index.htm(也可以按自己要求改)我是按下面这样改的
找到
--------------------------------------------------------------------------------
<td align="right" nowrap valign="bottom">
在后面插入
--------------------------------------------------------------------------------
今日贴数:<span class="bold">$_DCACHE['todaypost'][1]</span> / 昨日贴数:<span class="bold">$_DCACHE['yestodaypost'][1]</span><br> |