選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

users.php 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <?php
  2. /* Poweradmin, a friendly web-based admin tool for PowerDNS.
  3. * See <http://www.poweradmin.org> for more details.
  4. *
  5. * Copyright 2007-2010 Rejo Zenger <rejo@zenger.nl>
  6. * Copyright 2010-2017 Poweradmin Development Team
  7. * <http://www.poweradmin.org/credits.html>
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * Script that handles requests to update and list users
  24. *
  25. * @package Poweradmin
  26. * @copyright 2007-2010 Rejo Zenger <rejo@zenger.nl>
  27. * @copyright 2010-2017 Poweradmin Development Team
  28. * @license http://opensource.org/licenses/GPL-3.0 GPL
  29. */
  30. require_once ("inc/toolkit.inc.php");
  31. include_once ("inc/header.inc.php");
  32. do_hook ( 'verify_permission', 'user_view_others' ) ? $perm_view_others = "1" : $perm_view_others = "0";
  33. do_hook ( 'verify_permission', 'user_edit_own' ) ? $perm_edit_own = "1" : $perm_edit_own = "0";
  34. do_hook ( 'verify_permission', 'user_edit_others' ) ? $perm_edit_others = "1" : $perm_edit_others = "0";
  35. do_hook ( 'verify_permission', 'templ_perm_edit' ) ? $perm_templ_perm_edit = "1" : $perm_templ_perm_edit = "0";
  36. do_hook ( 'verify_permission', 'user_is_ueberuser' ) ? $perm_is_godlike = "1" : $perm_is_godlike = "0";
  37. do_hook ( 'verify_permission', 'user_add_new' ) ? $perm_add_new = "1" : $perm_add_new = "0";
  38. // f (isset($_GET['action']) && $_GET['action'] === "switchuser" && $perm_is_godlike === "1"){
  39. // $_SESSION["userlogin"] = $_GET['username'];
  40. // echo '<meta http-equiv="refresh" content="1"/>';
  41. //
  42. unset ( $commit_button );
  43. if (isset ( $_POST ['commit'] )) {
  44. foreach ( $_POST ['user'] as $user ) {
  45. do_hook('update_user_details' , $user );
  46. }
  47. }
  48. $users = do_hook ( 'get_user_detail_list', "" );
  49. echo " <h2>" . _ ( 'User administration' ) . "</h2>\n";
  50. echo " <form method=\"post\" action=\"\">\n";
  51. echo " <table>\n";
  52. echo " <tr>\n";
  53. echo " <th>&nbsp;</th>\n";
  54. echo " <th>" . _ ( 'Username' ) . "</th>\n";
  55. echo " <th>" . _ ( 'Fullname' ) . "</th>\n";
  56. echo " <th>" . _ ( 'Description' ) . "</th>\n";
  57. echo " <th>" . _ ( 'Email address' ) . "</th>\n";
  58. echo " <th>" . _ ( 'Template' ) . "</th>\n";
  59. if ($ldap_use) {
  60. echo " <th>" . _ ( 'LDAP' ) . "</th>\n";
  61. }
  62. echo " <th>" . _ ( 'Enabled' ) . "</th>\n";
  63. echo " </tr>\n";
  64. if (count ( $users ) > 0 ) {
  65. foreach ( $users as $user ) {
  66. if ($user ['active'] == "1") {
  67. $active = " checked";
  68. } else {
  69. $active = "";
  70. }
  71. if ($user ['use_ldap'] == "1") {
  72. $use_ldap = " checked";
  73. } else {
  74. $use_ldap = "";
  75. }
  76. if (($user ['uid'] == $_SESSION ["userid"] && $perm_edit_own == "1") || ($user ['uid'] != $_SESSION ["userid"] && $perm_edit_others == "1")) {
  77. $commit_button = "1";
  78. echo " <tr>\n";
  79. echo " <td>\n";
  80. echo " <input type=\"hidden\" name=\"user[" . $user ['uid'] . "][uid]\" value=\"" . $user ['uid'] . "\">\n";
  81. echo " <a href=\"edit_user.php?id=" . $user ['uid'] . "\"><img src=\"images/edit.gif\" alt=\"[ " . _ ( 'Edit user' ) . " ]\"></a>\n";
  82. // do not allow to delete him- or herself
  83. if ($user ['uid'] != $_SESSION ["userid"]) {
  84. echo " <a href=\"delete_user.php?id=" . $user ['uid'] . "\"><img src=\"images/delete.gif\" alt=\"[ " . _ ( 'Delete user' ) . " ]\"></a>";
  85. }
  86. // if ($user['uid'] != $_SESSION["userid"] && $perm_is_godlike == "1") {
  87. // echo " <a href=\"users.php?action=switchuser&username=" . $user['username'] . "\"><img src=\"images/switch_user.png\" alt=\"[ " . _('Switch user') . " ]\"></a>\n";
  88. // }
  89. echo " </td>\n";
  90. echo " <td><input type=\"text\" name=\"user[" . $user ['uid'] . "][username]\" value=\"" . $user ['username'] . "\"></td>\n";
  91. echo " <td><input type=\"text\" name=\"user[" . $user ['uid'] . "][fullname]\" value=\"" . $user ['fullname'] . "\"></td>\n";
  92. echo " <td><input type=\"text\" name=\"user[" . $user ['uid'] . "][descr]\" value=\"" . $user ['descr'] . "\"></td>\n";
  93. echo " <td><input type=\"text\" name=\"user[" . $user ['uid'] . "][email]\" value=\"" . $user ['email'] . "\"></td>\n";
  94. echo " <td>\n";
  95. if ($perm_templ_perm_edit == "1") {
  96. echo " <select name=\"user[" . $user ['uid'] . "][templ_id]\">\n";
  97. foreach ( do_hook('list_permission_templates') as $template ) {
  98. ($template ['id'] == $user ['tpl_id']) ? $select = " SELECTED" : $select = "";
  99. echo " <option value=\"" . $template ['id'] . "\"" . $select . ">" . $template ['name'] . "</option>\n";
  100. }
  101. echo " </select>\n";
  102. } else {
  103. echo " <input type=\"hidden\" name=\"user[" . $user ['uid'] . "][templ_id]\" value=\"" . $user ['tpl_id'] . "\">\n";
  104. echo " " . $user ['tpl_name'] . "\n";
  105. }
  106. echo " </td>\n";
  107. if ($ldap_use) {
  108. if (($perm_is_godlike == "1")) {
  109. echo " <td><input type=\"checkbox\" name=\"user[" . $user ['uid'] . "][use_ldap]\"" . $use_ldap . "></td>\n";
  110. } else {
  111. if ($use_ldap == " checked") {
  112. echo " <td>Yes</td>\n";
  113. } else {
  114. echo " <td>No</td>\n";
  115. }
  116. }
  117. }
  118. if ($user ['uid'] != $_SESSION ["userid"]) {
  119. echo " <td><input type=\"checkbox\" name=\"user[" . $user ['uid'] . "][active]\"" . $active . "></td>\n";
  120. } else {
  121. echo " <td><input type=\"hidden\" name=\"user[" . $user ['uid'] . "][active]\" value=\"on\"></td>\n";
  122. }
  123. echo " </tr>\n";
  124. } else {
  125. echo " <tr>\n";
  126. echo " <td>&nbsp;</td>\n";
  127. echo " <td>" . $user ['username'] . "</td>\n";
  128. echo " <td>" . $user ['fullname'] . "</td>\n";
  129. echo " <td>" . $user ['descr'] . "</td>\n";
  130. echo " <td>" . $user ['email'] . "</td>\n";
  131. echo " <td>" . $user ['tpl_name'] . "</td>\n";
  132. if ($active == " checked") {
  133. echo " <td>Yes</td>\n";
  134. } else {
  135. echo " <td>No</td>\n";
  136. }
  137. if ($use_ldap == " checked") {
  138. echo " <td>Yes</td>\n";
  139. } else {
  140. echo " <td>No</td>\n";
  141. }
  142. echo " </tr>\n";
  143. }
  144. }
  145. }
  146. echo " </table>\n";
  147. if (isset ( $commit_button ) && $commit_button) {
  148. echo " <input type=\"submit\" class=\"button\" name=\"commit\" value=\"" . _ ( 'Commit changes' ) . "\">\n";
  149. echo " <input type=\"reset\" class=\"button\" name=\"reset\" value=\"" . _ ( 'Reset changes' ) . "\">\n";
  150. }
  151. echo " </form>\n";
  152. if ($perm_templ_perm_edit == "1" || $perm_add_new == "1") {
  153. echo " <ul>\n";
  154. }
  155. if ($perm_templ_perm_edit == "1") {
  156. echo "<li><a href=\"list_perm_templ.php\">" . _ ( 'Edit permission template' ) . "</a>.</li>\n";
  157. }
  158. if ($perm_add_new == "1") {
  159. echo "<li><a href=\"add_user.php\">" . _ ( 'Add user' ) . "</a>.</li>\n";
  160. }
  161. if ($perm_templ_perm_edit == "1" || $perm_add_new == "1") {
  162. echo " </ul>\n";
  163. }
  164. include_once ("inc/footer.inc.php");