[UP] HHH_a, cgi can work perfect now, use escape and unescape lib
[archserver.git] / mail / postfix / cgi / user.lua
blobdad7f4c4e42799832a011010007b752aefaa7091
1 #!/usr/bin/lua
2 dofile "lib.inc";
4 function cb_head()
5 print([[<script type="text/javascript">
6 function do_submit()
10 function do_cancel()
14 function init()
18 </script>]])
19 end
21 function cb_table()
22 local i = 0;
23 local _td01 = "</td><td>";
25 --[[rows(con, "select id,email,clear,crypt,name,uid,gid,homedir,maildir,quota,access,"..
26 "postfix,disablepop3,disableimap,disablewebmail,sharedgroup,smtpaccess"..
27 " from postfix_users")
29 -- XXX do not show some fields
30 -- should we design a model to describe database, then will easy when database structure changed
31 -- email quota access postfix disablepop3 disableimap disablewebmail smtpaccess
33 print('<tr class="th"><td width="25%">'..lang.email..
34 '</td><td width="10%">' ..lang.quota..
35 '</td><td width="6%">' ..lang.access..
36 '</td><td width="8%">' ..lang.postfix..
37 '</td><td width="8%">' ..lang.disablepop3..
38 '</td><td width="8%">' ..lang.disableimap..
39 '</td><td width="12%">' ..lang.disablewebmail..
40 '</td><td width="8%">' ..lang.smtpaccess..
41 '</td><td>' ..lang.action..
42 '</td></tr>');
43 for id,email,clear,crypt,name,uid,gid,homedir,maildir,quota,access,postfix,disablespop3,
44 disableimap,disablewebmail,sharedgroup,smtpaccess
46 rows(con, "select id,email,clear,crypt,name,uid,gid,homedir,maildir,quota,access,"..
47 "postfix,disablepop3,disableimap,disablewebmail,sharedgroup,smtpaccess"..
48 " from postfix_users")
50 print('<tr class="tr_' .. (i%2) .. '"><td>' ..
51 email .. _td01 ..
52 quota .. _td01 ..
53 access .. _td01 ..
54 postfix .. _td01 ..
55 disablespop3 .. _td01 ..
56 disableimap .. _td01 ..
57 disablewebmail .. _td01 ..
58 smtpaccess .. _td01 ..
59 '</tr>');
60 i = i + 1;
61 end
62 end
64 -- create all element for add/edit in the form
65 function out_edit_element()
66 print('<tr><td width="120px">'..lang.email..'</td><td><input type=text id=email name=email>'..'</td>'
67 ..'<tr><td>'..lang.quota..'</td><td><input type=text id=quota name=quota>'..'</td>'
68 ..'<tr><td>'..lang.access..'</td><td><input type=text id=access name=access>'..'</td>'
69 ..'<tr><td>'..lang.postfix..'</td><td><input type=text id=postfix name=postfix>'..'</td>'
70 ..'<tr><td>'..lang.disablepop3..'</td><td><input type=text id=dpop3 name=dpop3>'..'</td>'
71 ..'<tr><td>'..lang.disableimap..'</td><td><input type=text id=dimap name=dimap>'..'</td>'
72 ..'<tr><td>'..lang.disablewebmail..'</td><td><input type=text id=dwebmail name=dwebmail>'..'</td>'
73 ..'<tr><td>'..lang.smtpaccess..'</td><td><input type=text id=smtpac name=smtpac>'..'</td>'
74 ..'<tr><td>&nbsp;</td><td><input type=submit id=submit name=submit onclick="do_submit();" value="'
75 ..lang.submit..'">&nbsp;<input type=button id=cancel onclick="do_cancel();" value="'
76 ..lang.cancel..'"></td></tr>');
77 end
79 function cb_form()
80 as_table(out_edit_element, "100%", "");
81 as_table(cb_table, "100%", "");
82 end
84 function cb_body()
85 print("<b>" .. lang["postfix user management"] .. ":</b><p>");
86 db_open();
87 --[[
88 for email, pwd in rows(con, "select email,clear from postfix_users") do
89 print(string.format ("%s:%s<br>", email, pwd));
90 end
92 show_errmsg()
93 as_form(cb_form, "do_user");
94 end
96 -- within framework
97 as_head(cb_head, lang["postfix user management"]);
98 as_body(cb_body, "init();");