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