gabrieljmj/httprefererfilter
Composer 安装命令:
composer require gabrieljmj/httprefererfilter
包简介
Blocker and allower to HTTP referers
README 文档
README
Filter to allow or block HTTP referers.
##Download Via Composer:
{
"require": {
"gabrieljmj/httprefererfilter": "dev-master"
}
}
##Blocker actions Blocker actions are actions to be executed when a referer not allowed try a request.
\Gabrieljmj\HttpRefererFilter\BlockerAction\RedirectWithHttpLocationHeader: Redirects to some address. Pass on constructor an instance of\Symfony\Component\HttpFoundation\RedirectResponse.\Gabrieljmj\HttpRefererFilter\BlockerAction\PageContent: Add on the page a content. Pass on constructor the content (string) and an instance of\Symfony\Component\HttpFoundation\Response.
##Blocking You can block specifc HTTP referers. ####Example
use Gabrieljmj\HttpRefererFilter\HttpRefererBlocker; use Gabrieljmj\HttpRefererFilter\BlockerAction\RedirectWithHttpLocationHeader; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; $action = new RedirectWithHttpLocationHeader(new RedirectResponse('http://mydomain.com/invalid-referer'); $blocker = new HttpRefererBlocker(); $blocker->add('http://example.com', $action) ->add('http://example2.com', $action); $request = new Request($_GET, $_POST, [], $_COOKIE, $_FILES, ['HTTP_REFERER' => 'http://example_valid.com']); var_dump($blocker->validate($request)); //bool(true)
If the domain (referer) is in the list, redirects to http://mydomain.com/invalid-referer.
##Allowing With it, allow the request just for specifc domains. ####Example
use Gabrieljmj\HttpRefererFilter\HttpRefererAllower; use Gabrieljmj\HttpRefererFilter\BlockerAction\RedirectWithHttpLocationHeader; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; $action = new RedirectWithHttpLocationHeader(new RedirectResponse('http://mydomain.com/invalid-referer'); $blocker = new HttpRefererAllower($action); $blocker->add('http://example.com') ->add('http://example2.com'); $request = new Request($_GET, $_POST, [], $_COOKIE, $_FILES, ['HTTP_REFERER' => 'http://example1.com']); var_dump($blocker->validate($request)); //bool(true)
If the domain (referer) is not in the list, redirects to http://mydomain.com/invalid-referer.
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-11-06