1
0

index.php 4.5 KB

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