域名不卖,勿扰!

最全的emlog统计代码

<?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; }?>

使用方法电脑版,将以上代码复制到module.php中,手机版复制粘帖到index.php文件中,然后在任意页面使用调用,例如需要在侧边栏显示日志总数,那么就需要在side.php中添加调用代码,代码添加在你想要显示的地方,调用代码为:
<?php echo 方法名; ?>
例如:

<?php echo count_com_all(); ?>

版权共享,随意转载:云破天开 » 最全的emlog统计代码