给emlog主页添加统计栏目代码及教程 - 华雨啦

给emlog主页添加统计栏目代码及教程

作者头像

作者: 华雨啦

请牢记域名 huayula.com (华雨拉) 或 CTRL+D 收藏!

标签:

emlog插件

温馨提示:本站公开发布的资源供测试,更多高质量高价值的资源,可加入华雨拉官方群在群文件下载获取,并在第一时间获得有效的代码和资源,还可在群内提问互助交流!华雨拉官方QQ群:497385575 华雨啦交流群

电脑演示图

手机演示图

简介:

最近较流行的网站资源统计代码美化版,很多大佬都在问,那个统计代码怎么放,我怎么放了没有用呀,听到这些,我也不想说了,下面直接给你们丢代码,喜欢花里胡哨的站长你们要的东西它来了……

方法步骤:

首页调用代码,这里我用的是fee主题,那么直接丢到log_list.php文件里头,当然也有人会问具体丢哪里,因为有很多那种刚玩网站的"大佬"不知道加哪里,然而加了把网站也打不开的那种,只要记住代码丢<?php }?>后面基本会没错,具体放入位置自己定!

<!--统计栏目-->
<div class="tpt-wp cl">
<ul>
<li class="tpt-md-4"><div class="tpt-cm">
<i class="layui-icon fa fa-folder-open-o" style="font-size: 20px; color: #e4ad85;vertical-align: middle;
    margin: 0px 3px;"></i>文章资源 <font color="#03f"><?php echo $sta_cache['lognum']; ?></font> 篇</div>
</li>
<li class="tpt-md-4"><div class="tpt-cm">
<i class="layui-icon fa fa-commenting-o" style="font-size: 20px; color: #27c24c;vertical-align: middle;
    margin: 0px 3px;"></i>评论回复 <font color="#03f"><?php echo $sta_cache['comnum_all']; ?></font> 次</div>
</li>
<li class="tpt-md-4"><div class="tpt-cm">
<i class="layui-icon fa fa-user-o" style="font-size: 20px; color: #23b7e5;vertical-align: middle;
    margin: 0px 3px;"></i>网站用户 <font color="#03f"><?php echo count_user_all();?> </font>位</div>
</li>
<li class="tpt-md-4"><div class="tpt-cm">
<i class="layui-icon fa fa-history" style="font-size: 20px; color: #7266ba;vertical-align: middle;
    margin: 0px 3px;"></i>最后更新 <font color="#ff0000"><?php echo last_post_log();?></font></a ></div>
</li>
</ul>
</div>

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

CSS部分

/*统计栏目*/
.new-content {margin-top: 5px;}
.tpt-wp{margin:0 auto;width:100%}.tpt-cm{color: #333;text-align: center;background: #FFF;height: 60px;line-height: 60px;    border: 1px solid #eaeaea;}.tpt-md-4{float:left}.tpt-md-3{float:left}.tpt-md-2{float:left}.tpt-md-1{width:100%}
@media only screen and (max-width:767px){.tpt-md-4{width:50%}.tpt-md-3{width:100%}.tpt-md-2{width:100%}.tpt-ml-3{display:none}.tpt-mr-3{display:none}.tpt-ml-7{width:100%}.tpt-mr-7{width:100%}}
@media only screen and (min-width:768px) and (max-width:1023px){.tpt-md-4{width:50%}.tpt-md-3{width:50%}.tpt-md-2{width:50%}.tpt-ml-3{display:none}.tpt-mr-3{display:none}.tpt-ml-7{width:100%}.tpt-mr-7{width:100%}}
@media only screen and (min-width:1024px) and (max-width:1199px){.tpt-md-4{width:33.33333333%}.tpt-md-3{width:33.33333333%}.tpt-md-2{width:50%}.tpt-ml-3{float:left;width:30%}.tpt-mr-3{float:right;width:30%}.tpt-ml-7{float:left;width:70%}.tpt-mr-7{float:right;width:70%}}
@media only screen and (min-width:1200px){.tpt-md-4{width:25%}.tpt-md-3{width:33.33333333%}.tpt-md-2{width:50%}.tpt-ml-3{float:left;width:30%}.tpt-mr-3{float:right;width:30%}.tpt-ml-7{float:left;width:70%}.tpt-mr-7{float:right;width:70%}.tpt-wp{width:100%;margin:0 auto;}}

最后:

代码已经完全分享了,该说的我也都说了,要是你还不会或者小白,请另择高明,或者花钱让人帮你装上,不要找我来帮你谢谢,其实我也很菜。

温馨提示:对于第一部分代码,如果你觉得他站你首页代码空间,以后不好找,不好改,你可以新建一个文件把他放入,然后利用php代码进行挂载,我的首页小刀的更新模块,就是利用挂载。

亲爱的宝宝们!喜欢华雨拉(huayula.com)吗?喜欢就按 CTRL+D 收藏吧!
华雨啦(huayula.com)将持续测试与提供可用的QQxml、QQjson代码及网站源码,更新维护不易,期待您的支持!
如果要支持我们,可点击或扫描下面的二维码加入本站QQ群,加入可获得收藏级的工具和代码,新人有好礼相赠!


分享到:
请加群支持华雨拉!
未经允许不得转载:

作者: 华雨啦, 转载或复制请以 超链接形式 并注明出处 华雨啦
原文地址: 《给emlog主页添加统计栏目代码及教程》 发布于2020-4-3

评论

切换注册

登录

忘记密码?

切换登录

注册

给emlog主页添加统计栏目代码及教程

长按图片转发给朋友

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

召唤伊斯特瓦尔