EngineGP/system/sections/control/reboot.php
Sergei Solovev b59003e559 Reformat code
This update contains code reformatting to meet PHP standards.
2023-11-12 21:12:42 +03:00

24 lines
876 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
if (!DEFINED('EGP'))
exit(header('Refresh: 0; URL=http://' . $_SERVER['SERVER_NAME'] . '/404'));
if ($ctrl['status'] != 'working')
sys::outjs(array('e' => 'Сервер должен быть в рабочем состоянии'));
$sql->query('SELECT `address`, `passwd` FROM `control` WHERE `id`="' . $id . '" LIMIT 1');
$ctrl = $sql->get();
include(LIB . 'ssh.php');
if (!$ssh->auth($ctrl['passwd'], $ctrl['address']))
sys::outjs(array('e' => 'Неудалось создать связь с физическим сервером'));
$ssh->set('screen -dmS reboot reboot');
$sql->query('UPDATE `control` set `status`="reboot" WHERE `id`="' . $id . '" LIMIT 1');
$sql->query('UPDATE `control_servers` set `status`="off" WHERE `unit`="' . $id . '" LIMIT 1');
$mcache->set('reboot_control_' . $id, true, false, 10);
sys::outjs(array('s' => 'ok'));
?>