本文章基于handsome6.0.0版本

网站总访问统计

网站总访问统计效果图

  1. usr/handsome/themes/libs/Contet.php 中的class Content{这一行上面添加:
//总访问量
    function theAllViews()
        {
            $db = Typecho_Db::get();
            $row = $db->fetchAll('SELECT SUM(VIEWS) FROM `typecho_contents`');
                echo number_format($row[0]['SUM(VIEWS)']);
        }

保存即可。

  1. 然后在你需要显示的位置(如:footer.phpsidebar.php 等)插入以下调用代码

handsome 主题添加代码位置在:网站根目录/usr/themes/handsome/component/sidebar.php

<li class="list-group-item"> <i class="glyphicon glyphicon-user text-muted"></i> <span class="badge
pull-right"><?php echo theAllViews();?></span><?php _me("访客总数") ?></li>

响应耗时

响应耗时效果图

  1. usr/handsome/themes/libs/Content.php 中的class Content{这一行上面添加:
//加载耗时
function timer_start() {
    global $timestart;
    $mtime     = explode( ' ', microtime() );
    $timestart = $mtime[1] + $mtime[0];
    return true;
}
timer_start();
function timer_stop( $display = 0, $precision = 3 ) {
    global $timestart, $timeend;
    $mtime     = explode( ' ', microtime() );
    $timeend   = $mtime[1] + $mtime[0];
    $timetotal = number_format( $timeend - $timestart, $precision );
    $r         = $timetotal < 1 ? $timetotal * 1000 . " ms" : $timetotal . " s";
    if ( $display ) {
        echo $r;
    }
    return $r;
}
    1. 然后在/usr/themes/handsome/component/sidebar.php下添加显示代码
<li class="list-group-item"> <i class="glyphicon glyphicon-time text-muted"></i> <span class="badge
pull-right"><?php echo timer_stop();?></span><?php _me("加载耗时") ?></li>

Last modification:February 9th, 2020 at 05:41 pm
如果觉得我的文章对你有用,请随意赞赏