|
|
@ -9,6 +9,7 @@ namespace yii\debug; |
|
|
|
|
|
|
|
|
|
|
|
use Yii; |
|
|
|
use Yii; |
|
|
|
use yii\base\View; |
|
|
|
use yii\base\View; |
|
|
|
|
|
|
|
use yii\web\HttpException; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
@ -64,17 +65,20 @@ class Module extends \yii\base\Module |
|
|
|
unset(Yii::$app->getLog()->targets['debug']); |
|
|
|
unset(Yii::$app->getLog()->targets['debug']); |
|
|
|
$this->logTarget = null; |
|
|
|
$this->logTarget = null; |
|
|
|
|
|
|
|
|
|
|
|
$ip = Yii::$app->getRequest()->getUserIP(); |
|
|
|
if ($this->checkAccess($action)) { |
|
|
|
foreach ($this->allowedIPs as $filter) { |
|
|
|
return true; |
|
|
|
if ($filter === '*' || $filter === $ip || (($pos = strpos($filter, '*')) !== false && !strncmp($ip, $filter, $pos))) { |
|
|
|
} elseif ($action->id === 'toolbar') { |
|
|
|
return parent::beforeAction($action); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
throw new HttpException(403, 'You are not allowed to access this page.'); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function renderToolbar($event) |
|
|
|
public function renderToolbar($event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (!$this->checkAccess()) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
$url = Yii::$app->getUrlManager()->createUrl($this->id . '/default/toolbar', array( |
|
|
|
$url = Yii::$app->getUrlManager()->createUrl($this->id . '/default/toolbar', array( |
|
|
|
'tag' => $this->logTarget->tag, |
|
|
|
'tag' => $this->logTarget->tag, |
|
|
|
)); |
|
|
|
)); |
|
|
@ -85,6 +89,17 @@ class Module extends \yii\base\Module |
|
|
|
echo '<script>' . $view->renderPhpFile(__DIR__ . '/views/default/toolbar.js') . '</script>'; |
|
|
|
echo '<script>' . $view->renderPhpFile(__DIR__ . '/views/default/toolbar.js') . '</script>'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected function checkAccess() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$ip = Yii::$app->getRequest()->getUserIP(); |
|
|
|
|
|
|
|
foreach ($this->allowedIPs as $filter) { |
|
|
|
|
|
|
|
if ($filter === '*' || $filter === $ip || (($pos = strpos($filter, '*')) !== false && !strncmp($ip, $filter, $pos))) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected function corePanels() |
|
|
|
protected function corePanels() |
|
|
|
{ |
|
|
|
{ |
|
|
|
return array( |
|
|
|
return array( |
|
|
|