index.php 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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_ou=get_const('default_user_ou_id');
  7. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/oufilter.php");
  8. $default_sort='login';
  9. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sortfilter.php");
  10. $msg_error = "";
  11. if (isset($_POST["create"])) {
  12. $login = trim($_POST["newlogin"]);
  13. if (!empty($login)) {
  14. $lcount = get_count_records($db_link,"User_list","LCase(login)=LCase('$login')");
  15. if ($lcount > 0) {
  16. $msg_error = WEB_cell_login." ".$login." ".$msg_exists."!";
  17. unset($_POST);
  18. } else {
  19. $new['login'] = $login;
  20. $new['ou_id'] = $rou;
  21. $ou_info = get_record_sql($db_link,"SELECT * FROM OU WHERE id=".$rou);
  22. if (!empty($ou_info)) {
  23. if (empty($ou_info['enabled'])) { $ou_info['enabled'] = 0; }
  24. if (empty($ou_info['queue_id'])) { $ou_info['queue_id'] = 0; }
  25. if (empty($ou_info['filter_group_id'])) { $ou_info['filter_group_id'] = 0; }
  26. $new['enabled'] = $ou_info['enabled'];
  27. $new['queue_id'] = $ou_info['queue_id'];
  28. $new['filter_group_id'] = $ou_info['filter_group_id'];
  29. }
  30. $lid=insert_record($db_link, "User_list", $new);
  31. LOG_WARNING($db_link,"Создан новый пользователь: Login => $login");
  32. header("Location: edituser.php?id=$lid");
  33. exit;
  34. }
  35. }
  36. header("Location: " . $_SERVER["REQUEST_URI"]);
  37. exit;
  38. }
  39. ?>
  40. <div id="cont">
  41. <?php
  42. if ($msg_error) {
  43. print "<div id='msg'><b>$msg_error</b></div><br>\n";
  44. }
  45. ?>
  46. <form id="filter" name="filter" action="index.php" method="post">
  47. <div>
  48. <b><?php print WEB_cell_ou; ?> - </b>
  49. <?php print_ou_select($db_link, 'ou', $rou); 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. </div>
  52. <br>
  53. <div>
  54. <?php echo WEB_new_user."&nbsp"; ?>
  55. <input type=text name=newlogin value="Unknown">
  56. <input type="submit" name="create" value="<?php echo WEB_btn_add; ?>">
  57. </div>
  58. </form>
  59. <br>
  60. <a class="mainButton" href="#modal"><?php print WEB_btn_apply_selected; ?></a>
  61. <div class="remodal" data-remodal-options="closeOnConfirm: true" data-remodal-id="modal" role="dialog" aria-labelledby="modal1Title" aria-describedby="modal1Desc">
  62. <div class="remodalBorder">
  63. <button data-remodal-action="close" class="remodal-close" aria-label="Close"></button>
  64. <form id="formUserApply">
  65. <h2 id="modal1Title"><?php print WEB_selection_title; ?></h2>
  66. <input type="hidden" name="ApplyForAll" value="MassChange">
  67. <table class="data" align=center>
  68. <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', 0); ?></td></tr>
  69. <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>
  70. <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>
  71. <tr><td><input type=checkbox class="putField" name="e_day_q" value='1'></td><td><?php print WEB_cell_perday."&nbsp"; ?><input type="text" name="a_day_q" value="0" size=5></td></tr>
  72. <tr><td><input type=checkbox class="putField" name="e_month_q" value='1'></td><td><?php print WEB_cell_permonth."&nbsp"; ?><input type="text" name="a_month_q" value="0" size=5></td></tr>
  73. <tr><td><input type=checkbox class="putField" name="e_new_ou" value='1'></td><td><?php print WEB_cell_ou."&nbsp";print_ou_select($db_link, 'a_new_ou', $rou); ?></td></tr>
  74. <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>
  75. <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>
  76. <tr><td><input type=checkbox class="putField" name="e_create_netdev" value='1'></td><td><?php print WEB_user_create_netdev."&nbsp";print_qa_select('a_create_netdev', 1);?></td></tr>
  77. </table>
  78. <input type="submit" name="submit" class="btn" value="<?php echo WEB_btn_apply; ?>">
  79. </form>
  80. </div>
  81. </div>
  82. <a class="delButton" href="#modalDel"><?php print WEB_btn_delete; ?></a>
  83. <div class="remodal" data-remodal-options="closeOnConfirm: true" data-remodal-id="modalDel" role="dialog" aria-labelledby="modal1Title" aria-describedby="modal1Desc">
  84. <div class="remodalBorder">
  85. <button data-remodal-action="close" class="remodal-close" aria-label="Close"></button>
  86. <form id="formUserDel">
  87. <h2 id="modal1Title"><?php print WEB_msg_delete_selected; ?></h2>
  88. <input type="hidden" name="RemoveUser" value="MassChange">
  89. <?php print_qa_select('f_deleted', 0);?><br><br>
  90. <input type="submit" name="submit" class="btn" value="<?php echo WEB_btn_apply; ?>">
  91. </form>
  92. </div>
  93. </div>
  94. <?php
  95. $sort_table = 'U';
  96. $sort_url = "<a href=/admin/users/index.php?";
  97. if ($rou == 0) { $filter = "U.ou_id=O.id and U.deleted=0"; } else { $filter = "U.OU_id=O.id and U.deleted=0 and U.ou_id=$rou"; }
  98. $countSQL = "SELECT Count(*) FROM User_list U, OU O WHERE $filter";
  99. $res = mysqli_query($db_link, $countSQL);
  100. $count_records = mysqli_fetch_array($res);
  101. $total=ceil($count_records[0]/$displayed);
  102. if ($page>$total) { $page=$total; }
  103. if ($page<1) { $page=1; }
  104. $start = ($page * $displayed) - $displayed;
  105. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  106. $sSQL = "SELECT U.id, U.login, U.fio, O.ou_name, U.enabled, U.day_quota, U.month_quota, U.blocked FROM User_list U, OU O WHERE $filter ORDER BY $sort_table.$sort_field $order LIMIT $start,$displayed";
  107. ?>
  108. <form id="def" name="def" >
  109. <table class="data">
  110. <tr align="center">
  111. <td><input type="checkbox" onClick="checkAll(this.checked);"></td>
  112. <td><b><?php print $sort_url . "sort=id&order=$new_order>id</a>"; ?></b></td>
  113. <td><b><?php print $sort_url . "sort=login&order=$new_order>" . WEB_cell_login . "</a>"; ?></b></td>
  114. <td><b><?php print $sort_url . "sort=fio&order=$new_order>" . WEB_cell_fio . "</a>"; ?></b></td>
  115. <td><b><?php print WEB_cell_rule; ?></b></td>
  116. <td><b><?php print WEB_cell_ou; ?></b></td>
  117. <td><b><?php print WEB_cell_enabled; ?></b></td>
  118. <td><b><?php print WEB_cell_perday; ?></b></td>
  119. <td><b><?php print WEB_cell_permonth; ?></b></td>
  120. <td><b><?php print WEB_cell_report; ?></b></td>
  121. </tr>
  122. <?php
  123. $users = get_records_sql($db_link, $sSQL);
  124. foreach ($users as $row) {
  125. $auth_customs = get_count_records($db_link,"User_auth","user_id=".$row['id']." AND deleted=0 AND enabled <>'".$row['enabled']."'");
  126. $cl = "data";
  127. if (! $row['enabled']) {
  128. $cl = "off";
  129. }
  130. if ($row['blocked']) {
  131. $cl = "error";
  132. }
  133. if ($auth_customs > 0) {
  134. $cl = "custom";
  135. }
  136. if (! get_auth_count($db_link, $row['id'])) {
  137. $cl = 'nb';
  138. }
  139. print "<tr align=center>\n";
  140. print "<td class=\"$cl\" style='padding:0'><input type=checkbox name=fid[] value=".$row['id']."></td>\n";
  141. print "<td class=\"$cl\">".$row['id']."</td>\n";
  142. if (empty($row['login'])) { $row['login']=$row['id']; }
  143. print "<td class=\"$cl\" align=left><a href=edituser.php?id=".$row['id'].">" . $row['login'] . "</a></td>\n";
  144. print "<td class=\"$cl\">".$row['fio']."</td>\n";
  145. $rules_count = get_count_records($db_link,"auth_rules","user_id=".$row['id']);
  146. print "<td class=\"$cl\">".$rules_count."</td>\n";
  147. print "<td class=\"$cl\">".$row['ou_name']."</td>\n";
  148. print "<td class=\"$cl\">".get_qa($row['enabled']) . "</td>\n";
  149. print "<td class=\"$cl\">".$row['day_quota']."</td>\n";
  150. print "<td class=\"$cl\">".$row['month_quota']."</td>\n";
  151. print "<td class=\"$cl\" align=center colspan=2><a href=../reports/userday.php?id=".$row['id'].">Просмотр</a></td>\n";
  152. }
  153. ?>
  154. </table>
  155. <?php
  156. print_navigation($page_url,$page,$displayed,$count_records[0],$total);
  157. ?>
  158. </form>
  159. <table class="data">
  160. <tr>
  161. <td colspan = 3><?php echo WEB_color_description; ?></td>
  162. </tr>
  163. <tr>
  164. <td class="nb"><?php echo WEB_color_user_empty; ?></td>
  165. <td class="off"><?php echo WEB_color_user_disabled; ?></td>
  166. <td class="error"><?php echo WEB_color_user_blocked; ?></td>
  167. <td class="custom"><?php echo WEB_color_user_custom; ?></td>
  168. </table>
  169. <script src="/js/remodal/remodal.min.js"></script>
  170. <script src="/js/remodal-user.js"></script>
  171. <script>
  172. document.getElementById('ou').addEventListener('change', function(event) {
  173. const buttonApply = document.getElementById('btn_filter');
  174. buttonApply.click();
  175. });
  176. document.getElementById('rows').addEventListener('change', function(event) {
  177. const buttonApply = document.getElementById('btn_filter');
  178. buttonApply.click();
  179. });
  180. </script>
  181. <?php
  182. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.simple.php");
  183. ?>