Browse Source

edit user

Serghey Rodin 14 years ago
parent
commit
f91f23a727

+ 2 - 0
bin/v_add_database

@@ -32,6 +32,8 @@ source $VESTA/func/db.sh
 
 # Hiding password
 A4='******'
+EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
+EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
 
 
 #----------------------------------------------------------#

+ 2 - 0
bin/v_add_mail_account

@@ -25,6 +25,8 @@ source $VESTA/func/domain.sh
 
 # Hiding password
 A4='******'
+EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
+EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
 
 
 #----------------------------------------------------------#

+ 2 - 0
bin/v_add_user

@@ -23,6 +23,8 @@ source $VESTA/func/main.sh
 
 # Hiding password
 A2='******'
+EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
+EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
 
 is_user_free() {
     check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" )

+ 2 - 0
bin/v_add_web_domain_stats_user

@@ -22,6 +22,8 @@ source $VESTA/func/domain.sh
 
 # Hiding password
 A4='******'
+EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
+EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
 
 
 #----------------------------------------------------------#

+ 2 - 0
bin/v_change_database_password

@@ -22,6 +22,8 @@ source $VESTA/func/db.sh
 
 # Hiding password
 A3='******'
+EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
+EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
 
 
 #----------------------------------------------------------#

+ 2 - 0
bin/v_change_mail_account_password

@@ -24,6 +24,8 @@ source $VESTA/func/domain.sh
 
 # Hiding password
 A4='******'
+EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
+EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
 
 
 #----------------------------------------------------------#

+ 3 - 1
bin/v_change_user_password

@@ -18,7 +18,9 @@ source $VESTA/conf/vesta.conf
 source $VESTA/func/main.sh
 
 # Hiding password
-A2='******'
+A2="******"
+EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
+EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
 
 
 #----------------------------------------------------------#

+ 0 - 1
web/add/user/index.php

@@ -17,7 +17,6 @@ if ($_SESSION['user'] == 'admin') {
 
     // Cancel
     if (!empty($_POST['cancel'])) {
-        echo $_POST['cancel'];
         header("Location: /list/user/");
     }
 

+ 152 - 0
web/edit/user/index.php

@@ -0,0 +1,152 @@
+<?php
+// Init
+//error_reporting(NULL);
+ob_start();
+session_start();
+$TAB = 'USER';
+include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
+
+// Header
+include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
+
+// Panel
+top_panel($user,$TAB);
+
+// Are you admin?
+if ($_SESSION['user'] == 'admin') {
+
+    // Check user argument?
+    if (empty($_GET['user'])) {
+        header("Location: /list/user/");
+    }
+
+    if (!empty($_POST['cancel'])) {
+        header("Location: /list/user/");
+    }
+
+    // Check user
+    $v_username = escapeshellarg($_GET['user']);
+    exec (VESTA_CMD."v_list_user ".$v_username." json", $output, $return_var);
+    if ($return_var != 0) {
+        $error = implode('<br>', $output);
+        if (empty($error)) $error = 'Error: vesta did not return any output.';
+        $_SESSION['error_msg'] = $error;
+    } else {
+        $data = json_decode(implode('', $output), true);
+        $v_username = $_GET['user'];
+        $v_password = "••••••••";
+        $v_email = $data[$v_username]['CONTACT'];
+        $v_package = $data[$v_username]['PACKAGE'];
+        $v_fname = $data[$v_username]['FNAME'];
+        $v_lname = $data[$v_username]['LNAME'];
+        $v_shell = $data[$v_username]['SHELL'];
+        $v_ns = $data[$v_username]['NS'];
+        $nameservers = explode(", ", $v_ns);
+        $v_ns1 = $nameservers[0];
+        $v_ns2 = $nameservers[1];
+        $v_ns3 = $nameservers[2];
+        $v_ns4 = $nameservers[3];
+
+        unset($output);
+
+        exec (VESTA_CMD."v_list_user_packages json", $output, $return_var);
+        $packages = json_decode(implode('', $output), true);
+        unset($output);
+
+        exec (VESTA_CMD."v_list_sys_shells json", $output, $return_var);
+        $shells = json_decode(implode('', $output), true);
+        unset($output);
+    }
+
+    if (!empty($_POST['save'])) {
+        $v_username = escapeshellarg($_POST['v_username']);
+
+        if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) {
+            $v_password = escapeshellarg($_POST['v_password']);
+            exec (VESTA_CMD."v_change_user_password ".$v_username." ".$v_password, $output, $return_var);
+            if ($return_var != 0) {
+                $error = implode('<br>', $output);
+                if (empty($error)) $error = 'Error: vesta did not return any output.';
+                $_SESSION['error_msg'] = $error;
+            }
+            $v_password = "••••••••";
+            unset($output);
+        }
+
+        if (($v_package != $_POST['v_package']) && (empty($_SESSION['error_msg']))) {
+            $v_package = escapeshellarg($_POST['v_package']);
+            exec (VESTA_CMD."v_change_user_package ".$v_username." ".$v_package, $output, $return_var);
+            if ($return_var != 0) {
+                $error = implode('<br>', $output);
+                if (empty($error)) $error = 'Error: vesta did not return any output.';
+                $_SESSION['error_msg'] = $error;
+            }
+            unset($output);
+        }
+
+        if (($v_shell != $_POST['v_shell']) && (empty($_SESSION['error_msg']))) {
+            $v_shell = escapeshellarg($_POST['v_shell']);
+            exec (VESTA_CMD."v_change_user_shell ".$v_username." ".$v_shell, $output, $return_var);
+            if ($return_var != 0) {
+                $error = implode('<br>', $output);
+                if (empty($error)) $error = 'Error: vesta did not return any output.';
+                $_SESSION['error_msg'] = $error;
+            }
+            unset($output);
+        }
+
+        if (($v_email != $_POST['v_email']) && (empty($_SESSION['error_msg']))) {
+            $v_email = escapeshellarg($_POST['v_email']);
+            exec (VESTA_CMD."v_change_user_contact ".$v_username." ".$v_email, $output, $return_var);
+            if ($return_var != 0) {
+                $error = implode('<br>', $output);
+                if (empty($error)) $error = 'Error: vesta did not return any output.';
+                $_SESSION['error_msg'] = $error;
+            }
+            unset($output);
+        }
+
+        if (($v_fname != $_POST['v_fname']) || ($v_lname != $_POST['v_lname']) && (empty($_SESSION['error_msg']))) {
+            $v_fname = escapeshellarg($_POST['v_fname']);
+            $v_lname = escapeshellarg($_POST['v_lname']);
+            exec (VESTA_CMD."v_change_user_name ".$v_username." ".$v_fname." ".$v_lname, $output, $return_var);
+            if ($return_var != 0) {
+                $error = implode('<br>', $output);
+                if (empty($error)) $error = 'Error: vesta did not return any output.';
+                $_SESSION['error_msg'] = $error;
+            }
+            unset($output);
+        }
+
+        if (($v_ns1 != $_POST['v_ns1']) || ($v_ns2 != $_POST['v_ns2']) || ($v_ns3 != $_POST['v_ns3']) || ($v_ns4 != $_POST['v_ns4']) && (empty($_SESSION['error_msg']))) {
+            $v_ns1 = escapeshellarg($_POST['v_ns1']);
+            $v_ns2 = escapeshellarg($_POST['v_ns2']);
+            $v_ns3 = escapeshellarg($_POST['v_ns3']);
+            $v_ns4 = escapeshellarg($_POST['v_ns4']);
+
+            $ns_cmd = VESTA_CMD."v_change_user_ns ".$v_username." ".$v_ns1." ".$v_ns2;
+            if (!empty($_POST['v_ns3'])) $ns_cmd = $ns_cmd." ".$v_ns3;
+            if (!empty($_POST['v_ns4'])) $ns_cmd = $ns_cmd." ".$v_ns4;
+            exec ($ns_cmd, $output, $return_var);
+            if ($return_var != 0) {
+                $error = implode('<br>', $output);
+                if (empty($error)) $error = 'Error: vesta did not return any output.';
+                $_SESSION['error_msg'] = $error;
+            }
+            unset($output);
+        }
+
+        if (empty($_SESSION['error_msg'])) {
+            $_SESSION['ok_msg'] = "OK: changes has been saved.";
+        }
+    }
+    include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_user.html');
+    include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_user.html');
+    unset($_SESSION['error_msg']);
+    unset($_SESSION['ok_msg']);
+
+
+}
+
+// Footer
+include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');

+ 74 - 0
web/templates/admin/edit_user.html

@@ -0,0 +1,74 @@
+<script type="text/javascript">
+function randomString() {
+var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
+var string_length = 10;
+var randomstring = '';
+for (var i=0; i<string_length; i++) {
+  var rnum = Math.floor(Math.random() * chars.length);
+  randomstring += chars.substring(rnum,rnum+1);
+}
+document.v_edit_user.v_password.value = randomstring;
+}
+</script>
+<table class='data'>
+<tr class="data-add">
+    <td class="data-dotted" style="padding: 0px 10px 0px 0px" width="150">
+        <table class="data-col1">
+            <tr><td style="padding: 18 0 4 18;"></td></tr>
+        </table>
+    </td>
+    <td class="data-dotted" width="830px" style="vertical-align:top;">
+        <table width="830px"><tr>
+            <td></td>
+        </tr></table>
+        <form method="post" name="v_edit_user">
+        <table class="data-col2" width="830px">
+            <tr><td class="add-text" style="padding: 10 0 0 2px;">Username</td></tr>
+            <tr><td><input type="text" size="20" class="add-input" name="v_user" <?php if (!empty($v_username)) echo "value=".$v_username;  ?> disabled> <input type="hidden" name="v_username" <?php if (!empty($v_username)) echo "value=".$v_username;  ?>></tr>
+            <tr><td class="add-text" style="padding: 10px 0 0 2px;">
+                Password <a href="#" onclick="randomString();" class="genpass">generate</a></td></tr>
+            <tr><td><input type="text" size="20" class="add-input" name="v_password" <?php if (!empty($v_password)) echo "value=".$v_password;  ?>></tr>
+            <tr><td class="add-text" style="padding: 10px 0 0 2px;">Email</td></tr>
+            <tr><td><input type="text" size="20" class="add-input" name="v_email" <?php if (!empty($v_email)) echo "value=".$v_email; ?>></tr>
+            <tr><td class="add-text" style="padding: 10px 0 0 2px;" >Package</td></tr>
+            <tr><td><select class="add-list" name="v_package">
+            <?php
+                foreach ($packages as $key => $value) {
+                    echo "\t\t\t\t<option value=\"".$key."\"";
+                    if ((!empty($v_package)) && ( $key == $v_package)){
+                        echo 'selected' ;
+                    }
+                    echo ">".$key."</option>\n";
+                }
+            ?>
+                </select></td></tr>
+            <tr><td class="add-text" style="padding: 10px 0 0 2px;">Frist Name</td></tr>
+            <tr><td><input type="text" size="20" class="add-input" name="v_fname" <?php if (!empty($v_fname)) echo "value=".$v_fname; ?>></tr>
+            <tr><td class="add-text" style="padding: 10px 0 0 2px;">Last Name</td></tr>
+            <tr><td><input type="text" size="20" class="add-input" name="v_lname" <?php if (!empty($v_lname)) echo "value=".$v_lname; ?>></tr>
+            <tr><td class="add-text" style="padding: 10px 0 0 2px;" >Shell</td></tr>
+            <tr><td><select class="add-list" name="v_shell">
+            <?php
+                foreach ($shells as $key => $value) {
+                    echo "\t\t\t\t<option value=\"".$value."\"";
+                    if ((!empty($v_shell)) && ( $value == $v_shell)){
+                        echo 'selected' ;
+                    }
+                    echo ">".$value."</option>\n";
+                }
+            ?>
+                </select></td></tr>
+            <tr><td class="add-text" style="padding: 10px 0 0 2px;">Name Servers </td></tr>
+            <tr><td><input type="text" size="20" class="add-input" name="v_ns1" <?php if (!empty($v_ns1)) echo "value=".$v_ns1; ?>></tr>
+            <tr><td><input type="text" size="20" class="add-input" name="v_ns2" <?php if (!empty($v_ns2)) echo "value=".$v_ns2; ?>></tr>
+            <tr><td><input type="text" size="20" class="add-input" name="v_ns3" <?php if (!empty($v_ns3)) echo "value=".$v_ns3; ?>></tr>
+            <tr><td><input type="text" size="20" class="add-input" name="v_ns4" <?php if (!empty($v_ns4)) echo "value=".$v_ns4; ?>></tr>
+            <tr><td style="padding: 24px 0 0 0;">
+                <input type="submit" class="add-button" name="save" value="Save">
+                <input type="submit" class="add-button" name="cancel" value="Cancel">
+            </td></tr>
+            </form>
+        </table>
+    </td>
+</tr>
+</table>

+ 3 - 3
web/templates/admin/menu_add_user.html

@@ -1,12 +1,12 @@
 <table class="sub-menu">
 <tr>
-    <td style="padding: 10px 2px 28px 0;" ><a class="add-name"><i>Adding New User Account </i></a>
+    <td style="padding: 10px 2px 28px 0;" ><a class="add-name"><i>Adding User</i></a>
     <?php 
         if (!empty($_SESSION['error_msg'])) {
-            echo "<a class=\"add-error\"><i>".$_SESSION['error_msg']."</i></a>";
+            echo "<a class=\"add-error\"><i>".$_SESSION['error_msg']."</i></a>";
         } else {
             if (!empty($_SESSION['ok_msg'])) {
-                echo "<a class=\"add-ok\"><i>".$_SESSION['ok_msg']."</i></a>";
+                echo "<a class=\"add-ok\"><i>".$_SESSION['ok_msg']."</i></a>";
             }
         }
     ?>

+ 1 - 1
web/templates/admin/menu_cron.html

@@ -1,6 +1,6 @@
 <table class="sub-menu">
 <tr>
-    <td style="padding: 4px 0 10px 0;"><a href="#" class="add"><img style="padding: 0 6px 0 18px;" border=0 src="/images/plus.png" width="12px" height="12px">New Cron Job</a></td>
+    <td style="padding: 4px 0 10px 0;"><a href="#" class="add"><img style="padding: 0 6px 0 18px;" border=0 src="/images/plus.png" width="12px" height="12px">Add Cron Job</a></td>
     <td style="text-align: right;"><input type="text" size="30" style="border: 2px solid #D3ECF8; padding: 2px 80px 3px 0;"> <button> Search </button></td>
 </tr><tr>
     <td style="padding: 0 0 0 18px;"><input type="checkbox" onclick="checkAll(this)"> <a style="padding: 0 4px 0 2px"> toggle all</a>

+ 1 - 1
web/templates/admin/menu_db.html

@@ -1,6 +1,6 @@
 <table class="sub-menu">
 <tr>
-    <td style="padding: 4px 0 10px 0;"><a href="#" class="add"><img style="padding: 0 6px 0 18px;" src="/images/plus.png" width="12px" height="12px">New Database</a></td>
+    <td style="padding: 4px 0 10px 0;"><a href="#" class="add"><img style="padding: 0 6px 0 18px;" src="/images/plus.png" width="12px" height="12px">Add Database</a></td>
     <td style="text-align: right;"><input type="text" size="30" style="border: 2px solid #D3ECF8; padding: 2px 80px 3px 0;"> <button> Search </button></td>
 </tr><tr>
     <td style="padding: 0 0 0 18px;"><input type="checkbox" onclick="checkAll(this)"> <a style="padding: 0 4px 0 2px"> toggle all</a>

+ 1 - 1
web/templates/admin/menu_dns.html

@@ -1,6 +1,6 @@
 <table class="sub-menu">
 <tr>
-    <td style="padding: 4px 0 10px 0;"><a href="#" class="add"><img style="padding: 0 6px 0 18px;"src="/images/plus.png" width="12px" height="12px">New DNS Domain</a></td>
+    <td style="padding: 4px 0 10px 0;"><a href="#" class="add"><img style="padding: 0 6px 0 18px;"src="/images/plus.png" width="12px" height="12px">Add DNS Domain</a></td>
     <td style="text-align: right;"><input type="text" size="30" style="border: 2px solid #D3ECF8; padding: 2px 80px 3px 0;"> <button> Search </button></td>
 </tr><tr>
     <td style="padding: 0 0 0 18px;"><input type="checkbox" onclick="checkAll(this)"> <a style="padding: 0 4px 0 2px"> toggle all</a>

+ 15 - 0
web/templates/admin/menu_edit_user.html

@@ -0,0 +1,15 @@
+<table class="sub-menu">
+<tr>
+    <td style="padding: 10px 2px 28px 0;" ><a class="add-name"><i>Editing User</i></a>
+    <?php 
+        if (!empty($_SESSION['error_msg'])) {
+            echo "<a class=\"add-error\"><i> → ".$_SESSION['error_msg']."</i></a>";
+        } else {
+            if (!empty($_SESSION['ok_msg'])) {
+                echo "<a class=\"add-ok\"><i> → ".$_SESSION['ok_msg']."</i></a>";
+            }
+        }
+    ?>
+    </td>
+</tr>
+</table>

+ 1 - 1
web/templates/admin/menu_ip.html

@@ -1,6 +1,6 @@
 <table class="sub-menu">
 <tr>
-    <td style="padding: 4px 0 10px 0;"><a href="#" class="add"><img style="padding: 0 6px 0 18px;" border=0 src="/images/plus.png" width="12px" height="12px">New IP</a></td>
+    <td style="padding: 4px 0 10px 0;"><a href="#" class="add"><img style="padding: 0 6px 0 18px;" border=0 src="/images/plus.png" width="12px" height="12px">Add IP</a></td>
     <td style="text-align: right;"><input type="text" size="30" style="border: 2px solid #D3ECF8; padding: 2px 80px 3px 0;"> <button> Search </button></td>
 </tr><tr>
     <td style="padding: 0 0 0 18px;"><input type="checkbox" onclick="checkAll(this)"> <a style="padding: 0 4px 0 2px"> toggle all</a>

+ 1 - 1
web/templates/admin/menu_mail.html

@@ -1,6 +1,6 @@
 <table class="sub-menu">
 <tr>
-    <td style="padding: 4px 0 10px 0;"><a href="#" class="add"><img style="padding: 0 6px 0 18px;" src="/images/plus.png" width="12px" height="12px">New Mail Domain</a></td>
+    <td style="padding: 4px 0 10px 0;"><a href="#" class="add"><img style="padding: 0 6px 0 18px;" src="/images/plus.png" width="12px" height="12px">Add Mail Domain</a></td>
     <td style="text-align: right;"><input type="text" size="30" style="border: 2px solid #D3ECF8; padding: 2px 80px 3px 0;"> <button> Search </button></td>
 </tr><tr>
     <td style="padding: 0 0 0 18px;"><input type="checkbox" onclick="checkAll(this)"> <a style="padding: 0 4px 0 2px"> toggle all</a>

+ 1 - 1
web/templates/admin/menu_user.html

@@ -1,6 +1,6 @@
 <table class="sub-menu">
 <tr>
-    <td style="padding: 4px 0 10px 0;"><a href="/add/user/" class="add"><img style="padding: 0 6px 0 18px;" src="/images/plus.png" width="12px" height="12px">New User</a></td>
+    <td style="padding: 4px 0 10px 0;"><a href="/add/user/" class="add"><img style="padding: 0 6px 0 18px;" src="/images/plus.png" width="12px" height="12px">Add User</a></td>
     <td style="text-align: right;"><input type="text" size="30" style="border: 2px solid #D3ECF8; padding: 2px 80px 3px 0;"> <button> Search </button></td>
 </tr><tr>
     <td style="padding: 0 0 0 18px;"><input type="checkbox" onclick="checkAll(this)"> <a style="padding: 0 4px 0 2px"> toggle all</a>

+ 1 - 1
web/templates/admin/menu_web.html

@@ -1,6 +1,6 @@
 <table class="sub-menu">
 <tr>
-    <td style="padding: 4px 0 10px 0;"><a href="#" class="add"><img style="padding: 0 6px 0 18px;" src="/images/plus.png" width="12px" height="12px">New Web Domain</a></td>
+    <td style="padding: 4px 0 10px 0;"><a href="#" class="add"><img style="padding: 0 6px 0 18px;" src="/images/plus.png" width="12px" height="12px">Add Web Domain</a></td>
     <td style="text-align: right;"><input type="text" size="30" style="border: 2px solid #D3ECF8; padding: 2px 80px 3px 0;"> <button> Search </button></td>
 </tr><tr>
     <td style="padding: 0 0 0 18;"><input type="checkbox" onclick="checkAll(this)"> <a style="padding: 0 4px 0 2px"> toggle all</a>

+ 2 - 1
web/templates/header.html

@@ -460,7 +460,8 @@ if (!empty($_SESSION['look'])) {
     }
 
     .add-input {
-        padding: 4px 80px 3px 0;
+        width: 280px;
+        padding: 4px;
         font-size: 14pt;
         color: #555;
     }