doubles.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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/header.php");
  5. if (isset($_POST["removeauth"])) {
  6. $auth_id = $_POST["f_auth_id"];
  7. foreach ($auth_id as $key => $val) {
  8. if ($val) {
  9. run_sql($db_link, 'DELETE FROM connections WHERE auth_id='.$val);
  10. run_sql($db_link, 'DELETE FROM User_auth_alias WHERE auth_id='.$val);
  11. $changes=delete_record($db_link, "User_auth", "id=" . $val);
  12. if (!empty($changes)) { LOG_INFO($db_link,"Remove user ip: $changes"); }
  13. }
  14. }
  15. header("Location: " . $_SERVER["REQUEST_URI"]);
  16. exit;
  17. }
  18. print_ip_submenu($page_url);
  19. ?>
  20. <div id="cont">
  21. <br>
  22. <form name="def" action="doubles.php" method="post">
  23. <table class="data">
  24. <tr>
  25. <td class="data"><input type="checkbox" onClick="checkAll(this.checked);"></td>
  26. <td align=Center><?php print WEB_cell_login; ?></td>
  27. <td align=Center><?php print WEB_cell_ip; ?></td>
  28. <td align=Center><?php print WEB_cell_mac ; ?></td>
  29. <td align=Center><?php print WEB_cell_comment; ?></td>
  30. <td align=Center><?php print WEB_cell_dns_name; ?></td>
  31. <td align=Center><?php print WEB_cell_created; ?></td>
  32. <td align=Center><?php print WEB_cell_last_found; ?></td>
  33. <td align=right><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="removeauth" value="<?php echo WEB_btn_delete; ?>"></td>
  34. </tr>
  35. <?php
  36. $sSQL = "SELECT U.id, U.ip, U.mac, U.last_found, S.subnet as net FROM User_auth U, subnets S WHERE (U.mac IS NOT NULL AND U.mac<>'') AND (U.ip_int BETWEEN S.ip_int_start AND S.ip_int_stop) AND S.office=1 AND deleted=0 ORDER BY net,mac,last_found";
  37. $users = get_records_sql($db_link,$sSQL);
  38. $f_subnet=NULL;
  39. $f_mac=NULL;
  40. $f_id=NULL;
  41. $printed = NULL;
  42. foreach ($users as $row) {
  43. if (empty($f_subnet)) { $f_subnet = $row['net']; $f_mac=$row['mac']; $f_id=$row['id']; continue; }
  44. if ($row['net'] === $f_subnet and $row['mac']===$f_mac) {
  45. if (!isset($printed[$f_id])) {
  46. $user = get_record_sql($db_link,"SELECT * FROM User_auth WHERE id=".$f_id);
  47. if (empty($user['last_found']) or $user['last_found'] === '0000-00-00 00:00:00') { $user['last_found'] = ''; }
  48. if (empty($user['timestamp']) or $user['timestamp'] === '0000-00-00 00:00:00') { $user['timestamp'] = ''; }
  49. if (empty($user['changed_time']) or $user['changed_time'] === '0000-00-00 00:00:00') { $user['changed_time'] = ''; }
  50. print "<tr align=center>\n";
  51. $cl = "data";
  52. print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_auth_id[] value=".$user["id"]." ></td>\n";
  53. print "<td class=\"$cl\" ><a href=/admin/users/edituser.php?id=".$user['user_id'].">" . get_login($db_link,$user['user_id']) . "</a></td>\n";
  54. print "<td class=\"$cl\" ><a href=/admin/users/editauth.php?id=".$user['id'].">" . $user['ip'] . "</a></td>\n";
  55. print "<td class=\"$cl\" >" . expand_mac($db_link,$user['mac']) . "</td>\n";
  56. if (isset($user['dhcp_hostname']) and strlen($user['dhcp_hostname']) > 0) {
  57. print "<td class=\"$cl\" >".$user['comments']." [" . $user['dhcp_hostname'] . "]</td>\n";
  58. } else {
  59. print "<td class=\"$cl\" >".$user['comments']."</td>\n";
  60. }
  61. print "<td class=\"$cl\" >".$user['dns_name']."</td>\n";
  62. print "<td class=\"$cl\" >".$user['timestamp']."</td>\n";
  63. print "<td class=\"$cl\" >".$user['last_found']."</td>\n";
  64. print "</tr>\n";
  65. $printed[$f_id] = 1;
  66. }
  67. if (!isset($printed[$row['id']])) {
  68. $user = get_record_sql($db_link,"SELECT * FROM User_auth WHERE id=".$row['id']);
  69. if (empty($user['last_found']) or $user['last_found'] === '0000-00-00 00:00:00') { $user['last_found'] = ''; }
  70. if (empty($user['timestamp']) or $user['timestamp'] === '0000-00-00 00:00:00') { $user['timestamp'] = ''; }
  71. if (empty($user['changed_time']) or $user['changed_time'] === '0000-00-00 00:00:00') { $user['changed_time'] = ''; }
  72. print "<tr align=center>\n";
  73. $cl = "data";
  74. print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_auth_id[] value=".$user["id"]." ></td>\n";
  75. print "<td class=\"$cl\" ><a href=/admin/users/edituser.php?id=".$user['user_id'].">" . get_login($db_link,$user['user_id']) . "</a></td>\n";
  76. print "<td class=\"$cl\" ><a href=/admin/users/editauth.php?id=".$user['id'].">" . $user['ip'] . "</a></td>\n";
  77. print "<td class=\"$cl\" >" . expand_mac($db_link,$user['mac']) . "</td>\n";
  78. if (isset($user['dhcp_hostname']) and strlen($user['dhcp_hostname']) > 0) {
  79. print "<td class=\"$cl\" >".$user['comments']." [" . $user['dhcp_hostname'] . "]</td>\n";
  80. } else {
  81. print "<td class=\"$cl\" >".$user['comments']."</td>\n";
  82. }
  83. print "<td class=\"$cl\" >".$user['dns_name']."</td>\n";
  84. print "<td class=\"$cl\" >".$user['timestamp']."</td>\n";
  85. print "<td class=\"$cl\" >".$user['last_found']."</td>\n";
  86. print "</tr>\n";
  87. $printed[$row['id']] = 1;
  88. }
  89. }
  90. $f_subnet = $row['net'];
  91. $f_mac=$row['mac'];
  92. $f_id=$row['id'];
  93. }
  94. print "</table>\n";
  95. ?>
  96. </form>
  97. <br>
  98. <?php
  99. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  100. ?>