EMLOG网站信息统计代码(全)

EMLOG网站信息统计代码(全)

EMLOGking2017-12-106:44:401173A+A-

方法一:官方缓存类统计代码。优点:加载速度快;缺点:可能信息更新不及时。

把以下代码添加到当前使用的主题模板文件中,如side.php文件:

<?php$sta_cache=Cache::getInstance()->readCache('sta');/*必须添加*/?><ul><li>文章总数:<?phpecho$sta_cache['lognum'];?>篇</li><li>评论总数:<?phpecho$sta_cache['comnum_all'];?>条</li><li>闲言碎语:<?phpecho$sta_cache['twnum'];?>条</li><li>网站运行:<?phpechofloor((time()-strtotime(20160423))/86400);?>天</li></ul>


附:$sta_cache[‘参数’]中的参数可选如下:
lognum游客可见日志总数
draftnum草稿,也就是隐藏文件数量
comnum未隐藏的评论数量
comnum_all所有评论数量
hidecomnum被隐藏的评论数量
twnum微语数量
checknum未审核的文章数量

方法二:自编函数,通过SQL语句查询相关数据。缺点:加载速度较缓存类慢;优点:实时显示
把下面的代码添加到主题的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!=''ANDtype='blog'");return$data['total'];}//统计页面总数functioncount_page_all(){$db=MySql::getInstance();$data=$db->once_fetch_array("SELECTCOUNT(*)AStotalFROM".DB_PREFIX."blogWHEREtype='page'");return$data['total'];}//统计评论总数functioncount_com_all(){$db=MySql::getInstance();$data=$db->once_fetch_array("SELECTCOUNT(*)AStotalFROM".DB_PREFIX."comment");return$data['total'];}//统计友链总数functioncount_link_all(){$db=MySql::getInstance();$data=$db->once_fetch_array("SELECTCOUNT(*)AStotalFROM".DB_PREFIX."link");return$data['total'];}//统计微语评论总数functioncount_treply_all(){$db=MySql::getInstance();$data=$db->once_fetch_array("SELECTCOUNT(*)AStotalFROM".DB_PREFIX."reply");return$data['total'];}//统计分类总数functioncount_sort_all(){$db=MySql::getInstance();$data=$db->once_fetch_array("SELECTCOUNT(*)AStotalFROM".DB_PREFIX."sort");return$data['total'];}//统计子分类数functioncount_sort_mod(){$db=MySql::getInstance();$data=$db->once_fetch_array("SELECTCOUNT(*)AStotalFROM".DB_PREFIX."sortWHEREpid!=0");return$data['total'];}//统计标签总数functioncount_tag_all(){$db=MySql::getInstance();$data=$db->once_fetch_array("SELECTCOUNT(*)AStotalFROM".DB_PREFIX."tag");return$data['total'];}//统计微语总数functioncount_tw_all(){$db=MySql::getInstance();$data=$db->once_fetch_array("SELECTCOUNT(*)AStotalFROM".DB_PREFIX."twitter");return$data['total'];}//统计用户总数functioncount_user_all(){$db=MySql::getInstance();$data=$db->once_fetch_array("SELECTCOUNT(*)AStotalFROM".DB_PREFIX."user");return$data['total'];}//统计管理员总数functioncount_user_admin(){$db=MySql::getInstance();$data=$db->once_fetch_array("SELECTCOUNT(*)AStotalFROM".DB_PREFIX."userWHERErole='admin'");return$data['total'];}//统计作者总数functioncount_user_writer(){$db=MySql::getInstance();$data=$db->once_fetch_array("SELECTCOUNT(*)AStotalFROM".DB_PREFIX."userWHERErole='writer'");return$data['total'];}//统计附件总数functioncount_att_all(){$db=MySql::getInstance();$data=$db->once_fetch_array("SELECTCOUNT(*)AStotalFROM".DB_PREFIX."attachment");return$data['total'];}//最后发表文章时间functionlast_post_log(){$db=MySql::getInstance();$sql="SELECT*FROM".DB_PREFIX."blogWHEREtype='blog'ORDERBYdateDESCLIMIT0,1";$res=$db->query($sql);$row=$db->fetch_array($res);$date=date('Y-n-jH:i',$row['date']);return$date;};?>

调用代码:

<ul><li>文章总数:<?phpechocount_log_all();?></li><li>置顶文章:<?phpechocount_log_top();?></li><li>隐藏文章:<?phpechocount_log_hide();?></li><li>待审文章:<?phpechocount_log_check();?></li><li>加密文章:<?phpechocount_log_pass();?></li><li>页面总数:<?phpechocount_page_all();?></li><li>评论总数:<?phpechocount_com_all();?></li><li>友链总数:<?phpechocount_link_all();?></li><li>微语评论:<?phpechocount_treply_all();?></li><li>分类总数:<?phpechocount_sort_all();?></li><li>子分类数:<?phpechocount_sort_mod();?></li><li>标签总数:<?phpechocount_tag_all();?></li><li>微语总数:<?phpechocount_tw_all();?></li><li>用户总数:<?phpechocount_user_all();?></li><li>管理员数:<?phpechocount_user_admin();?></li><li>作者总数:<?phpechocount_user_writer();?></li><li>附件总数:<?phpechocount_att_all();?></li><li>最后更新:<?phpecholast_post_log();?></li></ul>

点击这里复制本文地址以上内容由蒙文软件大全整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!

支持Ctrl+Enter提交

蒙文软件大全© All Rights Reserved.  蒙文软件大全 Copyright ©2018 蒙ICP备13001995号-4
PoweredbyZ-BlogPHPThemesby蒙古文软件
联系我们|关于注册|留言建议|管理|

本站会员尊享VIP特权,现在就加入我们吧!登录注册×
»
会员登录
新用户注册
×
会员注册
获取邀请码
已有账号登录
×