index.php 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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/cidrfilter.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 ($rou == 0) { $ou_filter = ''; } else { $ou_filter = " and User_list.ou_id=$rou "; }
  17. if (empty($rcidr)) { $cidr_filter = ''; } else {
  18. $cidr_range = cidrToRange($rcidr);
  19. if (!empty($cidr_range)) { $cidr_filter = " and User_auth.ip_int>=".ip2long($cidr_range[0])." and User_auth.ip_int<=".ip2long($cidr_range[1]); }
  20. }
  21. $enabled_filter='';
  22. if ($enabled>0) {
  23. if ($enabled===2) { $enabled_filter = ' and (User_auth.enabled=1 and User_list.enabled=1)'; }
  24. if ($enabled===1) { $enabled_filter = ' and (User_auth.enabled=0 or User_list.enabled=0)'; }
  25. }
  26. if (isset($_POST['ip'])) { $f_ip = $_POST['ip']; }
  27. if (!isset($f_ip) and isset($_SESSION[$page_url]['ip'])) { $f_ip=$_SESSION[$page_url]['ip']; }
  28. if (!isset($f_ip)) { $f_ip=''; }
  29. $_SESSION[$page_url]['ip']=$f_ip;
  30. $ip_where = '';
  31. if (!empty($f_ip)) {
  32. if (checkValidIp($f_ip)) { $ip_where = " and ip_int=inet_aton('" . $f_ip . "') "; }
  33. if (checkValidMac($f_ip)) { $ip_where = " and mac='" . mac_dotted($f_ip) . "' "; }
  34. $ip_list_filter = $ip_where;
  35. } else {
  36. $ip_list_filter = $ou_filter.$cidr_filter.$enabled_filter;
  37. }
  38. print_ip_submenu($page_url);
  39. ?>
  40. <div id="cont">
  41. <form name="filter" action="index.php" method="post">
  42. <table class="data">
  43. <tr>
  44. <td>
  45. <b><?php print WEB_cell_ou; ?> - </b><?php print_ou_select($db_link, 'ou', $rou); ?>
  46. <b><?php print WEB_network_subnet; ?> - </b><?php print_subnet_select_office_splitted($db_link, 'cidr', $rcidr); ?>
  47. <b><?php echo WEB_ips_show_by_state; ?> - </b><?php print_enabled_select('enabled', $enabled); ?>
  48. <?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})$"/>
  49. <?php print WEB_rows_at_page."&nbsp"; print_row_at_pages('rows',$displayed); ?>
  50. <input id="btn_filter" name="btn_filter" type="submit" value="<?php echo WEB_btn_show; ?>">
  51. </td>
  52. </tr>
  53. </table>
  54. </form>
  55. <a class="mainButton" href="#modal"><?php print WEB_btn_apply_selected; ?></a>
  56. <div class="remodal" data-remodal-options="closeOnConfirm: true" data-remodal-id="modal" role="dialog" aria-labelledby="modal1Title" aria-describedby="modal1Desc">
  57. <div class="remodalBorder">
  58. <button data-remodal-action="close" class="remodal-close" aria-label="Close"></button>
  59. <form id="formAuthApply">
  60. <h2 id="modal1Title"><?php print WEB_selection_title; ?></h2>
  61. <input type="hidden" name="ApplyForAll" value="MassChange">
  62. <table class="data" align=center>
  63. <tr><td><input type=checkbox class="putField" name="e_enabled" value='1'></td><td><?php print WEB_cell_enabled."&nbsp"; print_qa_select('a_enabled', 1);?></td></tr>
  64. <tr><td><input type=checkbox class="putField" name="e_group_id" value='1'></td><td><?php print WEB_cell_filter."&nbsp";print_group_select($db_link, 'a_group_id', 0);?></td></tr>
  65. <tr><td><input type=checkbox class="putField" name="e_queue_id" value='1'></td><td><?php print WEB_cell_shaper."&nbsp";print_queue_select($db_link, 'a_queue_id', 0);?></td></tr>
  66. <tr><td><input type=checkbox class="putField" name="e_dhcp" value='1'></td><td><?php print "Dhcp&nbsp"; print_qa_select('a_dhcp', 1);?></td></tr>
  67. <tr><td><input type=checkbox class="putField" name="e_dhcp_acl" value='1'></td><td><?php print "Dhcp-acl&nbsp";print_dhcp_acl_select('a_dhcp_acl','');?></td></tr>
  68. <tr><td><input type=checkbox class="putField" name="e_traf" value='1'></td><td><?php print "Save traffic&nbsp"; print_qa_select('a_traf',1);?></td></tr>
  69. <tr><td><input type=checkbox class="putField" name="e_bind_mac" value='1'></td><td><?php print WEB_user_bind_mac."&nbsp";print_qa_select('a_bind_mac', 1);?></td></tr>
  70. <tr><td><input type=checkbox class="putField" name="e_bind_ip" value='1'></td><td><?php print WEB_user_bind_ip."&nbsp";print_qa_select('a_bind_ip', 1);?></td></tr>
  71. </table>
  72. <input type="submit" name="submit" class="btn" value="<?php echo WEB_btn_apply; ?>">
  73. </form>
  74. </div>
  75. </div>
  76. <a class="delButton" href="#modalDel"><?php print WEB_btn_delete; ?></a>
  77. <div class="remodal" data-remodal-options="closeOnConfirm: true" data-remodal-id="modalDel" role="dialog" aria-labelledby="modal1Title" aria-describedby="modal1Desc">
  78. <div class="remodalBorder">
  79. <button data-remodal-action="close" class="remodal-close" aria-label="Close"></button>
  80. <form id="formAuthDel">
  81. <h2 id="modal1Title"><?php print WEB_msg_delete_selected; ?></h2>
  82. <input type="hidden" name="RemoveAuth" value="MassChange">
  83. <?php print_qa_select('f_deleted', 0);?><br><br>
  84. <input type="submit" name="submit" class="btn" value="<?php echo WEB_btn_apply; ?>">
  85. </form>
  86. </div>
  87. </div>
  88. <form id="def" name="def">
  89. <?php
  90. $countSQL="SELECT Count(*) FROM User_auth, User_list WHERE User_auth.user_id = User_list.id AND User_auth.deleted =0 $ip_list_filter";
  91. $res = mysqli_query($db_link, $countSQL);
  92. $count_records = mysqli_fetch_array($res);
  93. $total=ceil($count_records[0]/$displayed);
  94. if ($page>$total) { $page=$total; }
  95. if ($page<1) { $page=1; }
  96. $start = ($page * $displayed) - $displayed;
  97. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  98. ?>
  99. <br>
  100. <table class="data">
  101. <tr>
  102. <td align=Center><input type="checkbox" onClick="checkAll(this.checked);"></td>
  103. <td align=Center><?php print $sort_url . "&sort=login&order=$new_order>" . WEB_cell_login . "</a>"; ?></td>
  104. <td align=Center><?php print $sort_url . "&sort=ip_int&order=$new_order>" . WEB_cell_ip . "</a>"; ?></td>
  105. <td align=Center><?php print $sort_url . "&sort=mac&order=$new_order>" . WEB_cell_mac . "</a>"; ?></td>
  106. <td align=Center><?php print WEB_cell_comment; ?></td>
  107. <td align=Center><?php print WEB_cell_dns_name; ?></td>
  108. <td align=Center><?php print WEB_cell_enabled; ?></td>
  109. <td align=Center><?php print WEB_cell_filter; ?></td>
  110. <td align=Center><?php print WEB_cell_shaper; ?></td>
  111. <td align=Center><?php print WEB_cell_traf; ?></td>
  112. <td align=Center><?php print WEB_cell_dhcp; ?></td>
  113. <td align=Center><?php print WEB_cell_acl; ?></td>
  114. <td align=Center><?php print $sort_url . "&sort=dhcp_time&order=$new_order>DHCP event</a>"; ?></td>
  115. <td align=Center><?php print $sort_url . "&sort=last_found&order=$new_order>Last</a>"; ?></td>
  116. <td align=Center><?php print WEB_cell_connection; ?></td>
  117. </tr>
  118. <?php
  119. $sSQL = "SELECT User_auth.*, User_list.login, User_list.enabled as UEnabled, User_list.blocked as UBlocked FROM User_auth, User_list
  120. WHERE User_auth.user_id = User_list.id AND User_auth.deleted =0 $ip_list_filter
  121. ORDER BY $sort_table.$sort_field $order LIMIT $start,$displayed";
  122. $users = get_records_sql($db_link,$sSQL);
  123. foreach ($users as $user) {
  124. if ($user['dhcp_time'] == '0000-00-00 00:00:00') {
  125. $dhcp_str = '';
  126. } else {
  127. $dhcp_str = $user['dhcp_time'] . " (" . $user['dhcp_action'] . ")";
  128. }
  129. if ($user['last_found'] == '0000-00-00 00:00:00') { $user['last_found'] = ''; }
  130. print "<tr align=center>\n";
  131. $cl = "data";
  132. if (!$user['enabled']) { $cl = "warn"; }
  133. if ($user['blocked']) { $cl = "error"; }
  134. if (!$user['UEnabled'] or $user['UBlocked']) { $cl = "off"; }
  135. print "<td class=\"$cl\" style='padding:0'><input type=checkbox name=fid[] value=".$user['id']."></td>\n";
  136. print "<td class=\"$cl\" ><a href=/admin/users/edituser.php?id=".$user['user_id'].">" . $user['login'] . "</a></td>\n";
  137. print "<td class=\"$cl\" ><a href=/admin/users/editauth.php?id=".$user['id'].">" . $user['ip'] . "</a></td>\n";
  138. print "<td class=\"$cl\" >" . expand_mac($db_link,$user['mac']) . "</td>\n";
  139. if (isset($user['dhcp_hostname']) and strlen($user['dhcp_hostname']) > 0) {
  140. print "<td class=\"$cl\" width=200 >".$user['comments']." [" . $user['dhcp_hostname'] . "]</td>\n";
  141. } else {
  142. print "<td class=\"$cl\" width=200 >".$user['comments']."</td>\n";
  143. }
  144. print "<td class=\"$cl\" >".$user['dns_name']."</td>\n";
  145. print "<td class=\"$cl\" >" . get_qa($user['enabled']) . "</td>\n";
  146. print "<td class=\"$cl\" >" . get_group($db_link, $user['filter_group_id']) . "</td>\n";
  147. print "<td class=\"$cl\" >" . get_queue($db_link, $user['queue_id']) . "</td>\n";
  148. print "<td class=\"$cl\" >" . get_qa($user['save_traf']) . "</td>\n";
  149. print "<td class=\"$cl\" >" . get_qa($user['dhcp']) . "</td>\n";
  150. print "<td class=\"$cl\" >".$user['dhcp_acl']."</td>\n";
  151. print "<td class=\"$cl\" >".$dhcp_str."</td>\n";
  152. print "<td class=\"$cl\" >".$user['last_found']."</td>\n";
  153. print "<td class=\"$cl\" >" . get_connection($db_link, $user['id']) . "</td>\n";
  154. print "</tr>\n";
  155. }
  156. print "</table>\n";
  157. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  158. ?>
  159. <br>
  160. <table class="data">
  161. <tr><td><?php echo WEB_color_description; ?></td></tr>
  162. <tr>
  163. <td class="warn"><?php echo WEB_color_auth_disabled; ?></td>
  164. <td class="error"><?php echo WEB_color_user_blocked; ?></td>
  165. <td class="off"><?php echo WEB_color_user_disabled; ?></td>
  166. </table>
  167. <script src="/js/remodal/remodal.min.js"></script>
  168. <script src="/js/remodal-auth.js"></script>
  169. <?php
  170. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  171. ?>