作者:dianso
发布时间November 16, 2010
分类:談博說博
WordPress 本身文章没统计文章浏览数功能,所以只能用插件了,我使用的是 WP-PostViews 来统计文章浏览数,这个插件很久没更新了,而这个插件默认是没有统计总浏览数的功能的。
我爱水煮鱼写过一篇文章,安装一个插件就可以在后台显示每篇文章的浏览数,如图:

下载已删除,最新版的插件已集成。
统计总浏览数可以这样实现,首先把下面代码加入到 functions.php
/* Display Total Views */
if(!function_exists('get_totalviews')) {
function get_totalviews($display = true) {
global $wpdb;
$total_views = $wpdb->get_var("SELECT SUM(meta_value+0) FROM $wpdb->postmeta WHERE meta_key = 'views'");
if($display) {
echo number_format($total_views);
} else {
return number_format($total_views);
}
}
}然后在要调用的地方,比如侧边 (sidebar.php) 加上
<php get_totalviews();?>
效果可以看我的侧边上 :mrgreen:
最新版的插件,上面两个功能全默认带了,不需要这样弄了。
作者:dianso
发布时间September 23, 2010
分类:存檔備份
Step.1
wget http://humdi.net/vnstat/vnstat-1.10.tar.gz
tar xvzf vnstat-1.10.tar.gz
cd vnstat-1.10
make
make install
cd ..
Step.2
vnstat -u -i venet0
接著修改 vnStat 的部分設定
vi /etc/vnstat.conf
第 6 行的
Interface "eth0"
改成
Interface "venet0"
Step.3
wget http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.5.1.tar.gz
tar xvzf vnstat_php_frontend-1.5.1.tar.gz
mv -f vnstat_php_frontend-1.5.1 /home/wwwroot/vnstat
Step.4
vi /home/wwwroot/vnstat/config.php
第 31 行的
$language = 'nl';
改成
$language = 'en';
第 34 行
$iface_list = array('eth0', 'sixxs');
改成對應的網路連接介面
$iface_list = array('venet0', 'sixxs');
第 41 行
$iface_title['eth0'] = 'Internal';
改成對應的網路連接介面
$iface_title['venet0'] = 'Internal';
第 58 行
$data_dir = './dumps';
改成
$data_dir = '/var/lib/vnstat/';
第 61 行
$graph_format='svg';
改成
$graph_format='png';
Step.5
cp vnstat-1.10/examples/init.d/redhat/vnstat /etc/init.d/vnstat
chmod +x /etc/init.d/vnstat
chkconfig --level 235 vnstat on
/etc/init.d/vnstat start
Step.6
*/5 * * * * vnstat -u -i venet0
*/5 * * * * vnstat --dumpdb -i venet0 >/var/lib/vnstat/vnstat_dump_venet0
Step.7
rm -f vnstat-1.10.tar.gz
rm -f vnstat_php_frontend-1.5.1.tar.gz
rm -rf vnstat-1.10
没有安装 vi 的话,按吧
yum -y install gcc gcc-c++ autoconf crontabs
作者:dianso
发布时间August 13, 2010
分类:存檔備份
5636546
作者:dianso
发布时间May 29, 2010
分类:存檔備份
1. 用户总数
<?php $users = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users"); echo $users; ?> 位</li>2. 日志总数
<?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish;?> 篇</li>
3. 评论总数
<span title="访客 / 管理员:<?php $comment_guest = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1' AND comment_type != 'trackback' AND comment_type != 'pingback' AND user_id = 0"); echo $comment_guest; ?>/<?php $comment_author = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1' AND comment_type != 'trackback' AND comment_type != 'pingback' AND user_id > 0"); echo $comment_author; ?>">评论总数:<?php
$comment = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1' AND comment_type != 'trackback' AND comment_type != 'pingback'");
echo $comment;?></span> 篇</li>4. 标签总数
<?php echo $count_tags = wp_count_terms('post_tag'); ?> 个</li>5. 分类总数
<?php echo $count_categories = wp_count_terms('category'); ?> 个</li>6. 页面总数
<?php $count_pages = wp_count_posts('page'); echo $page_posts = $count_pages->publish; ?> 个</li>
7. 链接总数
<?php $link = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links WHERE link_visible = 'Y'"); echo $link; ?> 个</li>
8. 成立时间
<?php echo floor((time()-strtotime("2008-8-18"))/86400); ?>
9. 最后更新
<?php $last = $wpdb->get_results("SELECT MAX(post_modified) AS MAX_m FROM $wpdb->posts WHERE (post_type = 'post' OR post_type = 'page') AND (post_status = 'publish' OR post_status = 'private')");$last = date('Y-n-j', strtotime($last[0]->MAX_m));echo $last; ?>
10. 草稿数目
<?php $count_posts = wp_count_posts(); echo $draft_posts = $count_posts->draft; ?>
via:http://sunsunsun.org/wordpress/wp-tutorials/also-get-rid-of-a-plugin-wordpress-statistics-code.html
作者:dianso
发布时间May 7, 2009
分类:沒事折騰
去年或者更早,我给博客添加了好几个统计工具,今天才发现有点多了,于是就删除了,只保留了Google Analytics。
以下是yahoo! stats.截图

这张是nasboq截图

同时我还安装了Firestats做为统计插件,虽然不准确,占用的数据库也比较大,但一些小功能还是挺好用的。
太多的统计工具对我没任何帮助,以后就只用Google Analytics了。
- 1
- 2
- 3
- »