index-passive.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. $default_displayed=500;
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  4. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
  5. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  6. $default_sort='ip_int';
  7. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/oufilter.php");
  8. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/subnetfilter.php");
  9. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sortfilter.php");
  10. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/vendorfilter.php");
  11. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/devtypesfilter.php");
  12. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/buildingfilter.php");
  13. if (isset($_POST["removeauth"])) {
  14. $dev_ids = $_POST["fid"];
  15. foreach ($dev_ids as $key => $val) {
  16. if ($val) {
  17. $device= get_record($db_link,"devices","id='$val'");
  18. if (!empty($device)) {
  19. unbind_ports($db_link, $val);
  20. run_sql($db_link, 'DELETE FROM connections WHERE device_id='.$val);
  21. run_sql($db_link, 'DELETE FROM device_l3_interfaces WHERE device_id='.$val);
  22. run_sql($db_link, 'DELETE FROM device_ports WHERE device_id='.$val);
  23. delete_record($db_link, "devices", "id=".$val);
  24. LOG_WARNING($db_link,"Removed device ".$device['device_name']." id: ".$val);
  25. }
  26. }
  27. }
  28. header("Location: " . $_SERVER["REQUEST_URI"]);
  29. exit;
  30. }
  31. $unknown=1;
  32. if (!isset($_POST['f_unknown']) and isset($_POST['OK'])) { $unknown=0; }
  33. if (isset($_POST['f_unknown'])) { $unknown=$_POST['f_unknown']*1; }
  34. $unknown_checked='';
  35. if ($unknown) { $unknown_checked='checked="checked"'; }
  36. $sort_table = 'A';
  37. if ($sort_field == 'login') { $sort_table = 'L'; }
  38. if ($sort_field == 'fio') { $sort_table = 'L'; }
  39. if ($sort_field == 'model_name') { $sort_table = 'M'; }
  40. $sort_url = "<a href=index-passive.php?ou=" . $rou;
  41. if ($rou == 0) { $ou_filter = ''; } else { $ou_filter = " and L.ou_id=$rou "; }
  42. if ($rsubnet == 0) { $subnet_filter = ''; } else {
  43. $subnet_range = get_subnet_range($db_link,$rsubnet);
  44. if (!empty($subnet_range)) { $subnet_filter = " and A.ip_int>=".$subnet_range['start']." and A.ip_int<=".$subnet_range['stop']; }
  45. }
  46. $d_filter='';
  47. if ($f_building_id > 0) { $d_filter .= ' and D.building_id=' . $f_building_id; }
  48. if ($f_devtype_id > 0) { $d_filter .= ' and D.device_type=' . $f_devtype_id; } else { $d_filter .= ' and D.device_type>2'; }
  49. $ip_list_filter = $ou_filter.$subnet_filter;
  50. unset($_POST);
  51. print_device_submenu($page_url);
  52. ?>
  53. <div id="cont">
  54. <form name="def" action="index-passive.php" method="post">
  55. <table class="data">
  56. <tr>
  57. <td class="info"> <?php echo WEB_device_type_show; ?>: </td>
  58. <td class="info"> <?php print_devtypes_select($db_link, "devtypes", $f_devtype_id, "id>2"); ?>
  59. <td class="info"> <?php print WEB_device_show_location; ?></td>
  60. <td class="info"> <?php print_building_select($db_link, "building_id", $f_building_id); ?></td>
  61. <td class="info" colspan=2 align=right><input name="OK" type="submit" value="<?php echo WEB_btn_show; ?>"></td>
  62. <td align=right><input type="submit" onclick="return confirm('<?php print WEB_msg_delete; ?>?')" name="removeauth" value="<?php print WEB_btn_remove; ?>"></td>
  63. </tr>
  64. <tr>
  65. <td class="info"><?php print WEB_cell_ou."&nbsp"; ?> </td>
  66. <td class="info"><?php print_ou_select($db_link, 'ou', $rou); ?></td>
  67. <td class="info"><?php print WEB_rows_at_page."&nbsp:"; print_row_at_pages('rows',$displayed); ?></td>
  68. <td class="info"><?php print WEB_network_subnet; ?> </td>
  69. <td class="info"><?php print_subnet_select_office($db_link, 'subnet', $rsubnet); ?></td>
  70. <td class="info"><?php print WEB_device_hide_unknown."&nbsp"; ?> <input type=checkbox name=f_unknown value="1" <?php print $unknown_checked; ?>> </td>
  71. <td class="info"><?php print WEB_model_vendor."&nbsp"; print_vendor_select($db_link,"vendor_select",$f_vendor_select); ?></td>
  72. </td>
  73. </tr>
  74. </table>
  75. <?php
  76. $u_filter='';
  77. if ($unknown and $f_vendor_select==0) { $u_filter=' AND V.id<>1 '; } else {
  78. if (!empty($f_vendor_select) and $f_vendor_select>=1) {
  79. $u_filter = " AND V.id=".$f_vendor_select." ";
  80. }
  81. }
  82. $countSQL="SELECT Count(*) FROM User_auth A, User_list L, devices D, device_models M, vendors V
  83. WHERE D.user_id=L.id AND A.ip = D.ip AND D.device_model_id=M.id AND M.vendor_id=V.id AND A.deleted =0
  84. $u_filter $ip_list_filter $d_filter";
  85. $res = mysqli_query($db_link, $countSQL);
  86. $count_records = mysqli_fetch_array($res);
  87. $total=ceil($count_records[0]/$displayed);
  88. if ($page>$total) { $page=$total; }
  89. if ($page<1) { $page=1; }
  90. $start = ($page * $displayed) - $displayed;
  91. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  92. ?>
  93. <br>
  94. <table class="data">
  95. <tr>
  96. <td align=Center><input type="checkbox" onClick="checkAll(this.checked);"></td>
  97. <td align=Center><?php print $sort_url . "&sort=login&order=$new_order>" . WEB_cell_login . "</a>"; ?></td>
  98. <td align=Center><?php print $sort_url . "&sort=ip_int&order=$new_order>" . WEB_cell_ip . "</a>"; ?></td>
  99. <td align=Center><?php print $sort_url . "&sort=mac&order=$new_order>" . WEB_cell_mac . "</a>"; ?></td>
  100. <td align=Center><?php print $sort_url . "&sort=model_name&order=$new_order>".WEB_cell_host_model; ?></td>
  101. <td align=Center><?php print WEB_cell_comment; ?></td>
  102. <td align=Center><?php print WEB_cell_connection; ?></td>
  103. <td align=Center><?php print $sort_url . "&sort=last_found&order=$new_order>".WEB_cell_last_found."</a>"; ?></td>
  104. </tr>
  105. <?php
  106. $sSQL = "SELECT A.id, D.id as dev_id, D.device_type, A.ip, A.mac, A.user_id, L.login, D.comment, A.last_found, V.name, M.model_name
  107. FROM User_auth A, User_list L, devices D, device_models M, vendors V
  108. WHERE D.user_id=L.id AND A.ip = D.ip AND D.device_model_id=M.id AND M.vendor_id=V.id AND A.deleted =0
  109. $u_filter $ip_list_filter $d_filter
  110. ORDER BY $sort_table.$sort_field $order LIMIT $start,$displayed";
  111. $users = get_records_sql($db_link,$sSQL);
  112. foreach ($users as $user) {
  113. if ($user['last_found'] == '0000-00-00 00:00:00') { $user['last_found'] = ''; }
  114. print "<tr align=center>\n";
  115. $cl = "data";
  116. print "<td class='".$cl."' style='padding:0'><input type=checkbox name=fid[] value=".$user['dev_id']."></td>\n";
  117. print "<td class='".$cl."' ><a href=/admin/devices/editdevice.php?id=".$user['dev_id'].">" . $user['login'] . "</a></td>\n";
  118. print "<td class='".$cl."' ><a href=/admin/users/edituser.php?id=".$user['user_id'].">" . $user['ip'] . "</a></td>\n";
  119. print "<td class='".$cl."' >" . expand_mac($db_link,$user['mac']) . "</td>\n";
  120. print "<td class='".$cl."' >".$user['name'].' '.$user['model_name']."</td>\n";
  121. print "<td class='".$cl."' >".$user['comment']."</td>\n";
  122. print "<td class='data'>" . get_connection($db_link, $user['id']) . "</td>\n";
  123. print "<td class='".$cl."' >".$user['last_found']."</td>\n";
  124. print "</tr>\n";
  125. }
  126. print "</table>\n";
  127. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  128. ?>
  129. <br>
  130. <table class="data">
  131. <tr><td><?php echo WEB_color_description; ?></td></tr>
  132. <tr>
  133. <td class="warn"><?php echo WEB_color_user_disabled; ?></td>
  134. <td class="error"><?php echo WEB_color_user_blocked; ?></td>
  135. </table>
  136. <?php
  137. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  138. ?>