Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

users.php 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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-2014 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-2014 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. verify_permission('user_view_others') ? $perm_view_others = "1" : $perm_view_others = "0";
  33. verify_permission('user_edit_own') ? $perm_edit_own = "1" : $perm_edit_own = "0";
  34. verify_permission('user_edit_others') ? $perm_edit_others = "1" : $perm_edit_others = "0";
  35. verify_permission('templ_perm_edit') ? $perm_templ_perm_edit = "1" : $perm_templ_perm_edit = "0";
  36. verify_permission('user_is_ueberuser') ? $perm_is_godlike = "1" : $perm_is_godlike = "0";
  37. verify_permission('user_add_new') ? $perm_add_new = "1" : $perm_add_new = "0";
  38. #if (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. update_user_details($user);
  46. }
  47. }
  48. $users = 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. foreach ($users as $user) {
  65. if ($user['active'] == "1") {
  66. $active = " checked";
  67. } else {
  68. $active = "";
  69. }
  70. if ($user['use_ldap'] == "1") {
  71. $use_ldap = " checked";
  72. } else {
  73. $use_ldap = "";
  74. }
  75. if (($user['uid'] == $_SESSION["userid"] && $perm_edit_own == "1") || ($user['uid'] != $_SESSION["userid"] && $perm_edit_others == "1" )) {
  76. $commit_button = "1";
  77. echo " <tr>\n";
  78. echo " <td>\n";
  79. echo " <input type=\"hidden\" name=\"user[" . $user['uid'] . "][uid]\" value=\"" . $user['uid'] . "\">\n";
  80. echo " <a href=\"edit_user.php?id=" . $user['uid'] . "\"><img src=\"images/edit.gif\" alt=\"[ " . _('Edit user') . " ]\"></a>\n";
  81. // do not allow to delete him- or herself
  82. if ($user['uid'] != $_SESSION["userid"]) {
  83. echo " <a href=\"delete_user.php?id=" . $user['uid'] . "\"><img src=\"images/delete.gif\" alt=\"[ " . _('Delete user') . " ]\"></a>";
  84. }
  85. # if ($user['uid'] != $_SESSION["userid"] && $perm_is_godlike == "1") {
  86. # echo " <a href=\"users.php?action=switchuser&username=" . $user['username'] . "\"><img src=\"images/switch_user.png\" alt=\"[ " . _('Switch user') . " ]\"></a>\n";
  87. # }
  88. echo " </td>\n";
  89. echo " <td><input type=\"text\" name=\"user[" . $user['uid'] . "][username]\" value=\"" . $user['username'] . "\"></td>\n";
  90. echo " <td><input type=\"text\" name=\"user[" . $user['uid'] . "][fullname]\" value=\"" . $user['fullname'] . "\"></td>\n";
  91. echo " <td><input type=\"text\" name=\"user[" . $user['uid'] . "][descr]\" value=\"" . $user['descr'] . "\"></td>\n";
  92. echo " <td><input type=\"text\" name=\"user[" . $user['uid'] . "][email]\" value=\"" . $user['email'] . "\"></td>\n";
  93. echo " <td>\n";
  94. if ($perm_templ_perm_edit == "1") {
  95. echo " <select name=\"user[" . $user['uid'] . "][templ_id]\">\n";
  96. foreach (list_permission_templates() as $template) {
  97. ($template['id'] == $user['tpl_id']) ? $select = " SELECTED" : $select = "";
  98. echo " <option value=\"" . $template['id'] . "\"" . $select . ">" . $template['name'] . "</option>\n";
  99. }
  100. echo " </select>\n";
  101. } else {
  102. echo " <input type=\"hidden\" name=\"user[" . $user['uid'] . "][templ_id]\" value=\"" . $user['tpl_id'] . "\">\n";
  103. echo " " . $user['tpl_name'] . "\n";
  104. }
  105. echo " </td>\n";
  106. if ($ldap_use) {
  107. if (( $perm_is_godlike == "1")) {
  108. echo " <td><input type=\"checkbox\" name=\"user[" . $user['uid'] . "][use_ldap]\"" . $use_ldap . "></td>\n";
  109. } else {
  110. if ($use_ldap == " checked") {
  111. echo " <td>Yes</td>\n";
  112. } else {
  113. echo " <td>No</td>\n";
  114. }
  115. }
  116. }
  117. if ($user['uid'] != $_SESSION["userid"]) {
  118. echo " <td><input type=\"checkbox\" name=\"user[" . $user['uid'] . "][active]\"" . $active . "></td>\n";
  119. } else {
  120. echo " <td><input type=\"hidden\" name=\"user[" . $user['uid'] . "][active]\" value=\"on\"></td>\n";
  121. }
  122. echo " </tr>\n";
  123. } else {
  124. echo " <tr>\n";
  125. echo " <td>&nbsp;</td>\n";
  126. echo " <td>" . $user['username'] . "</td>\n";
  127. echo " <td>" . $user['fullname'] . "</td>\n";
  128. echo " <td>" . $user['descr'] . "</td>\n";
  129. echo " <td>" . $user['email'] . "</td>\n";
  130. echo " <td>" . $user['tpl_name'] . "</td>\n";
  131. if ($active == " checked") {
  132. echo " <td>Yes</td>\n";
  133. } else {
  134. echo " <td>No</td>\n";
  135. }
  136. if ($use_ldap == " checked") {
  137. echo " <td>Yes</td>\n";
  138. } else {
  139. echo " <td>No</td>\n";
  140. }
  141. echo " </tr>\n";
  142. }
  143. }
  144. echo " </table>\n";
  145. if (isset($commit_button) && $commit_button) {
  146. echo " <input type=\"submit\" class=\"button\" name=\"commit\" value=\"" . _('Commit changes') . "\">\n";
  147. echo " <input type=\"reset\" class=\"button\" name=\"reset\" value=\"" . _('Reset changes') . "\">\n";
  148. }
  149. echo " </form>\n";
  150. if ($perm_templ_perm_edit == "1" || $perm_add_new == "1") {
  151. echo " <ul>\n";
  152. }
  153. if ($perm_templ_perm_edit == "1") {
  154. echo "<li><a href=\"list_perm_templ.php\">" . _('Edit permission template') . "</a>.</li>\n";
  155. }
  156. if ($perm_add_new == "1") {
  157. echo "<li><a href=\"add_user.php\">" . _('Add user') . "</a>.</li>\n";
  158. }
  159. if ($perm_templ_perm_edit == "1" || $perm_add_new == "1") {
  160. echo " </ul>\n";
  161. }
  162. include_once("inc/footer.inc.php");