代码 创建一个跳转随机文章的独立页面
介绍创建一个随机阅读的独立页面演示https://typecho.team/random.html实现<?php
/**
* 随机阅读
*
* @package custom
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
$db = Typecho_Db::get();
// 统计符合条件的文章总数
$countSql = $...
代码 Typecho获取页面加载时间
在主题functions.php中插入/**
* 页面加载时间
*/
function timer_start() {
global $timestart;
$mtime = explode( ' ', microtime() );
$timestart = $mtime[1] + $mtime[0];
return true;
}
timer_sta...
代码 Typecho显示在线状态
/***
* 在线状态
*/
function get_last_login($user){
$user = '1';
$now = time();
$db = Typecho_Db::get();
$prefix = $db->getPrefix();
$row = $db->fetchRow($db->se...
代码 Typecho 获取在线人数
在主题的functions.php中加入function onlinePeople() {
// 使用 Helper 类获取主题路径
$theme_dir = Helper::options()->themeFile(Helper::options()->theme);
$filename = $theme_dir . '/online.txt'; // ...
代码 Typecho 获取站点统计信息(带缓存)
在主题中最后插入// 获取站点统计信息(带缓存)
function getSiteStatsWithCache() {
// 使用文件缓存(兼容性最好)
$cacheFile = __TYPECHO_ROOT_DIR__ . '/usr/cache/site_stats.cache';
$cacheTime = 3600; // 1小时缓存
if (file...
最新文章
热门文章
最新评论
正在加载今日诗词....