当前位置:首页 » Emlog教程 » emlog官方缓存类统计代码

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 未审核的文章数量


博客访问次数:

2014-8-13更新,来源于em论坛,缺点加载比较慢,把下面代码放入到模板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()代表友链数量
End
关键词: emlog Emlog代码
温馨提示:如果您对本文有疑问,请在本页留言即可!!!
觉得很赞 (0)付款方式
X
付款方式:
  • 微信
  • 支付宝
  • QQ红包

使用微信扫一扫
blogger
    发布日期:2014-04-13   所属类别:Emlog教程   浏览:8543次
    本文地址:http://www.shuyong.net/iemlog/385.html [ 百度已收录 ]
    声明:本页信息由网友自行发布或来源于网络,真实性、合法性由发布人负责,请仔细甄别!本站只为传递信息,我们不做任何双方证明,也不承担任何法律责任。文章内容若侵犯你的权益,请联系本站删除!

留言/评论:◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

填写好QQ号码,任点空白处自动获取

昵称

邮箱

网址

个人资料

舍力

博主:舍力

Emlog交流群

    简单的道理,复杂的人生!

博客统计

  • 文章数量:1133篇
  • 文章评论:3520条
  • 总访问量:10299825次
  • 微语数量:81条
  • 在线人数:4人
  • 本站运行:11年2月28天
  • 估计博主很忙,已经很久没更新了!
Q2 虚位以待
Copyright © 2024 舍力博客 版权所有   粤ICP备11021420号
基于宝塔面板,数据存储于阿里云ECS
Powered by emlog / &Author 舍力博客.