mallka/yii2-webshell

一个允许运行yii或其他控制台命令并创建自己命令的web shell。

资助包维护!
samdark
Patreon

安装: 61

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 0

分支: 36

语言:JavaScript

类型:yii2-extension

2.0.0 2016-03-04 01:01 UTC

This package is auto-updated.

Last update: 2024-09-13 17:43:54 UTC


README

注意:该包是从 samdark/yii2-webshell 分支出来的

我们做了哪些更改

  1. 允许运行其他控制台命令
  2. 由于一些时间以来bower目录不同,将jquery.terminal移动到asset文件夹中
  3. 更改了Asset类的源路径,因此不再需要设置别名配置。

Yii 2.0 web shell

Web shell允许使用浏览器运行yii控制台命令。

安装

安装此扩展的首选方式是通过 composer

运行以下命令:

php composer.phar require --prefer-dist mallka/yii2-webshell "dev-master"

或者

"mallka/yii2-webshell": "dev-master"

将以下内容添加到您的composer.json文件的require部分:

配置

要使用web shell,将其作为模块包含在应用程序配置中,如下所示

return [
    'modules' => [
        'webshell' => [
            'class' => 'mallka\webshell\Module',
            // 'yiiScript' => Yii::getAlias('@root'). '/yii', // adjust path to point to your ./yii script
        ],
    ],

    // ... other application configuration
]

使用上述配置,您将能够使用URL https:///path/to/index.php?r=webshell 在浏览器中访问web shell

访问控制

默认情况下,访问限制为本地IP。可以通过allowedIPs属性进行更改。此外,还有checkAccessCallback可用于引入自定义访问控制。

return [
    'modules' => [
        'webshell' => [
            'class' => 'mallka\webshell\Module',
            // 'yiiScript' => Yii::getAlias('@root'). '/yii', // adjust path to point to your ./yii script
            'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.2'],
            'checkAccessCallback' => function (\yii\base\Action $action) {
                // return true if access is granted or false otherwise
                return true;
            },
            
            //allow to run other commands,default is true,
            'unlimit'=>false,
            
            //unsupport command
            'unsupportCommands'=>['top','ping'],
        ],
    ],

    // ... other application configuration
]

限制

由于Web的请求-响应性质,Web shell无法进行交互式操作。因此,您应该禁用命令的交互模式。