Skip to content

Commit 3ecd6f0

Browse files
committed
fix(AllowIp): improve Typecho 1.3 compatibility
- support the Typecho 1.3 login success hook - use the plugin configuration object directly - update release metadata and add Ryan as a maintainer
1 parent 1bff0d7 commit 3ecd6f0

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

AllowIp/Plugin.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* 后台管理IP白名单
55
*
66
* @package AllowIp
7-
* @author Fuzqing
8-
* @version 1.0.1
7+
* @author Fuzqing, Ryan
8+
* @version 1.0.2
99
* @link https://huangweitong.com
1010
*/
1111
class AllowIp_Plugin implements Typecho_Plugin_Interface
@@ -14,7 +14,7 @@ class AllowIp_Plugin implements Typecho_Plugin_Interface
1414
* 插件版本号
1515
* @var string
1616
*/
17-
const _VERSION = '1.0.1';
17+
const _VERSION = '1.0.2';
1818

1919
/**
2020
* 激活插件方法,如果激活失败,直接抛出异常
@@ -27,6 +27,7 @@ public static function activate()
2727
{
2828
Typecho_Plugin::factory('admin/common.php')->begin = array('AllowIp_Plugin', 'check');
2929
Typecho_Plugin::factory('Widget_Login')->loginSucceed = array('AllowIp_Plugin', 'check');
30+
Typecho_Plugin::factory('Widget_Login')->loginSuccess = array('AllowIp_Plugin', 'check');
3031
}
3132

3233
/**
@@ -78,7 +79,7 @@ public static function check()
7879
$realip = isset($_SERVER) ? $_SERVER['REMOTE_ADDR'] : getenv("REMOTE_ADDR");
7980

8081
if($realip !== NULL){
81-
$config = json_decode(json_encode(unserialize(Helper::options()->plugin('AllowIp'))));
82+
$config = Helper::options()->plugin('AllowIp');
8283
if(empty($config->allow_ip)) {
8384
$options = Typecho_Widget::widget('Widget_Options');
8485
$config_url = trim($options->siteUrl,'/').'/'.trim(__TYPECHO_ADMIN_DIR__,'/').'/options-plugin.php?config=AllowIp';

AllowIp/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Typecho 后台IP白名单插件 AllowIp
22

3+
当前版本:1.0.2,兼容 Typecho 1.2.1+(包括 Typecho 1.3)。
4+
35
## 插件简介
46

57
设置后台管理IP白名单,也就是说只允许IP白名单内的IP登陆访问后台。<br>
@@ -17,3 +19,10 @@
1719
请打开"Plugin.php"文件中这一行的注释<br>
1820
//$allow_ip[] = '0.0.0.0';<br>
1921
打开保存之后就可以登陆了,不过这样子这个IP白名单插件也就没意义了。
22+
23+
## 更新记录
24+
25+
### 1.0.2
26+
27+
- 修复 Typecho 1.3 下读取插件配置时出现 `unserialize()` 警告的问题;
28+
- 同时兼容 Typecho 1.2.1 的 `loginSucceed` 和 Typecho 1.3 的 `loginSuccess` 登录成功钩子。

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
[AMP](AMP) | 生成AMP/MIP移动标准页面 | 0.7.6.1 | [Holmesian](https://github.com/holmesian) | [Download](https://github.com/typecho-fans/plugins/releases/download/plugins-A_to_C/AMP.zip)
4141
[AbbrSlug](AbbrSlug) | 生成数字文章缩略名 | 1.0.0 | [羽叶](https://github.com/cyea) | [Download](https://github.com/typecho-fans/plugins/releases/download/plugins-A_to_C/AbbrSlug.zip)
4242
[AjaxComments](AjaxComments) | 嵌套评论Ajax异步提交效果 | 1.2.0 | [Byends](https://github.com/visamz), Willin Kan | [Download](https://github.com/typecho-fans/plugins/releases/download/plugins-A_to_C/AjaxComments.zip)
43-
[AllowIp](AllowIp) | 限制访问后台IP白名单 | 1.0.1 | [Fuzqing](https://github.com/fuzqing) | [Download](https://github.com/typecho-fans/plugins/releases/download/plugins-A_to_C/AllowIp.zip)
43+
[AllowIp](AllowIp) | 限制访问后台IP白名单 | 1.0.2 | [Fuzqing](https://github.com/fuzqing), [Ryan](https://github.com/benzBrake) | [Download](https://github.com/typecho-fans/plugins/releases/download/plugins-A_to_C/AllowIp.zip)
4444
[Announcement](Announcement) | 仿Emlog博客悬浮式公告栏 | 1.0.0 | [skylzl](https://github.com/xiaogouxo) | [Download](https://github.com/typecho-fans/plugins/releases/download/plugins-A_to_C/Announcement.zip)
4545
[Another-Like](AnotherLike) | 基于[Like](Like)动画美化点赞按钮 | 1.0.0 | [idealclover](https://github.com/idealclover) | [Download](https://github.com/typecho-fans/plugins/releases/download/plugins-A_to_C/AnotherLike.zip)
4646
[AntiSpam](AntiSpam) | 经典反垃圾评论机器人陷阱 | 1.0.3 | Willin Kan | [Download](https://github.com/typecho-fans/plugins/releases/download/plugins-A_to_C/AntiSpam.zip)

0 commit comments

Comments
 (0)