广告位

emlog官方缓存类统计代码

先说调用代码:<?php $sta_cache = Cache::getInstance()->readCache('sta');?>
<?php echo $sta_cache['内容'];?>
例如调用日志数量
<?php echo $sta_cache['lognum'];?>
注意了这里的日志数量是前台显示出来的日志数量,未包含未审核以及隐藏的文章数量。
lognum 游客可见日志总数
draftnum  草稿,也就是隐藏文件数量
comnum  未隐藏的评论数量
comnum_all  所有评论数量
hidecomnum  被隐藏的评论数量
twnum  微语数量
checknum 未审核的文章数量


缺点加载比较慢,把下面代码放入到模板module.php文件中

<?php
//统计文章总数
function count_log_all(){
$db = MySql::getInstance();
$data = $db->once_fetch_array("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "blog WHERE type = 'blog'");
return $data['total'];
}
//置顶文章数
function count_log_top(){
$db = MySql::getInstance();
$data = $db->once_fetch_array("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "blog WHERE  top = 'y' or sortop = 'y' AND type = 'blog'");
return $data['total'];
}
//隐藏文章数
function count_log_hide(){
$db = MySql::getInstance();
$data = $db->once_fetch_array("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "blog WHERE hide = 'y' AND type = 'blog'");
return $data['total'];
}

//未审核文章数
function count_log_check(){
$db = MySql::getInstance();
$data = $db->once_fetch_array("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "blog WHERE checked = 'n' AND type = 'blog'");
return $data['total'];
}
//加密文章数
function count_log_pass(){
$db = MySql::getInstance();
$data = $db->once_fetch_array("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "blog WHERE  password !='' AND type = 'blog'");
return $data['total'];
}

//统计页面总数
function count_page_all(){
$db = MySql::getInstance();
$data = $db->once_fetch_array("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "blog WHERE type = 'page'");
return $data['total'];
}

//统计评论总数
function count_com_all(){
$db = MySql::getInstance();
$data = $db->once_fetch_array("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "comment");
return $data['total'];
}
//统计友链总数
function count_link_all(){
$db = MySql::getInstance();
$data = $db->once_fetch_array("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "link");
return $data['total'];
}

//统计微语评论总数
function count_treply_all(){
$db = MySql::getInstance();
$data = $db->once_fetch_array("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "reply");
return $data['total'];
}
//统计分类总数
function count_sort_all(){
$db = MySql::getInstance();
$data = $db->once_fetch_array("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "sort");
return $data['total'];
}
//统计子分类数
function count_sort_mod(){
$db = MySql::getInstance();
$data = $db->once_fetch_array("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "sort WHERE pid != 0");
return $data['total'];
}

//统计标签总数
function count_tag_all(){
$db = MySql::getInstance();
$data = $db->once_fetch_array("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "tag");
return $data['total'];
}
//统计微语总数
function count_tw_all(){
$db = MySql::getInstance();
$data = $db->once_fetch_array("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "twitter");
return $data['total'];
}

//统计用户总数
function count_user_all(){
$db = MySql::getInstance();
$data = $db->once_fetch_array("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "user");
return $data['total'];
}

//统计管理员总数
function count_user_admin(){
$db = MySql::getInstance();
$data = $db->once_fetch_array("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "user WHERE role = 'admin'");
return $data['total'];
}

//统计作者总数
function count_user_writer(){
$db = MySql::getInstance();
$data = $db->once_fetch_array("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "user WHERE role = 'writer'");
return $data['total'];
}
//统计附件总数
function count_att_all(){
$db = MySql::getInstance();
$data = $db->once_fetch_array("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "attachment");
return $data['total'];
}

//最后发表文章时间 function last_post_log(){
$db = MySql::getInstance();
$sql = "SELECT * FROM " . DB_PREFIX . "blog WHERE type='blog' ORDER BY date DESC LIMIT 0,1";
$res = $db->query($sql);
$row = $db->fetch_array($res);
$date = date('Y-n-j H:i',$row['date']);
return $date;       
};?>
在对应的位置插入<?php echo count_link_all();?>其中count_link_all()代表友链数量
转自舍力博客,原文地址:http://www.shuyong.net/iemlog/385.html
本博客所有文章如无特别注明均为原创。作者:fyq复制或转载请以超链接形式注明转自 免费精品资源分享
原文地址《emlog官方缓存类统计代码

相关推荐

广告位

发表评论

路人甲 表情
Ctrl+Enter快速提交

网友评论(0)