* @since 2.0 */ class Module extends \yii\base\Module implements BootstrapInterface { /** * @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 array the list of hosts that are allowed to access this module. * Each array element is a hostname that will be resolved to an IP address that is compared * with the IP address of the user. A use case is to use a dynamic DNS (DDNS) to allow access. * The default value is `[]`. */ public $allowedHosts = []; /** * @inheritdoc */ public $controllerNamespace = 'yii\debug\controllers'; /** * @var LogTarget */ public $logTarget; /** * @var array|Panel[] 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 permission to be set for newly created debugger data files. * This value will be used by PHP [[chmod()]] function. No umask will be applied. * If not set, the permission will be determined by the current environment. * @since 2.0.6 */ public $fileMode; /** * @var integer the permission to be set for newly created directories. * This value will be used by PHP [[chmod()]] function. No umask will be applied. * Defaults to 0775, meaning the directory is read-writable by owner and group, * but read-only for other users. * @since 2.0.6 */ public $dirMode = 0775; /** * @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; /** * @var boolean whether to enable message logging for the requests about debug module actions. * You normally do not want to keep these logs because they may distract you from the logs about your applications. * You may want to enable the debug logs if you want to investigate how the debug module itself works. */ public $enableDebugLogs = false; /** * Returns Yii logo ready to use in `'; /* @var $view View */ $view = $event->sender; // echo is used in order to support cases where asset manager is not available 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; } } foreach ($this->allowedHosts as $hostname) { $filter = gethostbyname($hostname); if ($filter === $ip) { return true; } } Yii::warning('Access to debugger is denied due to IP address restriction. The requesting IP address 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'], 'assets' => ['class' => 'yii\debug\panels\AssetPanel'], 'mail' => ['class' => 'yii\debug\panels\MailPanel'], ]; } }