6 local user_list
= get_samba_user()
7 local options
= "<option id=_select style=\"color:blue;\" value=myselect selected>------ 用户列表 ------</option>"
8 local hiddens
= [[<input type=hidden id="myselect">]]
9 local style
= [[style="background-image:url(icons/volume.png);"]]
11 for u
in pairs(user_list
) do
12 options
= options
..[[<option ]]..style
..[[ value="]]..u
..[[">]]..u
..[[</option>]]
17 <form action="shares_manager_user.cgi",method="post">
18 <table width="80%"><tr><td>
19 <select class="icon-menu" name="selTitle" size=10 id="titles" onchange="setOtherText(this)" width="100%">
27 <table width="90%" cellspacing="2" cellpadding="5" border="0">
28 <tr class=color_table_row1><td>
30 <input type="text" id="user_name" name="user_name">
32 <tr class=color_table_row2><td>
34 <input type="password" id="passwd" name="passwd">
36 <tr class=color_table_row1><td>
38 <input type="password" id="passwd_cf" name="passwd_cf">
41 <input type=hidden name=todo value="">
42 <input type="submit" value="新建用户" onclick="return mysubmit(1)">
43 <input type="submit" value="更新用户" onclick="return mysubmit(2)">
44 <input type="submit" value="删除用户" onclick="return mysubmit(3)">
53 function setOtherText(obj) {
54 if (!document.layers) {
55 var user = document.getElementById("user_name");
56 var passwd = document.getElementById("passwd");
57 var passwd_cf = document.getElementById("passwd_cf");
58 user.value = obj.value;
59 if (obj.value == "myselect") {
66 function mysubmit(value) {
68 document.forms[0].todo.value="create_user";
69 } else if (value == 2) {
70 document.forms[0].todo.value="update_user";
71 } else if (value == 3) {
72 var ss = "您要删除用户\""+document.getElementById("user_name").value + "\"吗?";
74 document.forms[0].todo.value="delete_user";
79 document.forms[0].submit();
85 -------------------------
87 -------------------------
90 print("todo="..qp
.todo
)
93 elseif qp
.todo
== "create_user" then
94 local user_list
= get_samba_user()
96 if qp
.user_name
and user_list
[qp
.user_name
] then
97 ui_message_err("用户 <strong>\""..qp
.user_name
.."\" </strong>已存在")
101 if qp
.username
=="" or qp
.passwd
=="" or qp
.passwd_cf
=="" then
102 ui_message_err("用户名和密码不能为空.")
106 if qp
.passwd
~= qp
.passwd_cf
then
107 ui_message_err("密码和确认密码不符.")
112 err
,ret
= myexec("sudo useradd "..qp
.user_name
)
113 if ret
~= 0 then ui_message_err(err
) return end
114 err
,ret
= myexec("(echo "..qp
.passwd
.."; echo "..qp
.passwd
..")|sudo smbpasswd -L -s -a "..qp
.user_name
)
115 if ret
~= 0 then ui_message_err(err
) return end
117 ui_message_success("添加用户: "..qp
.user_name
)
119 elseif qp
.todo
== "update_user" then
120 local user_list
= get_samba_user()
122 if not qp
.user_name
or not user_list
[qp
.user_name
] then
123 ui_message_err("用户 <strong>\""..qp
.user_name
.."\" </strong>不存在")
127 if qp
.username
=="" or qp
.passwd
=="" or qp
.passwd_cf
=="" then
128 ui_message_err("用户名和密码不能为空.")
132 if qp
.passwd
~= qp
.passwd_cf
then
133 ui_message_err("密码和确认密码不符.")
138 err
,ret
= myexec("(echo "..qp
.passwd
.."; echo "..qp
.passwd
..")|sudo smbpasswd -L -s -a "..qp
.user_name
)
139 if ret
~= 0 then ui_message_err(err
) return end
140 ui_message_success("更改用户: "..qp
.user_name
)
142 elseif qp
.todo
=="delete_user" then
143 if true then print("df") return end
144 if qp
.user_name
== "" then
145 ui_message_err("用户名不能为空.")