doubles.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. $auth["deleted"] = 1;
  12. $changes = get_diff_rec($db_link,"User_auth","id='$val'", '', 0);
  13. if (!empty($changes)) { LOG_WARNING($db_link,"Удалён адрес доступа: \r\n $changes"); }
  14. update_record($db_link, "User_auth", "id=" . $val, $auth);
  15. }
  16. }
  17. header("Location: " . $_SERVER["REQUEST_URI"]);
  18. exit;
  19. }
  20. print_ip_submenu($page_url);
  21. ?>
  22. <div id="cont">
  23. <br>
  24. <form name="def" action="doubles.php" method="post">
  25. <table class="data">
  26. <tr>
  27. <td class="data"><input type="checkbox" onClick="checkAll(this.checked);"></td>
  28. <td align=Center><?php print $cell_login; ?></td>
  29. <td align=Center><?php print $cell_ip; ?></td>
  30. <td align=Center><?php print $cell_mac ; ?></td>
  31. <td align=Center><?php print $cell_comment; ?></td>
  32. <td align=Center><?php print $cell_dns_name; ?></td>
  33. <td align=Center>Создан</td>
  34. <td align=Center>Работал</td>
  35. <td align=right><input type="submit" onclick="return confirm('Удалить выделенных?')" name="removeauth" value="Удалить выделенных"></td>
  36. </tr>
  37. <?php
  38. $sSQL = "SELECT U.id, U.ip, U.mac, 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,ip";
  39. $users = get_records_sql($db_link,$sSQL);
  40. $f_subnet=NULL;
  41. $f_mac=NULL;
  42. $f_id=NULL;
  43. $printed = NULL;
  44. foreach ($users as $row) {
  45. if (empty($f_subnet)) { $f_subnet = $row['net']; $f_mac=$row['mac']; $f_id=$row['id']; continue; }
  46. if ($row['net'] === $f_subnet and $row['mac']===$f_mac) {
  47. if (!isset($printed[$f_id])) {
  48. $user = get_record_sql($db_link,"SELECT * FROM User_auth WHERE id=".$f_id);
  49. if (empty($user['last_found']) or $user['last_found'] === '0000-00-00 00:00:00') { $user['last_found'] = ''; }
  50. if (empty($user['timestamp']) or $user['timestamp'] === '0000-00-00 00:00:00') { $user['timestamp'] = ''; }
  51. if (empty($user['changed_time']) or $user['changed_time'] === '0000-00-00 00:00:00') { $user['changed_time'] = ''; }
  52. print "<tr align=center>\n";
  53. $cl = "data";
  54. print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_auth_id[] value=".$user["id"]." ></td>\n";
  55. print "<td class=\"$cl\" ><a href=/admin/users/edituser.php?id=".$user['user_id'].">" . get_login($db_link,$user['user_id']) . "</a></td>\n";
  56. print "<td class=\"$cl\" ><a href=/admin/users/editauth.php?id=".$user['id'].">" . $user['ip'] . "</a></td>\n";
  57. print "<td class=\"$cl\" >" . expand_mac($db_link,$user['mac']) . "</td>\n";
  58. if (isset($user['dhcp_hostname']) and strlen($user['dhcp_hostname']) > 0) {
  59. print "<td class=\"$cl\" >".$user['comments']." [" . $user['dhcp_hostname'] . "]</td>\n";
  60. } else {
  61. print "<td class=\"$cl\" >".$user['comments']."</td>\n";
  62. }
  63. print "<td class=\"$cl\" >".$user['dns_name']."</td>\n";
  64. print "<td class=\"$cl\" >".$user['timestamp']."</td>\n";
  65. print "<td class=\"$cl\" >".$user['last_found']."</td>\n";
  66. print "</tr>\n";
  67. $printed[$f_id] = 1;
  68. }
  69. if (!isset($printed[$row['id']])) {
  70. $user = get_record_sql($db_link,"SELECT * FROM User_auth WHERE id=".$row['id']);
  71. if (empty($user['last_found']) or $user['last_found'] === '0000-00-00 00:00:00') { $user['last_found'] = ''; }
  72. if (empty($user['timestamp']) or $user['timestamp'] === '0000-00-00 00:00:00') { $user['timestamp'] = ''; }
  73. if (empty($user['changed_time']) or $user['changed_time'] === '0000-00-00 00:00:00') { $user['changed_time'] = ''; }
  74. print "<tr align=center>\n";
  75. $cl = "data";
  76. print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_auth_id[] value=".$user["id"]." ></td>\n";
  77. print "<td class=\"$cl\" ><a href=/admin/users/edituser.php?id=".$user['user_id'].">" . get_login($db_link,$user['user_id']) . "</a></td>\n";
  78. print "<td class=\"$cl\" ><a href=/admin/users/editauth.php?id=".$user['id'].">" . $user['ip'] . "</a></td>\n";
  79. print "<td class=\"$cl\" >" . expand_mac($db_link,$user['mac']) . "</td>\n";
  80. if (isset($user['dhcp_hostname']) and strlen($user['dhcp_hostname']) > 0) {
  81. print "<td class=\"$cl\" >".$user['comments']." [" . $user['dhcp_hostname'] . "]</td>\n";
  82. } else {
  83. print "<td class=\"$cl\" >".$user['comments']."</td>\n";
  84. }
  85. print "<td class=\"$cl\" >".$user['dns_name']."</td>\n";
  86. print "<td class=\"$cl\" >".$user['timestamp']."</td>\n";
  87. print "<td class=\"$cl\" >".$user['last_found']."</td>\n";
  88. print "</tr>\n";
  89. $printed[$row['id']] = 1;
  90. }
  91. }
  92. $f_subnet = $row['net'];
  93. $f_mac=$row['mac'];
  94. $f_id=$row['id'];
  95. }
  96. print "</table>\n";
  97. ?>
  98. </form>
  99. <br>
  100. <?php
  101. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  102. ?>