samdark / yii2-webshell Goto Github PK
View Code? Open in Web Editor NEWWeb shell allows to run yii console commands using a browser
Web shell allows to run yii console commands using a browser
And no error output in window - is this by design?
Another problem - Invalid UTF-8 sequence in argument
was caused by stacktrace of exception happened earlier (because of invalid config) and passed to json_encode()
- so stacktrace returned in output is actually useless
0: "#0 [internal function]: yii\base\ErrorHandler->handleError(2, 'json_encode(): ...', 'D:\\WebServers\\O...', 39, Array)"
1: "#1 ...\vendor\yiisoft\yii2\helpers\BaseJson.php(39): json_encode(Array, 320)"
2: "#2 ...\vendor\yiisoft\yii2\web\JsonResponseFormatter.php(53): yii\helpers\BaseJson::encode(Array)"
3: "#3 ...\vendor\yiisoft\yii2\web\JsonResponseFormatter.php(41): yii\web\JsonResponseFormatter->formatJson(Object(yii\web\Response))"
4: "#4 ...\vendor\yiisoft\yii2\web\Response.php(939): yii\web\JsonResponseFormatter->format(Object(yii\web\Response))"
5: "#5 ...\vendor\yiisoft\yii2\web\Response.php(310): yii\web\Response->prepare()"
6: "#6 ...\vendor\yiisoft\yii2\base\Application.php(381): yii\web\Response->send()"
7: "#7 ...\index.php(14): yii\base\Application->run()"
8: "#8 {main}"
type: "yii\base\ErrorException"
I've tried to install the webshell plugin for run some scripts in a project, but i had a problem when i tried to run the command:
composer require --prefer-dist samdark/yii2-webshell "~2.0"
The error message that i had was:
Problem 1
- Root composer.json requires samdark/yii2-webshell ~2.0 -> satisfiable by samdark/yii2-webshell[2.0.0].
- samdark/yii2-webshell 2.0.0 requires bower-asset/jquery.terminal ~0.8.8 -> could not be found in any version, there may be a typo in the package name.
Do you have an idea to solve this? Is there another package that can replace the missing?
When output from command execution is long it is not visible. Need to scroll to see result.
I test in Chrome and Firefox.
Requirements could be lowered by executing commands directly w/o popen
:
https://github.com/tebazil/yii2-console-runner/blob/master/src/ConsoleCommandRunner.php
Приветствую!
Я недавно подсел на Yii2 и есть вопрос с консолькой.
Нет доступа к по ssh к серверу, поэтому нашел Ваше решение.
У меня установлен yii2-advanced template
Если я правильно понимаю, то сам модуль ссылается на скриптовой файл yii
Этот скрипт лежит в корне директории.
В конфиге прописал:
'modules' => [
'webshell' => [
'class' => 'samdark\webshell\Module',
'allowedIPs' => ['*'],
'yiiScript' => '@root',
],
],
Все подключилось, но при выполнении команд ничего не происходит:
Problem 1
- Root composer.json requires bower-asset/jquery.terminal, it could not be found in any version, there may be a typo in the package name.
Problem 2
- Root composer.json requires samdark/yii2-webshell ~2.0 -> satisfiable by samdark/yii2-webshell[2.0.0].
- samdark/yii2-webshell 2.0.0 requires bower-asset/jquery.terminal ~0.8.8 -> could not be found in any version, there may be a typo in the package name.
On April 19 this issue was closed, however it reappears.
I could not get this module to reply something useful. All I get is Content-Type: application/json; charset=UTF-8
response.
At first, I was not providing correct yiiScript
value, but afterwards I changed it to correct one (tested it via ssh), but still, I'm getting strange result and I don't know what is the cause.
To debug this issue, I did a little rewrite of DefaultController::runConsole()
command (using code from AssetConverter::runCommand()) and made it into:
protected function runConsole($command)
{
$command = Yii::getAlias($this->module->yiiScript) . ' ' . $command;
$descriptor = [
1 => ['pipe', 'w'],
2 => ['pipe', 'w'],
];
$pipes = [];
$proc = proc_open($command, $descriptor, $pipes, $basePath);
$stdout = stream_get_contents($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
foreach ($pipes as $pipe) {
fclose($pipe);
}
$status = proc_close($proc);
$command_d = \yii\helpers\VarDumper::dumpAsString($command);
$stdout_d = \yii\helpers\VarDumper::dumpAsString($stdout);
$stderr_d = \yii\helpers\VarDumper::dumpAsString($stderr);
if ($status === 0) {
Yii::trace("Command $command_d ran successfully:\nSTDOUT:\n$stdout_d\nSTDERR:\n$stderr_d", __METHOD__);
} elseif (YII_DEBUG) {
throw new \yii\base\Exception("Command '$command_d' failed with exit code $status:\nSTDOUT:\n$stdout_d\nSTDERR:\n$stderr_d");
} else {
Yii::error("Command '$command_d' failed with exit code $status:\nSTDOUT:\n$stdout_d\nSTDERR:\n$stderr_d", __METHOD__);
}
return [$status, $stdout];
}
And I got this output in debug console:
Command 'php -c php.ini -f ../yii ' ran successfully:
STDOUT:
'Content-Type: application/json; charset=UTF-8
'
STDERR:
''
The package was install earlier but suddenly when ran composer update then below dependencies problems are there :
Problem 1
- Root composer.json requires samdark/yii2-webshell ~2.0 -> satisfiable by samdark/yii2-webshell[2.0.0].
- samdark/yii2-webshell 2.0.0 requires bower-asset/jquery.terminal ~0.8.8 -> found bower-asset/jquery.terminal[dev-master, 2.23.1, ..., 2.35.3] but it does not match the constraint.
Also tried installing this package with composer require but same output
Ref 1 : https://prnt.sc/qIlVdaRtX11K
Ref 2 : https://prnt.sc/Eop72TyyX9-J
Is there any additional config require?
При попытке создать/провести миграцию идет запрос на подтверждение.
Если ответить на запрос, выдает Unknown command.
$ yii migrate
Yii Migration Tool (based on Yii v2.0.6)
Total 1 new migration to be applied:
m150826_060922_test
Apply the above migration? (yes|no) [no]:
$ yes
Unknown command.
курсор автоматически переносит.
Может добавить allowedCallback какой нибудь? чтоб проверял до allowedIPs, например, если админ. IP все же неудобная фигня :(
Вываливается с ошибкой: Invalid path alias: @samdark/webshell/assets
. Что делать?
Did you test webshell with the migrate command?
I always get an "Unknown command." error after the "yes" prompt.
Yii 2.0 web shell
$ yii migrate
Yii Migration Tool (based on Yii v2.0.7)
Total 1 new migration to be applied:
m160329_110000_create_modelhistory
Apply the above migration? (yes|no) [no]:
$ y
Unknown command.
Running the "yii migrate" command in linux shell works without problems,
so there must be something wrong with webshell or my config:
'webshell' => [
'class' => 'samdark\webshell\Module',
'yiiScript' => '/var/www/html/myprojectfolder/yii'
]
The yiiScript is executable and works fine when run with one of the following commands:
php yii
./yii
Webshell works fine as long as there is no prompt.
I don't know where to start debugging...
Через шел работает /usr/bin/env php /home/***/yii
Через скрипт yii
выдает /usr/bin/env: php : No such file or directory
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.