Просмотр файла delta_framework-main/admin/hosts.php

Размер файла: 5.82Kb
  1. <?php
  2. /**
  3. * Copyright (c) 2022 Roman Grinko <rsgrinko@gmail.com>
  4. * Permission is hereby granted, free of charge, to any person obtaining
  5. * a copy of this software and associated documentation files (the
  6. * "Software"), to deal in the Software without restriction, including
  7. * without limitation the rights to use, copy, modify, merge, publish,
  8. * distribute, sublicense, and/or sell copies of the Software, and to
  9. * permit persons to whom the Software is furnished to do so, subject to
  10. * the following conditions:
  11. * The above copyright notice and this permission notice shall be included
  12. * in all copies or substantial portions of the Software.
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  14. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  15. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  16. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  17. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  18. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  19. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. */
  21.  
  22. use Core\Helpers\Pagination;
  23. use Core\ExternalServices\RemoteHosts;
  24. use Core\SystemConfig;
  25.  
  26. require_once __DIR__ . '/inc/header.php';
  27.  
  28. global $USER;
  29. if ($USER->isAdmin() === false) {
  30. header('Location: ./');
  31. die();
  32. }
  33. ?>
  34. <div class="pageheader">
  35. <div class="media">
  36. <div class="pageicon pull-left">
  37. <i class="fa fa-home"></i>
  38. </div>
  39. <div class="media-body">
  40. <ul class="breadcrumb">
  41. <li><a href=""><i class="glyphicon glyphicon-home"></i></a></li>
  42. <li>Список удаленных площадок</li>
  43. </ul>
  44. <h4>Список площадок</h4>
  45. </div>
  46. </div><!-- media -->
  47. </div><!-- pageheader -->
  48.  
  49. <div class="contentpanel">
  50. <!-- table -->
  51. <div class="row">
  52. <div class="col-md-12r">
  53. <form id="hostsForm">
  54. <div class="table-responsive">
  55. <table class="table table-primary table-hover mb30">
  56. <thead>
  57. <tr>
  58. <th>Выбор</th>
  59. <th>ID</th>
  60. <th>Статус</th>
  61. <th>URL</th>
  62. <th>Название</th>
  63. <th>Hostname</th>
  64. <th>Дата создания</th>
  65. <th>Дата обновления</th>
  66. </tr>
  67. </thead>
  68. <tbody>
  69. <?php
  70. Pagination::execute($_REQUEST['page'], RemoteHosts::getAllCount(), SystemConfig::getValue('PAGINATION_LIMIT'));
  71. $limit = Pagination::getLimit();
  72.  
  73. $arHosts = RemoteHosts::getHosts($limit);
  74. foreach ($arHosts as $elHost) {
  75. $hostObject = (new RemoteHosts())->selectHost($elHost['id']);
  76. ?>
  77. <tr>
  78. <td><input type="checkbox" name="hosts[]" value="<?= $elHost['id'] ?>"></td>
  79. <td><?= $elHost['id'] ?></td>
  80. <td><?php if ($hostObject->isOnline()) { ?>
  81. <span class="badge badge-success">Online</span></td>
  82. <?php } else { ?>
  83. <span class="badge badge-danger">Offline</span></td>
  84. <?php } ?>
  85. <td><?= $elHost['url'] ?></td>
  86. <td><?= $elHost['name'] ?></td>
  87. <td><?= $hostObject->getHostname() ?></td>
  88. <td><?= $elHost['date_created'] ? date('d.m.Y H:i:s', strtotime($elHost['date_created'])) : '-'; ?></td>
  89. <td><?= $elHost['date_updated'] ? date('d.m.Y H:i:s', strtotime($elHost['date_updated'])) : '-'; ?></td>
  90. </tr>
  91. <?php
  92. }
  93. ?>
  94. </tbody>
  95. </table>
  96. </div><!-- table-responsive -->
  97. <select name="cmd" class="form-control">
  98. <option value="getUname">uname -a</option>
  99. <option value="getUptime">uptime</option>
  100. <option value="getHostname">hostname</option>
  101. <option value="gethostInfo">Получить информацию о площадке</option>
  102. </select>
  103. <button class="btn btn-success form-control" id="execute">Выполнить</button>
  104. </form>
  105. <div class="result" id="result"></div>
  106. <?php Pagination::show('page') ?>
  107. </div>
  108. </div>
  109. <!-- end table -->
  110. </div><!-- contentpanel -->
  111. <script>
  112. $(document).ready(function(){
  113. var resultBox = $('#result');
  114. $('#hostsForm').on('submit', function (e) {
  115. e.preventDefault();
  116.  
  117. $.post(
  118. './ajax/executeRemoteHost.php',
  119. $('#hostsForm').serialize(),
  120.  
  121. function(data) {
  122. resultBox.html(data);
  123. }
  124. );
  125.  
  126. });
  127. });
  128. </script>
  129. <?php require_once __DIR__ . '/inc/footer.php'; ?>