mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
* src/ejabberd_auth.erl: Added get_vh_registered_users_number/1
function * src/ejabberd_auth_odbc.erl: Likewise * src/odbc/odbc_queries.erl: Added users_number/1 function * src/ejabberd.cfg.example: Added an example for pgsql_users_number_estimate option SVN Revision: 766
This commit is contained in:
parent
a10923c197
commit
8aab10d28c
@ -1,5 +1,12 @@
|
|||||||
2007-05-12 Alexey Shchepin <alexey@sevcom.net>
|
2007-05-12 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
|
* src/ejabberd_auth.erl: Added get_vh_registered_users_number/1
|
||||||
|
function
|
||||||
|
* src/ejabberd_auth_odbc.erl: Likewise
|
||||||
|
* src/odbc/odbc_queries.erl: Added users_number/1 function
|
||||||
|
* src/ejabberd.cfg.example: Added an example for
|
||||||
|
pgsql_users_number_estimate option
|
||||||
|
|
||||||
* src/ejabberd_auth_anonymous.erl: Added anonymous_purge_hook
|
* src/ejabberd_auth_anonymous.erl: Added anonymous_purge_hook
|
||||||
(thanks to Christophe Romain and Mickael Remond)
|
(thanks to Christophe Romain and Mickael Remond)
|
||||||
* src/mod_offline.erl: Likewise
|
* src/mod_offline.erl: Likewise
|
||||||
|
@ -96,6 +96,10 @@
|
|||||||
%{auth_method, odbc}.
|
%{auth_method, odbc}.
|
||||||
%{odbc_server, "DSN=ejabberd;UID=ejabberd;PWD=ejabberd"}.
|
%{odbc_server, "DSN=ejabberd;UID=ejabberd;PWD=ejabberd"}.
|
||||||
|
|
||||||
|
% Uncomment this if you are using postgres, having a large DB, and need a
|
||||||
|
% faster but inexact replacement for "select count(*) from users"
|
||||||
|
%{pgsql_users_number_estimate, true}.
|
||||||
|
|
||||||
|
|
||||||
% Host name:
|
% Host name:
|
||||||
{hosts, ["localhost"]}.
|
{hosts, ["localhost"]}.
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
try_register/3,
|
try_register/3,
|
||||||
dirty_get_registered_users/0,
|
dirty_get_registered_users/0,
|
||||||
get_vh_registered_users/1,
|
get_vh_registered_users/1,
|
||||||
|
get_vh_registered_users_number/1,
|
||||||
get_password/2,
|
get_password/2,
|
||||||
get_password_s/2,
|
get_password_s/2,
|
||||||
is_user_exists/2,
|
is_user_exists/2,
|
||||||
@ -107,6 +108,19 @@ get_vh_registered_users(Server) ->
|
|||||||
M:get_vh_registered_users(Server)
|
M:get_vh_registered_users(Server)
|
||||||
end, auth_modules(Server)).
|
end, auth_modules(Server)).
|
||||||
|
|
||||||
|
get_vh_registered_users_number(Server) ->
|
||||||
|
lists:sum(
|
||||||
|
lists:map(
|
||||||
|
fun(M) ->
|
||||||
|
case erlang:function_exported(
|
||||||
|
M, get_vh_registered_users_number, 1) of
|
||||||
|
true ->
|
||||||
|
M:get_vh_registered_users_number(Server);
|
||||||
|
false ->
|
||||||
|
length(M:get_vh_registered_users(Server))
|
||||||
|
end
|
||||||
|
end, auth_modules(Server))).
|
||||||
|
|
||||||
get_password(User, Server) ->
|
get_password(User, Server) ->
|
||||||
lists:foldl(
|
lists:foldl(
|
||||||
fun(M, false) ->
|
fun(M, false) ->
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
try_register/3,
|
try_register/3,
|
||||||
dirty_get_registered_users/0,
|
dirty_get_registered_users/0,
|
||||||
get_vh_registered_users/1,
|
get_vh_registered_users/1,
|
||||||
|
get_vh_registered_users_number/1,
|
||||||
get_password/2,
|
get_password/2,
|
||||||
get_password_s/2,
|
get_password_s/2,
|
||||||
is_user_exists/2,
|
is_user_exists/2,
|
||||||
@ -28,8 +29,6 @@
|
|||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
|
|
||||||
-record(passwd, {user, password}).
|
|
||||||
|
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%% API
|
%%% API
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
@ -123,6 +122,15 @@ get_vh_registered_users(Server) ->
|
|||||||
[]
|
[]
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
get_vh_registered_users_number(Server) ->
|
||||||
|
LServer = jlib:nameprep(Server),
|
||||||
|
case catch odbc_queries:users_number(LServer) of
|
||||||
|
{selected, [_], [{Res}]} ->
|
||||||
|
list_to_integer(Res);
|
||||||
|
_ ->
|
||||||
|
0
|
||||||
|
end.
|
||||||
|
|
||||||
get_password(User, Server) ->
|
get_password(User, Server) ->
|
||||||
case jlib:nodeprep(User) of
|
case jlib:nodeprep(User) of
|
||||||
error ->
|
error ->
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
del_user/2,
|
del_user/2,
|
||||||
del_user_return_password/3,
|
del_user_return_password/3,
|
||||||
list_users/1,
|
list_users/1,
|
||||||
|
users_number/1,
|
||||||
add_spool_sql/2,
|
add_spool_sql/2,
|
||||||
add_spool/2,
|
add_spool/2,
|
||||||
get_and_del_spool_msg_t/2,
|
get_and_del_spool_msg_t/2,
|
||||||
@ -109,6 +110,20 @@ list_users(LServer) ->
|
|||||||
LServer,
|
LServer,
|
||||||
"select username from users").
|
"select username from users").
|
||||||
|
|
||||||
|
users_number(LServer) ->
|
||||||
|
case ejabberd_config:get_local_option(
|
||||||
|
{pgsql_users_number_estimate, LServer}) of
|
||||||
|
true ->
|
||||||
|
ejabberd_odbc:sql_query(
|
||||||
|
LServer,
|
||||||
|
"select reltuples from pg_class "
|
||||||
|
"where oid = 'users'::regclass::oid");
|
||||||
|
_ ->
|
||||||
|
ejabberd_odbc:sql_query(
|
||||||
|
LServer,
|
||||||
|
"select count(*) from users")
|
||||||
|
end.
|
||||||
|
|
||||||
add_spool_sql(Username, XML) ->
|
add_spool_sql(Username, XML) ->
|
||||||
["insert into spool(username, xml) "
|
["insert into spool(username, xml) "
|
||||||
"values ('", Username, "', '",
|
"values ('", Username, "', '",
|
||||||
|
Loading…
Reference in New Issue
Block a user