Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
a622424d
Commit
a622424d
authored
Jul 05, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added IP filter.
parent
194ff131
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
1 deletion
+17
-1
Module.php
framework/yii/debug/Module.php
+17
-1
No files found.
framework/yii/debug/Module.php
View file @
a622424d
...
@@ -17,6 +17,15 @@ use yii\helpers\Html;
...
@@ -17,6 +17,15 @@ use yii\helpers\Html;
*/
*/
class
Module
extends
\yii\base\Module
class
Module
extends
\yii\base\Module
{
{
/**
* @var array the list of IPs that are allowed to access this module.
* Each array element represents a single IP filter which can be either an IP address
* or an address with wildcard (e.g. 192.168.0.*) to represent a network segment.
* The default value is `array('127.0.0.1', '::1')`, which means the module can only be accessed
* by localhost.
*/
public
$allowedIPs
=
array
(
'127.0.0.1'
,
'::1'
);
public
$controllerNamespace
=
'yii\debug\controllers'
;
public
$controllerNamespace
=
'yii\debug\controllers'
;
/**
/**
* @var array|Panel[]
* @var array|Panel[]
...
@@ -40,7 +49,14 @@ class Module extends \yii\base\Module
...
@@ -40,7 +49,14 @@ class Module extends \yii\base\Module
{
{
Yii
::
$app
->
getView
()
->
off
(
View
::
EVENT_END_BODY
,
array
(
$this
,
'renderToolbar'
));
Yii
::
$app
->
getView
()
->
off
(
View
::
EVENT_END_BODY
,
array
(
$this
,
'renderToolbar'
));
unset
(
Yii
::
$app
->
getLog
()
->
targets
[
'debug'
]);
unset
(
Yii
::
$app
->
getLog
()
->
targets
[
'debug'
]);
return
parent
::
beforeAction
(
$action
);
$ip
=
Yii
::
$app
->
getRequest
()
->
getUserIP
();
foreach
(
$this
->
allowedIPs
as
$filter
)
{
if
(
$filter
===
'*'
||
$filter
===
$ip
||
((
$pos
=
strpos
(
$filter
,
'*'
))
!==
false
&&
!
strncmp
(
$ip
,
$filter
,
$pos
)))
{
return
parent
::
beforeAction
(
$action
);
}
}
return
false
;
}
}
public
function
renderToolbar
(
$event
)
public
function
renderToolbar
(
$event
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment