mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-02 21:17:12 +02:00
* src/web/ejabberd_web.erl: Experiments with web-interface
SVN Revision: 214
This commit is contained in:
parent
20e297db3a
commit
a2b2d08ddc
|
@ -1,5 +1,7 @@
|
||||||
2004-03-12 Alexey Shchepin <alexey@sevcom.net>
|
2004-03-12 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
|
* src/web/ejabberd_web.erl: Experiments with web-interface
|
||||||
|
|
||||||
* src/configure.ac: Updated
|
* src/configure.ac: Updated
|
||||||
* src/Makefile.in: Likewise
|
* src/Makefile.in: Likewise
|
||||||
|
|
||||||
|
|
|
@ -93,22 +93,15 @@ process_config(#request{user = User,
|
||||||
path = ["acls"],
|
path = ["acls"],
|
||||||
q = Query,
|
q = Query,
|
||||||
lang = Lang} = Request) ->
|
lang = Lang} = Request) ->
|
||||||
case acl:match_rule(configure, jlib:make_jid(User, ?MYNAME, "")) of
|
Res = case lists:keysearch("acls", 1, Query) of
|
||||||
deny ->
|
{value, {_, String}} ->
|
||||||
{401, [], make_xhtml([?XC("h1", "Not Allowed")])};
|
case erl_scan:string(String) of
|
||||||
allow ->
|
{ok, Tokens, _} ->
|
||||||
Res = case lists:keysearch("acls", 1, Query) of
|
case erl_parse:parse_term(Tokens) of
|
||||||
{value, {_, String}} ->
|
{ok, NewACLs} ->
|
||||||
case erl_scan:string(String) of
|
case acl:add_list(NewACLs, true) of
|
||||||
{ok, Tokens, _} ->
|
ok ->
|
||||||
case erl_parse:parse_term(Tokens) of
|
ok;
|
||||||
{ok, NewACLs} ->
|
|
||||||
case acl:add_list(NewACLs, true) of
|
|
||||||
ok ->
|
|
||||||
ok;
|
|
||||||
_ ->
|
|
||||||
error
|
|
||||||
end;
|
|
||||||
_ ->
|
_ ->
|
||||||
error
|
error
|
||||||
end;
|
end;
|
||||||
|
@ -116,28 +109,80 @@ process_config(#request{user = User,
|
||||||
error
|
error
|
||||||
end;
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
nothing
|
error
|
||||||
end,
|
end;
|
||||||
ACLs = lists:flatten(io_lib:format("~p.", [ets:tab2list(acl)])),
|
_ ->
|
||||||
make_xhtml([?XC("h1", "ejabberd ACLs configuration")] ++
|
nothing
|
||||||
case Res of
|
end,
|
||||||
ok -> [?C("submited"), ?P];
|
ACLs = lists:flatten(io_lib:format("~p.", [ets:tab2list(acl)])),
|
||||||
error -> [?C("bad format"), ?P];
|
make_xhtml([?XC("h1", "ejabberd ACLs configuration")] ++
|
||||||
nothing -> []
|
case Res of
|
||||||
end ++
|
ok -> [?C("submited"), ?P];
|
||||||
[?XAE("form", [{"method", "post"}],
|
error -> [?C("bad format"), ?P];
|
||||||
[?XAC("textarea", [{"name", "acls"},
|
nothing -> []
|
||||||
{"rows", "16"},
|
end ++
|
||||||
{"cols", "80"}],
|
[?XAE("form", [{"method", "post"}],
|
||||||
ACLs),
|
[?XAC("textarea", [{"name", "acls"},
|
||||||
?BR,
|
{"rows", "16"},
|
||||||
?XA("input", [{"type", "submit"}])
|
{"cols", "80"}],
|
||||||
])
|
ACLs),
|
||||||
])
|
?BR,
|
||||||
end;
|
?XA("input", [{"type", "submit"}])
|
||||||
|
])
|
||||||
|
]);
|
||||||
|
|
||||||
|
process_config(#request{user = User,
|
||||||
|
path = ["acls2"],
|
||||||
|
q = Query,
|
||||||
|
lang = Lang} = Request) ->
|
||||||
|
ACLs = ets:tab2list(acl),
|
||||||
|
make_xhtml([?XC("h1", "ejabberd ACLs configuration")] ++
|
||||||
|
[?XAE("form", [{"method", "post"}],
|
||||||
|
[acls_to_xhtml(ACLs),
|
||||||
|
?BR,
|
||||||
|
?XA("input", [{"type", "submit"}])
|
||||||
|
])
|
||||||
|
]);
|
||||||
|
|
||||||
process_config(_Request) ->
|
process_config(_Request) ->
|
||||||
{404, [], make_xhtml([?XC("h1", "Not found")])}.
|
{404, [], make_xhtml([?XC("h1", "Not found")])}.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
acls_to_xhtml(ACLs) ->
|
||||||
|
?XAE("table", [],
|
||||||
|
[?XE("tbody",
|
||||||
|
lists:map(
|
||||||
|
fun({acl, Name, Spec}) ->
|
||||||
|
?XE("tr",
|
||||||
|
[?XC("td", atom_to_list(Name))] ++
|
||||||
|
acl_spec_to_xhtml(Spec)
|
||||||
|
)
|
||||||
|
end, ACLs)
|
||||||
|
)]).
|
||||||
|
|
||||||
|
-define(ACLINPUT(Text), ?XE("td", [?XA("input", [{"type", "text"},
|
||||||
|
{"name", ""},
|
||||||
|
{"value", Text}])])).
|
||||||
|
|
||||||
|
acl_spec_to_xhtml({user, U}) ->
|
||||||
|
[acl_spec_select(user), ?ACLINPUT(U)];
|
||||||
|
|
||||||
|
acl_spec_to_xhtml(Spec) ->
|
||||||
|
[acl_spec_select(raw),
|
||||||
|
?ACLINPUT(lists:flatten(io_lib:format("~p.", [Spec])))
|
||||||
|
].
|
||||||
|
|
||||||
|
acl_spec_select(Opt) ->
|
||||||
|
?XE("td",
|
||||||
|
[?XAE("select", [{"name", ""}],
|
||||||
|
lists:map(
|
||||||
|
fun(O) ->
|
||||||
|
Sel = if
|
||||||
|
O == Opt -> [{"selected", "selected"}];
|
||||||
|
true -> []
|
||||||
|
end,
|
||||||
|
?XAC("option",
|
||||||
|
Sel ++ [{"value", atom_to_list(O)}],
|
||||||
|
atom_to_list(O))
|
||||||
|
end, [all, user, server, raw]))]).
|
||||||
|
|
Loading…
Reference in New Issue
Block a user