ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
## 使用方法 1. **操作前请做好相应备份工作** 2. 此插件只适用于`Handsome`主题,未对其它主题优化!!! 3. 请先将插件置于`Typecho`的`plugins`目录下,且插件目录名应为`UserAgent`,注意大小写,否则将无法正常食用!!! 4. 修改`Handsome`主题,`component`目录下的`comments.php`代码文件,大概第`60~80`行左右, ~~~ <span class="comment-author vcard"> <b class="fn"><?php echo $author; ?></b><?php echo $Identity; ?> </span> ~~~ 添加代码`<?php UserAgent_Plugin::get_useragent($comments->agent,$comments->ip); ?>`,修改后代码如下: ~~~ <span class="comment-author vcard"> <b class="fn"><?php echo $author; ?></b><?php echo $Identity; ?><?php UserAgent_Plugin::get_useragent($comments->agent,$comments->ip); ?> </span> ~~~ ### 获取真实IP Typecho开启CDN后,可能无法获取访客真实IP,只能取得CDN节点IP,为此可以在Typecho博客网站的根目录的`config.inc.php`插入下面的代码: ~~~ //** 防止CDN造成无法获取客户真实IP地址 */ if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $list = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']); $_SERVER['REMOTE_ADDR'] = $list[0]; } ~~~ ## 插件下载 链接:https://pan.baidu.com/s/1rr8RfshbkG14yreAf4MTdw 提取码:xn9w ## 原文链接 松鼠博客: https://doge.uk/coding/useragent-modify.html