mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-20 17:27:00 +01:00
* src/eldap/eldap.erl: Fix compilation warnings: Part 4 (EJAB-290)
* src/web/ejabberd_web_admin.erl: Likewise SVN Revision: 1048
This commit is contained in:
parent
95c69b0251
commit
dd706eea94
@ -1,5 +1,8 @@
|
||||
2007-12-07 Badlop <badlop@process-one.net>
|
||||
|
||||
* src/eldap/eldap.erl: Fix compilation warnings: Part 4 (EJAB-290)
|
||||
* src/web/ejabberd_web_admin.erl: Likewise
|
||||
|
||||
* src/mod_irc/iconv.erl: Fix compilation warnings: 3 (EJAB-290)
|
||||
* src/mod_irc/mod_irc.erl: Likewise
|
||||
* src/mod_irc/mod_irc_connection.erl: Likewise
|
||||
|
@ -104,7 +104,7 @@ start_link(Name) ->
|
||||
gen_fsm:start_link({local, Reg_name}, ?MODULE, [], []).
|
||||
|
||||
start_link(Name, Hosts, Port, Rootdn, Passwd) ->
|
||||
Log = fun(N, Fmt, Args) -> io:format("---- " ++ Fmt, [Args]) end,
|
||||
Log = fun(_N, Fmt, Args) -> io:format("---- " ++ Fmt, [Args]) end,
|
||||
Reg_name = list_to_atom("eldap_" ++ Name),
|
||||
gen_fsm:start_link({local, Reg_name}, ?MODULE, {Hosts, Port, Rootdn, Passwd, Log}, []).
|
||||
|
||||
@ -299,7 +299,7 @@ parse_search_args([{timeout, Timeout}|T],A) when integer(Timeout) ->
|
||||
parse_search_args(T,A#eldap_search{timeout = Timeout});
|
||||
parse_search_args([{limit, Limit}|T],A) when is_integer(Limit) ->
|
||||
parse_search_args(T,A#eldap_search{limit = Limit});
|
||||
parse_search_args([H|T],A) ->
|
||||
parse_search_args([H|_],_) ->
|
||||
throw({error,{unknown_arg, H}});
|
||||
parse_search_args([],A) ->
|
||||
A.
|
||||
@ -414,11 +414,11 @@ connecting(timeout, S) ->
|
||||
%% {stop, Reason, NewStateData} |
|
||||
%% {stop, Reason, Reply, NewStateData}
|
||||
%%----------------------------------------------------------------------
|
||||
connecting(Event, From, S) ->
|
||||
connecting(_Event, _From, S) ->
|
||||
Reply = {error, connecting},
|
||||
{reply, Reply, connecting, S}.
|
||||
|
||||
wait_bind_response(Event, From, S) ->
|
||||
wait_bind_response(_Event, _From, S) ->
|
||||
Reply = {error, wait_bind_response},
|
||||
{reply, Reply, wait_bind_response, S}.
|
||||
|
||||
@ -454,7 +454,7 @@ active_bind(Event, From, S) ->
|
||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
||||
%% {stop, Reason, NewStateData}
|
||||
%%----------------------------------------------------------------------
|
||||
handle_event(close, StateName, S) ->
|
||||
handle_event(close, _StateName, S) ->
|
||||
gen_tcp:close(S#eldap.fd),
|
||||
{stop, closed, S};
|
||||
|
||||
@ -471,7 +471,7 @@ handle_event(process_bind_q, active_bind, #eldap{bind_q=Q} = S) ->
|
||||
{next_state, active, S}
|
||||
end;
|
||||
|
||||
handle_event(Event, StateName, S) ->
|
||||
handle_event(_Event, StateName, S) ->
|
||||
{next_state, StateName, S}.
|
||||
|
||||
%%----------------------------------------------------------------------
|
||||
@ -484,15 +484,16 @@ handle_event(Event, StateName, S) ->
|
||||
%% {stop, Reason, NewStateData} |
|
||||
%% {stop, Reason, Reply, NewStateData}
|
||||
%%----------------------------------------------------------------------
|
||||
handle_sync_event({debug_level, N}, From, StateName, S) ->
|
||||
handle_sync_event({debug_level, N}, _From, StateName, S) ->
|
||||
{reply, ok, StateName, S#eldap{debug_level = N}};
|
||||
|
||||
handle_sync_event(Event, From, StateName, S) ->
|
||||
{reply, {StateName, S}, StateName, S};
|
||||
handle_sync_event(_Event, _From, StateName, S) ->
|
||||
{reply, {StateName, S}, StateName, S}.
|
||||
|
||||
handle_sync_event(Event, From, StateName, S) ->
|
||||
Reply = ok,
|
||||
{reply, Reply, StateName, S}.
|
||||
%% TODO: Check this clause, because it never matches:
|
||||
%%handle_sync_event(Event, From, StateName, S) ->
|
||||
%% Reply = ok,
|
||||
%% {reply, Reply, StateName, S}.
|
||||
|
||||
%%----------------------------------------------------------------------
|
||||
%% Func: handle_info/3
|
||||
@ -504,34 +505,34 @@ handle_sync_event(Event, From, StateName, S) ->
|
||||
%%
|
||||
%% Packets arriving in various states
|
||||
%%
|
||||
handle_info({tcp, Socket, Data}, connecting, S) ->
|
||||
handle_info({tcp, _Socket, Data}, connecting, S) ->
|
||||
log1("eldap. tcp packet received when disconnected!~n~p~n", [Data], S),
|
||||
{next_state, connecting, S};
|
||||
|
||||
handle_info({tcp, Socket, Data}, wait_bind_response, S) ->
|
||||
handle_info({tcp, _Socket, Data}, wait_bind_response, S) ->
|
||||
cancel_timer(S#eldap.bind_timer),
|
||||
case catch recvd_wait_bind_response(Data, S) of
|
||||
bound -> {next_state, active, S};
|
||||
{fail_bind, Reason} -> close_and_retry(S),
|
||||
{fail_bind, _Reason} -> close_and_retry(S),
|
||||
{next_state, connecting, S#eldap{fd = null}};
|
||||
{'EXIT', Reason} -> close_and_retry(S),
|
||||
{'EXIT', _Reason} -> close_and_retry(S),
|
||||
{next_state, connecting, S#eldap{fd = null}};
|
||||
{error, Reason} -> close_and_retry(S),
|
||||
{error, _Reason} -> close_and_retry(S),
|
||||
{next_state, connecting, S#eldap{fd = null}}
|
||||
end;
|
||||
|
||||
handle_info({tcp, Socket, Data}, StateName, S)
|
||||
handle_info({tcp, _Socket, Data}, StateName, S)
|
||||
when StateName==active; StateName==active_bind ->
|
||||
case catch recvd_packet(Data, S) of
|
||||
{reply, Reply, To, NewS} -> gen_fsm:reply(To, Reply),
|
||||
{next_state, StateName, NewS};
|
||||
{ok, NewS} -> {next_state, StateName, NewS};
|
||||
{'EXIT', Reason} -> {next_state, StateName, S};
|
||||
{error, Reason} -> {next_state, StateName, S}
|
||||
{'EXIT', _Reason} -> {next_state, StateName, S};
|
||||
{error, _Reason} -> {next_state, StateName, S}
|
||||
end;
|
||||
|
||||
handle_info({tcp_closed, Socket}, All_fsm_states, S) ->
|
||||
F = fun(Id, [{Timer, From, Name}|Res]) ->
|
||||
handle_info({tcp_closed, _Socket}, _All_fsm_states, S) ->
|
||||
F = fun(_Id, [{Timer, From, _Name}|_]) ->
|
||||
gen_fsm:reply(From, {error, tcp_closed}),
|
||||
cancel_timer(Timer)
|
||||
end,
|
||||
@ -540,7 +541,7 @@ handle_info({tcp_closed, Socket}, All_fsm_states, S) ->
|
||||
{next_state, connecting, S#eldap{fd = null,
|
||||
dict = dict:new(), bind_q=queue:new()}};
|
||||
|
||||
handle_info({tcp_error, Socket, Reason}, Fsm_state, S) ->
|
||||
handle_info({tcp_error, _Socket, Reason}, Fsm_state, S) ->
|
||||
log1("eldap received tcp_error: ~p~nIn State: ~p~n", [Reason, Fsm_state], S),
|
||||
{next_state, Fsm_state, S};
|
||||
%%
|
||||
@ -550,14 +551,14 @@ handle_info({timeout, Timer, {cmd_timeout, Id}}, active, S) ->
|
||||
case cmd_timeout(Timer, Id, S) of
|
||||
{reply, To, Reason, NewS} -> gen_fsm:reply(To, Reason),
|
||||
{next_state, active, NewS};
|
||||
{error, Reason} -> {next_state, active, S}
|
||||
{error, _Reason} -> {next_state, active, S}
|
||||
end;
|
||||
|
||||
handle_info({timeout, retry_connect}, connecting, S) ->
|
||||
{ok, NextState, NewS} = connect_bind(S),
|
||||
{next_state, NextState, NewS};
|
||||
|
||||
handle_info({timeout, Timer, bind_timeout}, wait_bind_response, S) ->
|
||||
handle_info({timeout, _Timer, bind_timeout}, wait_bind_response, S) ->
|
||||
close_and_retry(S),
|
||||
{next_state, connecting, S#eldap{fd = null}};
|
||||
|
||||
@ -574,7 +575,7 @@ handle_info(Info, StateName, S) ->
|
||||
%% Purpose: Shutdown the fsm
|
||||
%% Returns: any
|
||||
%%----------------------------------------------------------------------
|
||||
terminate(Reason, StateName, StatData) ->
|
||||
terminate(_Reason, _StateName, _StatData) ->
|
||||
ok.
|
||||
|
||||
%%----------------------------------------------------------------------
|
||||
@ -582,7 +583,7 @@ terminate(Reason, StateName, StatData) ->
|
||||
%% Purpose: Convert process state when code is changed
|
||||
%% Returns: {ok, NewState, NewStateData}
|
||||
%%----------------------------------------------------------------------
|
||||
code_change(OldVsn, StateName, S, Extra) ->
|
||||
code_change(_OldVsn, StateName, S, _Extra) ->
|
||||
{ok, StateName, S}.
|
||||
|
||||
%%%----------------------------------------------------------------------
|
||||
@ -713,18 +714,18 @@ recvd_packet(Pkt, S) ->
|
||||
Error -> Error
|
||||
end.
|
||||
|
||||
check_reply(#'LDAPResult'{resultCode = success}, From) ->
|
||||
check_reply(#'LDAPResult'{resultCode = success}, _From) ->
|
||||
ok;
|
||||
check_reply(#'LDAPResult'{resultCode = Reason}, From) ->
|
||||
check_reply(#'LDAPResult'{resultCode = Reason}, _From) ->
|
||||
{error, Reason};
|
||||
check_reply(Other, From) ->
|
||||
check_reply(Other, _From) ->
|
||||
{error, Other}.
|
||||
|
||||
check_bind_reply(#'BindResponse'{resultCode = success}, From) ->
|
||||
check_bind_reply(#'BindResponse'{resultCode = success}, _From) ->
|
||||
ok;
|
||||
check_bind_reply(#'BindResponse'{resultCode = Reason}, From) ->
|
||||
check_bind_reply(#'BindResponse'{resultCode = Reason}, _From) ->
|
||||
{error, Reason};
|
||||
check_bind_reply(Other, From) ->
|
||||
check_bind_reply(Other, _From) ->
|
||||
{error, Other}.
|
||||
|
||||
get_op_rec(Id, Dict) ->
|
||||
@ -781,9 +782,9 @@ cancel_timer(Timer) ->
|
||||
%%% Sanity check of received packet
|
||||
check_tag(Data) ->
|
||||
case asn1rt_ber_bin:decode_tag(Data) of
|
||||
{Tag, Data1, Rb} ->
|
||||
{_Tag, Data1, _Rb} ->
|
||||
case asn1rt_ber_bin:decode_length(Data1) of
|
||||
{{Len,Data2}, Rb2} -> ok;
|
||||
{{_Len,_Data2}, _Rb2} -> ok;
|
||||
_ -> throw({error,decoded_tag_length})
|
||||
end;
|
||||
_ -> throw({error,decoded_tag})
|
||||
@ -813,7 +814,7 @@ cmd_timeout(Timer, Id, S) ->
|
||||
#eldap_search_result{entries = Res1,
|
||||
referrals = Ref1}},
|
||||
S#eldap{dict = New_dict}};
|
||||
Others ->
|
||||
_ ->
|
||||
New_dict = dict:erase(Id, Dict),
|
||||
{reply, From, {error, timeout}, S#eldap{dict = New_dict}}
|
||||
end;
|
||||
@ -857,13 +858,13 @@ connect_bind(S) ->
|
||||
{ok, wait_bind_response, NewS#eldap{fd = Socket,
|
||||
host = Host,
|
||||
bind_timer = Timer}};
|
||||
{error, Reason} ->
|
||||
{error, _Reason} ->
|
||||
gen_tcp:close(Socket),
|
||||
erlang:send_after(?RETRY_TIMEOUT, self(),
|
||||
{timeout, retry_connect}),
|
||||
{ok, connecting, S#eldap{host = Host}}
|
||||
end;
|
||||
{error, Reason} ->
|
||||
{error, _Reason} ->
|
||||
erlang:send_after(?RETRY_TIMEOUT, self(),
|
||||
{timeout, retry_connect}),
|
||||
{ok, connecting, S#eldap{host = Host}}
|
||||
@ -887,9 +888,9 @@ next_host(Host, Hosts) -> % Find next in turn
|
||||
next_host(Host, Hosts, Hosts).
|
||||
|
||||
next_host(Host, [Host], Hosts) -> hd(Hosts); % Wrap back to first
|
||||
next_host(Host, [Host|Tail], Hosts) -> hd(Tail); % Take next
|
||||
next_host(Host, [], Hosts) -> hd(Hosts); % Never connected before? (shouldn't happen)
|
||||
next_host(Host, [H|T], Hosts) -> next_host(Host, T, Hosts).
|
||||
next_host(Host, [Host|Tail], _Hosts) -> hd(Tail); % Take next
|
||||
next_host(_Host, [], Hosts) -> hd(Hosts); % Never connected before? (shouldn't happen)
|
||||
next_host(Host, [_|T], Hosts) -> next_host(Host, T, Hosts).
|
||||
|
||||
|
||||
%%% --------------------------------------------------------------------
|
||||
@ -918,7 +919,7 @@ v_modifications(Mods) ->
|
||||
|
||||
v_substr([{Key,Str}|T]) when list(Str),Key==initial;Key==any;Key==final ->
|
||||
[{Key,Str}|v_substr(T)];
|
||||
v_substr([H|T]) ->
|
||||
v_substr([H|_]) ->
|
||||
throw({error,{substring_arg,H}});
|
||||
v_substr([]) ->
|
||||
[].
|
||||
@ -973,7 +974,7 @@ get_integer(Key, List) ->
|
||||
case lists:keysearch(Key, 1, List) of
|
||||
{value, {Key, Value}} when integer(Value) ->
|
||||
Value;
|
||||
{value, {Key, Value}} ->
|
||||
{value, {Key, _Value}} ->
|
||||
throw({error, "Bad Value in Config for " ++ atom_to_list(Key)});
|
||||
false ->
|
||||
throw({error, "No Entry in Config for " ++ atom_to_list(Key)})
|
||||
@ -983,7 +984,7 @@ get_list(Key, List) ->
|
||||
case lists:keysearch(Key, 1, List) of
|
||||
{value, {Key, Value}} when list(Value) ->
|
||||
Value;
|
||||
{value, {Key, Value}} ->
|
||||
{value, {Key, _Value}} ->
|
||||
throw({error, "Bad Value in Config for " ++ atom_to_list(Key)});
|
||||
false ->
|
||||
throw({error, "No Entry in Config for " ++ atom_to_list(Key)})
|
||||
@ -993,10 +994,10 @@ get_log(Key, List) ->
|
||||
case lists:keysearch(Key, 1, List) of
|
||||
{value, {Key, Value}} when function(Value) ->
|
||||
Value;
|
||||
{value, {Key, Else}} ->
|
||||
{value, {Key, _Else}} ->
|
||||
false;
|
||||
false ->
|
||||
fun(Level, Format, Args) -> io:format("--- " ++ Format, Args) end
|
||||
fun(_Level, Format, Args) -> io:format("--- " ++ Format, Args) end
|
||||
end.
|
||||
|
||||
get_hosts(Key, List) ->
|
||||
@ -1009,7 +1010,7 @@ get_hosts(Key, List) ->
|
||||
({Key1, Value}) when list(Value),
|
||||
Key == Key1->
|
||||
Value;
|
||||
({Else, Value}) ->
|
||||
({_Else, _Value}) ->
|
||||
throw({error, "Bad Hostname in config"})
|
||||
end, List).
|
||||
|
||||
|
@ -24,9 +24,7 @@
|
||||
-include("ejabberd_web_admin.hrl").
|
||||
|
||||
|
||||
process(["server", SHost | RPath], #request{auth = Auth,
|
||||
q = Query,
|
||||
lang = Lang} = Request) ->
|
||||
process(["server", SHost | RPath], #request{auth = Auth} = Request) ->
|
||||
Host = jlib:nameprep(SHost),
|
||||
case lists:member(Host, ?MYHOSTS) of
|
||||
true ->
|
||||
@ -51,9 +49,7 @@ process(["server", SHost | RPath], #request{auth = Auth,
|
||||
ejabberd_web:error(not_found)
|
||||
end;
|
||||
|
||||
process(RPath, #request{auth = Auth,
|
||||
q = Query,
|
||||
lang = Lang} = Request) ->
|
||||
process(RPath, #request{auth = Auth} = Request) ->
|
||||
case get_auth(Auth) of
|
||||
{User, Server} ->
|
||||
case acl:match_rule(
|
||||
@ -584,10 +580,8 @@ logo_fill() ->
|
||||
"RK5CYII=").
|
||||
|
||||
process_admin(global,
|
||||
#request{us = US,
|
||||
path = [],
|
||||
q = Query,
|
||||
lang = Lang} = Request) ->
|
||||
#request{path = [],
|
||||
lang = Lang}) ->
|
||||
MenuItems1 = ejabberd_hooks:run_fold(webadmin_menu_main, [], []),
|
||||
MenuItems2 = [?LI([?ACT("/admin/"++MI_uri++"/", MI_name)]) || {MI_uri, MI_name} <- MenuItems1],
|
||||
make_xhtml([?XCT("h1", "Administration"),
|
||||
@ -604,10 +598,8 @@ process_admin(global,
|
||||
], global, Lang);
|
||||
|
||||
process_admin(Host,
|
||||
#request{us = US,
|
||||
path = [],
|
||||
q = Query,
|
||||
lang = Lang} = Request) ->
|
||||
#request{path = [],
|
||||
lang = Lang}) ->
|
||||
Base = "/admin/server/" ++ Host ++ "/",
|
||||
MenuItems1 = ejabberd_hooks:run_fold(webadmin_menu_host, Host, [], [Host]),
|
||||
MenuItems2 = [?LI([?ACT(Base ++ MI_uri ++ "/", MI_name)]) || {MI_uri, MI_name} <- MenuItems1],
|
||||
@ -626,39 +618,22 @@ process_admin(Host,
|
||||
)
|
||||
], Host, Lang);
|
||||
|
||||
process_admin(Host,
|
||||
#request{us = US,
|
||||
path = ["style.css"],
|
||||
q = Query,
|
||||
lang = Lang} = Request) ->
|
||||
process_admin(Host, #request{path = ["style.css"]}) ->
|
||||
{200, [{"Content-Type", "text/css"}], css(Host)};
|
||||
|
||||
process_admin(Host,
|
||||
#request{us = US,
|
||||
path = ["favicon.ico"],
|
||||
q = Query,
|
||||
lang = Lang} = Request) ->
|
||||
process_admin(_Host, #request{path = ["favicon.ico"]}) ->
|
||||
{200, [{"Content-Type", "image/x-icon"}], favicon()};
|
||||
|
||||
process_admin(Host,
|
||||
#request{us = US,
|
||||
path = ["logo.png"],
|
||||
q = Query,
|
||||
lang = Lang} = Request) ->
|
||||
process_admin(_Host, #request{path = ["logo.png"]}) ->
|
||||
{200, [{"Content-Type", "image/png"}], logo()};
|
||||
|
||||
process_admin(Host,
|
||||
#request{us = US,
|
||||
path = ["logo-fill.png"],
|
||||
q = Query,
|
||||
lang = Lang} = Request) ->
|
||||
process_admin(_Host, #request{path = ["logo-fill.png"]}) ->
|
||||
{200, [{"Content-Type", "image/png"}], logo_fill()};
|
||||
|
||||
process_admin(Host,
|
||||
#request{us = US,
|
||||
path = ["acls-raw"],
|
||||
#request{path = ["acls-raw"],
|
||||
q = Query,
|
||||
lang = Lang} = Request) ->
|
||||
lang = Lang}) ->
|
||||
Res = case lists:keysearch("acls", 1, Query) of
|
||||
{value, {_, String}} ->
|
||||
case erl_scan:string(String) of
|
||||
@ -703,10 +678,9 @@ process_admin(Host,
|
||||
|
||||
process_admin(Host,
|
||||
#request{method = Method,
|
||||
us = US,
|
||||
path = ["acls"],
|
||||
q = Query,
|
||||
lang = Lang} = Request) ->
|
||||
lang = Lang}) ->
|
||||
?DEBUG("query: ~p", [Query]),
|
||||
Res = case Method of
|
||||
'POST' ->
|
||||
@ -746,10 +720,9 @@ process_admin(Host,
|
||||
], Host, Lang);
|
||||
|
||||
process_admin(Host,
|
||||
#request{us = US,
|
||||
path = ["access-raw"],
|
||||
#request{path = ["access-raw"],
|
||||
q = Query,
|
||||
lang = Lang} = Request) ->
|
||||
lang = Lang}) ->
|
||||
SetAccess =
|
||||
fun(Rs) ->
|
||||
mnesia:transaction(
|
||||
@ -816,10 +789,9 @@ process_admin(Host,
|
||||
|
||||
process_admin(Host,
|
||||
#request{method = Method,
|
||||
us = US,
|
||||
path = ["access"],
|
||||
q = Query,
|
||||
lang = Lang} = Request) ->
|
||||
lang = Lang}) ->
|
||||
?DEBUG("query: ~p", [Query]),
|
||||
Res = case Method of
|
||||
'POST' ->
|
||||
@ -852,11 +824,9 @@ process_admin(Host,
|
||||
], Host, Lang);
|
||||
|
||||
process_admin(Host,
|
||||
#request{method = Method,
|
||||
us = US,
|
||||
path = ["access", SName],
|
||||
#request{path = ["access", SName],
|
||||
q = Query,
|
||||
lang = Lang} = Request) ->
|
||||
lang = Lang}) ->
|
||||
?DEBUG("query: ~p", [Query]),
|
||||
Name = list_to_atom(SName),
|
||||
Res = case lists:keysearch("rules", 1, Query) of
|
||||
@ -893,43 +863,35 @@ process_admin(Host,
|
||||
], Host, Lang);
|
||||
|
||||
process_admin(global,
|
||||
#request{us = US,
|
||||
path = ["vhosts"],
|
||||
q = Query,
|
||||
lang = Lang} = Request) ->
|
||||
#request{path = ["vhosts"],
|
||||
lang = Lang}) ->
|
||||
Res = list_vhosts(Lang),
|
||||
make_xhtml([?XCT("h1", "ejabberd virtual hosts")] ++ Res, global, Lang);
|
||||
|
||||
process_admin(Host,
|
||||
#request{us = US,
|
||||
path = ["users"],
|
||||
#request{path = ["users"],
|
||||
q = Query,
|
||||
lang = Lang} = Request) when is_list(Host) ->
|
||||
lang = Lang}) when is_list(Host) ->
|
||||
Res = list_users(Host, Query, Lang, fun url_func/1),
|
||||
make_xhtml([?XCT("h1", "Users")] ++ Res, Host, Lang);
|
||||
|
||||
process_admin(Host,
|
||||
#request{us = US,
|
||||
path = ["users", Diap],
|
||||
q = Query,
|
||||
lang = Lang} = Request) when is_list(Host) ->
|
||||
#request{path = ["users", Diap],
|
||||
lang = Lang}) when is_list(Host) ->
|
||||
Res = list_users_in_diapason(Host, Diap, Lang, fun url_func/1),
|
||||
make_xhtml([?XCT("h1", "Users")] ++ Res, Host, Lang);
|
||||
|
||||
process_admin(Host,
|
||||
#request{us = US,
|
||||
#request{
|
||||
path = ["online-users"],
|
||||
q = Query,
|
||||
lang = Lang} = Request) when is_list(Host) ->
|
||||
lang = Lang}) when is_list(Host) ->
|
||||
Res = list_online_users(Host, Lang),
|
||||
make_xhtml([?XCT("h1", "Online Users")] ++ Res, Host, Lang);
|
||||
|
||||
process_admin(Host,
|
||||
#request{method = Method,
|
||||
us = US,
|
||||
path = ["last-activity"],
|
||||
#request{path = ["last-activity"],
|
||||
q = Query,
|
||||
lang = Lang} = Request) when is_list(Host) ->
|
||||
lang = Lang}) when is_list(Host) ->
|
||||
?DEBUG("query: ~p", [Query]),
|
||||
Month = case lists:keysearch("period", 1, Query) of
|
||||
{value, {_, Val}} ->
|
||||
@ -966,34 +928,28 @@ process_admin(Host,
|
||||
Res, Host, Lang);
|
||||
|
||||
process_admin(Host,
|
||||
#request{us = US,
|
||||
path = ["stats"],
|
||||
q = Query,
|
||||
lang = Lang} = Request) ->
|
||||
#request{path = ["stats"],
|
||||
lang = Lang}) ->
|
||||
Res = get_stats(Host, Lang),
|
||||
make_xhtml([?XCT("h1", "Statistics")] ++ Res, Host, Lang);
|
||||
|
||||
process_admin(Host,
|
||||
#request{us = US,
|
||||
path = ["user", U],
|
||||
#request{path = ["user", U],
|
||||
q = Query,
|
||||
lang = Lang} = Request) ->
|
||||
lang = Lang}) ->
|
||||
Res = user_info(U, Host, Query, Lang),
|
||||
make_xhtml(Res, Host, Lang);
|
||||
|
||||
process_admin(Host,
|
||||
#request{us = US,
|
||||
path = ["nodes"],
|
||||
q = Query,
|
||||
lang = Lang} = Request) ->
|
||||
#request{path = ["nodes"],
|
||||
lang = Lang}) ->
|
||||
Res = get_nodes(Lang),
|
||||
make_xhtml(Res, Host, Lang);
|
||||
|
||||
process_admin(Host,
|
||||
#request{us = US,
|
||||
path = ["node", SNode | NPath],
|
||||
#request{path = ["node", SNode | NPath],
|
||||
q = Query,
|
||||
lang = Lang} = Request) ->
|
||||
lang = Lang}) ->
|
||||
case search_running_node(SNode) of
|
||||
false ->
|
||||
make_xhtml([?XCT("h1", "Node not found")], Host, Lang);
|
||||
@ -1115,7 +1071,7 @@ acl_parse_submit(ACLs, Query) ->
|
||||
NewACLs =
|
||||
lists:map(
|
||||
fun({acl, Name, Spec} = ACL) ->
|
||||
SName = atom_to_list(Name),
|
||||
%%SName = atom_to_list(Name),
|
||||
ID = term_to_id(ACL),
|
||||
case {lists:keysearch("type" ++ ID, 1, Query),
|
||||
lists:keysearch("value" ++ ID, 1, Query)} of
|
||||
@ -1176,7 +1132,7 @@ string_to_spec("raw", Val) ->
|
||||
acl_parse_delete(ACLs, Query) ->
|
||||
NewACLs =
|
||||
lists:filter(
|
||||
fun({acl, Name, Spec} = ACL) ->
|
||||
fun({acl, _Name, _Spec} = ACL) ->
|
||||
ID = term_to_id(ACL),
|
||||
not lists:member({"selected", ID}, Query)
|
||||
end, ACLs),
|
||||
@ -1221,7 +1177,7 @@ access_parse_query(Host, Query) ->
|
||||
end
|
||||
end.
|
||||
|
||||
access_parse_addnew(AccessRules, Host, Query) ->
|
||||
access_parse_addnew(_AccessRules, Host, Query) ->
|
||||
case lists:keysearch("namenew", 1, Query) of
|
||||
{value, {_, String}} when String /= "" ->
|
||||
Name = list_to_atom(String),
|
||||
@ -1250,7 +1206,7 @@ access_parse_delete(AccessRules, Host, Query) ->
|
||||
|
||||
access_rule_to_xhtml(Rules) ->
|
||||
Text = lists:flatmap(
|
||||
fun({Access, ACL} = Rule) ->
|
||||
fun({Access, ACL} = _Rule) ->
|
||||
SAccess = atom_to_list(Access),
|
||||
SACL = atom_to_list(ACL),
|
||||
SAccess ++ "\t" ++ SACL ++ "\n"
|
||||
@ -1318,7 +1274,7 @@ list_users(Host, Query, Lang, URLFunc) ->
|
||||
lists:flatmap(
|
||||
fun(K) ->
|
||||
L = K + M - 1,
|
||||
Node = integer_to_list(K) ++ "-" ++ integer_to_list(L),
|
||||
%%Node = integer_to_list(K) ++ "-" ++ integer_to_list(L),
|
||||
Last = if L < N -> su_to_list(lists:nth(L, SUsers));
|
||||
true -> su_to_list(lists:last(SUsers))
|
||||
end,
|
||||
@ -1397,7 +1353,7 @@ list_given_users(Users, Prefix, Lang, URLFunc) ->
|
||||
?XCT("td", "Last Activity")])]),
|
||||
?XE("tbody",
|
||||
lists:map(
|
||||
fun(SU = {Server, User}) ->
|
||||
fun(_SU = {Server, User}) ->
|
||||
US = {User, Server},
|
||||
QueueLen = length(mnesia:dirty_read({offline_msg, US})),
|
||||
FQueueLen = [?AC(URLFunc({users_queue, Prefix,
|
||||
@ -1475,10 +1431,10 @@ get_stats(Host, Lang) ->
|
||||
|
||||
|
||||
list_online_users(Host, _Lang) ->
|
||||
Users = [{S, U} || {U, S, R} <- ejabberd_sm:get_vh_session_list(Host)],
|
||||
Users = [{S, U} || {U, S, _R} <- ejabberd_sm:get_vh_session_list(Host)],
|
||||
SUsers = lists:usort(Users),
|
||||
lists:flatmap(
|
||||
fun({S, U} = SU) ->
|
||||
fun({_S, U} = SU) ->
|
||||
[?AC("../user/" ++ ejabberd_http:url_encode(U) ++ "/",
|
||||
su_to_list(SU)),
|
||||
?BR]
|
||||
@ -1696,7 +1652,7 @@ get_node(global, Node, [], Query, Lang) ->
|
||||
?INPUTT("submit", "stop", "Stop")])
|
||||
];
|
||||
|
||||
get_node(Host, Node, [], Query, Lang) ->
|
||||
get_node(Host, Node, [], _Query, Lang) ->
|
||||
MenuItems1 = ejabberd_hooks:run_fold(webadmin_menu_hostnode, Host, [], [Host, Node]),
|
||||
MenuItems2 = [?LI([?ACT(MI_uri++"/", MI_name)]) || {MI_uri, MI_name} <- MenuItems1],
|
||||
[?XC("h1", ?T("Node ") ++ atom_to_list(Node)),
|
||||
@ -1768,7 +1724,7 @@ get_node(global, Node, ["db"], Query, Lang) ->
|
||||
end;
|
||||
|
||||
get_node(global, Node, ["backup"], Query, Lang) ->
|
||||
Res = node_backup_parse_query(Node, Query),
|
||||
_Res = node_backup_parse_query(Node, Query),
|
||||
[?XC("h1", ?T("Backup of ") ++ atom_to_list(Node)),
|
||||
?XCT("p", "Remark that these options will only backup the builtin Mnesia database. If you are using the ODBC module, you also need to backup your SQL database separately."),
|
||||
?XAE("form", [{"action", ""}, {"method", "post"}],
|
||||
@ -1858,7 +1814,7 @@ get_node(Host, Node, ["modules"], Query, Lang) when is_list(Host) ->
|
||||
[node_modules_to_xhtml(NewModules, Lang)])
|
||||
];
|
||||
|
||||
get_node(global, Node, ["stats"], Query, Lang) ->
|
||||
get_node(global, Node, ["stats"], _Query, Lang) ->
|
||||
UpTime = rpc:call(Node, erlang, statistics, [wall_clock]),
|
||||
UpTimeS = io_lib:format("~.3f", [element(1, UpTime)/1000]),
|
||||
CPUTime = rpc:call(Node, erlang, statistics, [runtime]),
|
||||
@ -1904,7 +1860,7 @@ get_node(global, Node, ["update"], Query, Lang) ->
|
||||
rpc:call(Node, code, purge, [ejabberd_update]),
|
||||
Res = node_update_parse_query(Node, Query),
|
||||
rpc:call(Node, code, load_file, [ejabberd_update]),
|
||||
{ok, Dir, UpdatedBeams, Script, LowLevelScript, Check} =
|
||||
{ok, _Dir, UpdatedBeams, Script, LowLevelScript, Check} =
|
||||
rpc:call(Node, ejabberd_update, update_info, []),
|
||||
Mods =
|
||||
case UpdatedBeams of
|
||||
@ -2071,10 +2027,10 @@ node_ports_to_xhtml(Ports, Lang) ->
|
||||
])]),
|
||||
?XE("tbody",
|
||||
lists:map(
|
||||
fun({Port, Module, Opts} = E) ->
|
||||
fun({Port, Module, Opts} = _E) ->
|
||||
SPort = integer_to_list(Port),
|
||||
SModule = atom_to_list(Module),
|
||||
ID = term_to_id(E),
|
||||
%%ID = term_to_id(E),
|
||||
?XE("tr",
|
||||
[?XC("td", SPort),
|
||||
?XE("td", [?INPUT("text", "module" ++ SPort,
|
||||
@ -2151,9 +2107,9 @@ node_modules_to_xhtml(Modules, Lang) ->
|
||||
])]),
|
||||
?XE("tbody",
|
||||
lists:map(
|
||||
fun({Module, Opts} = E) ->
|
||||
fun({Module, Opts} = _E) ->
|
||||
SModule = atom_to_list(Module),
|
||||
ID = term_to_id(E),
|
||||
%%ID = term_to_id(E),
|
||||
?XE("tr",
|
||||
[?XC("td", SModule),
|
||||
?XE("td", [?INPUTS("text", "opts" ++ SModule,
|
||||
@ -2274,8 +2230,8 @@ pretty_print_xml({xmlelement, Name, Attrs, Els}, Prefix) ->
|
||||
|
||||
url_func({user_diapason, From, To}) ->
|
||||
integer_to_list(From) ++ "-" ++ integer_to_list(To) ++ "/";
|
||||
url_func({users_queue, Prefix, User, Server}) ->
|
||||
url_func({users_queue, Prefix, User, _Server}) ->
|
||||
Prefix ++ "user/" ++ User ++ "/queue/";
|
||||
url_func({user, Prefix, User, Server}) ->
|
||||
url_func({user, Prefix, User, _Server}) ->
|
||||
Prefix ++ "user/" ++ User ++ "/".
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user