index.php 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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/gatefilter.php");
  11. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/enabledfilter.php");
  12. $sort_table = 'User_auth';
  13. if ($sort_field == 'login') { $sort_table = 'User_list'; }
  14. if ($sort_field == 'fio') { $sort_table = 'User_list'; }
  15. $sort_url = "<a href=index.php?ou=" . $rou;
  16. if (isset($_POST["removeauth"])) {
  17. $auth_id = $_POST["fid"];
  18. foreach ($auth_id as $key => $val) {
  19. if ($val) {
  20. run_sql($db_link, 'DELETE FROM connections WHERE auth_id='.$val);
  21. run_sql($db_link, 'DELETE FROM User_auth_alias WHERE auth_id='.$val);
  22. $auth["deleted"] = 1;
  23. $changes = get_diff_rec($db_link,"User_auth","id='$val'", '', 0);
  24. if (!empty($changes)) { LOG_WARNING($db_link,"Remove user ip: \r\n $changes"); }
  25. update_record($db_link, "User_auth", "id=" . $val, $auth);
  26. }
  27. }
  28. header("Location: " . $_SERVER["REQUEST_URI"]);
  29. exit;
  30. }
  31. if (isset($_POST["ApplyForAll"])) {
  32. $auth_id = $_POST["fid"];
  33. $a_enabled = $_POST["a_enabled"] * 1;
  34. $a_dhcp = $_POST["a_dhcp"] * 1;
  35. $a_dhcp_acl = $_POST["a_dhcp_acl"];
  36. $a_queue = $_POST["a_queue_id"] * 1;
  37. $a_group = $_POST["a_group_id"] * 1;
  38. $a_traf = $_POST["a_traf"] * 1;
  39. $msg="Massive User change!";
  40. foreach ($auth_id as $key => $val) {
  41. if ($val) {
  42. unset($auth);
  43. $auth['enabled'] = $a_enabled;
  44. $auth['filter_group_id'] = $a_group;
  45. $auth['queue_id'] = $a_queue;
  46. $auth['dhcp'] = $a_dhcp;
  47. $auth['dhcp_acl'] = $a_dhcp_acl;
  48. $auth['save_traf'] = $a_traf;
  49. update_record($db_link, "User_auth", "id='" . $val . "'", $auth);
  50. }
  51. }
  52. LOG_WARNING($db_link,$msg);
  53. header("Location: " . $_SERVER["REQUEST_URI"]);
  54. exit;
  55. }
  56. if ($rou == 0) { $ou_filter = ''; } else { $ou_filter = " and User_list.ou_id=$rou "; }
  57. if ($rsubnet == 0) { $subnet_filter = ''; } else {
  58. $subnet_range = get_subnet_range($db_link,$rsubnet);
  59. if (!empty($subnet_range)) { $subnet_filter = " and User_auth.ip_int>=".$subnet_range['start']." and User_auth.ip_int<=".$subnet_range['stop']; }
  60. }
  61. $enabled_filter='';
  62. if ($enabled>0) {
  63. if ($enabled===2) { $enabled_filter = ' and User_auth.enabled=1'; }
  64. if ($enabled===1) { $enabled_filter = ' and User_auth.enabled=0'; }
  65. }
  66. if (isset($_POST['ip'])) { $f_ip = $_POST['ip']; }
  67. if (!isset($f_ip) and isset($_SESSION[$page_url]['ip'])) { $f_ip=$_SESSION[$page_url]['ip']; }
  68. if (!isset($f_ip)) { $f_ip=''; }
  69. $_SESSION[$page_url]['ip']=$f_ip;
  70. $ip_where = '';
  71. if (!empty($f_ip)) {
  72. if (checkValidIp($f_ip)) { $ip_where = " and ip_int=inet_aton('" . $f_ip . "') "; }
  73. if (checkValidMac($f_ip)) { $ip_where = " and mac='" . mac_dotted($f_ip) . "' "; }
  74. $ip_list_filter = $ip_where;
  75. } else {
  76. $ip_list_filter = $ou_filter.$subnet_filter.$enabled_filter;
  77. }
  78. print_ip_submenu($page_url);
  79. ?>
  80. <div id="cont">
  81. <form name="def" action="index.php" method="post">
  82. <table class="data">
  83. <tr>
  84. <td>
  85. <b><?php print WEB_cell_ou; ?> - </b><?php print_ou_select($db_link, 'ou', $rou); ?>
  86. <b><?php print WEB_network_subnet; ?> - </b><?php print_subnet_select_office($db_link, 'subnet', $rsubnet); ?>
  87. <b><?php echo WEB_ips_show_by_state; ?> - </b><?php print_enabled_select('enabled', $enabled); ?>
  88. <?php echo WEB_ips_search_host; ?>:&nbsp<input type="text" name="ip" value="<?php echo $f_ip; ?>" pattern="^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])|([0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}|([0-9a-fA-F]{4}[\\.-][0-9a-fA-F]{4}[\\.-][0-9a-fA-F]{4})|[0-9A-Fa-f]{12})$"/>
  89. <?php print WEB_rows_at_page."&nbsp"; print_row_at_pages('rows',$displayed); ?>
  90. <input type="submit" value="<?php echo WEB_btn_show; ?>">
  91. </td>
  92. </tr>
  93. </table>
  94. <?php
  95. $countSQL="SELECT Count(*) FROM User_auth, User_list WHERE User_auth.user_id = User_list.id AND User_auth.deleted =0 $ip_list_filter";
  96. $res = mysqli_query($db_link, $countSQL);
  97. $count_records = mysqli_fetch_array($res);
  98. $total=ceil($count_records[0]/$displayed);
  99. if ($page>$total) { $page=$total; }
  100. if ($page<1) { $page=1; }
  101. $start = ($page * $displayed) - $displayed;
  102. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  103. ?>
  104. <br>
  105. <table class="data">
  106. <tr>
  107. <td><?php print WEB_selection_title.": ".WEB_cell_enabled."&nbsp"; print_qa_select('a_enabled', 1); ?></td>
  108. <td><?php print WEB_cell_filter."&nbsp";print_group_select($db_link, 'a_group_id', 0); ?></td>
  109. <td><?php print WEB_cell_shaper."&nbsp";print_queue_select($db_link, 'a_queue_id', 0); ?></td>
  110. <td>Dhcp&nbsp<?php print_qa_select('a_dhcp', 1); ?></td>
  111. <td>Dhcp-acl&nbsp<?php print_dhcp_acl_select('a_dhcp_acl',''); ?></td>
  112. <td>Save traffic&nbsp<?php print_qa_select('a_traf',1); ?></td>
  113. <td>&nbsp<input type="submit" onclick="return confirm('<?php echo WEB_msg_apply_selected; ?>?')" name="ApplyForAll" value="<?php echo WEB_btn_apply; ?>"></td>
  114. <td align=right><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="removeauth" value="<?php echo WEB_btn_delete; ?>"></td>
  115. </tr>
  116. </table>
  117. <table class="data">
  118. <tr>
  119. <td align=Center><input type="checkbox" onClick="checkAll(this.checked);"></td>
  120. <td align=Center><?php print $sort_url . "&sort=login&order=$new_order>" . WEB_cell_login . "</a>"; ?></td>
  121. <td align=Center><?php print $sort_url . "&sort=ip_int&order=$new_order>" . WEB_cell_ip . "</a>"; ?></td>
  122. <td align=Center><?php print $sort_url . "&sort=mac&order=$new_order>" . WEB_cell_mac . "</a>"; ?></td>
  123. <td align=Center><?php print WEB_cell_comment; ?></td>
  124. <td align=Center><?php print WEB_cell_dns_name; ?></td>
  125. <td align=Center><?php print WEB_cell_enabled; ?></td>
  126. <td align=Center><?php print WEB_cell_filter; ?></td>
  127. <td align=Center><?php print WEB_cell_shaper; ?></td>
  128. <td align=Center><?php print WEB_cell_traf; ?></td>
  129. <td align=Center><?php print WEB_cell_dhcp; ?></td>
  130. <td align=Center><?php print WEB_cell_acl; ?></td>
  131. <td align=Center><?php print $sort_url . "&sort=dhcp_time&order=$new_order>DHCP event</a>"; ?></td>
  132. <td align=Center><?php print $sort_url . "&sort=last_found&order=$new_order>Last</a>"; ?></td>
  133. <td align=Center><?php print WEB_cell_connection; ?></td>
  134. </tr>
  135. <?php
  136. $sSQL = "SELECT User_auth.*, User_list.login FROM User_auth, User_list
  137. WHERE User_auth.user_id = User_list.id AND User_auth.deleted =0 $ip_list_filter
  138. ORDER BY $sort_table.$sort_field $order LIMIT $start,$displayed";
  139. $users = get_records_sql($db_link,$sSQL);
  140. foreach ($users as $user) {
  141. if ($user['dhcp_time'] == '0000-00-00 00:00:00') {
  142. $dhcp_str = '';
  143. } else {
  144. $dhcp_str = $user['dhcp_time'] . " (" . $user['dhcp_action'] . ")";
  145. }
  146. if ($user['last_found'] == '0000-00-00 00:00:00') { $user['last_found'] = ''; }
  147. print "<tr align=center>\n";
  148. $cl = "data";
  149. if (!$user['enabled']) { $cl = "warn"; }
  150. if ($user['blocked']) { $cl = "error"; }
  151. print "<td class=\"$cl\" style='padding:0'><input type=checkbox name=fid[] value=".$user['id']."></td>\n";
  152. print "<td class=\"$cl\" ><a href=/admin/users/edituser.php?id=".$user['user_id'].">" . $user['login'] . "</a></td>\n";
  153. print "<td class=\"$cl\" ><a href=/admin/users/editauth.php?id=".$user['id'].">" . $user['ip'] . "</a></td>\n";
  154. print "<td class=\"$cl\" >" . expand_mac($db_link,$user['mac']) . "</td>\n";
  155. if (isset($user['dhcp_hostname']) and strlen($user['dhcp_hostname']) > 0) {
  156. print "<td class=\"$cl\" width=200 >".$user['comments']." [" . $user['dhcp_hostname'] . "]</td>\n";
  157. } else {
  158. print "<td class=\"$cl\" width=200 >".$user['comments']."</td>\n";
  159. }
  160. print "<td class=\"$cl\" >".$user['dns_name']."</td>\n";
  161. print "<td class=\"$cl\" >" . get_qa($user['enabled']) . "</td>\n";
  162. print "<td class=\"$cl\" >" . get_group($db_link, $user['filter_group_id']) . "</td>\n";
  163. print "<td class=\"$cl\" >" . get_queue($db_link, $user['queue_id']) . "</td>\n";
  164. print "<td class=\"$cl\" >" . get_qa($user['save_traf']) . "</td>\n";
  165. print "<td class=\"$cl\" >" . get_qa($user['dhcp']) . "</td>\n";
  166. print "<td class=\"$cl\" >".$user['dhcp_acl']."</td>\n";
  167. print "<td class=\"$cl\" >".$dhcp_str."</td>\n";
  168. print "<td class=\"$cl\" >".$user['last_found']."</td>\n";
  169. print "<td class=\"$cl\" >" . get_connection($db_link, $user['id']) . "</td>\n";
  170. print "</tr>\n";
  171. }
  172. print "</table>\n";
  173. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  174. ?>
  175. <br>
  176. <table class="data">
  177. <tr><td><?php echo WEB_color_description; ?></td></tr>
  178. <tr>
  179. <td class="warn"><?php echo WEB_color_user_disabled; ?></td>
  180. <td class="error"><?php echo WEB_color_user_blocked; ?></td>
  181. </table>
  182. <?php
  183. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  184. ?>