index.php 5.3 KB

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