首先将以下代码加到themes/handsome/libs/Content.php中放在class Content{}之前
/_访问总量_/
function theAllViews(){
$db = Typecho\_Db::get();
$row = $db->fetchAll('SELECT SUM(VIEWS) FROM `typecho_contents`');
echo number\_format($row0);
}
/_响应时间_/
function timer\_start() {
global $timestart;
$mtime = explode( ' ', microtime() );
$timestart = $mtime1 + $mtime0;
return true;
}
timer\_start();
function timer\_stop( $display = 0, $precision = 3 ) {
global $timestart, $timeend;
$mtime = explode( ' ', microtime() );
$timeend = $mtime1 + $mtime0;
$timetotal = number\_format( $timeend - $timestart, $precision );
$r = $timetotal < 1 ? $timetotal \* 1000 . " ms" : $timetotal . " s";
if ( $display ) {
echo $r;
}
return $r;
}
然后在/usr/themes/handsome/component/sidebar.php文件内,找到博客信息下面添加以下代码
<li class="list-group-item text-second"> <span class="blog-info-icons"> <i data-feather="users"></i></span>
<span class="badge
pull-right"><?php echo theAllViews();?></span><?php _me("访客总数") ?></li>
<li class="list-group-item text-second"> <span class="blog-info-icons"> <i data-feather="refresh-ccw"></i></span>
<span class="badge
pull-right"><?php echo timer_stop();?></span><?php _me("响应耗时") ?></li>
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。