mirror of
https://github.com/processone/ejabberd.git
synced 2024-09-27 14:30:55 +02:00
Revert "Pass base path instead of level to support URL missing slash (#3177)"
This reverts commit e9d1201ea8
.
This commit is contained in:
parent
1ffa9a0cf5
commit
73ba38ae35
@ -29,8 +29,8 @@
|
|||||||
|
|
||||||
-author('alexey@process-one.net').
|
-author('alexey@process-one.net').
|
||||||
|
|
||||||
-export([process/2, list_users/5,
|
-export([process/2, list_users/4,
|
||||||
list_users_in_diapason/5, pretty_print_xml/1,
|
list_users_in_diapason/4, pretty_print_xml/1,
|
||||||
term_to_id/1]).
|
term_to_id/1]).
|
||||||
|
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
@ -95,20 +95,20 @@ get_jid(Auth, HostHTTP, Method) ->
|
|||||||
throw({unauthorized, Auth})
|
throw({unauthorized, Auth})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_menu_items(global, cluster, Lang, JID, Base) ->
|
get_menu_items(global, cluster, Lang, JID, Level) ->
|
||||||
{_BaseURL, _, Items} = make_server_menu([], [], Lang, JID, Base),
|
{_Base, _, Items} = make_server_menu([], [], Lang, JID, Level),
|
||||||
lists:map(fun ({URI, Name}) ->
|
lists:map(fun ({URI, Name}) ->
|
||||||
{<<Base/binary, URI/binary, "/">>, Name};
|
{<<URI/binary, "/">>, Name};
|
||||||
({URI, Name, _SubMenu}) ->
|
({URI, Name, _SubMenu}) ->
|
||||||
{<<Base/binary, URI/binary, "/">>, Name}
|
{<<URI/binary, "/">>, Name}
|
||||||
end,
|
end,
|
||||||
Items);
|
Items);
|
||||||
get_menu_items(Host, cluster, Lang, JID, Base) ->
|
get_menu_items(Host, cluster, Lang, JID, Level) ->
|
||||||
{_BaseURL, _, Items} = make_host_menu(Host, [], Lang, JID, Base),
|
{_Base, _, Items} = make_host_menu(Host, [], Lang, JID, Level),
|
||||||
lists:map(fun ({URI, Name}) ->
|
lists:map(fun ({URI, Name}) ->
|
||||||
{<<Base/binary, URI/binary, "/">>, Name};
|
{<<URI/binary, "/">>, Name};
|
||||||
({URI, Name, _SubMenu}) ->
|
({URI, Name, _SubMenu}) ->
|
||||||
{<<Base/binary, URI/binary, "/">>, Name}
|
{<<URI/binary, "/">>, Name}
|
||||||
end,
|
end,
|
||||||
Items).
|
Items).
|
||||||
|
|
||||||
@ -123,10 +123,10 @@ get_menu_items(Host, cluster, Lang, JID, Base) ->
|
|||||||
%% Items
|
%% Items
|
||||||
%% ).
|
%% ).
|
||||||
|
|
||||||
is_allowed_path(Base, {Path, _}, JID) ->
|
is_allowed_path(BasePath, {Path, _}, JID) ->
|
||||||
is_allowed_path(Base ++ [Path], JID);
|
is_allowed_path(BasePath ++ [Path], JID);
|
||||||
is_allowed_path(Base, {Path, _, _}, JID) ->
|
is_allowed_path(BasePath, {Path, _, _}, JID) ->
|
||||||
is_allowed_path(Base ++ [Path], JID).
|
is_allowed_path(BasePath ++ [Path], JID).
|
||||||
|
|
||||||
is_allowed_path([<<"admin">> | Path], JID) ->
|
is_allowed_path([<<"admin">> | Path], JID) ->
|
||||||
is_allowed_path(Path, JID);
|
is_allowed_path(Path, JID);
|
||||||
@ -152,7 +152,7 @@ url_to_path(URL) -> str:tokens(URL, <<"/">>).
|
|||||||
|
|
||||||
process([<<"server">>, SHost | RPath] = Path,
|
process([<<"server">>, SHost | RPath] = Path,
|
||||||
#request{auth = Auth, lang = Lang, host = HostHTTP,
|
#request{auth = Auth, lang = Lang, host = HostHTTP,
|
||||||
path = RequestPath, method = Method} =
|
method = Method} =
|
||||||
Request) ->
|
Request) ->
|
||||||
Host = jid:nameprep(SHost),
|
Host = jid:nameprep(SHost),
|
||||||
case ejabberd_router:is_my_host(Host) of
|
case ejabberd_router:is_my_host(Host) of
|
||||||
@ -160,8 +160,7 @@ process([<<"server">>, SHost | RPath] = Path,
|
|||||||
case get_auth_admin(Auth, HostHTTP, Path, Method) of
|
case get_auth_admin(Auth, HostHTTP, Path, Method) of
|
||||||
{ok, {User, Server}} ->
|
{ok, {User, Server}} ->
|
||||||
AJID = get_jid(Auth, HostHTTP, Method),
|
AJID = get_jid(Auth, HostHTTP, Method),
|
||||||
Base = extract_base_path(RequestPath, Path),
|
process_admin(Host,
|
||||||
process_admin(Base, Host,
|
|
||||||
Request#request{path = RPath,
|
Request#request{path = RPath,
|
||||||
us = {User, Server}},
|
us = {User, Server}},
|
||||||
AJID);
|
AJID);
|
||||||
@ -188,13 +187,12 @@ process([<<"server">>, SHost | RPath] = Path,
|
|||||||
end;
|
end;
|
||||||
process(RPath,
|
process(RPath,
|
||||||
#request{auth = Auth, lang = Lang, host = HostHTTP,
|
#request{auth = Auth, lang = Lang, host = HostHTTP,
|
||||||
path = Path, method = Method} =
|
method = Method} =
|
||||||
Request) ->
|
Request) ->
|
||||||
Base = extract_base_path(Path, RPath),
|
|
||||||
case get_auth_admin(Auth, HostHTTP, RPath, Method) of
|
case get_auth_admin(Auth, HostHTTP, RPath, Method) of
|
||||||
{ok, {User, Server}} ->
|
{ok, {User, Server}} ->
|
||||||
AJID = get_jid(Auth, HostHTTP, Method),
|
AJID = get_jid(Auth, HostHTTP, Method),
|
||||||
process_admin(Base, global,
|
process_admin(global,
|
||||||
Request#request{path = RPath,
|
Request#request{path = RPath,
|
||||||
us = {User, Server}},
|
us = {User, Server}},
|
||||||
AJID);
|
AJID);
|
||||||
@ -268,15 +266,16 @@ get_auth_account2(HostOfRule, AccessRule, User, Server,
|
|||||||
%%%==================================
|
%%%==================================
|
||||||
%%%% make_xhtml
|
%%%% make_xhtml
|
||||||
|
|
||||||
make_xhtml(Els, Host, Lang, JID, Base) ->
|
make_xhtml(Els, Host, Lang, JID, Level) ->
|
||||||
make_xhtml(Els, Host, cluster, Lang, JID, Base).
|
make_xhtml(Els, Host, cluster, Lang, JID, Level).
|
||||||
|
|
||||||
%% @spec (Els, Host, Node, Lang, JID) -> {200, [html], xmlelement()}
|
%% @spec (Els, Host, Node, Lang, JID) -> {200, [html], xmlelement()}
|
||||||
%% where Host = global | string()
|
%% where Host = global | string()
|
||||||
%% Node = cluster | atom()
|
%% Node = cluster | atom()
|
||||||
%% JID = jid()
|
%% JID = jid()
|
||||||
make_xhtml(Els, Host, Node, Lang, JID, Base) ->
|
make_xhtml(Els, Host, Node, Lang, JID, Level) ->
|
||||||
MenuItems = make_navigation(Host, Node, Lang, JID, Base),
|
Base = get_base_path_sum(0, 0, Level),
|
||||||
|
MenuItems = make_navigation(Host, Node, Lang, JID, Level),
|
||||||
{200, [html],
|
{200, [html],
|
||||||
#xmlel{name = <<"html">>,
|
#xmlel{name = <<"html">>,
|
||||||
attrs =
|
attrs =
|
||||||
@ -334,19 +333,19 @@ make_xhtml(Els, Host, Node, Lang, JID, Base) ->
|
|||||||
direction(<<"he">>) -> [{<<"dir">>, <<"rtl">>}];
|
direction(<<"he">>) -> [{<<"dir">>, <<"rtl">>}];
|
||||||
direction(_) -> [].
|
direction(_) -> [].
|
||||||
|
|
||||||
extract_base_path(Path, RPath) ->
|
get_base_path(Host, Node, Level) ->
|
||||||
Base = lists:sublist(Path, length(Path)-length(RPath)),
|
SumHost = case Host of
|
||||||
iolist_to_binary("/" ++ lists:join("/", Base) ++ "/").
|
global -> 0;
|
||||||
|
_ -> -2
|
||||||
|
end,
|
||||||
|
SumNode = case Node of
|
||||||
|
cluster -> 0;
|
||||||
|
_ -> -2
|
||||||
|
end,
|
||||||
|
get_base_path_sum(SumHost, SumNode, Level).
|
||||||
|
|
||||||
get_base_path(global, cluster, Base) -> Base;
|
get_base_path_sum(SumHost, SumNode, Level) ->
|
||||||
get_base_path(Host, cluster, Base) ->
|
iolist_to_binary(lists:duplicate(Level + SumHost + SumNode, "../")).
|
||||||
<<Base/binary, "/server/", Host/binary, "/">>;
|
|
||||||
get_base_path(global, Node, Base) ->
|
|
||||||
<<Base/binary, "/node/",
|
|
||||||
(iolist_to_binary(atom_to_list(Node)))/binary, "/">>;
|
|
||||||
get_base_path(Host, Node, Base) ->
|
|
||||||
<<Base/binary, "/server/", Host/binary, "/node/",
|
|
||||||
(iolist_to_binary(atom_to_list(Node)))/binary, "/">>.
|
|
||||||
|
|
||||||
%%%==================================
|
%%%==================================
|
||||||
%%%% css & images
|
%%%% css & images
|
||||||
@ -357,11 +356,11 @@ additions_js() ->
|
|||||||
{error, _} -> <<>>
|
{error, _} -> <<>>
|
||||||
end.
|
end.
|
||||||
|
|
||||||
css(Base, Host) ->
|
css(Host) ->
|
||||||
case misc:read_css("admin.css") of
|
case misc:read_css("admin.css") of
|
||||||
{ok, CSS} ->
|
{ok, CSS} ->
|
||||||
BP = get_base_path(Host, cluster, Base),
|
Base = get_base_path(Host, cluster, 0),
|
||||||
re:replace(CSS, <<"@BASE@">>, BP, [{return, binary}]);
|
re:replace(CSS, <<"@BASE@">>, Base, [{return, binary}]);
|
||||||
{error, _} ->
|
{error, _} ->
|
||||||
<<>>
|
<<>>
|
||||||
end.
|
end.
|
||||||
@ -387,73 +386,73 @@ logo_fill() ->
|
|||||||
%%%==================================
|
%%%==================================
|
||||||
%%%% process_admin
|
%%%% process_admin
|
||||||
|
|
||||||
process_admin(Base, global, #request{path = [], lang = Lang}, AJID) ->
|
process_admin(global, #request{path = [], lang = Lang}, AJID) ->
|
||||||
make_xhtml((?H1GL((translate:translate(Lang, ?T("Administration"))), <<"">>,
|
make_xhtml((?H1GL((translate:translate(Lang, ?T("Administration"))), <<"">>,
|
||||||
<<"Contents">>))
|
<<"Contents">>))
|
||||||
++
|
++
|
||||||
[?XE(<<"ul">>,
|
[?XE(<<"ul">>,
|
||||||
[?LI([?ACT(MIU, MIN)])
|
[?LI([?ACT(MIU, MIN)])
|
||||||
|| {MIU, MIN}
|
|| {MIU, MIN}
|
||||||
<- get_menu_items(global, cluster, Lang, AJID, Base)])],
|
<- get_menu_items(global, cluster, Lang, AJID, 0)])],
|
||||||
global, Lang, AJID, Base);
|
global, Lang, AJID, 0);
|
||||||
process_admin(Base, Host, #request{path = [], lang = Lang}, AJID) ->
|
process_admin(Host, #request{path = [], lang = Lang}, AJID) ->
|
||||||
make_xhtml([?XCT(<<"h1">>, ?T("Administration")),
|
make_xhtml([?XCT(<<"h1">>, ?T("Administration")),
|
||||||
?XE(<<"ul">>,
|
?XE(<<"ul">>,
|
||||||
[?LI([?ACT(MIU, MIN)])
|
[?LI([?ACT(MIU, MIN)])
|
||||||
|| {MIU, MIN}
|
|| {MIU, MIN}
|
||||||
<- get_menu_items(Host, cluster, Lang, AJID, Base)])],
|
<- get_menu_items(Host, cluster, Lang, AJID, 2)])],
|
||||||
Host, Lang, AJID, Base);
|
Host, Lang, AJID, 2);
|
||||||
process_admin(Base, Host, #request{path = [<<"style.css">>]}, _) ->
|
process_admin(Host, #request{path = [<<"style.css">>]}, _) ->
|
||||||
{200,
|
{200,
|
||||||
[{<<"Content-Type">>, <<"text/css">>}, last_modified(),
|
[{<<"Content-Type">>, <<"text/css">>}, last_modified(),
|
||||||
cache_control_public()],
|
cache_control_public()],
|
||||||
css(Base, Host)};
|
css(Host)};
|
||||||
process_admin(_Base, _Host, #request{path = [<<"favicon.ico">>]}, _) ->
|
process_admin(_Host, #request{path = [<<"favicon.ico">>]}, _) ->
|
||||||
{200,
|
{200,
|
||||||
[{<<"Content-Type">>, <<"image/x-icon">>},
|
[{<<"Content-Type">>, <<"image/x-icon">>},
|
||||||
last_modified(), cache_control_public()],
|
last_modified(), cache_control_public()],
|
||||||
favicon()};
|
favicon()};
|
||||||
process_admin(_Base, _Host, #request{path = [<<"logo.png">>]}, _) ->
|
process_admin(_Host, #request{path = [<<"logo.png">>]}, _) ->
|
||||||
{200,
|
{200,
|
||||||
[{<<"Content-Type">>, <<"image/png">>}, last_modified(),
|
[{<<"Content-Type">>, <<"image/png">>}, last_modified(),
|
||||||
cache_control_public()],
|
cache_control_public()],
|
||||||
logo()};
|
logo()};
|
||||||
process_admin(_Base, _Host, #request{path = [<<"logo-fill.png">>]}, _) ->
|
process_admin(_Host, #request{path = [<<"logo-fill.png">>]}, _) ->
|
||||||
{200,
|
{200,
|
||||||
[{<<"Content-Type">>, <<"image/png">>}, last_modified(),
|
[{<<"Content-Type">>, <<"image/png">>}, last_modified(),
|
||||||
cache_control_public()],
|
cache_control_public()],
|
||||||
logo_fill()};
|
logo_fill()};
|
||||||
process_admin(_Base, _Host, #request{path = [<<"additions.js">>]}, _) ->
|
process_admin(_Host, #request{path = [<<"additions.js">>]}, _) ->
|
||||||
{200,
|
{200,
|
||||||
[{<<"Content-Type">>, <<"text/javascript">>},
|
[{<<"Content-Type">>, <<"text/javascript">>},
|
||||||
last_modified(), cache_control_public()],
|
last_modified(), cache_control_public()],
|
||||||
additions_js()};
|
additions_js()};
|
||||||
process_admin(Base, global, #request{path = [<<"vhosts">>], lang = Lang}, AJID) ->
|
process_admin(global, #request{path = [<<"vhosts">>], lang = Lang}, AJID) ->
|
||||||
Res = list_vhosts(Lang, AJID),
|
Res = list_vhosts(Lang, AJID),
|
||||||
make_xhtml((?H1GL((translate:translate(Lang, ?T("Virtual Hosts"))),
|
make_xhtml((?H1GL((translate:translate(Lang, ?T("Virtual Hosts"))),
|
||||||
<<"virtual-hosting">>, ?T("Virtual Hosting")))
|
<<"virtual-hosting">>, ?T("Virtual Hosting")))
|
||||||
++ Res,
|
++ Res,
|
||||||
global, Lang, AJID, Base);
|
global, Lang, AJID, 1);
|
||||||
process_admin(Base, Host, #request{path = [<<"users">>], q = Query,
|
process_admin(Host, #request{path = [<<"users">>], q = Query,
|
||||||
lang = Lang}, AJID)
|
lang = Lang}, AJID)
|
||||||
when is_binary(Host) ->
|
when is_binary(Host) ->
|
||||||
Res = list_users(Base, Host, Query, Lang, fun url_func/1),
|
Res = list_users(Host, Query, Lang, fun url_func/1),
|
||||||
make_xhtml([?XCT(<<"h1">>, ?T("Users"))] ++ Res, Host,
|
make_xhtml([?XCT(<<"h1">>, ?T("Users"))] ++ Res, Host,
|
||||||
Lang, AJID, Base);
|
Lang, AJID, 3);
|
||||||
process_admin(Base, Host, #request{path = [<<"users">>, Diap],
|
process_admin(Host, #request{path = [<<"users">>, Diap],
|
||||||
lang = Lang}, AJID)
|
lang = Lang}, AJID)
|
||||||
when is_binary(Host) ->
|
when is_binary(Host) ->
|
||||||
Res = list_users_in_diapason(Base, Host, Diap, Lang,
|
Res = list_users_in_diapason(Host, Diap, Lang,
|
||||||
fun url_func/1),
|
fun url_func/1),
|
||||||
make_xhtml([?XCT(<<"h1">>, ?T("Users"))] ++ Res, Host,
|
make_xhtml([?XCT(<<"h1">>, ?T("Users"))] ++ Res, Host,
|
||||||
Lang, AJID, Base);
|
Lang, AJID, 4);
|
||||||
process_admin(Base, Host, #request{path = [<<"online-users">>],
|
process_admin(Host, #request{path = [<<"online-users">>],
|
||||||
lang = Lang}, AJID)
|
lang = Lang}, AJID)
|
||||||
when is_binary(Host) ->
|
when is_binary(Host) ->
|
||||||
Res = list_online_users(Host, Lang),
|
Res = list_online_users(Host, Lang),
|
||||||
make_xhtml([?XCT(<<"h1">>, ?T("Online Users"))] ++ Res,
|
make_xhtml([?XCT(<<"h1">>, ?T("Online Users"))] ++ Res,
|
||||||
Host, Lang, AJID, Base);
|
Host, Lang, AJID, 3);
|
||||||
process_admin(Base, Host, #request{path = [<<"last-activity">>],
|
process_admin(Host, #request{path = [<<"last-activity">>],
|
||||||
q = Query, lang = Lang}, AJID)
|
q = Query, lang = Lang}, AJID)
|
||||||
when is_binary(Host) ->
|
when is_binary(Host) ->
|
||||||
?DEBUG("Query: ~p", [Query]),
|
?DEBUG("Query: ~p", [Query]),
|
||||||
@ -494,37 +493,49 @@ process_admin(Base, Host, #request{path = [<<"last-activity">>],
|
|||||||
?INPUTT(<<"submit">>, <<"integral">>,
|
?INPUTT(<<"submit">>, <<"integral">>,
|
||||||
?T("Show Integral Table"))])]
|
?T("Show Integral Table"))])]
|
||||||
++ Res,
|
++ Res,
|
||||||
Host, Lang, AJID, Base);
|
Host, Lang, AJID, 3);
|
||||||
process_admin(Base, Host, #request{path = [<<"stats">>], lang = Lang}, AJID) ->
|
process_admin(Host, #request{path = [<<"stats">>], lang = Lang}, AJID) ->
|
||||||
Res = get_stats(Host, Lang),
|
Res = get_stats(Host, Lang),
|
||||||
PageH1 = ?H1GL(translate:translate(Lang, ?T("Statistics")), <<"mod-stats">>, <<"mod_stats">>),
|
PageH1 = ?H1GL(translate:translate(Lang, ?T("Statistics")), <<"mod-stats">>, <<"mod_stats">>),
|
||||||
make_xhtml(PageH1 ++ Res, Host, Lang, AJID, Base);
|
Level = case Host of
|
||||||
process_admin(Base, Host, #request{path = [<<"user">>, U],
|
global -> 1;
|
||||||
|
_ -> 3
|
||||||
|
end,
|
||||||
|
make_xhtml(PageH1 ++ Res, Host, Lang, AJID, Level);
|
||||||
|
process_admin(Host, #request{path = [<<"user">>, U],
|
||||||
q = Query, lang = Lang}, AJID) ->
|
q = Query, lang = Lang}, AJID) ->
|
||||||
case ejabberd_auth:user_exists(U, Host) of
|
case ejabberd_auth:user_exists(U, Host) of
|
||||||
true ->
|
true ->
|
||||||
Res = user_info(U, Host, Query, Lang),
|
Res = user_info(U, Host, Query, Lang),
|
||||||
make_xhtml(Res, Host, Lang, AJID, Base);
|
make_xhtml(Res, Host, Lang, AJID, 4);
|
||||||
false ->
|
false ->
|
||||||
make_xhtml([?XCT(<<"h1">>, ?T("Not Found"))], Host,
|
make_xhtml([?XCT(<<"h1">>, ?T("Not Found"))], Host,
|
||||||
Lang, AJID, Base)
|
Lang, AJID, 4)
|
||||||
end;
|
end;
|
||||||
process_admin(Base, Host, #request{path = [<<"nodes">>], lang = Lang}, AJID) ->
|
process_admin(Host, #request{path = [<<"nodes">>], lang = Lang}, AJID) ->
|
||||||
Res = get_nodes(Lang),
|
Res = get_nodes(Lang),
|
||||||
make_xhtml(Res, Host, Lang, AJID, Base);
|
Level = case Host of
|
||||||
process_admin(Base, Host, #request{path = [<<"node">>, SNode | NPath],
|
global -> 1;
|
||||||
|
_ -> 3
|
||||||
|
end,
|
||||||
|
make_xhtml(Res, Host, Lang, AJID, Level);
|
||||||
|
process_admin(Host, #request{path = [<<"node">>, SNode | NPath],
|
||||||
q = Query, lang = Lang}, AJID) ->
|
q = Query, lang = Lang}, AJID) ->
|
||||||
case search_running_node(SNode) of
|
case search_running_node(SNode) of
|
||||||
false ->
|
false ->
|
||||||
make_xhtml([?XCT(<<"h1">>, ?T("Node not found"))], Host,
|
make_xhtml([?XCT(<<"h1">>, ?T("Node not found"))], Host,
|
||||||
Lang, AJID, Base);
|
Lang, AJID, 2);
|
||||||
Node ->
|
Node ->
|
||||||
Res = get_node(Base, Host, Node, NPath, Query, Lang),
|
Res = get_node(Host, Node, NPath, Query, Lang),
|
||||||
make_xhtml(Res, Host, Node, Lang, AJID, Base)
|
Level = case Host of
|
||||||
|
global -> 2 + length(NPath);
|
||||||
|
_ -> 4 + length(NPath)
|
||||||
|
end,
|
||||||
|
make_xhtml(Res, Host, Node, Lang, AJID, Level)
|
||||||
end;
|
end;
|
||||||
%%%==================================
|
%%%==================================
|
||||||
%%%% process_admin default case
|
%%%% process_admin default case
|
||||||
process_admin(Base, Host, #request{lang = Lang} = Request, AJID) ->
|
process_admin(Host, #request{lang = Lang} = Request, AJID) ->
|
||||||
Res = case Host of
|
Res = case Host of
|
||||||
global ->
|
global ->
|
||||||
ejabberd_hooks:run_fold(
|
ejabberd_hooks:run_fold(
|
||||||
@ -533,13 +544,17 @@ process_admin(Base, Host, #request{lang = Lang} = Request, AJID) ->
|
|||||||
ejabberd_hooks:run_fold(
|
ejabberd_hooks:run_fold(
|
||||||
webadmin_page_host, Host, [], [Host, Request])
|
webadmin_page_host, Host, [], [Host, Request])
|
||||||
end,
|
end,
|
||||||
|
Level = case Host of
|
||||||
|
global -> length(Request#request.path);
|
||||||
|
_ -> 2 + length(Request#request.path)
|
||||||
|
end,
|
||||||
case Res of
|
case Res of
|
||||||
[] ->
|
[] ->
|
||||||
setelement(1,
|
setelement(1,
|
||||||
make_xhtml([?XC(<<"h1">>, <<"Not Found">>)], Host, Lang,
|
make_xhtml([?XC(<<"h1">>, <<"Not Found">>)], Host, Lang,
|
||||||
AJID, Base),
|
AJID, Level),
|
||||||
404);
|
404);
|
||||||
_ -> make_xhtml(Res, Host, Lang, AJID, Base)
|
_ -> make_xhtml(Res, Host, Lang, AJID, Level)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
term_to_id(T) -> base64:encode((term_to_binary(T))).
|
term_to_id(T) -> base64:encode((term_to_binary(T))).
|
||||||
@ -586,13 +601,13 @@ list_vhosts2(Lang, Hosts) ->
|
|||||||
%%%==================================
|
%%%==================================
|
||||||
%%%% list_users
|
%%%% list_users
|
||||||
|
|
||||||
list_users(Base, Host, Query, Lang, URLFunc) ->
|
list_users(Host, Query, Lang, URLFunc) ->
|
||||||
Res = list_users_parse_query(Query, Host),
|
Res = list_users_parse_query(Query, Host),
|
||||||
Users = ejabberd_auth:get_users(Host),
|
Users = ejabberd_auth:get_users(Host),
|
||||||
SUsers = lists:sort([{S, U} || {U, S} <- Users]),
|
SUsers = lists:sort([{S, U} || {U, S} <- Users]),
|
||||||
FUsers = case length(SUsers) of
|
FUsers = case length(SUsers) of
|
||||||
N when N =< 100 ->
|
N when N =< 100 ->
|
||||||
[list_given_users(Host, SUsers, Base, Lang,
|
[list_given_users(Host, SUsers, <<"../">>, Lang,
|
||||||
URLFunc)];
|
URLFunc)];
|
||||||
N ->
|
N ->
|
||||||
NParts = trunc(math:sqrt(N * 6.17999999999999993783e-1))
|
NParts = trunc(math:sqrt(N * 6.17999999999999993783e-1))
|
||||||
@ -668,18 +683,17 @@ list_users_parse_query(Query, Host) ->
|
|||||||
false -> nothing
|
false -> nothing
|
||||||
end.
|
end.
|
||||||
|
|
||||||
list_users_in_diapason(Base, Host, Diap, Lang, URLFunc) ->
|
list_users_in_diapason(Host, Diap, Lang, URLFunc) ->
|
||||||
Users = ejabberd_auth:get_users(Host),
|
Users = ejabberd_auth:get_users(Host),
|
||||||
SUsers = lists:sort([{S, U} || {U, S} <- Users]),
|
SUsers = lists:sort([{S, U} || {U, S} <- Users]),
|
||||||
[S1, S2] = ejabberd_regexp:split(Diap, <<"-">>),
|
[S1, S2] = ejabberd_regexp:split(Diap, <<"-">>),
|
||||||
N1 = binary_to_integer(S1),
|
N1 = binary_to_integer(S1),
|
||||||
N2 = binary_to_integer(S2),
|
N2 = binary_to_integer(S2),
|
||||||
Sub = lists:sublist(SUsers, N1, N2 - N1 + 1),
|
Sub = lists:sublist(SUsers, N1, N2 - N1 + 1),
|
||||||
[list_given_users(Host, Sub, Base, Lang,
|
[list_given_users(Host, Sub, <<"../../">>, Lang,
|
||||||
URLFunc)].
|
URLFunc)].
|
||||||
|
|
||||||
list_given_users(Host, Users, Base, Lang, URLFunc) ->
|
list_given_users(Host, Users, Prefix, Lang, URLFunc) ->
|
||||||
Prefix = get_base_path(Host, cluster, Base),
|
|
||||||
ModOffline = get_offlinemsg_module(Host),
|
ModOffline = get_offlinemsg_module(Host),
|
||||||
?XE(<<"table">>,
|
?XE(<<"table">>,
|
||||||
[?XE(<<"thead">>,
|
[?XE(<<"thead">>,
|
||||||
@ -1061,10 +1075,10 @@ search_running_node(SNode, [Node | Nodes]) ->
|
|||||||
_ -> search_running_node(SNode, Nodes)
|
_ -> search_running_node(SNode, Nodes)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_node(Base, global, Node, [], Query, Lang) ->
|
get_node(global, Node, [], Query, Lang) ->
|
||||||
Res = node_parse_query(Node, Query),
|
Res = node_parse_query(Node, Query),
|
||||||
BP = get_base_path(global, Node, Base),
|
Base = get_base_path(global, Node, 2),
|
||||||
MenuItems2 = make_menu_items(global, Node, BP, Lang),
|
MenuItems2 = make_menu_items(global, Node, Base, Lang),
|
||||||
[?XC(<<"h1">>,
|
[?XC(<<"h1">>,
|
||||||
(str:format(translate:translate(Lang, ?T("Node ~p")), [Node])))]
|
(str:format(translate:translate(Lang, ?T("Node ~p")), [Node])))]
|
||||||
++
|
++
|
||||||
@ -1085,12 +1099,12 @@ get_node(Base, global, Node, [], Query, Lang) ->
|
|||||||
[?INPUTT(<<"submit">>, <<"restart">>, ?T("Restart")),
|
[?INPUTT(<<"submit">>, <<"restart">>, ?T("Restart")),
|
||||||
?C(<<" ">>),
|
?C(<<" ">>),
|
||||||
?INPUTT(<<"submit">>, <<"stop">>, ?T("Stop"))])];
|
?INPUTT(<<"submit">>, <<"stop">>, ?T("Stop"))])];
|
||||||
get_node(Base, Host, Node, [], _Query, Lang) ->
|
get_node(Host, Node, [], _Query, Lang) ->
|
||||||
BP = get_base_path(Host, Node, Base),
|
Base = get_base_path(Host, Node, 4),
|
||||||
MenuItems2 = make_menu_items(Host, Node, BP, Lang),
|
MenuItems2 = make_menu_items(Host, Node, Base, Lang),
|
||||||
[?XC(<<"h1">>, (str:format(translate:translate(Lang, ?T("Node ~p")), [Node]))),
|
[?XC(<<"h1">>, (str:format(translate:translate(Lang, ?T("Node ~p")), [Node]))),
|
||||||
?XE(<<"ul">>, MenuItems2)];
|
?XE(<<"ul">>, MenuItems2)];
|
||||||
get_node(_Base, global, Node, [<<"db">>], Query, Lang) ->
|
get_node(global, Node, [<<"db">>], Query, Lang) ->
|
||||||
case ejabberd_cluster:call(Node, mnesia, system_info, [tables]) of
|
case ejabberd_cluster:call(Node, mnesia, system_info, [tables]) of
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
[?XCT(<<"h1">>, ?T("RPC Call Error"))];
|
[?XCT(<<"h1">>, ?T("RPC Call Error"))];
|
||||||
@ -1168,7 +1182,7 @@ get_node(_Base, global, Node, [<<"db">>], Query, Lang) ->
|
|||||||
<<"submit">>,
|
<<"submit">>,
|
||||||
?T("Submit"))])])]))])])]
|
?T("Submit"))])])]))])])]
|
||||||
end;
|
end;
|
||||||
get_node(_Base, global, Node, [<<"backup">>], Query, Lang) ->
|
get_node(global, Node, [<<"backup">>], Query, Lang) ->
|
||||||
HomeDirRaw = case {os:getenv("HOME"), os:type()} of
|
HomeDirRaw = case {os:getenv("HOME"), os:type()} of
|
||||||
{EnvHome, _} when is_list(EnvHome) -> list_to_binary(EnvHome);
|
{EnvHome, _} when is_list(EnvHome) -> list_to_binary(EnvHome);
|
||||||
{false, {win32, _Osname}} -> <<"C:/">>;
|
{false, {win32, _Osname}} -> <<"C:/">>;
|
||||||
@ -1318,7 +1332,7 @@ get_node(_Base, global, Node, [<<"backup">>], Query, Lang) ->
|
|||||||
?XE(<<"td">>,
|
?XE(<<"td">>,
|
||||||
[?INPUTT(<<"submit">>, <<"import_dir">>,
|
[?INPUTT(<<"submit">>, <<"import_dir">>,
|
||||||
?T("OK"))])])])])])];
|
?T("OK"))])])])])])];
|
||||||
get_node(_Base, global, Node, [<<"stats">>], _Query, Lang) ->
|
get_node(global, Node, [<<"stats">>], _Query, Lang) ->
|
||||||
UpTime = ejabberd_cluster:call(Node, erlang, statistics,
|
UpTime = ejabberd_cluster:call(Node, erlang, statistics,
|
||||||
[wall_clock]),
|
[wall_clock]),
|
||||||
UpTimeS = (str:format("~.3f",
|
UpTimeS = (str:format("~.3f",
|
||||||
@ -1367,7 +1381,7 @@ get_node(_Base, global, Node, [<<"stats">>], _Query, Lang) ->
|
|||||||
[?XCT(<<"td">>, ?T("Transactions Logged:")),
|
[?XCT(<<"td">>, ?T("Transactions Logged:")),
|
||||||
?XAC(<<"td">>, [{<<"class">>, <<"alignright">>}],
|
?XAC(<<"td">>, [{<<"class">>, <<"alignright">>}],
|
||||||
(pretty_string_int(TransactionsLogged)))])])])];
|
(pretty_string_int(TransactionsLogged)))])])])];
|
||||||
get_node(_Base, global, Node, [<<"update">>], Query, Lang) ->
|
get_node(global, Node, [<<"update">>], Query, Lang) ->
|
||||||
ejabberd_cluster:call(Node, code, purge, [ejabberd_update]),
|
ejabberd_cluster:call(Node, code, purge, [ejabberd_update]),
|
||||||
Res = node_update_parse_query(Node, Query),
|
Res = node_update_parse_query(Node, Query),
|
||||||
ejabberd_cluster:call(Node, code, load_file, [ejabberd_update]),
|
ejabberd_cluster:call(Node, code, load_file, [ejabberd_update]),
|
||||||
@ -1423,7 +1437,7 @@ get_node(_Base, global, Node, [<<"update">>], Query, Lang) ->
|
|||||||
?XC(<<"pre">>, (misc:atom_to_binary(Check))),
|
?XC(<<"pre">>, (misc:atom_to_binary(Check))),
|
||||||
?BR,
|
?BR,
|
||||||
?INPUTT(<<"submit">>, <<"update">>, ?T("Update"))])];
|
?INPUTT(<<"submit">>, <<"update">>, ?T("Update"))])];
|
||||||
get_node(_Base, Host, Node, NPath, Query, Lang) ->
|
get_node(Host, Node, NPath, Query, Lang) ->
|
||||||
Res = case Host of
|
Res = case Host of
|
||||||
global ->
|
global ->
|
||||||
ejabberd_hooks:run_fold(webadmin_page_node, Host, [],
|
ejabberd_hooks:run_fold(webadmin_page_node, Host, [],
|
||||||
@ -1735,19 +1749,19 @@ make_navigation_menu(Host, Node, Lang, JID, Level) ->
|
|||||||
make_server_menu(HostMenu, NodeMenu, Lang, JID, Level).
|
make_server_menu(HostMenu, NodeMenu, Lang, JID, Level).
|
||||||
|
|
||||||
%% @spec (Host, Node, Base, Lang) -> [LI]
|
%% @spec (Host, Node, Base, Lang) -> [LI]
|
||||||
make_menu_items(global, cluster, BP, Lang) ->
|
make_menu_items(global, cluster, Base, Lang) ->
|
||||||
HookItems = get_menu_items_hook(server, Lang),
|
HookItems = get_menu_items_hook(server, Lang),
|
||||||
make_menu_items(Lang, {BP, <<"">>, HookItems});
|
make_menu_items(Lang, {Base, <<"">>, HookItems});
|
||||||
make_menu_items(global, Node, BP, Lang) ->
|
make_menu_items(global, Node, Base, Lang) ->
|
||||||
HookItems = get_menu_items_hook({node, Node}, Lang),
|
HookItems = get_menu_items_hook({node, Node}, Lang),
|
||||||
make_menu_items(Lang, {BP, <<"">>, HookItems});
|
make_menu_items(Lang, {Base, <<"">>, HookItems});
|
||||||
make_menu_items(Host, cluster, BP, Lang) ->
|
make_menu_items(Host, cluster, Base, Lang) ->
|
||||||
HookItems = get_menu_items_hook({host, Host}, Lang),
|
HookItems = get_menu_items_hook({host, Host}, Lang),
|
||||||
make_menu_items(Lang, {BP, <<"">>, HookItems});
|
make_menu_items(Lang, {Base, <<"">>, HookItems});
|
||||||
make_menu_items(Host, Node, BP, Lang) ->
|
make_menu_items(Host, Node, Base, Lang) ->
|
||||||
HookItems = get_menu_items_hook({hostnode, Host, Node},
|
HookItems = get_menu_items_hook({hostnode, Host, Node},
|
||||||
Lang),
|
Lang),
|
||||||
make_menu_items(Lang, {BP, <<"">>, HookItems}).
|
make_menu_items(Lang, {Base, <<"">>, HookItems}).
|
||||||
|
|
||||||
make_host_node_menu(global, _, _Lang, _JID, _Level) ->
|
make_host_node_menu(global, _, _Lang, _JID, _Level) ->
|
||||||
{<<"">>, <<"">>, []};
|
{<<"">>, <<"">>, []};
|
||||||
@ -1789,19 +1803,22 @@ make_node_menu(global, Node, Lang, Level) ->
|
|||||||
{<<"stats">>, ?T("Statistics")},
|
{<<"stats">>, ?T("Statistics")},
|
||||||
{<<"update">>, ?T("Update")}]
|
{<<"update">>, ?T("Update")}]
|
||||||
++ get_menu_items_hook({node, Node}, Lang),
|
++ get_menu_items_hook({node, Node}, Lang),
|
||||||
{NodeBase, iolist_to_binary(atom_to_list(Node)), NodeFixed}.
|
{NodeBase, iolist_to_binary(atom_to_list(Node)),
|
||||||
|
NodeFixed};
|
||||||
|
make_node_menu(_Host, _Node, _Lang, _Level) ->
|
||||||
|
{<<"">>, <<"">>, []}.
|
||||||
|
|
||||||
make_server_menu(HostMenu, NodeMenu, Lang, JID, Level) ->
|
make_server_menu(HostMenu, NodeMenu, Lang, JID, Level) ->
|
||||||
BP = get_base_path(global, cluster, Level),
|
Base = get_base_path(global, cluster, Level),
|
||||||
Fixed = [{<<"vhosts">>, ?T("Virtual Hosts"), HostMenu},
|
Fixed = [{<<"vhosts">>, ?T("Virtual Hosts"), HostMenu},
|
||||||
{<<"nodes">>, ?T("Nodes"), NodeMenu},
|
{<<"nodes">>, ?T("Nodes"), NodeMenu},
|
||||||
{<<"stats">>, ?T("Statistics")}]
|
{<<"stats">>, ?T("Statistics")}]
|
||||||
++ get_menu_items_hook(server, Lang),
|
++ get_menu_items_hook(server, Lang),
|
||||||
Base = url_to_path(BP),
|
BasePath = url_to_path(Base),
|
||||||
Fixed2 = [Tuple
|
Fixed2 = [Tuple
|
||||||
|| Tuple <- Fixed,
|
|| Tuple <- Fixed,
|
||||||
is_allowed_path(Base, Tuple, JID)],
|
is_allowed_path(BasePath, Tuple, JID)],
|
||||||
{BP, <<"">>, Fixed2}.
|
{Base, <<"">>, Fixed2}.
|
||||||
|
|
||||||
get_menu_items_hook({hostnode, Host, Node}, Lang) ->
|
get_menu_items_hook({hostnode, Host, Node}, Lang) ->
|
||||||
ejabberd_hooks:run_fold(webadmin_menu_hostnode, Host,
|
ejabberd_hooks:run_fold(webadmin_menu_hostnode, Host,
|
||||||
|
Loading…
Reference in New Issue
Block a user