Skip to content

Commit f91f23a

Browse files
committed
edit user
1 parent e7f7371 commit f91f23a

20 files changed

+268
-13
lines changed

bin/v_add_database

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ source $VESTA/func/db.sh
3232

3333
# Hiding password
3434
A4='******'
35+
EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
36+
EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
3537

3638

3739
#----------------------------------------------------------#

bin/v_add_mail_account

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ source $VESTA/func/domain.sh
2525

2626
# Hiding password
2727
A4='******'
28+
EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
29+
EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
2830

2931

3032
#----------------------------------------------------------#

bin/v_add_user

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ source $VESTA/func/main.sh
2323

2424
# Hiding password
2525
A2='******'
26+
EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
27+
EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
2628

2729
is_user_free() {
2830
check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" )

bin/v_add_web_domain_stats_user

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ source $VESTA/func/domain.sh
2222

2323
# Hiding password
2424
A4='******'
25+
EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
26+
EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
2527

2628

2729
#----------------------------------------------------------#

bin/v_change_database_password

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ source $VESTA/func/db.sh
2222

2323
# Hiding password
2424
A3='******'
25+
EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
26+
EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
2527

2628

2729
#----------------------------------------------------------#

bin/v_change_mail_account_password

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ source $VESTA/func/domain.sh
2424

2525
# Hiding password
2626
A4='******'
27+
EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
28+
EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
2729

2830

2931
#----------------------------------------------------------#

bin/v_change_user_password

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ source $VESTA/conf/vesta.conf
1818
source $VESTA/func/main.sh
1919

2020
# Hiding password
21-
A2='******'
21+
A2="******"
22+
EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
23+
EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
2224

2325

2426
#----------------------------------------------------------#

web/add/user/index.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
// Cancel
1919
if (!empty($_POST['cancel'])) {
20-
echo $_POST['cancel'];
2120
header("Location: /list/user/");
2221
}
2322

web/edit/user/index.php

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
<?php
2+
// Init
3+
//error_reporting(NULL);
4+
ob_start();
5+
session_start();
6+
$TAB = 'USER';
7+
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
8+
9+
// Header
10+
include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
11+
12+
// Panel
13+
top_panel($user,$TAB);
14+
15+
// Are you admin?
16+
if ($_SESSION['user'] == 'admin') {
17+
18+
// Check user argument?
19+
if (empty($_GET['user'])) {
20+
header("Location: /list/user/");
21+
}
22+
23+
if (!empty($_POST['cancel'])) {
24+
header("Location: /list/user/");
25+
}
26+
27+
// Check user
28+
$v_username = escapeshellarg($_GET['user']);
29+
exec (VESTA_CMD."v_list_user ".$v_username." json", $output, $return_var);
30+
if ($return_var != 0) {
31+
$error = implode('<br>', $output);
32+
if (empty($error)) $error = 'Error: vesta did not return any output.';
33+
$_SESSION['error_msg'] = $error;
34+
} else {
35+
$data = json_decode(implode('', $output), true);
36+
$v_username = $_GET['user'];
37+
$v_password = "••••••••";
38+
$v_email = $data[$v_username]['CONTACT'];
39+
$v_package = $data[$v_username]['PACKAGE'];
40+
$v_fname = $data[$v_username]['FNAME'];
41+
$v_lname = $data[$v_username]['LNAME'];
42+
$v_shell = $data[$v_username]['SHELL'];
43+
$v_ns = $data[$v_username]['NS'];
44+
$nameservers = explode(", ", $v_ns);
45+
$v_ns1 = $nameservers[0];
46+
$v_ns2 = $nameservers[1];
47+
$v_ns3 = $nameservers[2];
48+
$v_ns4 = $nameservers[3];
49+
50+
unset($output);
51+
52+
exec (VESTA_CMD."v_list_user_packages json", $output, $return_var);
53+
$packages = json_decode(implode('', $output), true);
54+
unset($output);
55+
56+
exec (VESTA_CMD."v_list_sys_shells json", $output, $return_var);
57+
$shells = json_decode(implode('', $output), true);
58+
unset($output);
59+
}
60+
61+
if (!empty($_POST['save'])) {
62+
$v_username = escapeshellarg($_POST['v_username']);
63+
64+
if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) {
65+
$v_password = escapeshellarg($_POST['v_password']);
66+
exec (VESTA_CMD."v_change_user_password ".$v_username." ".$v_password, $output, $return_var);
67+
if ($return_var != 0) {
68+
$error = implode('<br>', $output);
69+
if (empty($error)) $error = 'Error: vesta did not return any output.';
70+
$_SESSION['error_msg'] = $error;
71+
}
72+
$v_password = "••••••••";
73+
unset($output);
74+
}
75+
76+
if (($v_package != $_POST['v_package']) && (empty($_SESSION['error_msg']))) {
77+
$v_package = escapeshellarg($_POST['v_package']);
78+
exec (VESTA_CMD."v_change_user_package ".$v_username." ".$v_package, $output, $return_var);
79+
if ($return_var != 0) {
80+
$error = implode('<br>', $output);
81+
if (empty($error)) $error = 'Error: vesta did not return any output.';
82+
$_SESSION['error_msg'] = $error;
83+
}
84+
unset($output);
85+
}
86+
87+
if (($v_shell != $_POST['v_shell']) && (empty($_SESSION['error_msg']))) {
88+
$v_shell = escapeshellarg($_POST['v_shell']);
89+
exec (VESTA_CMD."v_change_user_shell ".$v_username." ".$v_shell, $output, $return_var);
90+
if ($return_var != 0) {
91+
$error = implode('<br>', $output);
92+
if (empty($error)) $error = 'Error: vesta did not return any output.';
93+
$_SESSION['error_msg'] = $error;
94+
}
95+
unset($output);
96+
}
97+
98+
if (($v_email != $_POST['v_email']) && (empty($_SESSION['error_msg']))) {
99+
$v_email = escapeshellarg($_POST['v_email']);
100+
exec (VESTA_CMD."v_change_user_contact ".$v_username." ".$v_email, $output, $return_var);
101+
if ($return_var != 0) {
102+
$error = implode('<br>', $output);
103+
if (empty($error)) $error = 'Error: vesta did not return any output.';
104+
$_SESSION['error_msg'] = $error;
105+
}
106+
unset($output);
107+
}
108+
109+
if (($v_fname != $_POST['v_fname']) || ($v_lname != $_POST['v_lname']) && (empty($_SESSION['error_msg']))) {
110+
$v_fname = escapeshellarg($_POST['v_fname']);
111+
$v_lname = escapeshellarg($_POST['v_lname']);
112+
exec (VESTA_CMD."v_change_user_name ".$v_username." ".$v_fname." ".$v_lname, $output, $return_var);
113+
if ($return_var != 0) {
114+
$error = implode('<br>', $output);
115+
if (empty($error)) $error = 'Error: vesta did not return any output.';
116+
$_SESSION['error_msg'] = $error;
117+
}
118+
unset($output);
119+
}
120+
121+
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']))) {
122+
$v_ns1 = escapeshellarg($_POST['v_ns1']);
123+
$v_ns2 = escapeshellarg($_POST['v_ns2']);
124+
$v_ns3 = escapeshellarg($_POST['v_ns3']);
125+
$v_ns4 = escapeshellarg($_POST['v_ns4']);
126+
127+
$ns_cmd = VESTA_CMD."v_change_user_ns ".$v_username." ".$v_ns1." ".$v_ns2;
128+
if (!empty($_POST['v_ns3'])) $ns_cmd = $ns_cmd." ".$v_ns3;
129+
if (!empty($_POST['v_ns4'])) $ns_cmd = $ns_cmd." ".$v_ns4;
130+
exec ($ns_cmd, $output, $return_var);
131+
if ($return_var != 0) {
132+
$error = implode('<br>', $output);
133+
if (empty($error)) $error = 'Error: vesta did not return any output.';
134+
$_SESSION['error_msg'] = $error;
135+
}
136+
unset($output);
137+
}
138+
139+
if (empty($_SESSION['error_msg'])) {
140+
$_SESSION['ok_msg'] = "OK: changes has been saved.";
141+
}
142+
}
143+
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_user.html');
144+
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_user.html');
145+
unset($_SESSION['error_msg']);
146+
unset($_SESSION['ok_msg']);
147+
148+
149+
}
150+
151+
// Footer
152+
include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');

web/templates/admin/edit_user.html

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<script type="text/javascript">
2+
function randomString() {
3+
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
4+
var string_length = 10;
5+
var randomstring = '';
6+
for (var i=0; i<string_length; i++) {
7+
var rnum = Math.floor(Math.random() * chars.length);
8+
randomstring += chars.substring(rnum,rnum+1);
9+
}
10+
document.v_edit_user.v_password.value = randomstring;
11+
}
12+
</script>
13+
<table class='data'>
14+
<tr class="data-add">
15+
<td class="data-dotted" style="padding: 0px 10px 0px 0px" width="150">
16+
<table class="data-col1">
17+
<tr><td style="padding: 18 0 4 18;"></td></tr>
18+
</table>
19+
</td>
20+
<td class="data-dotted" width="830px" style="vertical-align:top;">
21+
<table width="830px"><tr>
22+
<td></td>
23+
</tr></table>
24+
<form method="post" name="v_edit_user">
25+
<table class="data-col2" width="830px">
26+
<tr><td class="add-text" style="padding: 10 0 0 2px;">Username</td></tr>
27+
<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>
28+
<tr><td class="add-text" style="padding: 10px 0 0 2px;">
29+
Password <a href="#" onclick="randomString();" class="genpass">generate</a></td></tr>
30+
<tr><td><input type="text" size="20" class="add-input" name="v_password" <?php if (!empty($v_password)) echo "value=".$v_password; ?>></tr>
31+
<tr><td class="add-text" style="padding: 10px 0 0 2px;">Email</td></tr>
32+
<tr><td><input type="text" size="20" class="add-input" name="v_email" <?php if (!empty($v_email)) echo "value=".$v_email; ?>></tr>
33+
<tr><td class="add-text" style="padding: 10px 0 0 2px;" >Package</td></tr>
34+
<tr><td><select class="add-list" name="v_package">
35+
<?php
36+
foreach ($packages as $key => $value) {
37+
echo "\t\t\t\t<option value=\"".$key."\"";
38+
if ((!empty($v_package)) && ( $key == $v_package)){
39+
echo 'selected' ;
40+
}
41+
echo ">".$key."</option>\n";
42+
}
43+
?>
44+
</select></td></tr>
45+
<tr><td class="add-text" style="padding: 10px 0 0 2px;">Frist Name</td></tr>
46+
<tr><td><input type="text" size="20" class="add-input" name="v_fname" <?php if (!empty($v_fname)) echo "value=".$v_fname; ?>></tr>
47+
<tr><td class="add-text" style="padding: 10px 0 0 2px;">Last Name</td></tr>
48+
<tr><td><input type="text" size="20" class="add-input" name="v_lname" <?php if (!empty($v_lname)) echo "value=".$v_lname; ?>></tr>
49+
<tr><td class="add-text" style="padding: 10px 0 0 2px;" >Shell</td></tr>
50+
<tr><td><select class="add-list" name="v_shell">
51+
<?php
52+
foreach ($shells as $key => $value) {
53+
echo "\t\t\t\t<option value=\"".$value."\"";
54+
if ((!empty($v_shell)) && ( $value == $v_shell)){
55+
echo 'selected' ;
56+
}
57+
echo ">".$value."</option>\n";
58+
}
59+
?>
60+
</select></td></tr>
61+
<tr><td class="add-text" style="padding: 10px 0 0 2px;">Name Servers </td></tr>
62+
<tr><td><input type="text" size="20" class="add-input" name="v_ns1" <?php if (!empty($v_ns1)) echo "value=".$v_ns1; ?>></tr>
63+
<tr><td><input type="text" size="20" class="add-input" name="v_ns2" <?php if (!empty($v_ns2)) echo "value=".$v_ns2; ?>></tr>
64+
<tr><td><input type="text" size="20" class="add-input" name="v_ns3" <?php if (!empty($v_ns3)) echo "value=".$v_ns3; ?>></tr>
65+
<tr><td><input type="text" size="20" class="add-input" name="v_ns4" <?php if (!empty($v_ns4)) echo "value=".$v_ns4; ?>></tr>
66+
<tr><td style="padding: 24px 0 0 0;">
67+
<input type="submit" class="add-button" name="save" value="Save">
68+
<input type="submit" class="add-button" name="cancel" value="Cancel">
69+
</td></tr>
70+
</form>
71+
</table>
72+
</td>
73+
</tr>
74+
</table>

0 commit comments

Comments
 (0)