插件名稱: 今日發貼數昨日發貼數 Cache 版 For D25
適用版本: D25
作 者: happy0429
數據
升級: 無
修改文件: include/cache.
php,
index.
php
修改
模板: index.htm
最後發表日期:05.2.2
插件功能簡介: 看到很多人在問這個,所以就做了一個,功能是在
首頁顯示今日發貼數,昨日發貼數,由於採用緩存技術,只是在更新的時候增加兩個查詢,基本不影響效率,今日發貼數的更新時間可以任意設定
演示或技術支援網站: 演示看
http://mtv.xianlai.com,有
問題請盡快聯繫我
[sell=20]
1. 修改 include/cache.php
找到
複製內容到剪貼簿
代碼:
'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>ok
[/sell]