安利一款Hansome主题专用的UserAgent插件

安利一款Hansome主题专用的UserAgent插件

低调G
2020-05-25 / 0 评论 / 1,435 阅读 / 正在检测是否收录...

食用指南

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];
}

[button color="info" icon="glyphicon glyphicon-download" url="https://doge.uk/wp-content/uploads/2020/03/1583421311-1902984185.zip" type=""]UserAgent-1.1.1.zip[/button]
[button color="info" icon="glyphicon glyphicon-download" url="https://doge.uk/wp-content/uploads/2020/03/1583421390-1651853883.zip" type=""]UserAgent-1.1.0.zip[/button]
[button color="success" icon="glyphicon glyphicon-link" url="https://doge.uk/coding/useragent-modify.html" type=""]作者松鼠博客[/button]

2

评论 (0)

取消