Просмотр исходного кода

Ensure status is set correctly and adjust layout

Kristan Kenney 5 лет назад
Родитель
Сommit
2a702e6814
2 измененных файлов с 44 добавлено и 34 удалено
  1. 20 11
      web/edit/user/index.php
  2. 24 23
      web/templates/pages/edit_user.html

+ 20 - 11
web/edit/user/index.php

@@ -179,25 +179,34 @@ if (!empty($_POST['save'])) {
         unset($output);
         unset($output);
     }
     }
 
 
-    // Update panel login status (admin only)
+    // Update Control Panel login disabled status (admin only)
     if (empty($_SESSION['error_msg'])) {
     if (empty($_SESSION['error_msg'])) {
-        if ($data[$user]['LOGIN_DISABLED'] != $_POST['v_login_disabled']) {
+        if ($_POST['v_login_disabled'] != $data[$user]['LOGIN_DISABLED']) {
             if ($_POST['v_login_disabled'] == 'on') { $_POST['v_login_disabled'] = 'yes'; } else { $_POST['v_login_disabled'] = 'no'; }
             if ($_POST['v_login_disabled'] == 'on') { $_POST['v_login_disabled'] = 'yes'; } else { $_POST['v_login_disabled'] = 'no'; }
             exec (HESTIA_CMD."v-change-user-config-value ".escapeshellarg($v_username)." LOGIN_DISABLED ".escapeshellarg($_POST['v_login_disabled']), $output, $return_var);
             exec (HESTIA_CMD."v-change-user-config-value ".escapeshellarg($v_username)." LOGIN_DISABLED ".escapeshellarg($_POST['v_login_disabled']), $output, $return_var);
             check_return_code($return_var,$output);
             check_return_code($return_var,$output);
+            $data[$user]['LOGIN_DISABLED'] = $_POST['v_login_disabled'];
             unset($output);
             unset($output);
-
-            $v_login_disabled = $_POST['v_login_disabled'];
         }
         }
     }
     }
 
 
-    // Change use IP allow list option (admin only)
-    if (($v_login_use_iplist != $_POST['v_login_use_iplist']) && (empty($_SESSION['error_msg']))) {
-        if ($_POST['v_login_use_iplist'] == 'on') { $_POST['v_login_use_iplist'] = 'yes'; } else { $_POST['v_login_use_iplist'] = 'no'; }
-        $v_login_use_iplist = escapeshellarg($_POST['v_login_use_iplist']);
-        exec (HESTIA_CMD."v-change-user-config-value ".escapeshellarg($v_username)." LOGIN_USE_IPLIST ".$v_login_use_iplist, $output, $return_var);
-        check_return_code($return_var,$output);
-        unset($output);
+    // Update IP whitelist option
+    if (empty($_SESSION['error_msg'])) {
+        if ($_POST['v_login_use_iplist'] != $data[$user]['LOGIN_USE_IPLIST']) {
+            if ($_POST['v_login_use_iplist'] == 'on') { $_POST['v_login_use_iplist'] = 'yes'; } else { $_POST['v_login_use_iplist'] = 'no'; }
+            exec (HESTIA_CMD."v-change-user-config-value ".escapeshellarg($v_username)." LOGIN_USE_IPLIST ".escapeshellarg($_POST['v_login_use_iplist']), $output, $return_var);
+            if ($_POST['v_login_use_iplist'] === 'no') {
+                exec (HESTIA_CMD."v-change-user-config-value ".escapeshellarg($v_username)." LOGIN_ALLOW_IPS ''", $output, $return_var);
+                $v_login_allowed_ips = '';
+            } else {
+                exec (HESTIA_CMD."v-change-user-config-value ".escapeshellarg($v_username)." LOGIN_ALLOW_IPS ".escapeshellarg($_POST['v_login_allowed_ips']), $output, $return_var);
+                unset($v_login_allowed_ips);
+                $v_login_allowed_ips = $_POST['v_login_allowed_ips'];
+            }
+            check_return_code($return_var,$output);
+            $data[$user]['LOGIN_USE_IPLIST'] = $_POST['v_login_use_iplist'];
+            unset($output);
+        }
     }
     }
 
 
     // Change package (admin only)
     // Change package (admin only)

+ 24 - 23
web/templates/pages/edit_user.html

@@ -129,11 +129,18 @@
                                     <meter max="4" id="meter"></meter>
                                     <meter max="4" id="meter"></meter>
                                 </td>
                                 </td>
                             </tr>
                             </tr>
+                            <? if ($_SESSION['userContext'] === 'admin') {?>
+                                <tr>
+                                    <td>
+                                        <label><input type="checkbox" size="20" class="vst-checkbox" onclick="javascript:elementHideShow('password-details')" name="v_login_disabled" <?php if ($data[$user]['LOGIN_DISABLED'] == "yes") echo "checked=yes" ?>><?php print _('Do not allow user to log in to Control Panel');?></label>
+                                    </td>
+                                </tr>
+                            <? } ?>
                             <tr>
                             <tr>
                                 <td>
                                 <td>
-                                    <table id="password-details">
+                                    <table id="password-details" style="<?php if ($data[$user]['LOGIN_DISABLED'] == "yes") { echo 'display: none;'; } else { echo 'display: table-cell;'; }?>">
                                         <tr>
                                         <tr>
-                                            <td class="vst-text">
+                                            <td class="vst-text step-top">
                                                 <?php print _('Your password must have at least');?>:
                                                 <?php print _('Your password must have at least');?>:
                                                 <ul>
                                                 <ul>
                                                     <li><?php print _('8 characters long');?></li>
                                                     <li><?php print _('8 characters long');?></li>
@@ -152,28 +159,20 @@
                                                 <?php } ?>
                                                 <?php } ?>
                                             </td>
                                             </td>
                                         </tr>
                                         </tr>
-                                    </table>
-                                </td>
-                            </tr>
-                            <? if ($_SESSION['userContext'] === 'admin') {?>
-                                <tr>
-                                    <td>
-                                        <label><input type="checkbox" size="20" class="vst-checkbox" name="v_login_disabled" <?php if ($data[$user]['LOGIN_DISABLED'] == "yes") echo "checked=yes" ?>><?php print _('User can not log in to Control Panel');?></label>
-                                    </td>
-                                </tr>
-                            <? } ?>
-                            <tr>
-                                <td>
-                                    <label><input type="checkbox" size="20" class="vst-checkbox" onclick="javascript:elementHideShow('ip-allowlist')" name="v_login_use_iplist" <?php if ($data[$user]['LOGIN_USE_IPLIST'] === "yes") echo "checked=yes" ?>><?php print _('Only allow logins from certain IP addresses');?></label>
-                                </td>
-                            </tr>
-                            <tr>
-                                <td>
-                                    <table id="ip-allowlist" style="<? if ($data[$user]['LOGIN_USE_IPLIST'] === 'yes') { echo 'display: table-cell;'; } else { echo 'display: none;'; } ?>">
                                         <tr>
                                         <tr>
                                             <td>
                                             <td>
-                                                <input type="text" size="20" class="vst-input" placeholder="<?=_('Example: 127.0.0.1,192.168.1.100');?>" name="v_login_allowed_ips" value="<?=htmlentities(trim($v_login_allowed_ips, "'"))?>">
-                                                <input type="hidden" name="v_login_allowed_ips" value="<?=htmlentities(trim($v_login_allowed_ips, "'"))?>">
+                                                <label><input type="checkbox" size="20" class="vst-checkbox" onclick="javascript:elementHideShow('ip-allowlist')" name="v_login_use_iplist" <?php if ($data[$user]['LOGIN_USE_IPLIST'] === "yes") echo "checked=yes" ?>><?php print _('Use IP address allow list for login attempts');?></label>
+                                            </td>
+                                        </tr>
+                                        <tr>
+                                            <td>
+                                                <table id="ip-allowlist" style="<? if ($data[$user]['LOGIN_USE_IPLIST'] === 'yes') { echo 'display: table-cell;'; } else { echo 'display: none;'; } ?>">
+                                                    <tr>
+                                                        <td>
+                                                            <input type="text" size="20" class="vst-input" placeholder="<?=_('Example: 127.0.0.1,192.168.1.100');?>" name="v_login_allowed_ips" value="<?=htmlentities(trim($v_login_allowed_ips, "'"))?>">
+                                                        </td>
+                                                    </tr>
+                                                </table>
                                             </td>
                                             </td>
                                         </tr>
                                         </tr>
                                     </table>
                                     </table>
@@ -250,9 +249,10 @@
                                 </td>
                                 </td>
                             </tr>
                             </tr>
                             <?}?>
                             <?}?>
+                            <? if ($_GET['user'] === $_SESSION['user']) { ?>
                             <tr>
                             <tr>
                                 <td class="vst-text input-label">
                                 <td class="vst-text input-label">
-                                    <?php print _('Default sort order');?>
+                                    <?php print _('Default list sort order');?>
                                 </td>
                                 </td>
                             </tr>
                             </tr>
                             <tr>
                             <tr>
@@ -263,6 +263,7 @@
                                     </select>
                                     </select>
                                 </td>
                                 </td>
                             </tr>
                             </tr>
+                            <? } ?>
                             <? if ($_SESSION['userContext'] === 'admin') {?>
                             <? if ($_SESSION['userContext'] === 'admin') {?>
                             <tr>
                             <tr>
                                 <td class="vst-text input-label">
                                 <td class="vst-text input-label">