想要知道目前整個部落格系統到底總訪問人數有多少?總網誌、總閱讀數有多少呢?
似乎沒有 API 可以直接呼叫!所以就要自行加入一些程式碼啦!

程式部份
在 LifeType 的資料夾內的 class\dao 資料夾內
blogs.class.php
bloginfo.class.php
兩個程式內增加程式碼
blogs.class.php 增加紅色程式碼
function disableBlog( $blogId )
{
$query = "UPDATE ".$this->getPrefix()."blogs
SET status = '".BLOG_STATUS_DISABLED."'
WHERE id = '".Db::qstr($blogId)."'";$result = $this->Execute( $query );
if( !$result )
return false;if( $this->_db->Affected_Rows() == 0 )
return false;return true;
}
/** JAY **/
function getTotalBlogs()
{
$query = "SELECT COUNT(*) as total FROM ".$this->getPrefix()."blogs";
$result = $this->_db->Execute( $query );if (!$result)
return false;$row = $result->FetchRow();
if (!isset($row["total"]))
return false;return intval($row["total"]);
}
/** JAY END **/
/** jay **/
function getAllBlogViewedTotal()
{
$query = "SELECT SUM(num_reads) as total FROM ".$this->getPrefix()."articles";$result = $this->_db->Execute( $query );
if (!$result)
return false;$row = $result->FetchRow();
if (!isset($row["total"]))
return false;return $row["total"];
}/** jay end **/
/** jay **/
function getBlogAllTotalPosts()
{
$query = "SELECT COUNT(*) as total FROM ".$this->getPrefix()."articles WHERE status = ".POST_STATUS_PUBLISHED;
$result = $this->_db->Execute( $query );if (!$result)
return false;$row = $result->FetchRow();
if (!isset($row["total"]))
return false;return intval($row["total"]);
}
bloginfo.class.php 增加紅色程式碼
function setResourcesQuota( $quota )
{
$this->_settings->setValue( "resources_quota", $quota );return true;
}
/** jay **/
function getAllTotalPosts( )
{
if( $this->_totalPosts == null ) {
$blogs = new Blogs();
$this->_totalPosts = $blogs->getBlogAllTotalPosts();
}return $this->_totalPosts;
}
/** jay **/
function getAllTotalBlogs()
{
if( $this->_totalBlogs == null ) {
$blogs = new Blogs();
$this->_totalBlogs = $blogs->getTotalBlogs();
}return $this->_totalBlogs;
}
/** jay **/
function getAllViewedTotal()
{
if( $this->_allviewedTotal == null ) {
$blogs = new Blogs();
$this->_allviewedTotal = $blogs->getAllBlogViewedTotal();
}return $this->_allviewedTotal;
}
/** jay end **/
模版部份
summary 模版要加入紅字程式碼 (這是配合北市教研中心版摘要頁)
在 templates 資料夾內 summary 資料夾的 index.template
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/right_a1.gif" alt="{$locale->tr("summary_search_blogs")}" width="168" height="34"></td>
</tr>
<tr>
<td height="80" bgcolor="#FFFFFF">
<table width="96%" border="0" align="center" cellpadding="3" cellspacing="1">
<form id="loginForm" method="post">
<fieldset>
<tr>
<td>
<label for="searchTerms">{$locale->tr("search_terms")}</label><input name="searchTerms" type="text" id="searchTerms" tabindex="20" value="" size="12">
</td>
</tr>
<tr>
<td align="center">
<input type="hidden" name="op" value="summarySearch">
<input type="submit" class="button" name="summarySearch" value="{$locale->tr("search")}" tabindex="21">
</td>
</tr>
</fieldset>
</form>
</table></td>
</tr>
</table>
<!-- jay -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/right_a4.gif" alt="{$locale->tr("summary_search_blogs")}" width="168" height="34"></td>
</tr>
<tr>
<td height="80" bgcolor="#FFFFFF">
部落格總數:{$blog->getAllTotalBlogs()} </br>
落格文章總數:{$blog->getAllTotalPosts()} </br>
落格總閱覽數:{$blog->getAllViewedTotal()}
</td>
</tr>
</table>
<!-- jay end -->
可以到
http://www.tiec.tp.edu.tw/lifetype/summary.php
在統計橫標圖上按 [右鍵選單> 另存圖檔] 到 LifeType 資料夾內的 images 資料夾內。