copy.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. if (!DEFINED('EGP'))
  3. exit(header('Refresh: 0; URL=http://' . $_SERVER['SERVER_NAME'] . '/404'));
  4. if ($go) {
  5. // Подразделы
  6. $aSub = array('fullcopy', 'create', 'recfull', 'recpart', 'remove', 'check');
  7. // Если выбран подраздел
  8. if (isset($url['subsection']) and in_array($url['subsection'], $aSub)) {
  9. if ($url['subsection'] != 'check')
  10. $nmch = sys::rep_act('server_copy_go_' . $id, 10);
  11. if ($server['status'] != 'off' and $url['subsection'] != 'remove')
  12. sys::outjs(array('e' => 'Игровой сервер должен быть выключен'), $nmch);
  13. $sql->query('SELECT `install` FROM `tarifs` WHERE `id`="' . $server['tarif'] . '" LIMIT 1');
  14. $tarif = $sql->get();
  15. $sql->query('SELECT `address`, `passwd` FROM `units` WHERE `id`="' . $server['unit'] . '" LIMIT 1');
  16. $unit = $sql->get();
  17. include(LIB . 'ssh.php');
  18. if (!$ssh->auth($unit['passwd'], $unit['address']))
  19. sys::outjs(array('e' => sys::text('error', 'ssh')), $nmch);
  20. include(SEC . 'servers/games/copy/' . $url['subsection'] . '.php');
  21. }
  22. }
  23. $html->nav($server['address'], $cfg['http'] . 'servers/id/' . $id);
  24. $html->nav('Резервные копии');
  25. if ($mcache->get('server_copy_' . $id) != '')
  26. $html->arr['main'] = $mcache->get('server_copy_' . $id);
  27. else {
  28. // Построение списка создания копии
  29. foreach (params::$section_copy[$server['game']]['aCopy'] as $name => $info) {
  30. $html->get('list', 'sections/servers/games/copy');
  31. $html->set('name', $name);
  32. $html->set('info', $info);
  33. $html->pack('list');
  34. }
  35. // Построение списка созданных копий
  36. $sql->query('SELECT `id`, `server`, `info`, `date`, `status` FROM `copy` WHERE `user`="' . $server['user'] . '_' . $server['unit'] . '" AND `game`="' . $server['game'] . '" ORDER BY `id` ASC');
  37. while ($copy = $sql->get()) {
  38. $html->get('copy', 'sections/servers/games/copy');
  39. $html->set('id', $copy['id']);
  40. $html->set('info', $copy['info']);
  41. $html->set('server', $copy['server']);
  42. $html->set('date', sys::today($copy['date']));
  43. if ($copy['status']) {
  44. $html->unit('created', 1);
  45. $html->unit('!created');
  46. } else {
  47. $html->unit('created');
  48. $html->unit('!created', 1);
  49. }
  50. $html->pack('copy');
  51. }
  52. $html->get('copy', 'sections/servers/' . $server['game']);
  53. $html->set('id', $id);
  54. $html->set('list', isset($html->arr['list']) ? $html->arr['list'] : '');
  55. $html->set('copy', isset($html->arr['copy']) ? $html->arr['copy'] : 'Резервные копии отсутствуют.');
  56. $html->pack('main');
  57. $mcache->set('server_copy_' . $id, $html->arr['main'], false, 4);
  58. }
  59. ?>