好!欢迎访问迷津渡口 现在时间是: 天气 °C ~ °C

迷津渡口

越感到迷惑 越接近真理

emlog博客统计信息添加方法详解

博客统计信息的查询有很多方法,大部分使用的是利用核心文件里面的缓存函数,还可以使用数据库查询的方法。

下面小指就为大家一一介绍~

首先是常用速度比较快的缓存函数方法,大家可以用编辑器打开模板的 module.php 文件,在末尾加上代码:

<?php
// 缓存函数统计博客信息
function ja_sta(){
  global $CACHE;
  $JA_STA = $CACHE->readCache('sta');
  $JA_STA['linknum'] = count($CACHE->readCache('link'));
  $JA_STA['sortnum'] = count($CACHE->readCache('sort'));
  $JA_STA['tagsnum'] = count($CACHE->readCache('tags'));
  $JA_STA['usernum'] = count($CACHE->readCache('user'));
  extract($JA_STA);
  echo "
  <li>游客可见文章数:$lognum 篇</li>
  <li>隐藏草稿:$draftnum 篇</li>
  <li>未审核的文章数量: $checknum 篇
  <li>未隐藏的评论数:$comnum 条</li>
  <li>被隐藏的评论数:$hidecomnum 条</li>
  <li>所有评论数:$comnum_all 条</li>
  <li>微语:$twnum 条</li>
  <li>友链:$linknum 个</li>
  <li>分类:$sortnum 个</li>
  <li>标签:$tagsnum 个</li>
  <li>作者:$usernum 人</li>
  ";
}
?>

然后在模板的 footer.php 文件或者 side.php 文件合适的位置添加使用代码:

<?php ja_sta(); ?>

在实际使用的时候大家可以自行调节输出的文字和格式。

另外一种方法是使用数据库查询的方法,这种方法比较准确但是加载慢一点~

同样在模板的 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;       
};

// 输出函数
function echo_count_info(){
echo "
  <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_sort_all(); ?></li>
  <li>分类总数:<?php echo count_log_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_tag_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>
  ";
}
?>

然后在模板的 footer.php或者side.php 文件添加代码:

<?php echo_count_info(); ?>

大家可以根据自己需要改变文字和格式,也可以单个使用哦,如文章总数可单独使用 <?php echo count_log_all(); ?> 得到~

如果大家有问题可以随时提问哦,小指会耐心解答的~


点赞0
   支持一下
挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
 点赞
 签到
 表情
 图片
 代码
提交评论

清空信息
关闭评论
isampled
 isampled 约 2 小时前回复
#373
<a href="http://www.sousoushop.com/nike-air-max-cage-venom-vert-chaussuresj">nike air max cage venom vert</a> <a href="http://www.rcfitcamp.com/dam%C3%A4nner-nike-shox-current-blau-orangen-schuhej">dam盲nner nike shox current blau orangen</a> <a href="http://www.milajerdchat.com/kvinders-air-max-90-hyperfuse-gul-hvid-skok">kvinders air max 90 hyperfuse gul hvid</a> <a href="http://www.girisweb.com/nike-lunar-flyknit-3-wolf-grigio-scarpeh">nike lunar flyknit 3 wolf grigio</a> <a href="http://www.abcmovieplot.com/nike-air-pegasus-92-gituttio-grigio-scarpei">nike air pegasus 92 gituttio grigio</a> <a href="http://www.oldhalliwell.com/kansas-city-chiefs-white-jersey-nflh">kansas city chiefs white jersey</a>
[url=http://www.isampled.com/]isampled[/url]
mustberavi
 mustberavi 约 6 小时前回复
#372
<a href="http://www.dbievents.com/mennns-nike-kobe-13-lilla-obuvi">mennns nike kobe 13 lilla</a> <a href="http://www.ilankocaeli.com/converse-mid-top-svart-l%C3%A6r-obuvk">converse mid top svart l忙r</a> <a href="http://www.msignworx.com/menn-menn-nike-air-max-2016-gr%C3%B8nn-svart-bl%C3%A5-obuvi">menn menn nike air max 2016 gr酶nn svart bl氓</a> <a href="http://www.dianegrams.com/mujeres-nike-air-max-invigor-print-amarillo-zapatosl">mujeres nike air max invigor print amarillo</a> <a href="http://www.jobstodayng.com/nike-hypervenom-iii-ic-arancia-nero-grass-verde-scarpeh">nike hypervenom iii ic arancia nero grass verde</a> <a href="http://www.hardcoreboris.com/adidas-stan-smith-all-white-price-shoesk">adidas stan smith all white price</a>
mustberavi http://www.mustberavi.com/
canvasvisual
 canvasvisual 约 10 小时前回复
#371
<a href="http://www.bitcoincyoja.com/nike-air-max-mennns-r%C3%B8d-scarpeb">nike air max mennns r酶d</a> <a href="http://www.checkvins.com/azul-gris-nike-free-run3-5.0-mujeres-zapatos-for-venta-schuhed">azul gris nike free run3 5.0 mujeres zapatos for venta</a> <a href="http://www.cootratel.com/nike-hyperrev-2017-gul-rosa-butyf">nike hyperrev 2017 gul rosa</a> <a href="http://www.dealdragonads.com/nike-free-og-14-marrone-obuvd">nike free og 14 marrone</a> <a href="http://www.expertcro.com/adidas-ultra-boost-triple-noir-ph-obuvg">adidas ultra boost triple noir ph</a> <a href="http://www.firmaeslestir.com/nike-hypervenom-reflective-fg-blanco-schuhef">nike hypervenom reflective fg blanco</a>
canvasvisual http://www.canvasvisual.com/
butterbroad
 butterbroad 约 15 小时前回复
#370
<a href="http://www.setusoftware.com/jordan-eclipse-chukka-gr%C3%B8nn-obuvi">jordan eclipse chukka gr酶nn</a> <a href="http://www.shopteamcubs.com/kvinner-air-jordan-low-future-svart-obuvk">kvinner air jordan low future svart</a> <a href="http://www.danieldavinci.com/adidas-radial-tubular-gr%C3%B8nn-obuvi">adidas radial tubular gr酶nn</a> <a href="http://www.lovirani.com/nike-blazer-high-azul-zapatosl">nike blazer high azul</a> <a href="http://www.rosebites.com/nike-kd-9-peacock-blu-verde-scarpeh">nike kd 9 peacock blu verde</a> <a href="http://www.webrushllc.com/men-nike-air-force-1-25th-low-metalic-dark-blue-shoesk">men nike air force 1 25th low metalic dark blue</a>
butterbroad http://www.butterbroad.com/
garagesetcinc
 garagesetcinc 2019-03-20 10:37回复
#369
<a href="http://www.foradocasulo.com/air-jordan-retro-5-dam%C3%A4nner-silber-gold-schuheg">air jordan retro 5 dam盲nner silber gold</a> <a href="http://www.kcsanpedro.com/nike-zoom-pegasus-31-sort-and-hvid-only-schuheb">nike zoom pegasus 31 sort and hvid only</a> <a href="http://www.lordofvirtue.com/nike-air-max-lunar1-iron-gr%C3%B8n-card-chaussurese">nike air max lunar1 iron gr酶n card</a> <a href="http://www.thbdtv.com/air-jordan-reveal-blanc-and-or-butyg">air jordan reveal blanc and or</a> <a href="http://www.easytanklevel.com/nike-lebron-12-low-tutti-over-rosso-light-scarpea">nike lebron 12 low tutti over rosso light</a> <a href="http://www.golfbreakuk.com/nike-air-max-95-neon-gelb-cool-grau-jack-schuheb">nike air max 95 neon gelb cool grau jack</a>
garagesetcinc http://www.garagesetcinc.com/
otuzbircek
 otuzbircek 2019-03-20 10:03回复
#368
<a href="http://www.tkbelazig.com/nike-shox-turbo-21-oranger-gris-chaussuresh">nike shox turbo 21 oranger gris</a> <a href="http://www.swiftgrocer.com/femminile-nike-air-max-tailwind-8-nero-grigio-scarpeq">femminile nike air max tailwind 8 nero grigio</a> <a href="http://www.warrnamboolag.com/nike-air-griffey-max-1-light-blue-white-shoesj">nike air griffey max 1 light blue white</a> <a href="http://www.paineesq.com/nike-zoom-pegasus-32-himmelbl%C3%A5-hvid-skoi">nike zoom pegasus 32 himmelbl氓 hvid</a> <a href="http://www.gemmatyndall.com/nike-shox-avenue-oro-nero-scarpel">nike shox avenue oro nero</a> <a href="http://www.cestreaming.com/nike-roshe-run-triangle-mens-red-shoesj">nike roshe run triangle mens red</a>
otuzbircek http://www.otuzbircek.com/
macusaa
 macusaa 2019-03-20 06:45回复
#367
<a href="http://www.bgaddiict.com/tennessee-volunteers-top-of-the-world-ncaa-white-booster-cap-hatj">tennessee volunteers top of the world ncaa white booster cap</a> <a href="http://www.deriogolf.com/maschio-nike-huarache-utility-blu-scarpej">maschio nike huarache utility blu</a> <a href="http://www.poluscompany.com/nike-mercurial-vapor-xi-fg-wei%C3%9F-schwarz-blau-schuhei">nike mercurial vapor xi fg wei脽 schwarz blau</a> <a href="http://www.pariswebjob.com/m%C3%A6nd-nike-free-flyknit-5.0-v2-dark-gr%C3%A5-hvid-skoh">m忙nd nike free flyknit 5.0 v2 dark gr氓 hvid</a> <a href="http://www.dakvideo.com/montreal-canadiens-price-jersey-nfli">montreal canadiens price jersey</a> <a href="http://www.freshkeema.com/nike-free-flyknit-bl%C3%A5-oransje-obuvk">nike free flyknit bl氓 oransje</a>
macusaa http://www.macusaa.com/
dkstekstil
 dkstekstil 2019-03-19 20:17回复
#366
<a href="http://www.sousoushop.com/puffer-jacket-womens-north-face-northfaceh">puffer jacket womens north face</a> <a href="http://www.rcfitcamp.com/nike-darwin-himmelblau-gold-schuheq">nike darwin himmelblau gold</a> <a href="http://www.milajerdchat.com/nike-free-run-3-femmes-tout-noir-chaussuresl">nike free run 3 femmes tout noir</a> <a href="http://www.girisweb.com/hombres-nike-air-max-zero-amarillo-negro-zapatosq">hombres nike air max zero amarillo negro</a> <a href="http://www.abcmovieplot.com/air-jordan-retro-3-alle-sort-skoj">air jordan retro 3 alle sort</a> <a href="http://www.oldhalliwell.com/nike-kobe-10-all-gr%C3%B8nn-obuvi">nike kobe 10 all gr酶nn</a>
dkstekstil http://www.dkstekstil.com/
alpigap
 alpigap 2019-03-19 01:39回复
#365
<a href="http://www.alquranschool.com/nike-womens-jalen-richard-limited-black-jersey-oakland-raiders-nfl-30-2016-salute-to-service-nflw">nike womens jalen richard limited black jersey oakland raiders nfl 30 2016 salute to service</a> <a href="http://www.ametinakar.com/womens-nike-philadelphia-eagles-26-jay-ajayi-black-name-number-logo-slim-fit-t-shirt-nflx">womens nike philadelphia eagles 26 jay ajayi black name number logo slim fit t shirt</a> <a href="http://www.bambubaits.com/nike-air-max-90-classic-obsidian-azul-denim-kurpesa">nike air max 90 classic obsidian azul denim</a> <a href="http://www.gogogeeky.com/nike-free-run-3.0-minzgr%C3%BCn-dam%C3%A4nner-butyg">nike free run 3.0 minzgr眉n dam盲nner</a> <a href="http://www.maxfornet.com/mens-nike-new-york-jets-40-trenton-cannon-game-navy-blue-alternate-nfl-jersey-nflw">mens nike new york jets 40 trenton cannon game navy blue alternate nfl jersey</a> <a href="http://www.pandrosos.com/nike-roshe-run-floreale-rosa-bianca-butye">nike roshe run floreale rosa bianca</a>
alpigap http://www.alpigap.com/
specpilot
 specpilot 2019-03-18 20:16回复
#364
<a href="http://www.ikennemer.com/nba-2k14-brooklyn-nets-jersey-nflx">nba 2k14 brooklyn nets jersey</a> <a href="http://www.inspiresatis.com/new-nike-hypervenom-phantom-ag-soccer-boots-cleats-rosado-negro-amarillo-kurpesc">new nike hypervenom phantom ag soccer boots cleats rosado negro amarillo</a> <a href="http://www.matjarkum.com/chris-doleman-womens-purple-nike-nfl-minnesota-vikings-t-shirt-name-number-logo-slim-fit-56-nflx">chris doleman womens purple nike nfl minnesota vikings t shirt name number logo slim fit 56</a> <a href="http://www.milligande.com/femminile-nike-air-presto-grigio-arancia-obuve">femminile nike air presto grigio arancia</a> <a href="http://www.mybizcounsel.com/adidas-tubular-runner-weave-naranja-p%C3%BArpura-scarpec">adidas tubular runner weave naranja p煤rpura</a> <a href="http://www.riddercorp.com/nike-free-5.0-gr%C3%B8n-glow-uk-kurpesb">nike free 5.0 gr酶n glow uk</a>
specpilot http://www.specpilot.com/
顶部留言底部
 00:00/00:00
我想和你虚度时光 - 花房姑娘(9)
  1. 我想和你虚度时光
  2. 花房姑娘
  3. 恋恋风尘
  4. 我喜爱一切不彻底的事物
  5. 我的心里是满的
  6. Long Way
  7. 给少年的歌
  8. 晴日共剪窗
  9. 天上的月你的脸