首页
微语
统计
友链
留言
memos
圈子
图床
推荐
相册
网站监控
VPS监控
Search
1
实现typecho微信时光机功能的图文教程
45,108 阅读
2
为Typecho添加webp解析
43,168 阅读
3
emlog数据成功迁移到typecho
26,688 阅读
4
Memos备忘录,记录瞬间想法
25,610 阅读
5
Jasmine - 简约、美观的博客主题
24,305 阅读
手机达人
免费资源
电脑网络
娱乐休闲
网站建设
威言威语
Typecho
Emlog
WordPress
服务器
主题
插件
排行榜    
登录
/
注册
Search
标签搜索
wordpress
发布
插件
免费
教程
typecho
EMlog
PHP
代码
CSS
华为
图片
代码修改
安装
评论
手机
诺基亚
微信
文章
智能
Chen'mo
累计撰写
1,266
篇文章
累计收到
374
条评论
首页
栏目
手机达人
免费资源
电脑网络
娱乐休闲
网站建设
威言威语
Typecho
Emlog
WordPress
服务器
主题
插件
页面
微语
统计
友链
留言
memos
推荐
相册
网站监控
VPS监控
搜索到
5
篇与
的结果
2021-06-08
Typecho的Joe主题新增cnzz统计
0.成品图{tabs}{tabs-pane label="后台设置"}{/tabs-pane}{tabs-pane label="前台展示"}{/tabs-pane}{/tabs}1.修改footer.php,新增代码,文件路径:usr/themes/Joe-master/public{tabs}{tabs-pane label="代码"}第一段,在文件最上方添加 <?php if(Helper::options()->CnzzType !== 'off') { $CnzzIdSave = Helper::options()->CnzzId; $CnzzTypeStyle = Helper::options()->CnzzType; $CnzzTypeStyle = str_replace("CnzzId", $CnzzIdSave, $CnzzTypeStyle); } ?> 第二段添加在网站运行时间前面 <div class="item" style="margin: 10px; <?php if(Helper::options()->CnzzType == 'off') echo 'display:none;' ?>"> <span id='cnzz_stat_icon_<?php Helper::options()->CnzzType ?>'></span><script src='<?php echo $CnzzTypeStyle ?>' type='text/javascript'></script> </div>{/tabs-pane}{tabs-pane label="代码位置图片"}{/tabs-pane}{/tabs}2.修改functions.php文件,新增代码,文件路径:/usr/themes/Joe-master{tabs}{tabs-pane label="代码"}$CnzzId = new Typecho_Widget_Helper_Form_Element_Text( 'CnzzId', NULL, NULL, 'cnzz站点ID', '介绍:填写此处用于展示cnzz统计,该地址进行申请 https://www.umeng.com/web' ); $CnzzId->setAttribute('class', 'joe_content joe_custom');// 如果后台无法展示设置,将joe_custom替换为joe_other $form->addInput($CnzzId->multiMode()); $CnzzType = new Typecho_Widget_Helper_Form_Element_Select( 'CnzzType', array( 'off' => '关闭(默认)', 'https://s4.cnzz.com/z_stat.php?id=CnzzId&web_id=CnzzId' => '文字形式', 'https://s4.cnzz.com/z_stat.php?id=CnzzId&show=pic' => '图片样式1', 'https://s4.cnzz.com/z_stat.php?id=CnzzId&show=pic1' => '图片样式2', 'https://s4.cnzz.com/z_stat.php?id=CnzzId&show=pic2' => '图片样式3', 'https://s4.cnzz.com/z_stat.php?id=CnzzId&online=2' => '在线人数', 'https://s4.cnzz.com/z_stat.php?id=CnzzId&online=1&show=line' => '横排数据显示', ), 'off', '选择cnzz样式', '介绍:开启时请填写cnzz站点ID' ); $CnzzType->setAttribute('class', 'joe_content joe_custom');// 如果后台无法展示设置,将joe_custom替换为joe_other $form->addInput($CnzzType->multiMode());{/tabs-pane}{tabs-pane label="代码位置图片"}{/tabs-pane}{/tabs}
2021年06月08日
6,532 阅读
2 评论
0 点赞
2021-06-04
Emlog实现网站信息统计的代码
前言:有时候想在网页中向访客展示[Emlog]个人博客的文章数量、评论数量、运行[时间]等信息但[emlog]后台侧边栏没有提供相关的模块,因此需要[站]长自主添加个人博客统计信息代码下面是整理的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 [sort](http://uqseo.com/tag/sort)op = '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']; } //统计[页面](http://aidezy.com/?s=%E9%A1%B5%E9%9D%A2)总数 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']; } //统计[标签](http://aidezy.com/?s=%E6%A0%87%E7%AD%BE)总数 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']; } //统计[用户](http://aidezy.com/?s=%E7%94%A8%E6%88%B7)总数 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>无陌然直接上图看效果,如果有什么不懂的可以留言
2021年06月04日
10,970 阅读
0 评论
0 点赞
2021-01-17
实现emlog网站信息统计的代码
有时候想在网页中向访客展示emlog博客的文章数量、评论数量、运行时间等信息,但emlog后台侧边栏没有提供相关的模块,因此需要博主自主添加博客统计信息代码。下面是博客吧整理的emlog网站信息统计代码,已在emlog 5.3.x上测试可用。 调用代码: 方法一:官方缓存类统计代码。优点:加载速度快;缺点:可能信息更新不及时。把以下代码添加到当前使用的主题模板文件中,如side.php文件:<?php $sta_cache = Cache::getInstance()->readCache('sta'); /*必须添加*/ ?> <ul> <li>文章总数:<?php echo $sta_cache['lognum']; ?> 篇</li> <li>评论总数:<?php echo $sta_cache['comnum_all']; ?> 条</li> <li>闲言碎语:<?php echo $sta_cache['twnum']; ?>条</li> <li>网站运行:<?php echo floor((time()-strtotime(20160423))/86400); ?> 天</li> </ul>附:$sta_cache[‘参数’]中的参数可选如下:lognum游客可见日志总数draftnum草稿,也就是隐藏文件数量comnum未隐藏的评论数量comnum_all所有评论数量hidecomnum被隐藏的评论数量twnum微语数量checknum未审核的文章数量方法二:自编函数,通过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>来自:https://pjax.cn/em_tongji.html
2021年01月17日
6,193 阅读
0 评论
0 点赞
2020-08-30
Typecho 统计最近更新文章数量
我最近又换主题了,每年不换十几个主题,心里总觉得不痛快,小灯泡的主题很好,我想改,但是一更新,我又麻烦了,所以就干脆自己搞吧。废话说了这么多,这个主题有个最近更新文章数量的统计,见下图:那么怎么实现呢?代码如下://统计多少天内发布的文章数量 function getNumPosts($days){ $db = Typecho_Db::get(); $st_days= time()-$days*24*60*60; $result = $db->fetchAll($db->select()->from('table.contents') ->where('status = ?','publish') ->where('type = ?', 'post') ->where('modified >= ?', $st_days) //统计时间 ); $total_posts = count($result); return $total_posts; }怎么调用呢?在你需要显示文章数的地方插入下面代码:<?php echo getNumPosts(1); ?>括号里面的1,表示1天内,可以自己根据需要修改天数。来源:https://pangsuan.com/p/typecho-posts-count.html
2020年08月30日
7,041 阅读
0 评论
0 点赞
2013-02-26
WordPress 简易信息统计(代码)
提到 WordPress,许多使用它来搭建的博客或网站都喜欢向用户显示一些网站统计数据,比如日志、评论、分类和用户等各自的总数,意义虽然并不是很大,但毕竟可以让读者/用户对自己的网站概况有一定的了解,因此,从这个角度来看也不是没有必要的。 其实,WordPress 已经内置有以上提及的这些数据统计功能,我们可以登录后台查看,但也仅限于管理员本人才拥有这个权限。而写作本文的初衷是向读者显示这些统计数据的,所以,应该将这些数据摆在前台。 WordPress 有许多实现这种数据统计功能的插件,但如果仅仅想要显示以上这几项的统计数据,似乎并没有必要安装任何的插件,我们可以只使用一段简单的代码就可以实事想要的效果。 下面的这段代码来自Deluxeblogtips,我照抄过来了,为了方便中文用户理解和使用,我将其中的几个英文名称改成了中文。好了,将这段代码添加到当前主题的 functions.php 文件中:function simple_stats() { global $wpdb; $stats = array(); $stats['posts'] = number_format_i18n(wp_count_posts('post')->publish); $stats['pages'] = number_format_i18n(wp_count_posts('page')->publish); $stats['cats'] = number_format_i18n(wp_count_terms('category')); $stats['tags'] = number_format_i18n(wp_count_terms('post_tag')); $stats['comments'] = number_format_i18n(wp_count_comments()->approved); $stats['users'] = $wpdb->get_var("SELECT COUNT(ID) FROM {$wpdb->prefix}users"); echo '<div class="simple-stats">', '<p>日志总数: <b>', $stats['posts'], '</b></p>', '<p>页面总数: <b>', $stats['pages'], '</b></p>', '<p>分类总数: <b>', $stats['cats'], '</b></p>', '<p>标签总数: <b>', $stats['tags'], '</b></p>', '<p>评论总数: <b>', $stats['comments'], '</b></p>', '<p>用户总数: <b>', $stats['users'], '</b></p>', '</div>'; }然后,在你想要显示统计数据的地方插入这条函数(比如 sidebar.php 等文件):<?php simple_stats(); ?>这样也就 OK 了。数据显示的样式默认是不作修饰的,如果你想要外观好看一些,上面代码中有一个 class 类,给其中的 simple-stats 添加一些CSS代码美化一下就可以了,这方面这里就不提了。 原文地址:http://www.sayblog.me/simple-statistics-on-wordpress.html
2013年02月26日
3,802 阅读
0 评论
0 点赞