* @since 2.0 */ 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 `['127.0.0.1', '::1']`, which means the module can only be accessed * by localhost. */ public $allowedIPs = ['127.0.0.1', '::1']; /** * @var string the namespace that controller classes are in. */ public $controllerNamespace = 'yii\debug\controllers'; /** * @var LogTarget */ public $logTarget; /** * @var array list of debug panels. The array keys are the panel IDs, and values are the corresponding * panel class names or configuration arrays. This will be merged with [[corePanels()]]. * You may reconfigure a core panel via this property by using the same panel ID. * You may also disable a core panel by setting it to be false in this property. */ public $panels = []; /** * @var string the directory storing the debugger data files. This can be specified using a path alias. */ public $dataPath = '@runtime/debug'; /** * @var integer the maximum number of debug data files to keep. If there are more files generated, * the oldest ones will be removed. */ public $historySize = 50; /** * Returns Yii logo ready to use in `'; /** @var View $view */ $view = $event->sender; echo ''; echo ''; } /** * Checks if current user is allowed to access the module * @return boolean if access is granted */ 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; } } Yii::warning('Access to debugger is denied due to IP address restriction. The requested IP is ' . $ip, __METHOD__); return false; } /** * @return array default set of panels */ protected function corePanels() { return [ 'config' => ['class' => 'yii\debug\panels\ConfigPanel'], 'request' => ['class' => 'yii\debug\panels\RequestPanel'], 'log' => ['class' => 'yii\debug\panels\LogPanel'], 'profiling' => ['class' => 'yii\debug\panels\ProfilingPanel'], 'db' => ['class' => 'yii\debug\panels\DbPanel'], 'mail' => ['class' => 'yii\debug\panels\MailPanel'], ]; } }