emlog网站信息统计代码-凯发网娱乐官网

微信扫一扫,分享到朋友圈

0

有时候想在网页中向访客展示emlog博客的文章数量、评论数量、运行时间等信息,但emlog后台侧边栏没有提供相关的模块,因此需要博主自主添加博客统计信息代码。下面是博客吧整理的emlog网站信息统计代码,已在emlog 5.3.x上测试可用。

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

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

readcache('sta'); /*必须添加*/ ?>
  • 文章总数: 篇
  • 评论总数: 条
  • 闲言碎语:条
  • 网站运行: 天

  附:$sta_cache[‘参数’]中的参数可选如下:
            lognum游客可见日志总数
            draftnum草稿,也就是隐藏文件数量
            comnum未隐藏的评论数量
            comnum_all所有评论数量
            hidecomnum被隐藏的评论数量
            twnum微语数量
            checknum未审核的文章数量
        方法二:自编函数,通过sql语句查询相关数据。缺点:加载速度较缓存类慢;优点:实时显示

        把下面的代码添加到主题的module.php文件中:

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

调用代码:

  • 文章总数:
  • 置顶文章:
  • 隐藏文章:
  • 待审文章:
  • 加密文章:
  • 页面总数:
  • 评论总数:
  • 友链总数:
  • 微语评论:
  • 分类总数:
  • 子分类数:
  • 标签总数:
  • 微语总数:
  • 用户总数:
  • 管理员数:
  • 作者总数:
  • 附件总数:
  • 最后更新:
展开阅读全文

微信扫一扫,分享到朋友圈

0
这个博主很懒,懒死了。
上一篇

emlog博客正文css实现首行缩进的方法,理论所有网页通用

下一篇

#脚本# 一键安装kms服务脚本,搭建自己的kms激活服务器

你也可能喜欢

发表评论

this site uses akismet to reduce spam. .

插入图片