change ssh2 into new SSH2
This commit is contained in:
@@ -402,9 +402,7 @@ class ServiceController extends Controller
|
||||
|
||||
\App\Jobs\VirtualMachine\Snapshot\CreateSnapshot::dispatch(
|
||||
$snapshot->id
|
||||
)
|
||||
->onQueue('snapshots')
|
||||
->delay(now()->addSeconds(3));
|
||||
)->delay(now()->addSeconds(3));
|
||||
|
||||
return redirect()->back()->with(
|
||||
'success',
|
||||
|
||||
@@ -300,11 +300,7 @@ class vCenter
|
||||
$action = "powershell.exe; Connect-viserver -Server '$this->apiUri' -User '$this->username' -Password \"'$this->password'\" -SaveCredentials; $cmd";
|
||||
|
||||
//Run action
|
||||
$stream = ssh2_exec($auth, $action);
|
||||
|
||||
stream_set_blocking($stream, true);
|
||||
|
||||
return stream_get_contents($stream);
|
||||
return $auth->exec($action);
|
||||
} catch (Exception $error) {
|
||||
return $error->getCode();
|
||||
}
|
||||
@@ -314,9 +310,10 @@ class vCenter
|
||||
{
|
||||
|
||||
try {
|
||||
$connection = ssh2_connect('10.10.10.173', 22);
|
||||
$connection = new SSH2('10.10.10.173', 22);
|
||||
|
||||
if (ssh2_auth_password($connection, 'administrator', 'Thegioiso@123**$$8899TgTk2')) {
|
||||
if ($connection->login('administrator', 'Thegioiso@123**$$8899TgTk2')) {
|
||||
$connection->setTimeout(0); // No timeout
|
||||
return $connection;
|
||||
}
|
||||
return false;
|
||||
@@ -351,14 +348,8 @@ class vCenter
|
||||
. '-Command "' . str_replace('"', '\"', $psCommand) . '"';
|
||||
|
||||
try {
|
||||
$stream = ssh2_exec($auth, $action);
|
||||
if (!$stream)
|
||||
throw new \RuntimeException("ssh2_exec failed");
|
||||
$err = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
|
||||
stream_set_blocking($stream, true);
|
||||
stream_set_blocking($err, true);
|
||||
$out = stream_get_contents($stream) ?: '';
|
||||
$errOut = stream_get_contents($err) ?: '';
|
||||
$out = $auth->exec($action);
|
||||
$errOut = $auth->getStdError();
|
||||
return $out . ($errOut ? "\n[STDERR]\n" . $errOut : '');
|
||||
} catch (\Throwable $e) {
|
||||
return "Error: " . $e->getMessage();
|
||||
@@ -412,14 +403,8 @@ PS;
|
||||
$action = "powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand $encoded";
|
||||
|
||||
try {
|
||||
$stream = ssh2_exec($auth, $action);
|
||||
if (!$stream)
|
||||
return "ssh2_exec failed";
|
||||
$err = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
|
||||
stream_set_blocking($stream, true);
|
||||
stream_set_blocking($err, true);
|
||||
$out = stream_get_contents($stream) ?: '';
|
||||
$errOut = stream_get_contents($err) ?: '';
|
||||
$out = $auth->exec($action);
|
||||
$errOut = $auth->getStdError();
|
||||
return $out . ($errOut ? "\n[STDERR]\n" . $errOut : '');
|
||||
} catch (\Throwable $e) {
|
||||
return "Error: " . $e->getMessage();
|
||||
@@ -467,15 +452,8 @@ PS;
|
||||
$action = "powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand $encoded";
|
||||
|
||||
try {
|
||||
$stream = ssh2_exec($auth, $action);
|
||||
if (!$stream)
|
||||
return "ssh2_exec failed";
|
||||
$err = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
|
||||
stream_set_blocking($stream, true);
|
||||
stream_set_blocking($err, true);
|
||||
|
||||
$out = stream_get_contents($stream) ?: '';
|
||||
$errOut = stream_get_contents($err) ?: '';
|
||||
$out = $auth->exec($action);
|
||||
$errOut = $auth->getStdError();
|
||||
|
||||
if ($expectJson) {
|
||||
// CẮT JSON cuối: {...} hoặc [...]
|
||||
|
||||
@@ -54,12 +54,13 @@
|
||||
<div class="right-top-bar px-4 md:px-0 w-full sm:w-auto">
|
||||
<!-- BEGIN: Breadcrumb -->
|
||||
<nav id="right-access-account" class="flex gap-2 sm:gap-4 mr-auto items-center justify-end sm:justify-end">
|
||||
<div class="md:hidden block">
|
||||
<div class="md:hidden block">
|
||||
<i data-lucide="menu" class="w-6 h-6"></i>
|
||||
</div>
|
||||
<div class="hidden lg:flex flex-wrap gap-2 sm:gap-4">
|
||||
|
||||
<!-- Số dư -->
|
||||
<a href="#"
|
||||
<div
|
||||
class="animate__animated animate__fadeInLeft items-center gap-2 text-sm text-primary hover:text-primary bg-white shadow-lg rounded-lg p-2 transition-transform duration-300 hover:translate-y-[10%] flex">
|
||||
<div class="flex gap-2 items-center">
|
||||
<span>
|
||||
@@ -69,7 +70,7 @@
|
||||
{{ format_price(auth('users')->user()->credit ?? 0) }}
|
||||
</span>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- Mobile Info Cards -->
|
||||
|
||||
Reference in New Issue
Block a user