Skip to content

Commit

Permalink
✨ 增加恶意统计关键字访问屏蔽功能
Browse files Browse the repository at this point in the history
  • Loading branch information
Licoy committed May 6, 2023
1 parent 0c7dba1 commit 91d4503
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions inc/fun/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function pk_ajax_resp_error($msg = 'fail', $data = null)
require_once PUOCK_ABS_DIR . '/inc/ext/init.php';
require_once PUOCK_ABS_DIR . '/inc/fun/ajax.php';
require_once PUOCK_ABS_DIR . '/inc/fun/oauth.php';
require_once PUOCK_ABS_DIR . '/inc/fun/security.php';
require_once PUOCK_ABS_DIR . '/inc/fun/comment-ajax.php';
require_once PUOCK_ABS_DIR . '/inc/fun/widget.php';
require_once PUOCK_ABS_DIR . '/inc/init.php';
Expand Down
18 changes: 18 additions & 0 deletions inc/fun/security.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php


function pk_baidu_wd_reject()
{
$key_list = array_map('trim', explode(',', pk_get_option('vd_kwd_access_reject_list', '')));
if(count($key_list) > 0){
foreach ($key_list as $key){
if(isset($_GET[$key])){
header('HTTP/1.1 403 Forbidden');
exit;
}
}
}
}
if(pk_is_checked('vd_kwd_access_reject')){
add_action('init', 'pk_baidu_wd_reject');
}
15 changes: 14 additions & 1 deletion inc/setting/options/OptionValidate.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,20 @@ function get_fields(): array
'sdt' => ''
]
]
]
],
[
'id' => 'vd_kwd_access_reject',
'label' => __('恶意统计关键字访问屏蔽', PUOCK),
'type' => 'switch',
'tips' => __('开启后,将会使含有指定关键字的query参数请求得到403拒绝访问,防止站点统计的恶意刷量', PUOCK),
'sdt' => false,
],
[
'id' => 'vd_kwd_access_reject_list',
'label' => __('恶意统计关键字访问屏蔽参数', PUOCK),
'tips' => __('多个之间使用半角<code>,</code>进行分隔', PUOCK),
'sdt' => 'wd,str',
],
],
];
}
Expand Down

0 comments on commit 91d4503

Please sign in to comment.