diff --git a/framework/yii/debug/Module.php b/framework/yii/debug/Module.php index 6908b00..0d31bd3 100644 --- a/framework/yii/debug/Module.php +++ b/framework/yii/debug/Module.php @@ -9,6 +9,7 @@ namespace yii\debug; use Yii; use yii\base\View; +use yii\web\HttpException; /** * @author Qiang Xue @@ -64,17 +65,20 @@ class Module extends \yii\base\Module unset(Yii::$app->getLog()->targets['debug']); $this->logTarget = null; - $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); - } + if ($this->checkAccess($action)) { + return true; + } elseif ($action->id === 'toolbar') { + return false; + } else { + throw new HttpException(403, 'You are not allowed to access this page.'); } - return false; } public function renderToolbar($event) { + if (!$this->checkAccess()) { + return; + } $url = Yii::$app->getUrlManager()->createUrl($this->id . '/default/toolbar', array( 'tag' => $this->logTarget->tag, )); @@ -85,6 +89,17 @@ class Module extends \yii\base\Module echo ''; } + 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() { return array( diff --git a/framework/yii/debug/assets/main.css b/framework/yii/debug/assets/main.css index d5eefc6..b60e180 100644 --- a/framework/yii/debug/assets/main.css +++ b/framework/yii/debug/assets/main.css @@ -1,4 +1,12 @@ +body { + padding-top: 60px; +} + #yii-debug-toolbar { + position: fixed; + top: 0; + left: 0; + right: 0; margin: 0 0 20px 0; padding: 0; z-index: 1000000; diff --git a/framework/yii/debug/panels/DbPanel.php b/framework/yii/debug/panels/DbPanel.php index dae155c..3da55f0 100644 --- a/framework/yii/debug/panels/DbPanel.php +++ b/framework/yii/debug/panels/DbPanel.php @@ -36,9 +36,8 @@ class DbPanel extends Panel $url = $this->getUrl(); $output = << - - DB queries: $queryCount - time: $queryTime + + DB $queryCount $queryTime EOD; diff --git a/framework/yii/debug/panels/LogPanel.php b/framework/yii/debug/panels/LogPanel.php index 9f3bbfa..68f2f7f 100644 --- a/framework/yii/debug/panels/LogPanel.php +++ b/framework/yii/debug/panels/LogPanel.php @@ -44,7 +44,7 @@ class LogPanel extends Panel $url = $this->getUrl(); return << - Log: $log + Log $log EOD; } diff --git a/framework/yii/debug/panels/ProfilingPanel.php b/framework/yii/debug/panels/ProfilingPanel.php index b614611..ca9d070 100644 --- a/framework/yii/debug/panels/ProfilingPanel.php +++ b/framework/yii/debug/panels/ProfilingPanel.php @@ -33,10 +33,10 @@ class ProfilingPanel extends Panel return << - Time: $time + Time $time EOD; } diff --git a/framework/yii/debug/panels/RequestPanel.php b/framework/yii/debug/panels/RequestPanel.php index e9b1750..333c01b 100644 --- a/framework/yii/debug/panels/RequestPanel.php +++ b/framework/yii/debug/panels/RequestPanel.php @@ -45,10 +45,10 @@ class RequestPanel extends Panel return << - Status: $statusCode + Status $statusCode EOD; }