Emlog实行网站消息统计的代码

原创

Emlog实行网站消息统计的代码

有功夫想在网页中向来访的客人展现Emlog部分博客的作品数目、指摘数目、运转功夫等消息

但emlog后盾侧边栏没有供给关系的模块,所以须要站长自决增添部分博客统计消息代码

底下是重庆SEO整治的Emlog网站消息统计代码,已在emlog 5.3.1+上尝试可用,最新版6.0.1也是不妨用的

本领一

运用Emlog官方缓存类统计代码

便宜:加载速率快

缺陷:大概消息革新不迭时

把以次代码增添到暂时运用的中心沙盘文献中,冬镜倡导放在侧边栏side.php文献底部

<?php $sta_cache = Cache::getInstance()->readCache(‘sta’); ?>

<li>日记数目:<?php echo $sta_cache[‘lognum’]; ?></li>

<li>指摘数目:<?php echo $sta_cache[‘comnum’]; ?></li>

<li>微语数目:<?php echo $sta_cache[‘tbnum’]; ?></li>

<li>运转功夫:<?php echo floor((time()-strtotime(“2018-04-04”))/86400); ?>天</li>

这边证明一下代码:

$sta_cache[‘参数’]中的参数可选如次

lognum 乘客看来日记总额

comnum 未湮没的指摘数目

tbnum 微语数目

本领二

自编因变量经过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 !=” 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;

};

?>

而后在须要的场合挪用就行,挪用代码如次

<ul>

<li>作品总额:<?php echo count_log_all();?></li>

<li>置顶作品:<?php echo count_log_top();?></li>

<li>湮没作品:<?php echo count_log_hide();?></li>

<li>待审作品:<?php echo count_log_check();?></li>

<li>加密作品:<?php echo count_log_pass();?></li>

<li>页面总额:<?php echo count_page_all();?></li>

<li>指摘总额:<?php echo count_com_all();?></li>

<li>友链总额:<?php echo count_link_all();?></li>

<li>微语指摘:<?php echo count_treply_all();?></li>

<li>分门别类总额:<?php echo count_sort_all();?></li>

<li>子分门别类数:<?php echo count_sort_mod();?></li>

<li>标签总额:<?php echo count_tag_all();?></li>

<li>微语总额:<?php echo count_tw_all();?></li>

<li>用户总额:<?php echo count_user_all();?></li>

<li>处置员数:<?php echo count_user_admin();?></li>

<li>作家总额:<?php echo count_user_writer();?></li>

<li>附属类小部件总额:<?php echo count_att_all();?></li>

<li>结果革新:<?php echo last_post_log();?></li>

</ul>

冬镜径直上海图书馆看功效,即使有什么不懂的不妨留言

免责声明: 本站提供的一切软件、教程和内容信息仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络收集整理,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑或手机中彻底删除上述内容。如果您喜欢该程序和内容,请支持正版,购买注册,得到更好的正版服务。我们非常重视版权问题,如有侵权请邮件与我们联系处理。敬请谅解!
转载请注明出处:
网赚 » Emlog实行网站消息统计的代码

提供最优质的资源集合

赞助会员 了解详情
Emlog实行网站消息统计的代码-网赚

Emlog实行网站消息统计的代码

原创

Emlog实行网站消息统计的代码

有功夫想在网页中向来访的客人展现Emlog部分博客的作品数目、指摘数目、运转功夫等消息

但emlog后盾侧边栏没有供给关系的模块,所以须要站长自决增添部分博客统计消息代码

底下是重庆SEO整治的Emlog网站消息统计代码,已在emlog 5.3.1+上尝试可用,最新版6.0.1也是不妨用的

本领一

运用Emlog官方缓存类统计代码

便宜:加载速率快

缺陷:大概消息革新不迭时

把以次代码增添到暂时运用的中心沙盘文献中,冬镜倡导放在侧边栏side.php文献底部

<?php $sta_cache = Cache::getInstance()->readCache(‘sta’); ?>

<li>日记数目:<?php echo $sta_cache[‘lognum’]; ?></li>

<li>指摘数目:<?php echo $sta_cache[‘comnum’]; ?></li>

<li>微语数目:<?php echo $sta_cache[‘tbnum’]; ?></li>

<li>运转功夫:<?php echo floor((time()-strtotime(“2018-04-04”))/86400); ?>天</li>

这边证明一下代码:

$sta_cache[‘参数’]中的参数可选如次

lognum 乘客看来日记总额

comnum 未湮没的指摘数目

tbnum 微语数目

本领二

自编因变量经过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 !=” 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;

};

?>

而后在须要的场合挪用就行,挪用代码如次

<ul>

<li>作品总额:<?php echo count_log_all();?></li>

<li>置顶作品:<?php echo count_log_top();?></li>

<li>湮没作品:<?php echo count_log_hide();?></li>

<li>待审作品:<?php echo count_log_check();?></li>

<li>加密作品:<?php echo count_log_pass();?></li>

<li>页面总额:<?php echo count_page_all();?></li>

<li>指摘总额:<?php echo count_com_all();?></li>

<li>友链总额:<?php echo count_link_all();?></li>

<li>微语指摘:<?php echo count_treply_all();?></li>

<li>分门别类总额:<?php echo count_sort_all();?></li>

<li>子分门别类数:<?php echo count_sort_mod();?></li>

<li>标签总额:<?php echo count_tag_all();?></li>

<li>微语总额:<?php echo count_tw_all();?></li>

<li>用户总额:<?php echo count_user_all();?></li>

<li>处置员数:<?php echo count_user_admin();?></li>

<li>作家总额:<?php echo count_user_writer();?></li>

<li>附属类小部件总额:<?php echo count_att_all();?></li>

<li>结果革新:<?php echo last_post_log();?></li>

</ul>

冬镜径直上海图书馆看功效,即使有什么不懂的不妨留言

免责声明: 本站提供的一切软件、教程和内容信息仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络收集整理,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑或手机中彻底删除上述内容。如果您喜欢该程序和内容,请支持正版,购买注册,得到更好的正版服务。我们非常重视版权问题,如有侵权请邮件与我们联系处理。敬请谅解!
转载请注明出处:
网赚 » Emlog实行网站消息统计的代码

提供最优质的资源集合

赞助会员 了解详情