index.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
  4. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/devtypesfilter.php");
  5. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/devmodelsfilter.php");
  6. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/buildingfilter.php");
  7. $default_sort='device_name';
  8. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sortfilter.php");
  9. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  10. if (isset($_POST["remove_device"])) {
  11. $dev_ids = $_POST["fid"];
  12. foreach ($dev_ids as $key => $val) {
  13. if ($val) { delete_device($db_link,$val); }
  14. }
  15. header("Location: " . $_SERVER["REQUEST_URI"]);
  16. exit;
  17. }
  18. print_device_submenu($page_url);
  19. $sort_sql=" ORDER BY device_name";
  20. if (!empty($sort_field) and !empty($order)) { $sort_sql = " ORDER BY $sort_field $order"; }
  21. ?>
  22. <div id="cont">
  23. <br>
  24. <form name="def" action="index.php" method="post">
  25. <table class="data">
  26. <tr class="info" align="right">
  27. <td class="info" colspan=3> <?php print WEB_device_type_show; print_devtypes_select($db_link, "devtypes", $f_devtype_id, "id<3"); ?>
  28. <td class="info" colspan=3> <?php print WEB_models; print_devmodels_select($db_link, "devmodels", $f_devmodel_id); ?>
  29. <?php print WEB_device_show_location; print_building_select($db_link, "building_id", $f_building_id); ?></td>
  30. <td class="info"><input type="submit" id="apply" name="apply" value="<?php echo WEB_btn_show; ?>"></td>
  31. <td class="info" colspan=2><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="remove_device" value="<?php echo WEB_btn_delete; ?>"></td>
  32. </tr>
  33. <tr align="center">
  34. <td align=Center><input type="checkbox" onClick="checkAll(this.checked);"></td>
  35. <td><b><a href=index.php?sort=device_type&order=<?php print $new_order; ?>><?php echo WEB_cell_type; ?></a></b></td>
  36. <td><b><a href=index.php?sort=device_name&order=<?php print $new_order; ?>><?php echo WEB_cell_name; ?></a></b></td>
  37. <td><b><a href=index.php?sort=ip&order=<?php print $new_order; ?>><?php echo WEB_cell_ip; ?></a></b></td>
  38. <td><b><a href=index.php?sort=device_model_id&order=<?php print $new_order; ?>><?php echo WEB_cell_host_model; ?></a></b></td>
  39. <td><b><a href=index.php?sort=building_id&order=<?php print $new_order; ?>><?php echo WEB_location_name; ?></a></b></td>
  40. <td><b><?php echo WEB_device_port_count; ?></b></td>
  41. <td><b><?php echo WEB_nagios; ?></b></td>
  42. <td><b><?php echo WEB_network_discovery; ?></b></td>
  43. </tr>
  44. <?php
  45. $filter = '';
  46. if ($f_building_id > 0) { $filter .= ' and building_id=' . $f_building_id; }
  47. if ($f_devtype_id >= 0) { $filter .= ' and device_type=' . $f_devtype_id; } else { $filter .= ' and device_type<=2'; }
  48. if ($f_devmodel_id > 0) { $filter .= ' and device_model_id=' . $f_devmodel_id; }
  49. $dSQL = 'SELECT * FROM devices WHERE deleted=0 '.$filter.' '.$sort_sql;
  50. $switches = get_records_sql($db_link,$dSQL);
  51. foreach ($switches as $row) {
  52. print "<tr align=center>\n";
  53. $cl = "data";
  54. if (isset($row['nagios_status'])) {
  55. $cl = 'shutdown';
  56. if ($row['nagios_status'] == 'UP') { $cl = 'up'; }
  57. }
  58. print "<td class=\"$cl\" style='padding:0'><input type=checkbox name=fid[] value=".$row['id']."></td>\n";
  59. print "<td class=\"$cl\">".get_devtype_name($db_link,$row['device_type'])."</td>\n";
  60. print "<td class=\"$cl\" align=left><a href=editdevice.php?id=".$row['id'].">" . $row['device_name'] . "</a></td>\n";
  61. if (isset($row['user_id']) and $row['user_id']>0) {
  62. print "<td class=\"$cl\"><a href=/admin/users/edituser.php?id=".$row['user_id'].">".$row['ip']."</a></td>\n";
  63. } else {
  64. print "<td class=\"$cl\">".$row['ip']."</td>\n";
  65. }
  66. print "<td class=\"$cl\">" . get_vendor_name($db_link, $row['vendor_id']) . " " . get_device_model($db_link,$row['device_model_id']) . "</td>\n";
  67. print "<td class=\"$cl\">" . get_building($db_link, $row['building_id']) . "(" . $row['comment'] . ")</td>\n";
  68. print "<td class=\"$cl\">".$row['port_count']."</td>\n";
  69. print "<td class=\"$cl\">" . get_qa($row['nagios']) . "</td>\n";
  70. print "<td class=\"$cl\">" . get_qa($row['discovery']) . "</td>\n";
  71. }
  72. ?>
  73. </table>
  74. </form>
  75. <table class="data">
  76. <tr><td><?php echo WEB_color_device_description; ?></td></tr>
  77. <tr>
  78. <td class="shutdown"><?php echo WEB_device_down; ?></td>
  79. <td class="up"><?php echo WEB_device_online; ?></td>
  80. <tr>
  81. </table>
  82. <script>
  83. document.getElementById('devtypes').addEventListener('change', function(event) {
  84. const buttonApply = document.getElementById('apply');
  85. buttonApply.click();
  86. });
  87. document.getElementById('devmodels').addEventListener('change', function(event) {
  88. const buttonApply = document.getElementById('apply');
  89. buttonApply.click();
  90. });
  91. document.getElementById('building_id').addEventListener('change', function(event) {
  92. const buttonApply = document.getElementById('apply');
  93. buttonApply.click();
  94. });
  95. </script>
  96. <?php
  97. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php");
  98. ?>