mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-02 21:17:12 +02:00
* src/web/ejabberd_web.erl: Added interface for users listsing and
statistics SVN Revision: 216
This commit is contained in:
parent
b4798f76a3
commit
60cb9fc959
|
@ -1,3 +1,8 @@
|
||||||
|
2004-03-14 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
|
* src/web/ejabberd_web.erl: Added interface for users listsing and
|
||||||
|
statistics
|
||||||
|
|
||||||
2004-03-13 Alexey Shchepin <alexey@sevcom.net>
|
2004-03-13 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
* src/web/ejabberd_web.erl: New interface for ACLs editing
|
* src/web/ejabberd_web.erl: New interface for ACLs editing
|
||||||
|
|
|
@ -47,7 +47,7 @@ make_xhtml(Els) ->
|
||||||
|
|
||||||
|
|
||||||
process_get(#request{user = User,
|
process_get(#request{user = User,
|
||||||
path = ["config" | RPath],
|
path = ["admin" | RPath],
|
||||||
q = Query,
|
q = Query,
|
||||||
lang = Lang} = Request) ->
|
lang = Lang} = Request) ->
|
||||||
if
|
if
|
||||||
|
@ -56,7 +56,7 @@ process_get(#request{user = User,
|
||||||
deny ->
|
deny ->
|
||||||
{401, [], make_xhtml([?XC("h1", "Not Allowed")])};
|
{401, [], make_xhtml([?XC("h1", "Not Allowed")])};
|
||||||
allow ->
|
allow ->
|
||||||
process_config(Request#request{path = RPath})
|
process_admin(Request#request{path = RPath})
|
||||||
end;
|
end;
|
||||||
true ->
|
true ->
|
||||||
{401,
|
{401,
|
||||||
|
@ -76,21 +76,22 @@ process_get(_Request) ->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
process_config(#request{user = User,
|
process_admin(#request{user = User,
|
||||||
path = [],
|
path = [],
|
||||||
q = Query,
|
q = Query,
|
||||||
lang = Lang} = Request) ->
|
lang = Lang} = Request) ->
|
||||||
make_xhtml([?XC("h1", "ejabberd configuration"),
|
make_xhtml([?XC("h1", "ejabberd administration"),
|
||||||
?XE("ul",
|
?XE("ul",
|
||||||
[?LI([?AC("acls/", "Access Control Lists"), ?C(" "),
|
[?LI([?AC("acls/", "Access Control Lists"), ?C(" "),
|
||||||
?AC("acls-raw/", "(raw)")]),
|
?AC("acls-raw/", "(raw)")]),
|
||||||
?LI([?AC("access/", "Access Rules")]),
|
?LI([?AC("access/", "Access Rules")]),
|
||||||
?LI([?AC("users/", "Users")]),
|
?LI([?AC("users/", "Users")]),
|
||||||
?LI([?AC("nodes/", "Nodes")])
|
?LI([?AC("nodes/", "Nodes")]),
|
||||||
|
?LI([?AC("stats/", "Statistics")])
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
process_config(#request{user = User,
|
process_admin(#request{user = User,
|
||||||
path = ["acls-raw"],
|
path = ["acls-raw"],
|
||||||
q = Query,
|
q = Query,
|
||||||
lang = Lang} = Request) ->
|
lang = Lang} = Request) ->
|
||||||
|
@ -132,7 +133,7 @@ process_config(#request{user = User,
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
process_config(#request{method = Method,
|
process_admin(#request{method = Method,
|
||||||
user = User,
|
user = User,
|
||||||
path = ["acls"],
|
path = ["acls"],
|
||||||
q = Query,
|
q = Query,
|
||||||
|
@ -176,7 +177,28 @@ process_config(#request{method = Method,
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
process_config(_Request) ->
|
process_admin(#request{user = User,
|
||||||
|
path = ["users"],
|
||||||
|
q = Query,
|
||||||
|
lang = Lang} = Request) ->
|
||||||
|
Res = list_users(),
|
||||||
|
make_xhtml([?XC("h1", "ejabberd users")] ++ Res);
|
||||||
|
|
||||||
|
process_admin(#request{user = User,
|
||||||
|
path = ["users", Diap],
|
||||||
|
q = Query,
|
||||||
|
lang = Lang} = Request) ->
|
||||||
|
Res = list_users_in_diapason(Diap),
|
||||||
|
make_xhtml([?XC("h1", "ejabberd users")] ++ Res);
|
||||||
|
|
||||||
|
process_admin(#request{user = User,
|
||||||
|
path = ["stats"],
|
||||||
|
q = Query,
|
||||||
|
lang = Lang} = Request) ->
|
||||||
|
Res = get_stats(),
|
||||||
|
make_xhtml([?XC("h1", "ejabberd stats")] ++ Res);
|
||||||
|
|
||||||
|
process_admin(_Request) ->
|
||||||
{404, [], make_xhtml([?XC("h1", "Not found")])}.
|
{404, [], make_xhtml([?XC("h1", "Not found")])}.
|
||||||
|
|
||||||
|
|
||||||
|
@ -320,3 +342,60 @@ acl_parse_delete(ACLs, Query) ->
|
||||||
NewACLs.
|
NewACLs.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
list_users() ->
|
||||||
|
Users = ejabberd_auth:dirty_get_registered_users(),
|
||||||
|
SUsers = lists:sort(Users),
|
||||||
|
case length(SUsers) of
|
||||||
|
N when N =< 100 ->
|
||||||
|
lists:flatmap(
|
||||||
|
fun(U) ->
|
||||||
|
[?AC("../user/" ++ U, U), ?BR]
|
||||||
|
end, SUsers);
|
||||||
|
N ->
|
||||||
|
NParts = trunc(math:sqrt(N * 0.618)) + 1,
|
||||||
|
M = trunc(N / NParts) + 1,
|
||||||
|
lists:flatmap(
|
||||||
|
fun(K) ->
|
||||||
|
L = K + M - 1,
|
||||||
|
Node = integer_to_list(K) ++ "-" ++ integer_to_list(L),
|
||||||
|
Last = if L < N -> lists:nth(L, SUsers);
|
||||||
|
true -> lists:last(SUsers)
|
||||||
|
end,
|
||||||
|
Name =
|
||||||
|
lists:nth(K, SUsers) ++ " -- " ++
|
||||||
|
Last,
|
||||||
|
[?AC(Node ++ "/", Name), ?BR]
|
||||||
|
end, lists:seq(1, N, M))
|
||||||
|
end.
|
||||||
|
|
||||||
|
list_users_in_diapason(Diap) ->
|
||||||
|
Users = ejabberd_auth:dirty_get_registered_users(),
|
||||||
|
SUsers = lists:sort(Users),
|
||||||
|
{ok, [S1, S2]} = regexp:split(Diap, "-"),
|
||||||
|
N1 = list_to_integer(S1),
|
||||||
|
N2 = list_to_integer(S2),
|
||||||
|
Sub = lists:sublist(SUsers, N1, N2 - N1 + 1),
|
||||||
|
lists:flatmap(
|
||||||
|
fun(U) ->
|
||||||
|
[?AC("../../user/" ++ U, U), ?BR]
|
||||||
|
end, Sub).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
get_stats() ->
|
||||||
|
OnlineUsers = mnesia:table_info(presence, size),
|
||||||
|
AuthUsers = mnesia:table_info(session, size),
|
||||||
|
RegisteredUsers = mnesia:table_info(passwd, size),
|
||||||
|
|
||||||
|
[?XAE("table", [],
|
||||||
|
[?XE("tbody",
|
||||||
|
[?XE("tr", [?XC("td", "Registered users"),
|
||||||
|
?XC("td", integer_to_list(RegisteredUsers))]),
|
||||||
|
?XE("tr", [?XC("td", "Authentificated users"),
|
||||||
|
?XC("td", integer_to_list(AuthUsers))]),
|
||||||
|
?XE("tr", [?XC("td", "Online users"),
|
||||||
|
?XC("td", integer_to_list(OnlineUsers))])
|
||||||
|
])
|
||||||
|
|
||||||
|
])].
|
||||||
|
|
Loading…
Reference in New Issue
Block a user