edit_user.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <!-- Begin toolbar -->
  2. <div class="toolbar">
  3. <div class="toolbar-inner">
  4. <div class="toolbar-buttons">
  5. <a class="button button-secondary button-back js-button-back" href="/list/user/">
  6. <i class="fas fa-arrow-left icon-blue"></i><?= _("Back") ?>
  7. </a>
  8. <?php
  9. if (($_SESSION['userContext'] === 'admin') && ($_SESSION['look'] === '' ) && ($_SESSION['user'] !== $v_username)) {
  10. $ssh_key_url = "/list/key/?user=".htmlentities($_GET['user'])."&token=".$_SESSION['token']."";
  11. $log_url = "/list/log/?user=".htmlentities($_GET['user'])."&token=".$_SESSION['token']."";
  12. $keys_url = "/list/access-key/?user=".htmlentities($_GET['user'])."&token=".$_SESSION['token']."";
  13. }else{
  14. $ssh_key_url = "/list/key/";
  15. $log_url = "/list/log/";
  16. $keys_url = "/list/access-key/";
  17. }
  18. ?>
  19. <a href="<?= $ssh_key_url; ?>" class="button button-secondary js-button-create" title="<?= _("Manage SSH Keys") ?>">
  20. <i class="fas fa-key icon-orange"></i><?= _("Manage SSH Keys") ?>
  21. </a>
  22. <?php if ($_SESSION["userContext"] == "admin" || ($_SESSION["userContext"] !== "admin" && $_SESSION["POLICY_USER_VIEW_LOGS"] !== "no")) { ?>
  23. <a href="<?= $log_url ?>" class="button button-secondary js-button-create" title="<?= _("Logs") ?>">
  24. <i class="fas fa-clock-rotate-left icon-maroon"></i><?= _("Logs") ?>
  25. </a>
  26. <?php } ?>
  27. <?php
  28. $api_status = (!empty($_SESSION['API_SYSTEM']) && is_numeric($_SESSION['API_SYSTEM'])) ? $_SESSION['API_SYSTEM'] : 0;
  29. if (($user_plain == 'admin' && $api_status > 0) || ($user_plain != 'admin' && $api_status > 1)) { ?>
  30. <a href="<?= $keys_url; ?>" class="button button-secondary js-button-create" title="<?= _("Access Keys") ?>">
  31. <i class="fas fa-key icon-purple"></i><?= _("Access Keys") ?>
  32. </a>
  33. <?php } ?>
  34. </div>
  35. <div class="toolbar-buttons">
  36. <button type="submit" class="button" form="main-form">
  37. <i class="fas fa-floppy-disk icon-purple"></i><?= _("Save") ?>
  38. </button>
  39. </div>
  40. </div>
  41. </div>
  42. <!-- End toolbar -->
  43. <div class="container">
  44. <form
  45. x-data="{
  46. loginDisabled: <?= $v_login_disabled === "yes" ? "true" : "false" ?>,
  47. useIpAllowList: <?= $v_login_use_iplist === "yes" ? "true" : "false" ?>,
  48. showAdvanced: false,
  49. }"
  50. id="main-form"
  51. method="post"
  52. name="v_edit_user"
  53. class="<?= $v_status ?>"
  54. >
  55. <input type="hidden" name="token" value="<?= $_SESSION["token"] ?>">
  56. <input type="hidden" name="save" value="save">
  57. <div class="form-container">
  58. <h1 class="u-mb20"><?= _("Edit User") ?></h1>
  59. <?php show_alert_message($_SESSION); ?>
  60. <div class="u-mb10">
  61. <label for="v_user" class="form-label"><?= _("Username") ?></label>
  62. <input type="text" class="form-control" name="v_user" id="v_user" value="<?= htmlentities(trim($v_username, "'")) ?>" disabled required>
  63. <input type="hidden" name="v_username" value="<?= htmlentities(trim($v_username, "'")) ?>">
  64. </div>
  65. <div class="u-mb10">
  66. <label for="v_name" class="form-label"><?= _("Contact Name") ?></label>
  67. <input type="text" class="form-control" name="v_name" id="v_name" value="<?= htmlentities(trim($v_name, "'")) ?>" <?php if (($_SESSION['userContext'] !=='admin' ) && ($_SESSION['POLICY_USER_EDIT_DETAILS'] !=='yes' )) { echo 'disabled' ; }?> required>
  68. <?php if (($_SESSION['userContext'] !== 'admin') && ($_SESSION['POLICY_USER_EDIT_DETAILS'] !== 'yes')) { ?>
  69. <input type="hidden" name="v_name" value="<?= htmlentities(trim($v_name, "'")) ?>">
  70. <?php } ?>
  71. </div>
  72. <div class="u-mb10">
  73. <label for="v_email" class="form-label"><?= _("Email") ?></label>
  74. <input type="email" class="form-control" name="v_email" id="v_email" value="<?= htmlentities(trim($v_email, "'")) ?>" <?php if (($_SESSION['userContext'] !=='admin' ) && ($_SESSION['POLICY_USER_EDIT_DETAILS'] !=='yes' )) { echo 'disabled' ; }?> required>
  75. <?php if (($_SESSION['userContext'] !== 'admin') && ($_SESSION['POLICY_USER_EDIT_DETAILS'] !== 'yes')) { ?>
  76. <input type="hidden" name="v_email" value="<?= htmlentities(trim($v_email, "'")) ?>">
  77. <?php } ?>
  78. </div>
  79. <div class="u-mb10">
  80. <label for="v_password" class="form-label">
  81. <?= _("Password") ?>
  82. <button type="button" title="<?= _("Generate") ?>" class="u-unstyled-button u-ml5 js-generate-password">
  83. <i class="fas fa-arrows-rotate icon-green"></i>
  84. </button>
  85. </label>
  86. <div class="u-pos-relative u-mb10">
  87. <input type="text" class="form-control js-password-input" name="v_password" id="v_password" value="<?= htmlentities(trim($v_password, "'")) ?>">
  88. <div class="password-meter">
  89. <meter max="4" class="password-meter-input js-password-meter"></meter>
  90. </div>
  91. </div>
  92. </div>
  93. <div id="password-details" class="u-mb20">
  94. <?php require $_SERVER["HESTIA"] . "/web/templates/includes/password-requirements.php"; ?>
  95. <?php if ($_SESSION["userContext"] === "admin") { ?>
  96. <div class="form-check">
  97. <input x-model="loginDisabled" class="form-check-input" type="checkbox" name="v_login_disabled" id="v_login_disabled">
  98. <label for="v_login_disabled">
  99. <?= _("Do not allow user to log in to Control Panel") ?>
  100. </label>
  101. </div>
  102. <?php } ?>
  103. <div x-cloak x-show="!loginDisabled" id="password-options">
  104. <div class="form-check">
  105. <input class="form-check-input" type="checkbox" name="v_twofa" id="v_twofa" <?php if (!empty($v_twofa)) echo 'checked' ?>>
  106. <label for="v_twofa">
  107. <?= _("Enable two-factor authentication") ?>
  108. </label>
  109. </div>
  110. <?php if (!empty($v_twofa)) { ?>
  111. <p class="u-mb10"><?= _("Account Recovery Code") . ": " . $v_twofa ?></p>
  112. <p class="u-mb10"><?= _("Please scan the code below in your 2FA application") ?>:</p>
  113. <div class="u-mb10">
  114. <img class="qr-code" src="<?= htmlentities($v_qrcode) ?>" alt="<?= _("2FA QR Code") ?>">
  115. </div>
  116. <?php } ?>
  117. </div>
  118. <div x-cloak x-show="!loginDisabled" id="password-options-ip">
  119. <div class="form-check">
  120. <input x-model="useIpAllowList" class="form-check-input" type="checkbox" name="v_login_use_iplist" id="v_login_use_iplist">
  121. <label for="v_login_use_iplist">
  122. <?= _("Use IP address allow list for login attempts") ?>
  123. </label>
  124. </div>
  125. </div>
  126. <div x-cloak x-show="useIpAllowList" id="ip-allowlist" class="u-mt10">
  127. <input type="text" class="form-control" name="v_login_allowed_ips" value="<?= htmlentities(trim($v_login_allowed_ips, "'")) ?>" placeholder="<?= _("For example") ?>: 127.0.0.1,192.168.1.100">
  128. </div>
  129. </div>
  130. <div class="u-mb10">
  131. <label for="v_language" class="form-label"><?= _("Language") ?></label>
  132. <select class="form-select" name="v_language" id="v_language" required>
  133. <?php
  134. foreach ($languages as $key => $value) {
  135. echo "\n\t\t\t\t\t\t\t\t\t<option value=\"".$key."\"";
  136. $skey = "'".$key."'";
  137. if (( $key == $v_language ) || ( $skey == $v_language)){
  138. echo 'selected' ;
  139. }
  140. if (( $key == detect_user_language() ) && (empty($v_language))){
  141. echo 'selected' ;
  142. }
  143. echo ">".htmlentities($value)."</option>\n";
  144. }
  145. ?>
  146. </select>
  147. </div>
  148. <?php if ($v_username != "admin" && $_SESSION["userContext"] === "admin" && $_SESSION["user"] != $v_username): ?>
  149. <div class="u-mb10">
  150. <label for="v_role" class="form-label"><?= _("Role") ?></label>
  151. <select class="form-select" name="v_role" id="v_role" required>
  152. <option value="user"><?= _("User") ?></option>
  153. <option value="admin" <?= $v_role == "admin" ? "selected" : "" ?>><?= _("Administrator") ?></option>
  154. <option value="dns-cluster" <?= $v_role == "dns-cluster" ? "selected" : "" ?>><?= _("DNS Sync User") ?></option>
  155. </select>
  156. </div>
  157. <?php endif; ?>
  158. <?php if ($_SESSION["POLICY_USER_CHANGE_THEME"] !== "no") { ?>
  159. <div class="u-mb10">
  160. <label for="v_user_theme" class="form-label"><?= _("Theme") ?></label>
  161. <select class="form-select" name="v_user_theme" id="v_user_theme">
  162. <?php
  163. foreach ($themes as $key => $value) {
  164. echo "\t\t\t\t<option value=\"".$value."\"";
  165. if ((!empty($_SESSION['userTheme'])) && ( $value == $v_user_theme )) {
  166. echo ' selected' ;
  167. }
  168. if ((empty($v_user_theme) && (!empty($_SESSION['THEME']))) && ( $value == $_SESSION['THEME'] )) {
  169. echo ' selected' ;
  170. }
  171. echo ">".$value."</option>\n";
  172. }
  173. ?>
  174. </select>
  175. </div>
  176. <?php } ?>
  177. <div class="u-mb10">
  178. <label for="v_sort_order" class="form-label"><?= _("Default List Sort Order") ?></label>
  179. <select class="form-select" name="v_sort_order" id="v_sort_order">
  180. <option value='date' <?php if ($v_sort_order === 'date') echo 'selected' ?>><?= _("Date") ?></option>
  181. <option value='name' <?php if ($v_sort_order === 'name') echo 'selected' ?>><?= _("Name") ?></option>
  182. </select>
  183. </div>
  184. <?php if ($_SESSION['userContext'] === 'admin') { ?>
  185. <div class="u-mb20">
  186. <label for="v_package" class="form-label"><?= _("Package") ?></label>
  187. <select class="form-select" name="v_package" id="v_package" required>
  188. <?php
  189. foreach ($packages as $key => $value) {
  190. echo "\n\t\t\t\t\t\t\t\t\t<option value=\"".htmlentities($key)."\"";
  191. $skey = "'".$key."'";
  192. if (( $key == $v_package ) || ( $skey == $v_package)){
  193. echo 'selected' ;
  194. }
  195. echo ">".htmlentities($key)."</option>\n";
  196. }
  197. ?>
  198. </select>
  199. </div>
  200. <div class="u-mb20">
  201. <button x-on:click="showAdvanced = !showAdvanced" type="button" class="button button-secondary">
  202. <?= _("Advanced Options") ?>
  203. </button>
  204. </div>
  205. <div x-cloak x-show="showAdvanced">
  206. <div class="u-mb10">
  207. <label for="v_shell" class="form-label"><?= _("SSH Access") ?></label>
  208. <select class="form-select" name="v_shell" id="v_shell">
  209. <?php
  210. foreach ($shells as $key => $value) {
  211. echo "\t\t\t\t<option value=\"".htmlentities($value)."\"";
  212. $svalue = "'".$value."'";
  213. if (( $value == $v_shell ) || ($svalue == $v_shell )){
  214. echo 'selected' ;
  215. }
  216. echo ">".htmlentities($value)."</option>\n";
  217. }
  218. ?>
  219. </select>
  220. </div>
  221. <div class="u-mb10">
  222. <label for="v_phpcli" class="form-label"><?= _("PHP CLI Version") ?></label>
  223. <select class="form-select" name="v_phpcli" id="v_phpcli">
  224. <?php
  225. foreach ($php_versions as $key => $value) {
  226. $php = explode('-',$value);
  227. echo "\t\t\t\t<option value=\"".$value."\"";
  228. $svalue = "'".$value."'";
  229. if ((!empty($v_phpcli)) && ( $value == $v_phpcli ) || ($svalue == $v_phpcli)){
  230. echo ' selected' ;
  231. }
  232. if ((empty($v_phpcli)) && ($value == DEFAULT_PHP_VERSION)){
  233. echo ' selected' ;
  234. }
  235. echo ">".htmlentities($value)."</option>\n";
  236. }
  237. ?>
  238. </select>
  239. </div>
  240. <?php if ((isset($_SESSION['DNS_SYSTEM'])) && (!empty($_SESSION['DNS_SYSTEM']))) { ?>
  241. <p class="form-label u-mb10"><?= _("Default Name Servers") ?></p>
  242. <div class="u-mb5">
  243. <input type="text" class="form-control" name="v_ns1" value="<?= htmlentities(trim($v_ns1, "'")) ?>">
  244. </div>
  245. <div class="u-mb5">
  246. <input type="text" class="form-control" name="v_ns2" value="<?= htmlentities(trim($v_ns2, "'")) ?>">
  247. </div>
  248. <?php require $_SERVER["HESTIA"] . "/web/templates/includes/extra-ns-fields.php"; ?>
  249. <button type="button" class="form-link u-mt20 js-add-ns" <?php if ($v_ns8) echo 'style="display:none;"'; ?>>
  250. <?= _("Add Name Server") ?>
  251. </button>
  252. <?php } ?>
  253. </div>
  254. <?php } ?>
  255. </div>
  256. </form>
  257. </div>