列印

今日發貼數昨日發貼數 Cache 版 For D25

今日發貼數昨日發貼數 Cache 版 For D25

插件名稱: 今日發貼數昨日發貼數 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]
Hack 安裝錯誤, 80% 來自粗心, 請專心安裝
Linux0911 打造您的個性論壇

本人現在忙於研究所, 沒多的時間管論壇, 有問題別發 pm 給我, 謝謝~
Linux0911 Forum © 2004-2009 All Rights Reserved.

TOP



論壇聲明
  • 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
    如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
    請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!
最佳瀏覽解析度:不低於 1024 (最佳 1280 以上).(支援 IE 7, Mozilla Firefox, Safari, Chrome)
The Best Surfing Resolution: No Lower than 1024 (Best: above 1280).(IE 7, Mozilla Firefox, Safari, Chrome Supported)